Skip to content

Add typed JSON output to theme metafields pull - #8682

Open
gonzaloriestra wants to merge 1 commit into
gonzalo/json-theme-initfrom
gonzalo/json-theme-metafields-pull
Open

gonzaloriestra wants to merge 1 commit into
gonzalo/json-theme-initfrom
gonzalo/json-theme-metafields-pull

Conversation

@gonzaloriestra

@gonzaloriestra gonzaloriestra commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

theme metafields pull writes definitions to a file but has no typed, discoverable JSON result.

Closes shop/issues-develop#23694 together with the preceding package and init PRs.

WHAT is this pull request doing?

Use one supported-owner mapping for download requests, required definition keys, and the failed-owner enum. Adding a supported owner updates the output schema together with the downloader.

Return downloaded definitions and the output path as typed data, with explicit failed and skipped outcomes. Preserve the file contents, text messages, partial downloads, nonfatal total-fetch failures, and silent downloads used by theme dev. JSON results go to stdout; diagnostics stay on stderr.

Normal output:

Metafield definitions have been successfully downloaded.

Matching JSON example:

{
  "status": "downloaded",
  "path": "/themes/example/.shopify/metafields.json",
  "definitions": {
    "article": [],
    "blog": [],
    "collection": [],
    "company": [],
    "company_location": [],
    "location": [],
    "market": [],
    "order": [],
    "page": [],
    "product": [
      {
        "key": "subtitle",
        "namespace": "custom",
        "name": "Subtitle",
        "description": null,
        "type": {
          "name": "single_line_text_field",
          "category": "TEXT"
        }
      }
    ],
    "variant": [],
    "shop": []
  },
  "failedOwnerTypes": []
}

How to manually test your changes?

pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20260928103209
shopify theme metafields pull --store YOUR_STORE --path YOUR_THEME
shopify theme metafields pull --store YOUR_STORE --path YOUR_THEME --json
shopify theme metafields pull --json-schema

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.

@github-actions github-actions Bot added the Area: @shopify/cli @shopify/cli package issues label Sep 28, 2026
@gonzaloriestra
gonzaloriestra added this pull request to stack #8673 September 28, 2026 09:53
@gonzaloriestra
gonzaloriestra marked this pull request as ready for review September 28, 2026 10:22
@gonzaloriestra
gonzaloriestra requested review from a team as code owners September 28, 2026 10:22
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-metafields-pull branch from e49d75e to b3c2a68 Compare September 28, 2026 10:25
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-metafields-pull branch from b3c2a68 to 3907b2d Compare September 28, 2026 11:39
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-metafields-pull branch from 3907b2d to 6063572 Compare September 28, 2026 11:52
product: zod.array(MetafieldDefinitionSchema),
variant: zod.array(MetafieldDefinitionSchema),
shop: zod.array(MetafieldDefinitionSchema),
})

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 know if this is a stable list of fields or if it can easily change? if it changes often this can get stale soon

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.

The list was actually copied from metafields-pull.ts. I removed the duplicated lists: all share the handleToOwnerType mapping defined here now.

@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-metafields-pull branch from 6063572 to cedfc3d Compare September 29, 2026 10:28
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-metafields-pull branch from cedfc3d to 97dad3d Compare September 29, 2026 11:11
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-metafields-pull branch from 97dad3d to 872479d Compare September 29, 2026 11:38
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-metafields-pull branch from 872479d to ad8a3a9 Compare September 29, 2026 13:44
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-metafields-pull branch 2 times, most recently from 6817d73 to dc572f7 Compare September 29, 2026 14:40
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-metafields-pull branch from dc572f7 to 07395a8 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants