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

Library functions are hard to upgrade #126

Closed
wolfgang42 opened this issue Oct 17, 2021 · 3 comments · Fixed by #144
Closed

Library functions are hard to upgrade #126

wolfgang42 opened this issue Oct 17, 2021 · 3 comments · Fixed by #144
Labels
enhancement New feature or request

Comments

@wolfgang42
Copy link
Collaborator

Right now, adding the built-in libraries to a program with bashly add just copies the files out of the Bashly source code and into the user program. As a result, the user program doesn't get any improvements to the library when it's changed upstream.

Here are a couple ideas for ways this might be improved:

  • Add support to bashly for upgrading the libraries, e.g. a bashly status that checks if the library is outdated and a bashly upgrade that copies over a new version. This should probably keep a list of old library version hashes or something, so it can tell if the library has been modified since being added to avoid deleting user customizations.
  • Alternately, don't copy over the libraries. Instead, have a lib config key which lists which built-in libraries to add to the program. In this way, the libraries will be automatically updated when a new bashly version is used. bashly add could be renamed e.g. bashly fork-lib for the case when a program author wants to have a version of the library with custom changes.

(I think I'd prefer the second option, but not strongly.)

@DannyBen DannyBen added the enhancement New feature or request label Oct 17, 2021
@DannyBen
Copy link
Owner

DannyBen commented Oct 19, 2021

I don't think there is any problem that needs solving in this regard.

  1. Bashly's libraries are changed very infrequently, if at all.
  2. If you have modified a copied lib file, there is no way to upgrade it.
  3. If you haven't modified a copied lib file, you can just run bashly add thatlib --force.
  4. There is really never a reason to upgrade blindly, without knowing that you need a functionality that was added.

In addition, the fact that we have a configuration YAML, does not mean we need to overload it with details. I want users to not need to constantly refer to the documentation. The bashly add * set of functions work consistently and simply - they add files to your code, so you have a better "starting point". There is no "hidden magic".

That said - there might be a case for creating some simple functionality, which should aim to be zero-effort from the user standpoint, to solve things like #86 - for example:

  1. Generated library files will be generated with some magic comment marker in the first line, like # bashly-auto-upgrade:completions.
  2. The command bashly generate gets a new flag: --upgrade
  3. When executed, it will scan for these comments and also run bashly add "$2" --force

Or something of that sort.

@wolfgang42
Copy link
Collaborator Author

My experience has been, that even if it is not necessary to upgrade now, it is usually better to do it anyway so that when there is something you need you don't also end up with a bunch of other new changes to sort through if something goes funny.

Anyway, I like your suggestion of just having a # bashly-auto-upgrade comment at the top of the file, it does seem like a simple and easy-to-understand way of solving the problem.

This was referenced Oct 29, 2021
@DannyBen
Copy link
Owner

This is now implemented.

If you already have library functions, you will need to first re-add them using the new version (once it is released, using bashly add <lib> --force), and from this point on running bashly generate --upgrade will upgrade them, unless you modified them and removed the magic comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants