Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/theme-commands-json.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/cli': minor
---

Add structured JSON output to finite theme operations, including metafield downloads.
11 changes: 10 additions & 1 deletion docs-shopify.dev/generated/generated_docs_data_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -9417,6 +9417,15 @@
"isOptional": true,
"environmentValue": "SHOPIFY_FLAG_ENVIRONMENT"
},
{
"filePath": "docs-shopify.dev/commands/interfaces/theme-metafields-pull.interface.ts",
"syntaxKind": "PropertySignature",
"name": "-j, --json",
"value": "''",
"description": "Output the result as JSON. Automatically disables color output.",
"isOptional": true,
"environmentValue": "SHOPIFY_FLAG_JSON"
},
{
"filePath": "docs-shopify.dev/commands/interfaces/theme-metafields-pull.interface.ts",
"syntaxKind": "PropertySignature",
Expand All @@ -9427,7 +9436,7 @@
"environmentValue": "SHOPIFY_FLAG_STORE"
}
],
"value": "export interface thememetafieldspull {\n /**\n * Alias of the Shopify account to use for authentication.\n * @environment SHOPIFY_FLAG_AUTH_ALIAS\n */\n '--auth-alias <value>'?: string\n\n /**\n * The environment to apply to the current command.\n * @environment SHOPIFY_FLAG_ENVIRONMENT\n */\n '-e, --environment <value>'?: string\n\n /**\n * Print the command's JSON schemas.\n * @environment SHOPIFY_FLAG_JSON_SCHEMA\n */\n '--json-schema'?: ''\n\n /**\n * Disable color output.\n * @environment SHOPIFY_FLAG_NO_COLOR\n */\n '--no-color'?: ''\n\n /**\n * Disable interactive prompts and browser authentication.\n * @environment SHOPIFY_FLAG_NO_INPUT\n */\n '--no-input'?: ''\n\n /**\n * Password generated from the Theme Access app or an Admin API token.\n * @environment SHOPIFY_CLI_THEME_TOKEN\n */\n '--password <value>'?: string\n\n /**\n * The path where you want to run the command. Defaults to the current working directory.\n * @environment SHOPIFY_FLAG_PATH\n */\n '--path <value>'?: string\n\n /**\n * Store URL. It can be the store prefix (example) or the full myshopify.com URL (example.myshopify.com, https://example.myshopify.com).\n * @environment SHOPIFY_FLAG_STORE\n */\n '-s, --store <value>'?: string\n\n /**\n * Increase the verbosity of the output. May include sensitive data.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n}"
"value": "export interface thememetafieldspull {\n /**\n * Alias of the Shopify account to use for authentication.\n * @environment SHOPIFY_FLAG_AUTH_ALIAS\n */\n '--auth-alias <value>'?: string\n\n /**\n * The environment to apply to the current command.\n * @environment SHOPIFY_FLAG_ENVIRONMENT\n */\n '-e, --environment <value>'?: string\n\n /**\n * Output the result as JSON. Automatically disables color output.\n * @environment SHOPIFY_FLAG_JSON\n */\n '-j, --json'?: ''\n\n /**\n * Print the command's JSON schemas.\n * @environment SHOPIFY_FLAG_JSON_SCHEMA\n */\n '--json-schema'?: ''\n\n /**\n * Disable color output.\n * @environment SHOPIFY_FLAG_NO_COLOR\n */\n '--no-color'?: ''\n\n /**\n * Disable interactive prompts and browser authentication.\n * @environment SHOPIFY_FLAG_NO_INPUT\n */\n '--no-input'?: ''\n\n /**\n * Password generated from the Theme Access app or an Admin API token.\n * @environment SHOPIFY_CLI_THEME_TOKEN\n */\n '--password <value>'?: string\n\n /**\n * The path where you want to run the command. Defaults to the current working directory.\n * @environment SHOPIFY_FLAG_PATH\n */\n '--path <value>'?: string\n\n /**\n * Store URL. It can be the store prefix (example) or the full myshopify.com URL (example.myshopify.com, https://example.myshopify.com).\n * @environment SHOPIFY_FLAG_STORE\n */\n '-s, --store <value>'?: string\n\n /**\n * Increase the verbosity of the output. May include sensitive data.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n}"
}
},
"themeopen": {
Expand Down
348 changes: 347 additions & 1 deletion packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12697,14 +12697,18 @@ Download metafields definitions from your shop into a local file.

```
USAGE
$ shopify theme metafields pull [--auth-alias <value>] [-e <value>...] [--json-schema] [--no-color] [--no-input]
$ shopify theme metafields pull [--auth-alias <value>] [-e <value>...] [-j] [--json-schema] [--no-color] [--no-input]
[--password <value>] [--path <value>] [-s <value>] [--verbose]

FLAGS
-e, --environment=<value>...
The environment to apply to the current command.
[env: SHOPIFY_FLAG_ENVIRONMENT]

-j, --json
Output the result as JSON. Automatically disables color output.
[env: SHOPIFY_FLAG_JSON]

-s, --store=<value>
Store URL. It can be the store prefix (example) or the full myshopify.com URL (example.myshopify.com,
https://example.myshopify.com).
Expand Down Expand Up @@ -12744,6 +12748,348 @@ DESCRIPTION
Retrieves metafields from Shopify Admin.

If the metafields file already exists, it will be overwritten.

Use `--json-schema` to print the result, error, and event schemas.

Output from `--json` conforms to the `ThemeMetafieldsPullResult` schema.

```json
{
"anyOf": [
{
"$ref": "#/definitions/ThemeEnvironment/anyOf/0/properties/result"
},
{
"type": "object",
"properties": {
"environments": {
"type": "array",
"items": {
"$ref": "#/definitions/ThemeEnvironment"
}
}
},
"required": [
"environments"
],
"additionalProperties": false
}
],
"title": "ThemeMetafieldsPullResult",
"definitions": {
"MetafieldDefinition": {
"type": "object",
"properties": {
"ownerType": {
"type": "string",
"description": "The upstream owner type, such as PRODUCT or COMPANY_LOCATION."
},
"key": {
"type": "string"
},
"namespace": {
"type": "string"
},
"name": {
"type": "string"
},
"description": {
"type": [
"string",
"null"
]
},
"type": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The upstream metafield type, such as single_line_text_field."
},
"category": {
"type": "string",
"description": "The upstream metafield category."
}
},
"required": [
"name",
"category"
],
"additionalProperties": false
}
},
"required": [
"ownerType",
"key",
"namespace",
"name",
"description",
"type"
],
"additionalProperties": false
},
"ThemeEnvironment": {
"anyOf": [
{
"type": "object",
"properties": {
"environment": {
"type": "string"
},
"result": {
"anyOf": [
{
"anyOf": [
{
"type": "object",
"properties": {
"status": {
"type": "string",
"enum": [
"success",
"partial"
]
},
"changed": {
"type": "boolean",
"const": true
},
"path": {
"type": "string",
"description": "The absolute path of the native language-server metafields JSON artifact."
},
"definitions": {
"type": "array",
"items": {
"$ref": "#/definitions/MetafieldDefinition"
},
"description": "All fetched definitions, flattened across owner types."
},
"failedOwnerTypes": {
"type": "array",
"items": {
"type": "string"
},
"description": "Upstream owner types whose fetch failed."
}
},
"required": [
"status",
"changed",
"path",
"definitions",
"failedOwnerTypes"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"status": {
"type": "string",
"const": "skipped"
},
"reason": {
"type": "string",
"const": "not-a-theme"
}
},
"required": [
"status",
"reason"
],
"additionalProperties": false
}
]
},
{
"type": "object",
"properties": {
"status": {
"type": "string",
"const": "cancelled"
}
},
"required": [
"status"
],
"additionalProperties": false
}
]
}
},
"required": [
"environment",
"result"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"environment": {
"type": "string"
},
"error": {
"anyOf": [
{
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "abort"
},
"message": {
"type": "string"
},
"code": {
"type": "string",
"minLength": 1,
"description": "A stable error code, included only when known."
},
"tryMessage": {
"type": "string"
},
"nextSteps": {
"type": "array",
"items": {
"type": "string"
}
},
"customSections": {
"type": "array",
"items": {
"type": "object",
"properties": {
"title": {
"type": "string"
},
"body": {
"anyOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "array",
"items": {
"type": "string"
}
}
}
]
}
},
"required": [
"body"
],
"additionalProperties": false
}
},
"details": {
"description": "Selected domain details, preserving native API payloads such as GraphQL errors, extensions, and data."
}
},
"required": [
"type",
"message"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "bug"
},
"message": {
"$ref": "#/definitions/ThemeEnvironment/anyOf/1/properties/error/anyOf/0/properties/message"
},
"code": {
"$ref": "#/definitions/ThemeEnvironment/anyOf/1/properties/error/anyOf/0/properties/code"
},
"tryMessage": {
"$ref": "#/definitions/ThemeEnvironment/anyOf/1/properties/error/anyOf/0/properties/tryMessage"
},
"nextSteps": {
"$ref": "#/definitions/ThemeEnvironment/anyOf/1/properties/error/anyOf/0/properties/nextSteps"
},
"customSections": {
"$ref": "#/definitions/ThemeEnvironment/anyOf/1/properties/error/anyOf/0/properties/customSections"
},
"details": {
"$ref": "#/definitions/ThemeEnvironment/anyOf/1/properties/error/anyOf/0/properties/details"
},
"stack": {
"type": "string"
}
},
"required": [
"type",
"message"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "external"
},
"message": {
"$ref": "#/definitions/ThemeEnvironment/anyOf/1/properties/error/anyOf/0/properties/message"
},
"code": {
"$ref": "#/definitions/ThemeEnvironment/anyOf/1/properties/error/anyOf/0/properties/code"
},
"tryMessage": {
"$ref": "#/definitions/ThemeEnvironment/anyOf/1/properties/error/anyOf/0/properties/tryMessage"
},
"nextSteps": {
"$ref": "#/definitions/ThemeEnvironment/anyOf/1/properties/error/anyOf/0/properties/nextSteps"
},
"customSections": {
"$ref": "#/definitions/ThemeEnvironment/anyOf/1/properties/error/anyOf/0/properties/customSections"
},
"details": {
"$ref": "#/definitions/ThemeEnvironment/anyOf/1/properties/error/anyOf/0/properties/details"
},
"command": {
"type": "string"
},
"args": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"type",
"message",
"command",
"args"
],
"additionalProperties": false
}
]
}
},
"required": [
"environment",
"error"
],
"additionalProperties": false
}
]
}
},
"$schema": "http://json-schema.org/draft-07/schema#"
}
```
```

## `shopify theme open`
Expand Down
Loading
Loading