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

Check for new CLI versions when creating projects #518

Merged
merged 4 commits into from
Feb 17, 2023

Conversation

frandiox
Copy link
Contributor

@frandiox frandiox commented Feb 15, 2023

This adds a check to the init command to show available upgrades for the CLI:

image

It's just an "info" log and you can continue generating the project with the current version (the  ELIFECYCLE  Command failed in the screenshot is just because I ctrl+c'd).

The check happens upfront so the whole process is slightly delayed, but I think it's better to do it at this time than later after choosing template etc.

@frandiox frandiox requested a review from a team February 15, 2023 09:39
Copy link
Contributor

@lordofthecactus lordofthecactus left a comment

Choose a reason for hiding this comment

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

Looks good ✅

expect(checkForNewVersion).toHaveBeenCalledWith(
'@shopify/hydrogen',
// Calver
expect.stringMatching(/20\d{2}\.\d{1,2}\.\d{1,3}/),
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this won't work if we have 1000 patches or this package lives till 2100 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah at this rate AI will conquer us before any of that happens 👍

@mynameisadamf
Copy link

@frandiox Will this version check address this issue #508 and not need the @latest for each instance?

@frandiox
Copy link
Contributor Author

@mynameisadamf Not really, the @latest will still be necessary. We don't know if the user has an older version cached that doesn't implement this check.

The idea is that this check basically reminds you to use @latest if you didn't (and if there's a new version).

if (process.env.LOCAL_DEV) return;
const pkgName = PACKAGE_NAMES[pkgKey];

const require = createRequire(import.meta.url);
const pkgJsonPath = locateDependency(
Copy link
Contributor

Choose a reason for hiding this comment

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

Just double checking, this function resolves to the package in their local node_modules rather what version is listed in the project package.json?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it resolves to the installed version, not the listed one. That's the correct behavior, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed! Thanks for clarifying, this looks good to me 👍

@frandiox frandiox merged commit a699735 into 2023-01 Feb 17, 2023
@frandiox frandiox deleted the fd-check-cli-version branch February 17, 2023 09:06
@github-actions github-actions bot mentioned this pull request Feb 20, 2023
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.

4 participants