HaxeFoundation / haxelib

The Haxe library manager
https://lib.haxe.org/
MIT License
173 stars 77 forks source link

Install dependencies from haxelib.json #508

Open jerrygreen opened 3 years ago

jerrygreen commented 3 years ago

There's already a command:

haxelib install all

What it does: it reads current folder for .hxml files, lookups -lib flags, and installs all these libs with the latest versions. Which is quite handy at first, but it has two cons:

I came from JS/TS world, and kinda expected haxelib install to install all versions taken from dependency list from haxelib.json, but it seems nor haxelib install, nor haxelib install all doesn't work this way.

I personally don't have a problem with it, since I can just list those dependencies in a file like install.sh:

haxelib install heaps 1.8.0
haxelib install hlsdl 1.10.0
haxelib install hldx 1.10.0
# etc

And then just run ./install.sh in terminal anytime later so even if some time will pass, it will be possible to setup the project with just one command, and not meet dozens of errors. But unfortunately there's no guideline or something like that, so I see some projects or examples like these:

https://github.com/Beeblerox/Simplest-Heaps-Examples

Which is quite a lot of work, but kinda useless work, because those examples just don't work with modern versions, and it's not possible to see them in action.

My proposal

kLabz commented 3 years ago

You can also haxelib install install.hxml with install.hxml containing specific versions:

# from haxelib
-lib js-object:0.0.7

# from git
-lib some-lib:git:git@github.com:user/some-repo.git
# from git with reference (branch, tag, commit hash..)
-lib other-lib:git:git@github.com:user/repo.git#281f723e

I personnally add --skip-dependencies to haxelib command and add dependencies to this install.hxml myself to be able to pin their versions too.

See also https://github.com/HaxeFoundation/haxe/wiki/Haxe-haxec-haxelib-plan for future plans. Edit: haxelib.json was meant for libs, not for projects, and that doesn't seem to be really open for change

jerrygreen commented 3 years ago

Actually, that is a handy thing. I suspected something like that is possible, even tried -lib js-object@0.0.7 (@ symbol), but it didn't work. Neither I found any info about versions in docs.

I've just noticed it's shown in schema hint though:

image

But what's about --skip-dependencies? How do you use it?

kLabz commented 3 years ago

It prevents haxelib from installing dependencies of libraries I install, because I cannot pin their versions (the libraries might pin their dependencies' versions but that may not be what I want either). So I add my libraries' dependencies myself in install.hxml too

jerrygreen commented 3 years ago

@kLabz yeah, I understand meaning of install.hxml, - that's pretty handy. You run something like haxelib install install.hxml, right?

I don't get where do you get benefit of using --skip-dependencies

kLabz commented 3 years ago

My previous message was entirely about --skip-dependencies flag

jerrygreen commented 3 years ago

@kLabz oh shi, it's for DEPENDENCIES of your DEPENDENCIES... I got it now. I'm ~just not very smart~ awake around 24hr already, and struggled to figure out why would you skip dependencies while you're installing dependencies.

NQNStudios commented 1 year ago

Actually, that is a handy thing. I suspected something like that is possible, even tried -lib js-object@0.0.7 (@ symbol), but it didn't work. Neither I found any info about versions in docs.

I too was just trying to pin my dependency versions and didn't find the syntax for -lib <library>:<version> in the docs!

Turns out it's not explained on this page but it IS on this one. Which I do find confusing. I actually found it in kLabz's example here first.