gleam-lang / gleam

⭐️ A friendly language for building type-safe, scalable systems!
https://gleam.run
Apache License 2.0
17.88k stars 745 forks source link

Add a command to update indivudual dependencies #2170

Closed NthTensor closed 1 week ago

NthTensor commented 1 year ago

It would be nice to be able to use gleam deps update <package_1> <package_2> to update specific packages.

Use case: When local dependencies get merged we will have to update them with gleam deps update or similar. Unfortunately, this also updates all the other packages.

Happy to add this if it seems useful.

lpil commented 1 year ago

Agreed! This would be a fab addition. I like the suggested gleam deps update <package_1> <package_2> CLI.

SnakeDoc commented 2 months ago

I have an interest in seeing this feature implemented. @NthTensor were you able to get anywhere on this?

I'd like to help land this feature. Before I take a swing (knowing nothing about rust ;), are there any "gotchas" I need to be aware of?

Motivation behind this feature: https://github.com/renovatebot/renovate/pull/31002

SnakeDoc commented 2 months ago

Couple thoughts after taking a look under the hood:

  1. Gleam is now 1.x, so we should avoid breaking/changing the existing CLI for gleam update and gleam deps update.
  2. We should strive to make the command immune to common scripting "gotchas", such as undefined/unresolved variables.

The previously proposed command was:

gleam update <package names>
gleam deps update <package names>

This retains compatibility with the existing 1.x CLI, and allows the original gleam deps update command to continue updating all available dependencies. However, this proposal exposes some potential problems for script writers.

Consider the following scenario:

gleam deps update ${PACKAGES}

Where ${PACKAGES} is undefined. This will result in the Gleam CLI interpreting this command as-if the user intended to update all available dependencies. Instead, we should throw an error of some kind.

This leads me to propose the following CLI:

# updates all available deps
# retained for compatibility, perhaps to be deprecated and eventually removed?
gleam deps update

# explicitly updates all available deps
gleam deps update --all

# update the list of packages
gleam deps update --packages <list of packages>

Effectively, gleam deps update would become an alias of the more explicit command, gleam deps update --all.

Then, gleam deps update --packages <packages> would allow users to safely do something like gleam deps update --packages ${PACKAGES}. In the event ${PACKAGES} is undefined or empty, we would throw an error instead of proceeding against the user's intentions.

@lpil Thoughts?

lpil commented 2 months ago

Let's go with the API extension NthTensor suggested.

This would be implemented by unlocking the dependencies specified along with any dependencies they bring in.

GearsDatapacks commented 1 week ago

Can this issue be closed now that #3602 is merged?

SnakeDoc commented 1 week ago

I think this issue is fully covered by #3602. Good to close from in my opinion! :100:

lpil commented 1 week ago

Yes, thank you!