@shopify/cli 3.46.0-pre.2 → 3.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,77 @@
1
+ import Command from '@shopify/cli-kit/node/base-command';
2
+ import { renderTable, renderText } from '@shopify/cli-kit/node/ui';
3
+ import { Flags } from '@oclif/core';
4
+ export default class CommandFlags extends Command {
5
+ async run() {
6
+ const { flags } = await this.parse(CommandFlags);
7
+ const data = [];
8
+ for (const plugin of this.config.plugins) {
9
+ for (const command of plugin.commands) {
10
+ // We have to load the command, otherwise OCLIF will just use the manifest, and we need the actual class
11
+ // eslint-disable-next-line no-await-in-loop
12
+ const loaded = await command.load();
13
+ let pluginName;
14
+ if (plugin.name.startsWith('@shopify')) {
15
+ pluginName = plugin.name.substring('@shopify/'.length);
16
+ }
17
+ else {
18
+ pluginName = plugin.name.startsWith('@oclif') ? plugin.name.substring('@oclif/'.length) : plugin.name;
19
+ }
20
+ const flags = loaded.flags;
21
+ if (flags) {
22
+ for (const [flagName, flagConfig] of Object.entries(flags)) {
23
+ data.push({
24
+ pluginName,
25
+ command: command.id,
26
+ flagName: `--${flagName}`,
27
+ flagChar: flagConfig.char ? `-${flagConfig.char}` : '',
28
+ flagEnv: flagConfig.env,
29
+ });
30
+ }
31
+ }
32
+ }
33
+ }
34
+ if (flags.csv) {
35
+ const columns = ['pluginName', 'command', 'flagName', 'flagChar', 'flagEnv'];
36
+ const header = `${columns.join(',')}\n`;
37
+ const rows = data.map((obj) => columns.map((key) => obj[key]).join(',')).join('\n');
38
+ const csvString = header + rows;
39
+ renderText({ text: csvString });
40
+ }
41
+ else {
42
+ renderTable({
43
+ rows: data,
44
+ columns: {
45
+ pluginName: {
46
+ header: 'plugin',
47
+ color: 'red',
48
+ },
49
+ command: {},
50
+ flagName: {
51
+ header: 'long flag',
52
+ color: 'green',
53
+ },
54
+ flagChar: {
55
+ header: 'short flag',
56
+ color: 'green',
57
+ },
58
+ flagEnv: {
59
+ header: 'env variable',
60
+ color: 'blueBright',
61
+ },
62
+ },
63
+ });
64
+ }
65
+ }
66
+ }
67
+ CommandFlags.description = 'View all the available command flags';
68
+ CommandFlags.hidden = true;
69
+ CommandFlags.flags = {
70
+ // Similar options as the `commands` command from `plugin-commands`
71
+ csv: Flags.boolean({
72
+ description: 'Output as CSV',
73
+ env: 'SHOPIFY_FLAG_OUTPUT_CSV',
74
+ default: false,
75
+ }),
76
+ };
77
+ //# sourceMappingURL=command-flags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-flags.js","sourceRoot":"","sources":["../../../../src/cli/commands/debug/command-flags.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,oCAAoC,CAAA;AACxD,OAAO,EAAC,WAAW,EAAE,UAAU,EAAC,MAAM,0BAA0B,CAAA;AAChE,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AAEjC,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,OAAO;IAa/C,KAAK,CAAC,GAAG;QACP,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;QAE9C,MAAM,IAAI,GAAkG,EAAE,CAAA;QAC9G,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;YACxC,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE;gBACrC,wGAAwG;gBACxG,4CAA4C;gBAC5C,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,CAAA;gBAEnC,IAAI,UAAU,CAAA;gBACd,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;oBACtC,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;iBACvD;qBAAM;oBACL,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ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AO,EAAE;oBACP,UAAU,EAAE;wBACV,MAAM,EAAE,QAAQ;wBAChB,KAAK,EAAE,KAAK;qBACb;oBACD,OAAO,EAAE,EAAE;oBACX,QAAQ,EAAE;wBACR,MAAM,EAAE,WAAW;wBACnB,KAAK,EAAE,OAAO;qBACf;oBACD,QAAQ,EAAE;wBACR,MAAM,EAAE,YAAY;wBACpB,KAAK,EAAE,OAAO;qBACf;oBACD,OAAO,EAAE;wBACP,MAAM,EAAE,cAAc;wBACtB,KAAK,EAAE,YAAY;qBACpB;iBACF;aACF,CAAC,CAAA;SACH;IACH,CAAC;;AA1EM,wBAAW,GAAG,sCAAsC,CAAA;AACpD,mBAAM,GAAG,IAAI,CAAA;AAEb,kBAAK,GAAG;IACb,mEAAmE;IACnE,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC;QACjB,WAAW,EAAE,eAAe;QAC5B,GAAG,EAAE,yBAAyB;QAC9B,OAAO,EAAE,KAAK;KACf,CAAC;CACH,CAAA","sourcesContent":["import Command from '@shopify/cli-kit/node/base-command'\nimport {renderTable, renderText} from '@shopify/cli-kit/node/ui'\nimport {Flags} from '@oclif/core'\n\nexport default class CommandFlags extends Command {\n static description = 'View all the available command flags'\n static hidden = true\n\n static flags = {\n // Similar options as the `commands` command from `plugin-commands`\n csv: Flags.boolean({\n description: 'Output as CSV',\n env: 'SHOPIFY_FLAG_OUTPUT_CSV',\n default: false,\n }),\n }\n\n async run(): Promise<void> {\n const {flags} = await this.parse(CommandFlags)\n\n const data: {pluginName: string; command: string; flagName: string; flagChar: string; flagEnv?: string}[] = []\n for (const plugin of this.config.plugins) {\n for (const command of plugin.commands) {\n // We have to load the command, otherwise OCLIF will just use the manifest, and we need the actual class\n // eslint-disable-next-line no-await-in-loop\n const loaded = await command.load()\n\n let pluginName\n if (plugin.name.startsWith('@shopify')) {\n pluginName = plugin.name.substring('@shopify/'.length)\n } else {\n pluginName = plugin.name.startsWith('@oclif') ? plugin.name.substring('@oclif/'.length) : plugin.name\n }\n\n const flags = loaded.flags\n if (flags) {\n for (const [flagName, flagConfig] of Object.entries(flags)) {\n data.push({\n pluginName,\n command: command.id,\n flagName: `--${flagName}`,\n flagChar: flagConfig.char ? `-${flagConfig.char}` : '',\n flagEnv: flagConfig.env,\n })\n }\n }\n }\n }\n\n if (flags.csv) {\n const columns = ['pluginName', 'command', 'flagName', 'flagChar', 'flagEnv'] as const\n const header = `${columns.join(',')}\\n`\n const rows = data.map((obj) => columns.map((key) => obj[key]).join(',')).join('\\n')\n const csvString = header + rows\n renderText({text: csvString})\n } else {\n renderTable({\n rows: data,\n columns: {\n pluginName: {\n header: 'plugin',\n color: 'red',\n },\n command: {},\n flagName: {\n header: 'long flag',\n color: 'green',\n },\n flagChar: {\n header: 'short flag',\n color: 'green',\n },\n flagEnv: {\n header: 'env variable',\n color: 'blueBright',\n },\n },\n })\n }\n }\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import Command from '@shopify/cli-kit/node/base-command';
2
+ export default class Catalog extends Command {
3
+ static description: string;
4
+ static hidden: boolean;
5
+ run(): Promise<void>;
6
+ }
@@ -0,0 +1,31 @@
1
+ import { demo } from '../../services/demo.js';
2
+ import Command from '@shopify/cli-kit/node/base-command';
3
+ import { readFile } from '@shopify/cli-kit/node/fs';
4
+ import { joinPath } from '@shopify/cli-kit/node/path';
5
+ import { outputInfo } from '@shopify/cli-kit/node/output';
6
+ import { renderAutocompletePrompt } from '@shopify/cli-kit/node/ui';
7
+ import { fileURLToPath } from 'url';
8
+ export default class Catalog extends Command {
9
+ async run() {
10
+ const catalogFile = joinPath(fileURLToPath(import.meta.url), '../../../../../assets/demo-catalog.json');
11
+ const { steps } = JSON.parse(await readFile(catalogFile));
12
+ const stepSelection = await renderAutocompletePrompt({
13
+ message: 'Step to display',
14
+ choices: steps.map(({ title, type }) => {
15
+ return {
16
+ label: title,
17
+ value: title,
18
+ group: type,
19
+ };
20
+ }),
21
+ });
22
+ const selectedStep = steps.find(({ title }) => title === stepSelection);
23
+ outputInfo('The step looks like this:');
24
+ await demo({ steps: [selectedStep] });
25
+ outputInfo('JSON for this step:');
26
+ outputInfo(JSON.stringify(selectedStep, null, 2));
27
+ }
28
+ }
29
+ Catalog.description = 'Browse the catalog for steps';
30
+ Catalog.hidden = true;
31
+ //# sourceMappingURL=catalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../../../src/cli/commands/demo/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAW,MAAM,wBAAwB,CAAA;AACrD,OAAO,OAAO,MAAM,oCAAoC,CAAA;AACxD,OAAO,EAAC,QAAQ,EAAC,MAAM,0BAA0B,CAAA;AACjD,OAAO,EAAC,QAAQ,EAAC,MAAM,4BAA4B,CAAA;AACnD,OAAO,EAAC,UAAU,EAAC,MAAM,8BAA8B,CAAA;AACvD,OAAO,EAAC,wBAAwB,EAAC,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAC,aAAa,EAAC,MAAM,KAAK,CAAA;AAEjC,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,OAAO;IAI1C,KAAK,CAAC,GAAG;QACP,MAAM,WAAW,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,yCAAyC,CAAC,CAAA;QACvG,MAAM,EAAC,KAAK,EAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,WAAW,CAAC,CAAwB,CAAA;QAC9E,MAAM,aAAa,GAAG,MAAM,wBAAwB,CAAC;YACnD,OAAO,EAAE,iBAAiB;YAC1B,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,EAAC,KAAK,EAAE,IAAI,EAAC,EAAE,EAAE;gBACnC,OAAO;oBACL,KAAK,EAAE,KAAM;oBACb,KAAK,EAAE,KAAM;oBACb,KAAK,EAAE,IAAI;iBACZ,CAAA;YACH,CAAC,CAAC;SACH,CAAC,CAAA;QACF,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,EAAC,KAAK,EAAC,EAAE,EAAE,CAAC,KAAK,KAAK,aAAa,CAAE,CAAA;QACtE,UAAU,CAAC,2BAA2B,CAAC,CAAA;QACvC,MAAM,IAAI,CAAC,EAAC,KAAK,EAAE,CAAC,YAAY,CAAC,EAAC,CAAC,CAAA;QACnC,UAAU,CAAC,qBAAqB,CAAC,CAAA;QACjC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;IACnD,CAAC;;AArBM,mBAAW,GAAG,8BAA8B,CAAA;AAC5C,cAAM,GAAG,IAAI,CAAA","sourcesContent":["import {demo, DemoStep} from '../../services/demo.js'\nimport Command from '@shopify/cli-kit/node/base-command'\nimport {readFile} from '@shopify/cli-kit/node/fs'\nimport {joinPath} from '@shopify/cli-kit/node/path'\nimport {outputInfo} from '@shopify/cli-kit/node/output'\nimport {renderAutocompletePrompt} from '@shopify/cli-kit/node/ui'\nimport {fileURLToPath} from 'url'\n\nexport default class Catalog extends Command {\n static description = 'Browse the catalog for steps'\n static hidden = true\n\n async run(): Promise<void> {\n const catalogFile = joinPath(fileURLToPath(import.meta.url), '../../../../../assets/demo-catalog.json')\n const {steps} = JSON.parse(await readFile(catalogFile)) as {steps: DemoStep[]}\n const stepSelection = await renderAutocompletePrompt({\n message: 'Step to display',\n choices: steps.map(({title, type}) => {\n return {\n label: title!,\n value: title!,\n group: type,\n }\n }),\n })\n const selectedStep = steps.find(({title}) => title === stepSelection)!\n outputInfo('The step looks like this:')\n await demo({steps: [selectedStep]})\n outputInfo('JSON for this step:')\n outputInfo(JSON.stringify(selectedStep, null, 2))\n }\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import Command from '@shopify/cli-kit/node/base-command';
2
+ export default class GenerateFile extends Command {
3
+ static description: string;
4
+ static summary: string;
5
+ static hidden: boolean;
6
+ static flags: {
7
+ path: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
8
+ file: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
9
+ };
10
+ run(): Promise<void>;
11
+ }
@@ -0,0 +1,86 @@
1
+ var _a;
2
+ import { demoStepsSchema } from '../../services/demo.js';
3
+ import zodToJsonSchema from 'zod-to-json-schema';
4
+ import { Flags } from '@oclif/core';
5
+ import Command from '@shopify/cli-kit/node/base-command';
6
+ import { AbortError } from '@shopify/cli-kit/node/error';
7
+ import { mkdir, fileExists, readFile, writeFile } from '@shopify/cli-kit/node/fs';
8
+ import { outputContent, outputSuccess, outputToken } from '@shopify/cli-kit/node/output';
9
+ import { resolvePath, joinPath, cwd } from '@shopify/cli-kit/node/path';
10
+ import { renderAutocompletePrompt } from '@shopify/cli-kit/node/ui';
11
+ import { fileURLToPath } from 'url';
12
+ const schemaFilename = 'demo-schema.json';
13
+ export default class GenerateFile extends Command {
14
+ async run() {
15
+ const { flags } = await this.parse(GenerateFile);
16
+ await mkdir(flags.path);
17
+ const demoFilePath = joinPath(flags.path, flags.file);
18
+ if (await fileExists(demoFilePath)) {
19
+ throw new AbortError(`The file ${demoFilePath} already exists.`);
20
+ }
21
+ const demoSchemaPath = joinPath(flags.path, schemaFilename);
22
+ const jsonSchema = zodToJsonSchema.default(demoStepsSchema, 'demo-steps');
23
+ await Promise.all([
24
+ writeFile(demoSchemaPath, JSON.stringify(jsonSchema, null, 2)),
25
+ writeFile(demoFilePath, JSON.stringify({
26
+ $schema: `./${schemaFilename}`,
27
+ steps: await selectSteps(),
28
+ }, null, 2)),
29
+ ]);
30
+ outputSuccess(outputContent `Created ${outputToken.path(demoFilePath)} and ${outputToken.path(demoSchemaPath)}`);
31
+ }
32
+ }
33
+ _a = GenerateFile;
34
+ GenerateFile.description = 'Create a command design file';
35
+ GenerateFile.summary = 'Creates a JSON file alongside a JSON schema that will validate it';
36
+ GenerateFile.hidden = true;
37
+ GenerateFile.flags = {
38
+ path: Flags.string({
39
+ hidden: false,
40
+ description: 'The directory for generating the demo file.',
41
+ env: 'SHOPIFY_FLAG_PATH',
42
+ parse: async (input) => resolvePath(input),
43
+ default: async () => cwd(),
44
+ }),
45
+ file: Flags.string({
46
+ hidden: false,
47
+ description: 'The name of the demo file.',
48
+ env: 'SHOPIFY_FLAG_FILENAME',
49
+ required: true,
50
+ validate: (input) => {
51
+ if (input === schemaFilename) {
52
+ return `The demo file can't be named ${schemaFilename}, as this is used for the schema file.`;
53
+ }
54
+ return true;
55
+ },
56
+ }),
57
+ };
58
+ async function selectSteps() {
59
+ const catalogFile = joinPath(fileURLToPath(import.meta.url), '../../../../../assets/demo-catalog.json');
60
+ const { steps } = JSON.parse(await readFile(catalogFile));
61
+ const selectedSteps = [];
62
+ while (true) {
63
+ // eslint-disable-next-line no-await-in-loop
64
+ const stepSelection = await renderAutocompletePrompt({
65
+ message: 'Add a step to the demo file',
66
+ choices: [
67
+ {
68
+ label: "I'm done",
69
+ value: 'done',
70
+ },
71
+ ...steps.map(({ title, type }) => {
72
+ return {
73
+ label: title,
74
+ value: title,
75
+ group: type,
76
+ };
77
+ }),
78
+ ],
79
+ });
80
+ if (stepSelection === 'done')
81
+ break;
82
+ selectedSteps.push(steps.find(({ title }) => title === stepSelection));
83
+ }
84
+ return selectedSteps;
85
+ }
86
+ //# sourceMappingURL=generate-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-file.js","sourceRoot":"","sources":["../../../../src/cli/commands/demo/generate-file.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,eAAe,EAAW,MAAM,wBAAwB,CAAA;AAChE,OAAO,eAAe,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,OAAO,MAAM,oCAAoC,CAAA;AACxD,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAC,KAA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M,wBAAwB,CAAC;YACnD,OAAO,EAAE,6BAA6B;YACtC,OAAO,EAAE;gBACP;oBACE,KAAK,EAAE,UAAU;oBACjB,KAAK,EAAE,MAAM;iBACd;gBACD,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,EAAC,KAAK,EAAE,IAAI,EAAC,EAAE,EAAE;oBAC7B,OAAO;wBACL,KAAK,EAAE,KAAM;wBACb,KAAK,EAAE,KAAM;wBACb,KAAK,EAAE,IAAI;qBACZ,CAAA;gBACH,CAAC,CAAC;aACH;SACF,CAAC,CAAA;QACF,IAAI,aAAa,KAAK,MAAM;YAAE,MAAK;QACnC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAC,KAAK,EAAC,EAAE,EAAE,CAAC,KAAK,KAAK,aAAa,CAAE,CAAC,CAAA;KACtE;IACD,OAAO,aAAa,CAAA;AACtB,CAAC","sourcesContent":["import {demoStepsSchema, DemoStep} from '../../services/demo.js'\nimport zodToJsonSchema from 'zod-to-json-schema'\nimport {Flags} from '@oclif/core'\nimport Command from '@shopify/cli-kit/node/base-command'\nimport {AbortError} from '@shopify/cli-kit/node/error'\nimport {mkdir, fileExists, readFile, writeFile} from '@shopify/cli-kit/node/fs'\nimport {outputContent, outputSuccess, outputToken} from '@shopify/cli-kit/node/output'\nimport {resolvePath, joinPath, cwd} from '@shopify/cli-kit/node/path'\nimport {renderAutocompletePrompt} from '@shopify/cli-kit/node/ui'\nimport {fileURLToPath} from 'url'\n\nconst schemaFilename = 'demo-schema.json'\n\nexport default class GenerateFile extends Command {\n static description = 'Create a command design file'\n static summary = 'Creates a JSON file alongside a JSON schema that will validate it'\n static hidden = true\n\n static flags = {\n path: Flags.string({\n hidden: false,\n description: 'The directory for generating the demo file.',\n env: 'SHOPIFY_FLAG_PATH',\n parse: async (input) => resolvePath(input),\n default: async () => cwd(),\n }),\n file: Flags.string({\n hidden: false,\n description: 'The name of the demo file.',\n env: 'SHOPIFY_FLAG_FILENAME',\n required: true,\n validate: (input: string) => {\n if (input === schemaFilename) {\n return `The demo file can't be named ${schemaFilename}, as this is used for the schema file.`\n }\n return true\n },\n }),\n }\n\n async run(): Promise<void> {\n const {flags} = await this.parse(GenerateFile)\n await mkdir(flags.path)\n const demoFilePath = joinPath(flags.path, flags.file)\n if (await fileExists(demoFilePath)) {\n throw new AbortError(`The file ${demoFilePath} already exists.`)\n }\n const demoSchemaPath = joinPath(flags.path, schemaFilename)\n const jsonSchema = zodToJsonSchema.default(demoStepsSchema, 'demo-steps')\n await Promise.all([\n writeFile(demoSchemaPath, JSON.stringify(jsonSchema, null, 2)),\n writeFile(\n demoFilePath,\n JSON.stringify(\n {\n $schema: `./${schemaFilename}`,\n steps: await selectSteps(),\n },\n null,\n 2,\n ),\n ),\n ])\n outputSuccess(outputContent`Created ${outputToken.path(demoFilePath)} and ${outputToken.path(demoSchemaPath)}`)\n }\n}\n\nasync function selectSteps(): Promise<DemoStep[]> {\n const catalogFile = joinPath(fileURLToPath(import.meta.url), '../../../../../assets/demo-catalog.json')\n const {steps} = JSON.parse(await readFile(catalogFile)) as {steps: DemoStep[]}\n const selectedSteps: DemoStep[] = []\n while (true) {\n // eslint-disable-next-line no-await-in-loop\n const stepSelection = await renderAutocompletePrompt({\n message: 'Add a step to the demo file',\n choices: [\n {\n label: \"I'm done\",\n value: 'done',\n },\n ...steps.map(({title, type}) => {\n return {\n label: title!,\n value: title!,\n group: type,\n }\n }),\n ],\n })\n if (stepSelection === 'done') break\n selectedSteps.push(steps.find(({title}) => title === stepSelection)!)\n }\n return selectedSteps\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import Command from '@shopify/cli-kit/node/base-command';
2
+ export default class Demo extends Command {
3
+ static description: string;
4
+ static hidden: boolean;
5
+ static flags: {
6
+ file: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
7
+ };
8
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,27 @@
1
+ var _a;
2
+ import { demo } from '../../services/demo.js';
3
+ import { Flags } from '@oclif/core';
4
+ import Command from '@shopify/cli-kit/node/base-command';
5
+ import { readFile } from '@shopify/cli-kit/node/fs';
6
+ import { resolvePath, cwd } from '@shopify/cli-kit/node/path';
7
+ export default class Demo extends Command {
8
+ async run() {
9
+ const { flags } = await this.parse(Demo);
10
+ const contents = await readFile(flags.file);
11
+ const design = JSON.parse(contents);
12
+ await demo(design);
13
+ }
14
+ }
15
+ _a = Demo;
16
+ Demo.description = 'Demo a command design defined in a file';
17
+ Demo.hidden = true;
18
+ Demo.flags = {
19
+ file: Flags.string({
20
+ hidden: false,
21
+ description: 'The path to the design file.',
22
+ env: 'SHOPIFY_FLAG_PATH',
23
+ parse: async (input) => resolvePath(input),
24
+ default: async () => cwd(),
25
+ }),
26
+ };
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/cli/commands/demo/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,wBAAwB,CAAA;AAC3C,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,OAAO,MAAM,oCAAoC,CAAA;AACxD,OAAO,EAAC,QAAQ,EAAC,MAAM,0BAA0B,CAAA;AACjD,OAAO,EAAC,WAAW,EAAE,GAAG,EAAC,MAAM,4BAA4B,CAAA;AAE3D,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,OAAO;IAcvC,KAAK,CAAC,GAAG;QACP,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACtC,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;QACnC,MAAM,IAAI,CAAC,MAAM,CAAC,CAAA;IACpB,CAAC;;;AAlBM,gBAAW,GAAG,yCAAyC,CAAA;AACvD,WAAM,GAAG,IAAI,CAAA;AAEb,UAAK,GAAG;IACb,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC;QACjB,MAAM,EAAE,KAAK;QACb,WAAW,EAAE,8BAA8B;QAC3C,GAAG,EAAE,mBAAmB;QACxB,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC;QAC1C,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,GAAG,EAAE;KAC3B,CAAC;CACH,CAAA","sourcesContent":["import {demo} from '../../services/demo.js'\nimport {Flags} from '@oclif/core'\nimport Command from '@shopify/cli-kit/node/base-command'\nimport {readFile} from '@shopify/cli-kit/node/fs'\nimport {resolvePath, cwd} from '@shopify/cli-kit/node/path'\n\nexport default class Demo extends Command {\n static description = 'Demo a command design defined in a file'\n static hidden = true\n\n static flags = {\n file: Flags.string({\n hidden: false,\n description: 'The path to the design file.',\n env: 'SHOPIFY_FLAG_PATH',\n parse: async (input) => resolvePath(input),\n default: async () => cwd(),\n }),\n }\n\n async run(): Promise<void> {\n const {flags} = await this.parse(Demo)\n const contents = await readFile(flags.file)\n const design = JSON.parse(contents)\n await demo(design)\n }\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import Command from '@shopify/cli-kit/node/base-command';
2
+ export default class PrintAIPrompt extends Command {
3
+ static description: string;
4
+ static hidden: boolean;
5
+ run(): Promise<void>;
6
+ }
@@ -0,0 +1,38 @@
1
+ import { demoStepsSchema } from '../../services/demo.js';
2
+ import zodToJsonSchema from 'zod-to-json-schema';
3
+ import Command from '@shopify/cli-kit/node/base-command';
4
+ import { renderInfo } from '@shopify/cli-kit/node/ui';
5
+ import { outputInfo } from '@shopify/cli-kit/node/output';
6
+ export default class PrintAIPrompt extends Command {
7
+ async run() {
8
+ const jsonSchema = zodToJsonSchema.default(demoStepsSchema, 'demo-steps');
9
+ const printable = JSON.stringify(jsonSchema);
10
+ renderInfo({ body: 'Copy and paste the following into the system prompt.' });
11
+ outputInfo(`You are creating a demo for a Shopify CLI command, using a strictly typed JSON file.
12
+ The file defines the steps that will be executed during the demo.
13
+
14
+ The JSON schema for this file is:
15
+ \`\`\`json
16
+ ${printable}
17
+ \`\`\`
18
+ `);
19
+ renderInfo({ body: 'Then, fill out the following and paste it into the chat box.' });
20
+ outputInfo(`Generate a human-readable JSON file which will be used to create the demo. The JSON file must be typed according to the JSON schema.
21
+
22
+ The purpose of the command is: {A short description of the command.}
23
+
24
+ The demo should perform the following steps:
25
+
26
+ {
27
+ List the steps for the command, like:
28
+ 1. Prompt for this
29
+ 2. Autocomplete that
30
+ }
31
+
32
+ ============================================================
33
+ `);
34
+ }
35
+ }
36
+ PrintAIPrompt.description = 'Prints the prompts for a chat-enabled LLM to generate a demo';
37
+ PrintAIPrompt.hidden = true;
38
+ //# sourceMappingURL=print-ai-prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"print-ai-prompt.js","sourceRoot":"","sources":["../../../../src/cli/commands/demo/print-ai-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAA;AACtD,OAAO,eAAe,MAAM,oBAAoB,CAAA;AAChD,OAAO,OAAO,MAAM,oCAAoC,CAAA;AACxD,OAAO,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAA;AACnD,OAAO,EAAC,UAAU,EAAC,MAAM,8BAA8B,CAAA;AAEvD,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,OAAO;IAIhD,KAAK,CAAC,GAAG;QACP,MAAM,UAAU,GAAG,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE,YAAY,CAAC,CAAA;QACzE,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;QAC5C,UAAU,CAAC,EAAC,IAAI,EAAE,sDAAsD,EAAC,CAAC,CAAA;QAC1E,UAAU,CAAC;;;;;EAKb,SAAS;;CAEV,CAAC,CAAA;QACE,UAAU,CAAC,EAAC,IAAI,EAAE,8DAA8D,EAAC,CAAC,CAAA;QAElF,UAAU,CAAC;;;;;;;;;;;;;CAad,CAAC,CAAA;IACA,CAAC;;AA/BM,yBAAW,GAAG,8DAA8D,CAAA;AAC5E,oBAAM,GAAG,IAAI,CAAA","sourcesContent":["import {demoStepsSchema} from '../../services/demo.js'\nimport zodToJsonSchema from 'zod-to-json-schema'\nimport Command from '@shopify/cli-kit/node/base-command'\nimport {renderInfo} from '@shopify/cli-kit/node/ui'\nimport {outputInfo} from '@shopify/cli-kit/node/output'\n\nexport default class PrintAIPrompt extends Command {\n static description = 'Prints the prompts for a chat-enabled LLM to generate a demo'\n static hidden = true\n\n async run(): Promise<void> {\n const jsonSchema = zodToJsonSchema.default(demoStepsSchema, 'demo-steps')\n const printable = JSON.stringify(jsonSchema)\n renderInfo({body: 'Copy and paste the following into the system prompt.'})\n outputInfo(`You are creating a demo for a Shopify CLI command, using a strictly typed JSON file.\nThe file defines the steps that will be executed during the demo.\n\nThe JSON schema for this file is:\n\\`\\`\\`json\n${printable}\n\\`\\`\\`\n`)\n renderInfo({body: 'Then, fill out the following and paste it into the chat box.'})\n\n outputInfo(`Generate a human-readable JSON file which will be used to create the demo. The JSON file must be typed according to the JSON schema.\n\nThe purpose of the command is: {A short description of the command.}\n\nThe demo should perform the following steps:\n\n{\n List the steps for the command, like:\n 1. Prompt for this\n 2. Autocomplete that\n}\n\n============================================================\n`)\n }\n}\n"]}