Use findUp instead of npm prefix to find the project folder#7228
Use findUp instead of npm prefix to find the project folder#7228gonzaloriestra wants to merge 1 commit intomainfrom
Conversation
|
/snapit |
|
🫰✨ Thanks @gonzaloriestra! Your snapshot has been published to npm. Test the snapshot by installing your package globally: npm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20260409112001Caution After installing, validate the version by running |
Merge activity
|
|
I can see this is merging, and it may be the right fix for the immediate problem. I just want to make sure we’re explicitly aligned on the architectural direction here. As I understand it, this changes
to:
I’ve been working on a follow-up stack under a different assumption: keep the root/workspace-oriented behavior for the broad helper, then add narrower helper boundaries for cases that need different intent:
So this PR seems like more than an implementation detail — it changes the default resolution model. If that shift is intentional, I should probably rework parts of my stack accordingly, especially |
WHY are these changes introduced?
Related to: https://shopify.slack.com/archives/C07UJ7UNMTK/p1775663292357249
getPackageManager()spawnsnpm prefixas a subprocess to locate the project root. Ifnpmis unavailable, the subprocess fails and the function falls back to the user agent string. When the CLI is invoked directly (not viapnpm shopify), the user agent is unset, so the package manager resolves to"unknown"— causing commands likeshopify app generate extensionto fail withspawn unknown ENOENT.WHAT is this pull request doing?
Replaces the
npm prefixsubprocess call withfindPathUp('package.json'), a pure-filesystem walk that's already available in cli-kit. This eliminates the dependency onnpm, making package manager detection reliable regardless of how the CLI is invoked.How to test your changes?
pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20260409112001shopify app initshopify app generate extension --template checkout_ui --name test-extChecklist
pnpm changeset add