-
Notifications
You must be signed in to change notification settings - Fork 126
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
Show a warning when there are multiple CLI installations #4629
base: main
Are you sure you want to change the base?
Conversation
Thanks for your contribution! Depending on what you are working on, you may want to request a review from a Shopify team:
|
…hopify/cli into multiple-installations-warning
Coverage report
Show files with reduced coverage 🔻
Test suite run success1905 tests passing in 866 suites. Report generated by 🧪jest coverage report action from 2b4fde9 |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
headline: 'There are two installations of the CLI: global and as a dependency of the project.', | ||
body: [`We recommend to remove the @shopify/cli and @shopify/app dependencies from your package.json.`], |
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.
PR looks good, we might want to check this copy with product though
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.
And maybe link to this doc: https://shopify.dev/docs/apps/build/cli-for-apps#switch-to-a-global-executable-or-local-dependency
?
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.
@jessehoek could you review this new message? 🙏
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.
Sure thing! Can we use the headline to let the user know which one (and which version) will be used for the current command?
Eg
In the local case:
Two Shopify CLI installations found – using local dependency: v3.50.1
A global installation (v3.68.1) and a local dependency (v3.50.1) were detected. We recommend removing the `@shopify/cli` and `@shopify/app` dependencies from your package.json.
In the global case:
Two Shopify CLI installations found – using global installation: v3.68.1
A global installation (v3.68.1) and a local dependency (v3.50.1) were detected. We recommend removing the `@shopify/cli` and `@shopify/app` dependencies from your package.json.
I think it's helpful to confirm which one is being used, and which version that is. Thoughts? Also, do we recommend removing the Global CLI if you are using the local one?
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.
Thank you! That makes total sense, and showing the versions will be very useful, because they are usually confused about what they are using.
About the recommendation, I think we prefer them to use the global CLI. And I guess most of the times they are using it by mistake. If they prefer to keep using that, they can check the documentation to uninstall the global one or simply ignore the warning.
One more doubt: is it ok to show this as an info
banner? Or maybe better as a warning
?
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.
Ah, I might suggest a slight rewording then, so that it doesn't feel like a dev is doing something wrong if they really want to use the local dependency approach. And I think info
works well, since there's not anything we know is dangerous or wrong.
In the local case:
Two Shopify CLI installations found – using local dependency: v3.50.1
A global installation (v3.68.1) and a local dependency (v3.50.1) were detected. We recommend removing the `@shopify/cli` and `@shopify/app` dependencies from your package.json, unless you want to use different versions across multiple apps.
In the global case:
Two Shopify CLI installations found – using global installation: v3.68.1
A global installation (v3.68.1) and a local dependency (v3.50.1) were detected. We recommend removing the `@shopify/cli` and `@shopify/app` dependencies from your package.json, unless you want to use different versions across multiple apps.
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.
Thanks, that looks much better. I've updated the code and the screenshot in the description. I've just changed two details:
- Removed the version from the title, because it's already in the next line
- Separated the content in two lines
WDYT?
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.
Looks good! Small thing - For the very last line, is it possible to only make the "Shopify CLI documentation" text the link, instead of the whole sentence?
48728c4
to
a74f30b
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
/snapit |
Differences in type declarationsWe detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:
New type declarationsWe found no new type declarations in this PR Existing type declarationspackages/cli-kit/dist/public/node/is-global.d.ts@@ -12,6 +12,12 @@ export declare function currentProcessIsGlobal(argv?: string[]): boolean;
* @returns if the global CLI is installed.
*/
export declare function isGlobalCLIInstalled(): Promise<boolean>;
+/**
+ * Returns true if the global CLI is installed.
+ *
+ * @returns if the global CLI is installed.
+ */
+export declare function globalCLIVersion(): Promise<string | undefined>;
/**
* Installs the global Shopify CLI, using the provided package manager.
*
packages/cli-kit/dist/public/node/node-package-manager.d.ts@@ -306,4 +306,11 @@ export declare function writePackageJSON(directory: string, packageJSON: Package
* @returns The inferred package manager as a PackageManager type.
*/
export declare function inferPackageManager(optionsPackageManager: string | undefined, env?: NodeJS.ProcessEnv): PackageManager;
+/**
+ * Returns the version of the local dependency of the CLI if it's installed in the provided directory.
+ *
+ * @param directory - path of the project to look for the dependency.
+ * @returns the CLI version or undefined if the dependency is not installed.
+ */
+export declare function localCLIVersion(directory: string): Promise<string | undefined>;
export {};
\ No newline at end of file
|
🫰✨ Thanks @gonzaloriestra! Your snapshot has been published to npm. Test the snapshot by intalling your package globally: pnpm i -g @shopify/[email protected]
|
WHY are these changes introduced?
The CLI can be installed both locally (as a project dependency) and globally at the same time, and it can be confusing for the users, who could be running an unexpected version.
We already had a warning when you run the global CLI having a local installation. But not in the opposite scenario: when you run the CLI locally having a global installation.
WHAT is this pull request doing?
Shows the warning when we detect multiple installations, no matter which one you are running:
How to test your changes?
Without a global installation:
npm i @shopify/[email protected]
npm run shopify app info
Install the global dependency:
npm i -g @shopify/[email protected]
shopify app info
npm run shopify app info
Measuring impact
How do we know this change was effective? Please choose one:
Checklist