-
Notifications
You must be signed in to change notification settings - Fork 190
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 --update option #693
add --update option #693
Conversation
Hi. Thanks for contributing this. Just a first few suggestions:
In a previous attempt I started a while back I added an argument (updatable) to distinguish the frameworks that shouldn't be updatet through umake (e.g. those that have their own updater). |
You can find the old version of the update function here: Just to have a quick look at the defaults and "updatable" argument. |
Hi @NicolasKeita Did you manage to look at making the update function more modular? |
Hi, I believe that I approached the task with the mindset of adding my code on top of the existing code rather than modifying it to avoid any potential disruptions. |
Thank you very much for the patience and willingness to look into this. My proposal would be to split this in two:
Let me know what you think, and thank you again! |
Thanks. I understood the proposal. Looks good to me. I'll take your pull request (#506) code as base. I should be submitting something in the next few days. |
Keep in mind that my old pull request is very old now, so it's not up to date. Just look at it for pointers, or rebase that on master. The first one might be easier. Let me know if you need help with anything! The changes I'll be making should not interfere with whatever you do, and at the moment they live in different branches. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I gave your code another look,
I think it's great, and the only thing required is to avoid repeating too much code in the single frameworks.
If possible keep the default methods (those that say missing information) in baseinstaller, and the frameworks only override them if they are updatable by umake.
umake/frameworks/crystal.py
Outdated
@@ -75,3 +75,10 @@ def post_install(self): | |||
"""Add Crystal necessary env variables""" | |||
add_env_to_user(self.name, {"PATH": {"value": os.path.join(self.install_path, "bin")}}) | |||
UI.delayed_display(DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name))) | |||
|
|||
def parse_latest_version_from_package_url(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially you can remove these empty methods, and add them to baseinstaller/init
so the single frameworks only override this if they can
umake/frameworks/dart.py
Outdated
@@ -79,6 +79,18 @@ def post_install(self): | |||
add_env_to_user(self.name, {"PATH": {"value": os.path.join(self.install_path, "bin")}}) | |||
UI.delayed_display(DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name))) | |||
|
|||
def parse_latest_version_from_package_url(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are fine, since they add what is specific to a package, although they could simply return the regex string, and let a method in baseinstaller deal with evaluating the regex
@@ -243,9 +300,52 @@ def main(parser): | |||
print(get_version()) | |||
sys.exit(0) | |||
|
|||
if args.update: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep this as is, we can evantually replace the prettyprint, but it looks good for now
@staticmethod | ||
def get_current_user_version(install_path): | ||
return None | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding two default methods for each framework.
get_latest_version() is getting the version from parsing the download_url.
get_current_user_version() is overridden in each of the framework. It is checking the installed files (like VERSION.txt for example) to fetch the version.
umake/frameworks/__init__.py
Outdated
@@ -153,6 +154,8 @@ def __init__(self, name, description, category, force_loading=False, logo_path=N | |||
self.packages_requirements.extend(self.category.packages_requirements) | |||
self.only_for_removal = only_for_removal | |||
self.expect_license = expect_license | |||
self.version_regex = version_regex | |||
self.forbidden_to_update = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.forbidden_to_update = False
This was my way of preventing an update on some frameworks like Intellij.
Set by default at False then overridden in the class BaseJetBrains for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have used it the other way around, keeping the default as not updatable, and setting a framework to updatable explicitly. This way we only add information for those that have this functionality.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After thinking about it, I 100% agree with you. I have committed these changes 👍
umake/ui/cli/__init__.py
Outdated
for outdated_framework in outdated_frameworks: | ||
if outdated_framework['forbidden_to_update'] is False: | ||
args = parser.parse_args([outdated_framework['category_name'], outdated_framework['framework_name']]) | ||
CliUI() | ||
run_command_for_args(args) | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If multiple outdated frameworks are present, only the first framework updates (the return statement is early).
I struggled a bit with running CliUI() in a loop.
PS: sorry about the useless/extra commit (Merge branch 'ubuntu:master' into master)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll look into this.
The best way would probably be to relaunch umake, but I'll let you know
Set specific frameworks to be updatable and make non-updatable the default for all other frameworks
Great! The only thing missing now is to add a couple of tests. Do you think you could look into that? Specifically a "small" test (you can find them in the tests/small folder), to see if the behaviour is consistent. I've been looking into the multiple update, and I think I have an idea, but I need to test it out. Basically we should have a way to run umake with multiple frameworks first (for the install as well), then we could reuse that for the update. |
Yes, working on it 👍 |
Hi, I couldn't add proper tests. |
I'll look at adding a few tests, just to check that future updates don't break everything, then I'll merge. Thanks again! |
Merging in a separate branch to check and add tests if possible. |
add --update option (or -u) to enable comparing the user's version of each framework to the latest version available.
Inspired by an old issue #74 and I wanted to help.
Side nodes:
Feature details: