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

[Upgrade Tool] Chores / Quality of Life Improvements #19053

Merged
merged 10 commits into from Dec 15, 2023

Conversation

Convly
Copy link
Member

@Convly Convly commented Dec 14, 2023

What does it do?

  • Update logs to display more information about the upgrade process
  • Add a -y, --yes CLI option for major, minor, and patch commands (cc @pwizla)
    • Default to false, automatically answers yes to every prompt (for now, it'll basically ignore optional requirements and proceed anyway)
  • Make major upgrade requirements required (were optional up until now)
  • Various small improvements around the code quality
  • Update some logs to make them more user-friendly

Why is it needed?

Quality of life improvements

How to test it?

  • The yes should ignore prompts & answer yes anyway (easy to test with the GIT_CLEAN requirement, the warning should be prompted but the process should continue)
  • The major requirements should now be required, and the upgrade major process should fail (as there are no V5 to upgrade to anyway)

Copy link
Contributor

@innerdvations innerdvations left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! Just a couple comments

@@ -15,6 +15,11 @@ const addReleaseUpgradeCommand = (releaseType: Version.ReleaseType, description:
.option('-n, --dry', 'Simulate the upgrade without updating any files', false)
.option('-d, --debug', 'Get more logs in debug mode', false)
.option('-s, --silent', "Don't log anything", false)
.option(
'-y, --yes',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use "force" everywhere else, like data-transfer. The only reason I would switch to "yes" is if we consider force="yes to all", yes="yes to things that are non-destructive" (and thus have both available here)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, it doesn't mean the same thing. Force means "go for it even if we have weird stuff on the way" whereas "yes" means... answering "yes" to all prompts where you can answer "yes". I don't know if that makes sense though

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although for now, I agree it is similar, since the only things we're answering to are optional requirements

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it would technically be 'yes' in this case and then we would introduce 'force' if we encountered something like "run this codemod even if it's unpredictable based on your code" but my worry is that we already use force for data-transfer and now we'd have two different wordings that don't really make that distinction clear.

@marcoautiero your thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but my worry is that we already use force for data-transfer and now we'd have two different wordings that don't really make that distinction clear.

I agree, it was my worry too. But I believe that in the long run having well-documented atomic options/flags, is more helpful than trying to accommodate everything under a big one-do-it-all

Also, yes is quite a well-known flag since it's already used quite a lot by package managers & other CLI. So I don't think people would be lost

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use force to ignore prompts with experimental commands in the strapi CLI by the way. I originally wrote yes but Ben highlighted that we use force in DTS.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, we do use force in the DTS, but again, I feel like it's not aiming at doing the same thing 😕
I don't really see why both couldn't live together

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a problem with yes, but imo if you are ignoring prompts with yes i think you need to change the CLI too because that is doing the same thing as here, otherwise it's just an inconsistency.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2023-12-14 at 16 28 16
Do we have potentially destructive effects here?

Copy link
Member Author

@Convly Convly Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in the current prompts

@Convly
Copy link
Member Author

Convly commented Dec 14, 2023

Also, looks like unit tests are failing since merging the minor/patch dependencies install PR, but I don't understand the errors. I'll keep digging this later

@Convly
Copy link
Member Author

Convly commented Dec 14, 2023

Also, looks like unit tests are failing since merging the minor/patch PR, but I don't understand the errors. I'll keep digging this later

I mean... What?

image

@Convly
Copy link
Member Author

Convly commented Dec 14, 2023

Removing the preferred-pm import from packages/core/utils/src/package-manager.ts does fix the test for the upload...
I'm confused, will keep digging

@Bassel17
Copy link
Member

Just to clarify the test failing come from this PR: #19009
the update of the execa package maybe related, although am not sure

@Convly
Copy link
Member Author

Convly commented Dec 14, 2023

Just to clarify the test failing come from this PR: 19009 the update of the execa package maybe related, although am not sure

You're completely right, I even commented it, my bad 🤦‍♂️

@Convly
Copy link
Member Author

Convly commented Dec 14, 2023

Fixed the issue in 1f39b5b

The mock used in the test file made promisify fail due to fs.path being undefined (instead of an actual function). The fix consists of properly mocking the file-system using memfs (like for the other fs tests for the upgrade tool)

The issue appeared because of preferred-pm having dependencies calling promisify(fs.path) and being exposed in strapi/utils (which is used (import * as utils from "@strapi/utils") by the test file)

Copy link
Contributor

Size Change: 0 B

Total Size: 627 kB

ℹ️ View Unchanged
Filename Size
examples/getstarted/build/bb4d0d527bdfb161bc5a.svg 2.33 kB
examples/getstarted/build/index.html 610 B
examples/getstarted/build/main.********.js 619 kB
examples/getstarted/build/runtime~main.********.js 4.23 kB

compressed-size-action

Copy link
Member

@christiancp100 christiancp100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍🏼

@Convly Convly merged commit 9fbf226 into features/upgrade-tool Dec 15, 2023
72 of 77 checks passed
@Convly Convly deleted the upgrade-tool/chores branch December 15, 2023 14:22
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

6 participants