Guard Hydrogen primitives projects from classic CLI commands#3846
Conversation
|
Oxygen deployed a preview of your
Learn more about Hydrogen's GitHub integration. |
Hydrogen packages can declare unsupported Shopify CLI command IDs in shopify.cli.disabledCommands. Read that metadata from the installed package and stop listed commands with a generic error while leaving unlisted integration commands available. Assisted-By: devx/82312b61-7c91-4344-a141-09987c8b46eb
ec615f8 to
247902d
Compare
| } | ||
| } | ||
|
|
||
| export function isHydrogenProject(projectPath: string) { |
There was a problem hiding this comment.
Curious, this changed to also check devDeps and peerDeps, was it on purpose or LLM decision?
It also dropped support for --diff, which I think we don't use anymore since we have cookbook/recipes, but perhaps better to double check.
There was a problem hiding this comment.
It also dropped support for --diff, which I think we don't use anymore since we have cookbook/recipes, but perhaps better to double check.
Correct! I had a very hard time figuring out why that was there 😄
this changed to also check devDeps and peerDeps, was it on purpose or LLM decision?
this was an LLM decision but it made sense to me. I'm not sure why a user would have it as a non-prod dependency but if the package is available it makes sense that we should consider it a repo that a user can run commands in.
Hydrogen packages can support Shopify integration commands without also supporting Hydrogen classic's app lifecycle commands. The CLI needs that compatibility decision to come from the installed package rather than inferring it from the package shape.
This PR adds a central command policy to the CLI init hook:
shopify.cli.disabledCommandsfrom the installed@shopify/hydrogen/package.jsonThe disabled command list intentionally lives in the package rather than the CLI. This lets a Hydrogen package change its supported command surface without requiring another command-policy release. The matching metadata for the preview Hydrogen package is in #3847.
Tophatting 🎩
From a checkout of this PR:
Until the package metadata lands, patch the installed
@shopify/hydrogen/package.jsonin the project you want to test:This only changes the local
node_modulescopy. Reinstalling dependencies removes the patch.Then run the patched CLI from the Hydrogen checkout:
The first two commands should stop with the generic unsupported-command error.
env pullis not listed in the metadata and should continue to its help output.Validation