Skip to content

Add typed JSON output to theme duplicate - #8640

Open
gonzaloriestra wants to merge 1 commit into
gonzalo/json-theme-openfrom
gonzalo/json-theme-duplicate
Open

gonzaloriestra wants to merge 1 commit into
gonzalo/json-theme-openfrom
gonzalo/json-theme-duplicate

Conversation

@gonzaloriestra

@gonzaloriestra gonzaloriestra commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

theme duplicate supports JSON, but its output contract is not discoverable and the service mixes mutation results with presentation.

Part of shop/issues-develop#23692.

WHAT is this pull request doing?

Add a shared success schema for theme mutations. Successful duplication returns status: "success", the original theme identity, and the new theme with preview_url. Validation and API errors return status: "failed"; an internally completed API call is not treated as success when it contains errors.

Add a domain-owned Zod schema, return typed outcomes from duplication, and move final output into a presenter. Preserve compact JSON, error messages, request-ID omission, terminal output, prompts, and exit behavior. Refresh help, the manifest, and the README.

For a theme named Original, normal output includes:

The theme 'Original' (#1) has been duplicated.

The matching JSON for the new copy is:

{
  "status": "success",
  "originalTheme": {
    "id": 1,
    "name": "Original",
    "role": "unpublished"
  },
  "theme": {
    "id": 2,
    "name": "Copy",
    "role": "unpublished",
    "shop": "example.myshopify.com",
    "preview_url": "https://example.myshopify.com?preview_theme_id=2"
  }
}

How to manually test your changes?

pnpm shopify theme duplicate --help
pnpm shopify theme duplicate --json-schema
pnpm shopify theme duplicate --store "$STORE" --theme "$THEME_ID" --name Copy --force
pnpm shopify theme duplicate --store "$STORE" --theme "$THEME_ID" --name Copy --force --json

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • A single changeset for all theme migrations is added in the last PR, #8682.

@gonzaloriestra gonzaloriestra changed the title gonzalo/json theme duplicate Add typed JSON output to theme duplicate Sep 24, 2026
@github-actions github-actions Bot added the Area: @shopify/cli @shopify/cli package issues label Sep 24, 2026
@gonzaloriestra
gonzaloriestra added this pull request to stack #8654 September 24, 2026 09:47
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-duplicate branch from d0ed9ba to c3e4082 Compare September 24, 2026 10:04
@gonzaloriestra
gonzaloriestra removed this pull request from stack #8654 September 24, 2026 10:04
@gonzaloriestra
gonzaloriestra changed the base branch from main to gonzalo/json-theme-open September 24, 2026 10:05
@gonzaloriestra
gonzaloriestra added this pull request to stack #8655 September 24, 2026 10:05
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-duplicate branch from c3e4082 to 827589c Compare September 24, 2026 10:13
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-duplicate branch from 827589c to 25b84a6 Compare September 24, 2026 10:25
@github-actions github-actions Bot added no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users. and removed Area: @shopify/cli @shopify/cli package issues labels Sep 24, 2026
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-duplicate branch from 25b84a6 to af1f31c Compare September 24, 2026 11:56
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-duplicate branch from af1f31c to 79c0066 Compare September 24, 2026 13:46
@gonzaloriestra
gonzaloriestra marked this pull request as ready for review September 24, 2026 14:12
@gonzaloriestra
gonzaloriestra requested review from a team as code owners September 24, 2026 14:12
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-duplicate branch from 79c0066 to d1a063b Compare September 24, 2026 14:36
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-duplicate branch from d1a063b to 5c39b71 Compare September 25, 2026 12:27
@gonzaloriestra
gonzaloriestra removed this pull request from stack #8655 September 25, 2026 12:28
@gonzaloriestra
gonzaloriestra added this pull request to stack #8673 September 25, 2026 12:29
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-duplicate branch from 5c39b71 to e67fd64 Compare September 28, 2026 08:20
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-duplicate branch 2 times, most recently from be76aef to b0ed722 Compare September 28, 2026 11:39
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-duplicate branch from b0ed722 to 10ddf56 Compare September 28, 2026 11:51
shop: adminSession.storeFqdn,
previewUrl: result.theme ? themePreviewUrl(result.theme, adminSession) : undefined,
...result,
})

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.

I'm not seeing any of these fields in the final JSON result, I just see the theme object, but not the status, originalTheme or previewUrl, are we filtering those?

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.

Right, the presenter was filtering them. Successful JSON now includes status: "success", originalTheme (ID, name, and role), and theme.preview_url, matching the URL naming used by push and pull. Error responses include status: "failed". The internal completed status is not forwarded because the API can complete with user errors or no copied theme.

@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-duplicate branch 2 times, most recently from 848aa4f to 3845191 Compare September 29, 2026 11:11
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-duplicate branch from 3845191 to b9d2115 Compare September 29, 2026 11:38
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-duplicate branch from b9d2115 to 0e18b79 Compare September 29, 2026 13:44
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-duplicate branch 2 times, most recently from 0816752 to 53cd727 Compare September 29, 2026 14:40
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-duplicate branch from 53cd727 to a7fafbf Compare October 1, 2026 08:52
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Differences in type declarations

We 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:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

We found no new type declarations in this PR

Existing type declarations

packages/cli-kit/dist/public/node/base-command.d.ts
@@ -35,6 +35,7 @@ declare abstract class BaseCommand extends Command {
         argv: string[];
     }>;
     protected environmentsFilename(): string | undefined;
+    protected validateNonTTYFlags(flags: FlagOutput): void;
     protected failMissingNonTTYFlags(flags: FlagOutput, requiredFlags: string[]): void;
     private failMissingNonTTYFlagRequirements;
     private applicableNonTTYFlagRequirements;

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users. shopify.dev preview

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants