-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create
shopify theme metafields pull
command
- Loading branch information
Showing
12 changed files
with
662 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
'@shopify/theme': minor | ||
'@shopify/cli': minor | ||
--- | ||
|
||
New CLI command under `shopify theme` to pull metafield definitions from the shop | ||
|
||
Run command by calling `shopify theme metafields pull` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@shopify/cli-kit': patch | ||
--- | ||
|
||
Introduce method to fetch metafield definitions by ownerType from Admin API |
80 changes: 80 additions & 0 deletions
80
packages/cli-kit/src/cli/api/graphql/admin/generated/metafield_definitions_by_owner_type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* eslint-disable @typescript-eslint/consistent-type-definitions */ | ||
import * as Types from './types.js' | ||
|
||
import {TypedDocumentNode as DocumentNode} from '@graphql-typed-document-node/core' | ||
|
||
export type MetafieldDefinitionsByOwnerTypeQueryVariables = Types.Exact<{ | ||
ownerType: Types.MetafieldOwnerType | ||
}> | ||
|
||
export type MetafieldDefinitionsByOwnerTypeQuery = { | ||
metafieldDefinitions: { | ||
nodes: {name: string; namespace: string; description?: string | null; type: {category: string; name: string}}[] | ||
} | ||
} | ||
|
||
export const MetafieldDefinitionsByOwnerType = { | ||
kind: 'Document', | ||
definitions: [ | ||
{ | ||
kind: 'OperationDefinition', | ||
operation: 'query', | ||
name: {kind: 'Name', value: 'metafieldDefinitionsByOwnerType'}, | ||
variableDefinitions: [ | ||
{ | ||
kind: 'VariableDefinition', | ||
variable: {kind: 'Variable', name: {kind: 'Name', value: 'ownerType'}}, | ||
type: {kind: 'NonNullType', type: {kind: 'NamedType', name: {kind: 'Name', value: 'MetafieldOwnerType'}}}, | ||
}, | ||
], | ||
selectionSet: { | ||
kind: 'SelectionSet', | ||
selections: [ | ||
{ | ||
kind: 'Field', | ||
name: {kind: 'Name', value: 'metafieldDefinitions'}, | ||
arguments: [ | ||
{ | ||
kind: 'Argument', | ||
name: {kind: 'Name', value: 'ownerType'}, | ||
value: {kind: 'Variable', name: {kind: 'Name', value: 'ownerType'}}, | ||
}, | ||
{kind: 'Argument', name: {kind: 'Name', value: 'first'}, value: {kind: 'IntValue', value: '250'}}, | ||
], | ||
selectionSet: { | ||
kind: 'SelectionSet', | ||
selections: [ | ||
{ | ||
kind: 'Field', | ||
name: {kind: 'Name', value: 'nodes'}, | ||
selectionSet: { | ||
kind: 'SelectionSet', | ||
selections: [ | ||
{kind: 'Field', name: {kind: 'Name', value: 'name'}}, | ||
{kind: 'Field', name: {kind: 'Name', value: 'namespace'}}, | ||
{kind: 'Field', name: {kind: 'Name', value: 'description'}}, | ||
{ | ||
kind: 'Field', | ||
name: {kind: 'Name', value: 'type'}, | ||
selectionSet: { | ||
kind: 'SelectionSet', | ||
selections: [ | ||
{kind: 'Field', name: {kind: 'Name', value: 'category'}}, | ||
{kind: 'Field', name: {kind: 'Name', value: 'name'}}, | ||
{kind: 'Field', name: {kind: 'Name', value: '__typename'}}, | ||
], | ||
}, | ||
}, | ||
{kind: 'Field', name: {kind: 'Name', value: '__typename'}}, | ||
], | ||
}, | ||
}, | ||
{kind: 'Field', name: {kind: 'Name', value: '__typename'}}, | ||
], | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
} as unknown as DocumentNode<MetafieldDefinitionsByOwnerTypeQuery, MetafieldDefinitionsByOwnerTypeQueryVariables> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...ges/cli-kit/src/cli/api/graphql/admin/queries/metafield_definitions_by_owner_type.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
query metafieldDefinitionsByOwnerType($ownerType: MetafieldOwnerType!) { | ||
metafieldDefinitions(ownerType: $ownerType, first: 250) { | ||
nodes { | ||
name | ||
namespace | ||
description | ||
type { | ||
category | ||
name | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import {themeFlags} from '../../../flags.js' | ||
import {metafieldsPull, MetafieldsPullFlags} from '../../../services/metafields-pull.js' | ||
import ThemeCommand from '../../../utilities/theme-command.js' | ||
import {globalFlags} from '@shopify/cli-kit/node/cli' | ||
import {Flags} from '@oclif/core' | ||
|
||
export default class MetafieldsPull extends ThemeCommand { | ||
static summary = 'Download metafields defined on Shopify Admin into a local file.' | ||
|
||
static descriptionWithMarkdown = `Retrieves metafields from Shopify Admin. | ||
If the metafields file already exists, it will be overwritten.` | ||
|
||
static description = this.descriptionWithoutMarkdown() | ||
|
||
static flags = { | ||
...globalFlags, | ||
...{ | ||
path: themeFlags.path, | ||
password: themeFlags.password, | ||
store: themeFlags.store, | ||
}, | ||
force: Flags.boolean({ | ||
hidden: true, | ||
char: 'f', | ||
description: 'Proceed without confirmation, if current directory does not seem to be theme directory.', | ||
env: 'SHOPIFY_FLAG_FORCE', | ||
}), | ||
} | ||
|
||
async run(): Promise<void> { | ||
const {flags} = await this.parse(MetafieldsPull) | ||
const args: MetafieldsPullFlags = { | ||
path: flags.path, | ||
password: flags.password, | ||
store: flags.store, | ||
force: flags.force, | ||
verbose: flags.verbose, | ||
noColor: flags['no-color'], | ||
} | ||
|
||
await metafieldsPull(args) | ||
} | ||
} |
Oops, something went wrong.