Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "state save" and "state load" commands #610

Merged
merged 20 commits into from
Oct 25, 2023
Merged

Conversation

j-jzk
Copy link
Contributor

@j-jzk j-jzk commented Oct 12, 2023

This PR adds two new commands:

  • haxelib state save haxelib-lock.hxml
  • haxelib state load haxelib-lock.hxml

This manifest file (note that .hxml extension isn't mandatory here) is used to "lock" the current state of the libraries in the project. This is useful for reproducing the exact state of dependencies in a project (on a new machine or in Docker), especially when working with libraries installed from git.

The intended workflow is following:

  1. do package management operations
  2. lock the dependencies: haxelib state save haxelib-lock.hxml
  3. apply the manifest file in another environment: haxelib state load haxelib-lock.hxml

This manifest mechanism supports published haxelib versions, as well as exact git and mercurial references. haxelib dev libs are ignored (with a warning), and try to resolve to "non-dev" version for the manifest file, allowing you to work with dev libs locally without altering the pin file.

I switched to file output instead of stdout for better cross-platform support, and API consistency.
"manifest" terminology comes from https://learn.microsoft.com/en-us/vcpkg/users/manifests


Original PR description below:

This PR adds a new lock command which, as in other library managers, "locks" the current state of the libraries in the project. This is useful for reproducing the exact state of dependencies in a project (on a new machine or in Docker), especially when working with libraries installed from git.

The output is in HXML (-L lib:version ...) and it is dumped to stdout instead of a file.
The intended workflow is following:

  1. do package management operations
  2. lock the dependencies: haxelib lock > haxelib-lock.hxml
  3. apply the lockfile in another environment: haxelib install --skip-dependencies --always haxelib-lock.hxml

I've created this for my personal usage and providing this patch hoping it could be useful to more developers. If inappropriate, feel free to add notes/close the PR.
Before merging, support for locking versions of Mercurial libs (installed using haxelib hg ...) should be added. I am not a Mercurial user myself, so help would be greatly appreciated.

src/haxelib/client/Main.hx Outdated Show resolved Hide resolved
src/haxelib/client/Main.hx Outdated Show resolved Hide resolved
src/haxelib/client/Args.hx Outdated Show resolved Hide resolved
src/haxelib/api/Vcs.hx Outdated Show resolved Hide resolved
@kLabz
Copy link
Contributor

kLabz commented Oct 17, 2023

Thanks!
I think this can be merged once the above points have been handled

- fix crash for libraries with no non-dev version
- output --lib instead of -L for compatibility and clarity
- move the command to the Misc category
@j-jzk
Copy link
Contributor Author

j-jzk commented Oct 17, 2023

Hopefully I will finish this till the end of the week.

@kLabz
Copy link
Contributor

kLabz commented Oct 20, 2023

This PR is now ready as far as I'm concerned.
Will wait a bit before merging in case someone has some argument against it.

src/haxelib/client/Args.hx Outdated Show resolved Hide resolved
src/haxelib/client/Main.hx Outdated Show resolved Hide resolved
src/haxelib/client/Main.hx Outdated Show resolved Hide resolved
src/haxelib/client/Main.hx Outdated Show resolved Hide resolved
Also write directly to file instead of stdout, and added 'pin apply' command as alias to 'install --always --skip-dependencies'
@kLabz kLabz changed the title Add a lock command Add "pin generate" and "pin apply" commands Oct 20, 2023
@kLabz kLabz changed the title Add "pin generate" and "pin apply" commands Add "generate manifest" and "apply manifest" commands Oct 21, 2023
@kLabz kLabz changed the title Add "generate manifest" and "apply manifest" commands Add "state save" and "state load" commands Oct 21, 2023
@j-jzk
Copy link
Contributor Author

j-jzk commented Oct 22, 2023

Thanks for all the work :) Just sat down to work on this and saw you'd already finished it (much better than I would have).

@kLabz
Copy link
Contributor

kLabz commented Oct 22, 2023

Hope it still matches your workflow! Changed into a file arg so that windows people don't freak out 😅

@kLabz
Copy link
Contributor

kLabz commented Oct 25, 2023

@Simn is it ok to merge this?
Documentation will wait a bit (for a new haxelib release), and can be done on a separate PR.

@Simn Simn merged commit eb9d4e5 into HaxeFoundation:development Oct 25, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants