Skip to content

Add link shop and storefront creation flags#3834

Open
gonzaloriestra wants to merge 2 commits into
mainfrom
gdt-hydrogen-link-create-flags
Open

Add link shop and storefront creation flags#3834
gonzaloriestra wants to merge 2 commits into
mainfrom
gdt-hydrogen-link-create-flags

Conversation

@gonzaloriestra

@gonzaloriestra gonzaloriestra commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

Fixes https://github.com/shop/issues-develop/issues/22878

shopify hydrogen link still required prompts to choose the shop and name a new storefront, which blocked noninteractive agent runs after project scaffolding.

WHAT is this pull request doing?

Adds --shop, --create-storefront, and --storefront-name to hydrogen link so agents can select a shop and create or link a storefront without prompts.

HOW to test your changes?

Use an unlinked Hydrogen project and a development shop:

shopify hydrogen link --path ./my-hydrogen-app --shop <store>.myshopify.com --storefront "Existing Storefront Name" --force
shopify hydrogen link --path ./my-hydrogen-app --shop <store>.myshopify.com --create-storefront --storefront-name "Agent CLI Test Storefront" --force

Both commands should complete without prompting for shop selection, storefront selection, or the new storefront name.

Post-merge steps

None.

gonzaloriestra commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

@gonzaloriestra gonzaloriestra force-pushed the gdt-hydrogen-env-pull-yes branch from 2caddc8 to f64cea7 Compare July 2, 2026 11:13
@gonzaloriestra gonzaloriestra force-pushed the gdt-hydrogen-link-create-flags branch from b06380d to 8406940 Compare July 2, 2026 11:13
@shopify

shopify Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Oxygen deployed a preview of your gdt-hydrogen-link-create-flags branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
Skeleton (skeleton.hydrogen.shop) ✅ Successful (Logs) Preview deployment Inspect deployment July 9, 2026 8:24 AM

Learn more about Hydrogen's GitHub integration.

@gonzaloriestra gonzaloriestra force-pushed the gdt-hydrogen-env-pull-yes branch from f64cea7 to 56f192c Compare July 3, 2026 12:10
@gonzaloriestra gonzaloriestra force-pushed the gdt-hydrogen-link-create-flags branch from 8406940 to 2250851 Compare July 3, 2026 12:10
@gonzaloriestra gonzaloriestra changed the title Add link storefront creation flags Add link shop and storefront creation flags Jul 3, 2026
@gonzaloriestra gonzaloriestra changed the base branch from gdt-hydrogen-env-pull-yes to graphite-base/3834 July 3, 2026 12:23
@gonzaloriestra gonzaloriestra force-pushed the gdt-hydrogen-link-create-flags branch from 2250851 to 0147582 Compare July 3, 2026 12:23
@gonzaloriestra gonzaloriestra changed the base branch from graphite-base/3834 to gdt-hydrogen-deploy-yes July 3, 2026 12:23
@gonzaloriestra gonzaloriestra force-pushed the gdt-hydrogen-link-create-flags branch from 0147582 to 97b8c94 Compare July 3, 2026 12:33
@gonzaloriestra gonzaloriestra force-pushed the gdt-hydrogen-deploy-yes branch from b337244 to 019d75b Compare July 3, 2026 12:33
@gonzaloriestra gonzaloriestra force-pushed the gdt-hydrogen-link-create-flags branch from 97b8c94 to 29ebc6c Compare July 3, 2026 14:07
@gonzaloriestra gonzaloriestra marked this pull request as ready for review July 3, 2026 14:29
@gonzaloriestra gonzaloriestra requested a review from a team as a code owner July 3, 2026 14:29

@lucyxiang lucyxiang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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


Review assisted by pair-review

});

it('normalizes CLI flag names before creating a storefront', async () => {
await Link.run([

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pair review pointed out this is the only time we use Link.run instead of runLink, which depends on "oclif resolving a Config in the vitest environment, which no other test in the suite relies on". Is this a valid issue- I don't have much context here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I replaced this with direct runLink coverage, so this test no longer depends on oclif resolving a Config in the Vitest environment.

}),
'storefront-name': Flags.string({
description: 'The name to use when creating a new Hydrogen storefront.',
env: 'SHOPIFY_HYDROGEN_STOREFRONT_NAME',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we want to use SHOPIFY_HYDROGEN_FLAG_STOREFRONT_NAME like most of the other variables

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated. The creation name flag now uses the standard flag env var pattern as SHOPIFY_HYDROGEN_FLAG_NAME.

}),
'storefront-name': Flags.string({
description: 'The name to use when creating a new Hydrogen storefront.',
env: 'SHOPIFY_HYDROGEN_STOREFRONT_NAME',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thoughts on storefront-create-name/ create-storefront-name ? Since this is only used with create-storefront. I find it confusing there's --storefront and now --storefront-name

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Or just --name?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Went with --name. In the hydrogen link command context it reads cleaner than another storefront-prefixed flag, and it avoids the --storefront / --storefront-name ambiguity.

root,
session,
storefronts,
storefrontName,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This createNewStorefront call sits in the final else branch, which is only reached when flagStorefront is falsy AND (flagCreateStorefront || storefrontName) is also falsy. storefrontName here can only be falsy — passing it implies there is additional data here.

Suggestion: Consider dropping the always-falsy argument

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed. The fallback createNewStorefront call no longer passes the name argument from the branch where it can only be absent.

defaultValue: defaultProjectName,
});
const projectName =
storefrontName ??

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The branch selector at line 180 uses a truthy test (flagCreateStorefront || storefrontName) while createNewStorefront uses a nullish fallback (storefrontName ?? renderTextPrompt(...)). An empty string is falsy but not nullish, creating a storefront with a blank name and no prompt (I assume blank name is invalid).

Suggestion: Consider treating a blank --storefront-name as absent (normalize '' to undefined) before the branch decision, or guard against an empty name explicitly, so the || and ?? checks share the same emptiness semantics.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed. The name is trimmed and blank values normalize to undefined before branch selection, with test coverage for the blank-name case.

@gonzaloriestra gonzaloriestra force-pushed the gdt-hydrogen-link-create-flags branch from 29ebc6c to ceded69 Compare July 7, 2026 10:13
@gonzaloriestra gonzaloriestra force-pushed the gdt-hydrogen-deploy-yes branch 2 times, most recently from b941d59 to e2e5d2e Compare July 8, 2026 08:55
@gonzaloriestra gonzaloriestra force-pushed the gdt-hydrogen-link-create-flags branch from ceded69 to bec4169 Compare July 8, 2026 08:55
@gonzaloriestra gonzaloriestra force-pushed the gdt-hydrogen-deploy-yes branch 2 times, most recently from 1085989 to fcc0333 Compare July 8, 2026 09:27
@gonzaloriestra gonzaloriestra force-pushed the gdt-hydrogen-link-create-flags branch 2 times, most recently from a44fa79 to d156023 Compare July 8, 2026 09:44
@gonzaloriestra gonzaloriestra force-pushed the gdt-hydrogen-deploy-yes branch 2 times, most recently from 5852064 to a72a9b3 Compare July 9, 2026 07:44
@gonzaloriestra gonzaloriestra force-pushed the gdt-hydrogen-deploy-yes branch from a72a9b3 to 286e006 Compare July 9, 2026 07:50
Add --create-storefront and --storefront-name to hydrogen link so agents can create a new Hydrogen storefront without answering the storefront selection and name prompts.\n\nThe existing --storefront flag remains the explicit existing-storefront path and is validated against the creation flags. Passing --storefront-name implies creating a new storefront and skips the name prompt; passing --create-storefront skips storefront selection and keeps the existing name prompt.\n\nTests cover both creation flags and the conflict with --storefront. The Oclif manifest and changeset are updated for the new user-facing flags.\n\nCloses shop/issues-develop#22878
@gonzaloriestra gonzaloriestra force-pushed the gdt-hydrogen-link-create-flags branch from d156023 to 8612b1e Compare July 9, 2026 08:22
Base automatically changed from gdt-hydrogen-deploy-yes to main July 9, 2026 08:24
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.

3 participants