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 json flag and output schema for all theme commands
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 @@ -8096,6 +8096,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 @@ -8106,7 +8115,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 * 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 * 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
247 changes: 245 additions & 2 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8765,14 +8765,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] [--password <value>]
[--path <value>] [-s <value>] [--verbose]
$ shopify theme metafields pull [--auth-alias <value>] [-e <value>...] [-j] [--json-schema] [--no-color] [--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 @@ -8808,6 +8812,245 @@ 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": [
{
"type": "object",
"properties": {
"status": {
"type": "string",
"const": "downloaded"
},
"path": {
"type": "string"
},
"definitions": {
"$ref": "#/definitions/MetafieldDefinitions"
},
"failedOwnerTypes": {
"type": "array",
"items": {
"$ref": "#/definitions/MetafieldOwnerType"
}
}
},
"required": [
"status",
"path",
"definitions",
"failedOwnerTypes"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"status": {
"type": "string",
"const": "failed"
},
"failedOwnerTypes": {
"type": "array",
"items": {
"$ref": "#/definitions/MetafieldOwnerType"
}
}
},
"required": [
"status",
"failedOwnerTypes"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"status": {
"type": "string",
"const": "skipped"
},
"reason": {
"type": "string",
"enum": [
"not-a-theme",
"cancelled"
]
}
},
"required": [
"status",
"reason"
],
"additionalProperties": false
}
],
"title": "ThemeMetafieldsPullResult",
"definitions": {
"MetafieldOwnerType": {
"type": "string",
"enum": [
"ARTICLE",
"BLOG",
"COLLECTION",
"COMPANY",
"COMPANY_LOCATION",
"LOCATION",
"MARKET",
"ORDER",
"PAGE",
"PRODUCT",
"PRODUCTVARIANT",
"SHOP"
]
},
"MetafieldType": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"category": {
"type": "string"
}
},
"required": [
"name",
"category"
],
"additionalProperties": false
},
"MetafieldDefinition": {
"type": "object",
"properties": {
"key": {
"type": "string"
},
"namespace": {
"type": "string"
},
"name": {
"type": "string"
},
"description": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/MetafieldType"
}
},
"required": [
"key",
"namespace",
"name",
"type"
],
"additionalProperties": false
},
"MetafieldDefinitions": {
"type": "object",
"properties": {
"article": {
"type": "array",
"items": {
"$ref": "#/definitions/MetafieldDefinition"
}
},
"blog": {
"type": "array",
"items": {
"$ref": "#/definitions/MetafieldDefinition"
}
},
"collection": {
"type": "array",
"items": {
"$ref": "#/definitions/MetafieldDefinition"
}
},
"company": {
"type": "array",
"items": {
"$ref": "#/definitions/MetafieldDefinition"
}
},
"company_location": {
"type": "array",
"items": {
"$ref": "#/definitions/MetafieldDefinition"
}
},
"location": {
"type": "array",
"items": {
"$ref": "#/definitions/MetafieldDefinition"
}
},
"market": {
"type": "array",
"items": {
"$ref": "#/definitions/MetafieldDefinition"
}
},
"order": {
"type": "array",
"items": {
"$ref": "#/definitions/MetafieldDefinition"
}
},
"page": {
"type": "array",
"items": {
"$ref": "#/definitions/MetafieldDefinition"
}
},
"product": {
"type": "array",
"items": {
"$ref": "#/definitions/MetafieldDefinition"
}
},
"variant": {
"type": "array",
"items": {
"$ref": "#/definitions/MetafieldDefinition"
}
},
"shop": {
"type": "array",
"items": {
"$ref": "#/definitions/MetafieldDefinition"
}
}
},
"required": [
"article",
"blog",
"collection",
"company",
"company_location",
"location",
"market",
"order",
"page",
"product",
"variant",
"shop"
],
"additionalProperties": false
}
},
"$schema": "http://json-schema.org/draft-07/schema#"
}
```
```
## `shopify theme open`
Expand Down
11 changes: 10 additions & 1 deletion packages/cli/oclif.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10540,7 +10540,7 @@
"args": {
},
"customPluginName": "@shopify/theme",
"description": "Retrieves metafields from Shopify Admin.\n\nIf the metafields file already exists, it will be overwritten.",
"description": "Retrieves metafields from Shopify Admin.\n\nIf the metafields file already exists, it will be overwritten.\n\nUse `--json-schema` to print the result, error, and event schemas.\n\nOutput from `--json` conforms to the `ThemeMetafieldsPullResult` schema.\n\n```json\n{\n \"anyOf\": [\n {\n \"type\": \"object\",\n \"properties\": {\n \"status\": {\n \"type\": \"string\",\n \"const\": \"downloaded\"\n },\n \"path\": {\n \"type\": \"string\"\n },\n \"definitions\": {\n \"$ref\": \"#/definitions/MetafieldDefinitions\"\n },\n \"failedOwnerTypes\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/definitions/MetafieldOwnerType\"\n }\n }\n },\n \"required\": [\n \"status\",\n \"path\",\n \"definitions\",\n \"failedOwnerTypes\"\n ],\n \"additionalProperties\": false\n },\n {\n \"type\": \"object\",\n \"properties\": {\n \"status\": {\n \"type\": \"string\",\n \"const\": \"failed\"\n },\n \"failedOwnerTypes\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/definitions/MetafieldOwnerType\"\n }\n }\n },\n \"required\": [\n \"status\",\n \"failedOwnerTypes\"\n ],\n \"additionalProperties\": false\n },\n {\n \"type\": \"object\",\n \"properties\": {\n \"status\": {\n \"type\": \"string\",\n \"const\": \"skipped\"\n },\n \"reason\": {\n \"type\": \"string\",\n \"enum\": [\n \"not-a-theme\",\n \"cancelled\"\n ]\n }\n },\n \"required\": [\n \"status\",\n \"reason\"\n ],\n \"additionalProperties\": false\n }\n ],\n \"title\": \"ThemeMetafieldsPullResult\",\n \"definitions\": {\n \"MetafieldOwnerType\": {\n \"type\": \"string\",\n \"enum\": [\n \"ARTICLE\",\n \"BLOG\",\n \"COLLECTION\",\n \"COMPANY\",\n \"COMPANY_LOCATION\",\n \"LOCATION\",\n \"MARKET\",\n \"ORDER\",\n \"PAGE\",\n \"PRODUCT\",\n \"PRODUCTVARIANT\",\n \"SHOP\"\n ]\n },\n \"MetafieldType\": {\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\n \"type\": \"string\"\n },\n \"category\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"name\",\n \"category\"\n ],\n \"additionalProperties\": false\n },\n \"MetafieldDefinition\": {\n \"type\": \"object\",\n \"properties\": {\n \"key\": {\n \"type\": \"string\"\n },\n \"namespace\": {\n \"type\": \"string\"\n },\n \"name\": {\n \"type\": \"string\"\n },\n \"description\": {\n \"type\": [\n \"string\",\n \"null\"\n ]\n },\n \"type\": {\n \"$ref\": \"#/definitions/MetafieldType\"\n }\n },\n \"required\": [\n \"key\",\n \"namespace\",\n \"name\",\n \"type\"\n ],\n \"additionalProperties\": false\n },\n \"MetafieldDefinitions\": {\n \"type\": \"object\",\n \"properties\": {\n \"article\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/definitions/MetafieldDefinition\"\n }\n },\n \"blog\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/definitions/MetafieldDefinition\"\n }\n },\n \"collection\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/definitions/MetafieldDefinition\"\n }\n },\n \"company\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/definitions/MetafieldDefinition\"\n }\n },\n \"company_location\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/definitions/MetafieldDefinition\"\n }\n },\n \"location\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/definitions/MetafieldDefinition\"\n }\n },\n \"market\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/definitions/MetafieldDefinition\"\n }\n },\n \"order\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/definitions/MetafieldDefinition\"\n }\n },\n \"page\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/definitions/MetafieldDefinition\"\n }\n },\n \"product\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/definitions/MetafieldDefinition\"\n }\n },\n \"variant\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/definitions/MetafieldDefinition\"\n }\n },\n \"shop\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/definitions/MetafieldDefinition\"\n }\n }\n },\n \"required\": [\n \"article\",\n \"blog\",\n \"collection\",\n \"company\",\n \"company_location\",\n \"location\",\n \"market\",\n \"order\",\n \"page\",\n \"product\",\n \"variant\",\n \"shop\"\n ],\n \"additionalProperties\": false\n }\n },\n \"$schema\": \"http://json-schema.org/draft-07/schema#\"\n}\n```",
"descriptionWithMarkdown": "Retrieves metafields from Shopify Admin.\n\nIf the metafields file already exists, it will be overwritten.",
"enableJsonFlag": false,
"flags": {
Expand Down Expand Up @@ -10570,6 +10570,15 @@
"name": "force",
"type": "boolean"
},
"json": {
"allowNo": false,
"char": "j",
"description": "Output the result as JSON. Automatically disables color output.",
"env": "SHOPIFY_FLAG_JSON",
"hidden": false,
"name": "json",
"type": "boolean"
},
"json-schema": {
"allowNo": false,
"description": "Print the command's JSON schemas.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ const commandExceptions = [
'packages/plugin-did-you-mean/src/commands/config/autocorrect/off.ts',
'packages/plugin-did-you-mean/src/commands/config/autocorrect/on.ts',
'packages/plugin-did-you-mean/src/commands/config/autocorrect/status.ts',
'packages/theme/src/cli/commands/theme/metafields/pull.ts',

// Streaming commands without a single finite result.
'packages/app/src/cli/commands/app/dev.ts',
Expand Down
Loading
Loading