@shopify/create-app 3.58.2 → 3.59.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.
- package/dist/chunk-3JLUTHGR.js +114 -0
- package/dist/chunk-3JNB3A7C.js +14080 -0
- package/dist/chunk-4DXNY52K.js +104 -0
- package/dist/chunk-4SXWHRL5.js +62 -0
- package/dist/chunk-5RH4B5Q7.js +30996 -0
- package/dist/chunk-7XQTD3L4.js +213522 -0
- package/dist/chunk-ADG25CKO.js +2468 -0
- package/dist/chunk-ASLSMEKR.js +18914 -0
- package/dist/chunk-BOIUUJSH.js +99 -0
- package/dist/chunk-CKY5L2DS.js +37 -0
- package/dist/chunk-CPDHSAO5.js +3179 -0
- package/dist/chunk-FBB6KUZG.js +821 -0
- package/dist/chunk-G6FN5VUE.js +102 -0
- package/dist/chunk-GXPKATXW.js +194 -0
- package/dist/chunk-H7CRO63U.js +11 -0
- package/dist/chunk-JP7Y3CTL.js +72 -0
- package/dist/chunk-LKGDG6WW.js +87 -0
- package/dist/chunk-M63RTPGR.js +63 -0
- package/dist/chunk-ND5WSAZY.js +7817 -0
- package/dist/chunk-P4TVG45N.js +900 -0
- package/dist/chunk-TMGCRPEZ.js +4283 -0
- package/dist/chunk-UVY6LL5H.js +145 -0
- package/dist/chunk-VMPTLMJN.js +144 -0
- package/dist/chunk-WCNR75S2.js +73 -0
- package/dist/chunk-WLJ2CNLG.js +45349 -0
- package/dist/chunk-YLEF4RUH.js +144 -0
- package/dist/chunk-ZDCQCTOO.js +13764 -0
- package/dist/chunk-ZPB26OWQ.js +5605 -0
- package/dist/commands/init.d.ts +2 -1
- package/dist/commands/init.js +31 -123
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/init.test.js +123 -0
- package/dist/constants-K3R4N3N3.js +19 -0
- package/dist/custom-oclif-loader-GA6B7DEF.js +83 -0
- package/dist/del-A5YM6R3Y.js +2846 -0
- package/dist/devtools-KQM4GF6J.js +3685 -0
- package/dist/error-handler-U53E7YKG.js +34 -0
- package/dist/hooks/postrun.js +108 -2
- package/dist/hooks/prerun.js +77 -2
- package/dist/index.js +22 -7
- package/dist/lib-76JUGQYQ.js +8 -0
- package/dist/local-XVLEGQFE.js +59 -0
- package/dist/magic-string.es-6WMSFIAX.js +1291 -0
- package/dist/multipart-parser-O2BQODS2.js +359 -0
- package/dist/node-package-manager-76YAD3UB.js +68 -0
- package/dist/open-B7XFJJCK.js +290 -0
- package/dist/out-JZ52TJE3.js +5 -0
- package/dist/path-HO4HBKK5.js +28 -0
- package/dist/prompts/init.d.ts +4 -3
- package/dist/prompts/init.js +23 -118
- package/dist/prompts/init.js.map +1 -1
- package/dist/prompts/init.test.js +115 -0
- package/dist/services/init.d.ts +3 -1
- package/dist/services/init.js +25 -139
- package/dist/services/init.js.map +1 -1
- package/dist/services/init.test.js +18 -0
- package/dist/system-XBDENYNR.js +25 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui-ZVCYWXG6.js +49 -0
- package/dist/utils/template/cleanup.js +18 -19
- package/dist/utils/template/cleanup.test.js +74 -0
- package/dist/utils/template/npm.d.ts +2 -1
- package/dist/utils/template/npm.js +22 -58
- package/dist/utils/template/npm.js.map +1 -1
- package/dist/utils/template/npm.test.js +153 -0
- package/dist/yoga.wasm +0 -0
- package/oclif.manifest.json +1 -1
- package/package.json +5 -6
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +0 -2
- package/dist/constants.js.map +0 -1
- package/dist/utils/versions.d.ts +0 -1
- package/dist/utils/versions.js +0 -21
- package/dist/utils/versions.js.map +0 -1
package/dist/commands/init.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import Command from '@shopify/cli-kit/node/base-command';
|
|
3
|
-
import {
|
|
3
|
+
import { PackageManager } from '@shopify/cli-kit/node/node-package-manager';
|
|
4
4
|
export default class Init extends Command {
|
|
5
5
|
static summary?: string | undefined;
|
|
6
6
|
static flags: {
|
|
@@ -17,4 +17,5 @@ export default class Init extends Command {
|
|
|
17
17
|
validateTemplateValue(template: string | undefined): void;
|
|
18
18
|
validateFlavorValue(template: string | undefined, flavor: string | undefined): void;
|
|
19
19
|
parseURL(url: string): URL | undefined;
|
|
20
|
+
inferPackageManager(optionsPackageManager: string | undefined): PackageManager;
|
|
20
21
|
}
|
package/dist/commands/init.js
CHANGED
|
@@ -1,124 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
local: flags.local,
|
|
33
|
-
directory: flags.path,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
validateTemplateValue(template) {
|
|
37
|
-
if (!template) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const url = this.parseURL(template);
|
|
41
|
-
if (url && url.origin !== 'https://github.com')
|
|
42
|
-
throw new AbortError('Only GitHub repository references are supported, ' +
|
|
43
|
-
'e.g., https://github.com/Shopify/<repository>/[subpath]#[branch]');
|
|
44
|
-
if (!url && !isPredefinedTemplate(template))
|
|
45
|
-
throw new AbortError(outputContent `Only ${visibleTemplates
|
|
46
|
-
.map((alias) => outputContent `${outputToken.yellow(alias)}`.value)
|
|
47
|
-
.join(', ')} template aliases are supported`);
|
|
48
|
-
}
|
|
49
|
-
validateFlavorValue(template, flavor) {
|
|
50
|
-
if (!template) {
|
|
51
|
-
if (flavor) {
|
|
52
|
-
throw new AbortError(outputContent `The ${outputToken.yellow('--flavor')} flag requires the ${outputToken.yellow('--template')} flag to be set`);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (!flavor) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
if (!isPredefinedTemplate(template)) {
|
|
62
|
-
throw new AbortError(outputContent `The ${outputToken.yellow('--flavor')} flag is not supported for custom templates`);
|
|
63
|
-
}
|
|
64
|
-
const templateConfig = templates[template];
|
|
65
|
-
if (!templateConfig.branches) {
|
|
66
|
-
throw new AbortError(outputContent `The ${outputToken.yellow(template)} template does not support flavors`);
|
|
67
|
-
}
|
|
68
|
-
if (!templateConfig.branches.options[flavor]) {
|
|
69
|
-
throw new AbortError(outputContent `Invalid option for ${outputToken.yellow('--flavor')}\nThe ${outputToken.yellow('--flavor')} flag for ${outputToken.yellow(template)} accepts only ${Object.keys(templateConfig.branches.options)
|
|
70
|
-
.map((alias) => outputContent `${outputToken.yellow(alias)}`.value)
|
|
71
|
-
.join(', ')}`);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
parseURL(url) {
|
|
75
|
-
try {
|
|
76
|
-
return new URL(url);
|
|
77
|
-
// eslint-disable-next-line no-catch-all/no-catch-all
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
return undefined;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
_a = Init;
|
|
85
|
-
Init.summary = 'Create a new app project';
|
|
86
|
-
Init.flags = {
|
|
87
|
-
...globalFlags,
|
|
88
|
-
name: Flags.string({
|
|
89
|
-
char: 'n',
|
|
90
|
-
env: 'SHOPIFY_FLAG_NAME',
|
|
91
|
-
hidden: false,
|
|
92
|
-
}),
|
|
93
|
-
path: Flags.string({
|
|
94
|
-
char: 'p',
|
|
95
|
-
env: 'SHOPIFY_FLAG_PATH',
|
|
96
|
-
parse: async (input) => resolvePath(input),
|
|
97
|
-
default: async () => cwd(),
|
|
98
|
-
hidden: false,
|
|
99
|
-
}),
|
|
100
|
-
template: Flags.string({
|
|
101
|
-
description: `The app template. Accepts one of the following:
|
|
102
|
-
- <${visibleTemplates.join('|')}>
|
|
103
|
-
- Any GitHub repo with optional branch and subpath, e.g., https://github.com/Shopify/<repository>/[subpath]#[branch]`,
|
|
104
|
-
env: 'SHOPIFY_FLAG_TEMPLATE',
|
|
105
|
-
}),
|
|
106
|
-
flavor: Flags.string({
|
|
107
|
-
description: 'Which flavor of the given template to use.',
|
|
108
|
-
env: 'SHOPIFY_FLAG_TEMPLATE_FLAVOR',
|
|
109
|
-
}),
|
|
110
|
-
'package-manager': Flags.string({
|
|
111
|
-
char: 'd',
|
|
112
|
-
env: 'SHOPIFY_FLAG_PACKAGE_MANAGER',
|
|
113
|
-
hidden: false,
|
|
114
|
-
options: ['npm', 'yarn', 'pnpm', 'bun'],
|
|
115
|
-
}),
|
|
116
|
-
local: Flags.boolean({
|
|
117
|
-
char: 'l',
|
|
118
|
-
env: 'SHOPIFY_FLAG_LOCAL',
|
|
119
|
-
default: false,
|
|
120
|
-
hidden: true,
|
|
121
|
-
}),
|
|
1
|
+
import {
|
|
2
|
+
Init
|
|
3
|
+
} from "../chunk-ADG25CKO.js";
|
|
4
|
+
import "../chunk-CPDHSAO5.js";
|
|
5
|
+
import "../chunk-LKGDG6WW.js";
|
|
6
|
+
import "../chunk-ND5WSAZY.js";
|
|
7
|
+
import "../chunk-CKY5L2DS.js";
|
|
8
|
+
import "../chunk-4SXWHRL5.js";
|
|
9
|
+
import "../chunk-ASLSMEKR.js";
|
|
10
|
+
import "../chunk-5RH4B5Q7.js";
|
|
11
|
+
import "../chunk-H7CRO63U.js";
|
|
12
|
+
import "../chunk-TMGCRPEZ.js";
|
|
13
|
+
import "../chunk-BOIUUJSH.js";
|
|
14
|
+
import "../chunk-JP7Y3CTL.js";
|
|
15
|
+
import "../chunk-ZDCQCTOO.js";
|
|
16
|
+
import "../chunk-4DXNY52K.js";
|
|
17
|
+
import "../chunk-VMPTLMJN.js";
|
|
18
|
+
import "../chunk-WLJ2CNLG.js";
|
|
19
|
+
import "../chunk-FBB6KUZG.js";
|
|
20
|
+
import "../chunk-YLEF4RUH.js";
|
|
21
|
+
import "../chunk-G6FN5VUE.js";
|
|
22
|
+
import "../chunk-UVY6LL5H.js";
|
|
23
|
+
import "../chunk-7XQTD3L4.js";
|
|
24
|
+
import "../chunk-P4TVG45N.js";
|
|
25
|
+
import "../chunk-ZPB26OWQ.js";
|
|
26
|
+
import "../chunk-WCNR75S2.js";
|
|
27
|
+
import "../chunk-3JLUTHGR.js";
|
|
28
|
+
import "../chunk-GXPKATXW.js";
|
|
29
|
+
import "../chunk-M63RTPGR.js";
|
|
30
|
+
export {
|
|
31
|
+
Init as default
|
|
122
32
|
};
|
|
123
|
-
export default Init;
|
|
124
|
-
//# sourceMappingURL=init.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":";AAAA,OAAO,UAAU,EAAE,EAAC,oBAAoB,EAAE,SAAS,EAAE,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AAChG,OAAO,WAAW,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAA;AACrD,OAAO,OAAO,MAAM,oCAAoC,CAAA;AACxD,OAAO,EAAC,WAAW,EAAE,GAAG,EAAC,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,8BAA8B,CAAA;AACvE,OAAO,EAAC,iBAAiB,EAAC,MAAM,gCAAgC,CAAA;AAChE,kDAAkD;AAClD,OAAO,EAAC,GAAG,EAAC,MA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AE,KAAK;QACb,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC;KACxC,CAAC;IACF,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC;QACnB,IAAI,EAAE,GAAG;QACT,GAAG,EAAE,oBAAoB;QACzB,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,IAAI;KACb,CAAC;CACH,AApCW,CAoCX;eAvCkB,IAAI","sourcesContent":["import initPrompt, {isPredefinedTemplate, templates, visibleTemplates} from '../prompts/init.js'\nimport initService from '../services/init.js'\nimport {Flags} from '@oclif/core'\nimport {globalFlags} from '@shopify/cli-kit/node/cli'\nimport Command from '@shopify/cli-kit/node/base-command'\nimport {resolvePath, cwd} from '@shopify/cli-kit/node/path'\nimport {AbortError} from '@shopify/cli-kit/node/error'\nimport {outputContent, outputToken} from '@shopify/cli-kit/node/output'\nimport {addPublicMetadata} from '@shopify/cli-kit/node/metadata'\n// eslint-disable-next-line node/prefer-global/url\nimport {URL} from 'url'\n\nexport default class Init extends Command {\n static summary?: string | undefined = 'Create a new app project'\n\n static flags = {\n ...globalFlags,\n name: Flags.string({\n char: 'n',\n env: 'SHOPIFY_FLAG_NAME',\n hidden: false,\n }),\n path: Flags.string({\n char: 'p',\n env: 'SHOPIFY_FLAG_PATH',\n parse: async (input) => resolvePath(input),\n default: async () => cwd(),\n hidden: false,\n }),\n template: Flags.string({\n description: `The app template. Accepts one of the following:\n - <${visibleTemplates.join('|')}>\n - Any GitHub repo with optional branch and subpath, e.g., https://github.com/Shopify/<repository>/[subpath]#[branch]`,\n env: 'SHOPIFY_FLAG_TEMPLATE',\n }),\n flavor: Flags.string({\n description: 'Which flavor of the given template to use.',\n env: 'SHOPIFY_FLAG_TEMPLATE_FLAVOR',\n }),\n 'package-manager': Flags.string({\n char: 'd',\n env: 'SHOPIFY_FLAG_PACKAGE_MANAGER',\n hidden: false,\n options: ['npm', 'yarn', 'pnpm', 'bun'],\n }),\n local: Flags.boolean({\n char: 'l',\n env: 'SHOPIFY_FLAG_LOCAL',\n default: false,\n hidden: true,\n }),\n }\n\n async run(): Promise<void> {\n const {flags} = await this.parse(Init)\n\n this.validateTemplateValue(flags.template)\n this.validateFlavorValue(flags.template, flags.flavor)\n\n const promptAnswers = await initPrompt({\n name: flags.name,\n template: flags.template,\n flavor: flags.flavor,\n directory: flags.path,\n })\n\n await addPublicMetadata(() => ({\n cmd_create_app_template: promptAnswers.templateType,\n cmd_create_app_template_url: promptAnswers.template,\n }))\n\n await initService({\n name: promptAnswers.name,\n packageManager: flags['package-manager'],\n template: promptAnswers.template,\n local: flags.local,\n directory: flags.path,\n })\n }\n\n validateTemplateValue(template: string | undefined) {\n if (!template) {\n return\n }\n\n const url = this.parseURL(template)\n if (url && url.origin !== 'https://github.com')\n throw new AbortError(\n 'Only GitHub repository references are supported, ' +\n 'e.g., https://github.com/Shopify/<repository>/[subpath]#[branch]',\n )\n if (!url && !isPredefinedTemplate(template))\n throw new AbortError(\n outputContent`Only ${visibleTemplates\n .map((alias) => outputContent`${outputToken.yellow(alias)}`.value)\n .join(', ')} template aliases are supported`,\n )\n }\n\n validateFlavorValue(template: string | undefined, flavor: string | undefined) {\n if (!template) {\n if (flavor) {\n throw new AbortError(\n outputContent`The ${outputToken.yellow('--flavor')} flag requires the ${outputToken.yellow(\n '--template',\n )} flag to be set`,\n )\n } else {\n return\n }\n }\n\n if (!flavor) {\n return\n }\n\n if (!isPredefinedTemplate(template)) {\n throw new AbortError(\n outputContent`The ${outputToken.yellow('--flavor')} flag is not supported for custom templates`,\n )\n }\n\n const templateConfig = templates[template]\n\n if (!templateConfig.branches) {\n throw new AbortError(outputContent`The ${outputToken.yellow(template)} template does not support flavors`)\n }\n\n if (!templateConfig.branches.options[flavor]) {\n throw new AbortError(\n outputContent`Invalid option for ${outputToken.yellow('--flavor')}\\nThe ${outputToken.yellow(\n '--flavor',\n )} flag for ${outputToken.yellow(template)} accepts only ${Object.keys(templateConfig.branches.options)\n .map((alias) => outputContent`${outputToken.yellow(alias)}`.value)\n .join(', ')}`,\n )\n }\n }\n\n parseURL(url: string): URL | undefined {\n try {\n return new URL(url)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n return undefined\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":";AAAA,OAAO,UAAU,EAAE,EAAC,oBAAoB,EAAE,SAAS,EAAE,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AAChG,OAAO,WAAW,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAA;AACrD,OAAO,OAAO,MAAM,oCAAoC,CAAA;AACxD,OAAO,EAAC,WAAW,EAAE,GAAG,EAAC,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,8BAA8B,CAAA;AACvE,OAAO,EAAC,iBAAiB,EAAC,MAAM,gCAAgC,CAAA;AAEhE,OAAO,EAAiB,cAAc,EAAE,2BAA2B,EAAC,MAAM,4CAA4C,CAAA;AACtH,OAAO,EAAC,+BAA+B,EAAE,uBAAuB,EAAC,MAAM,iCAAiC,CAAA;AAExG,MAAqB,IAAK,SAAQ,OAAO;IAyCvC,KAAK,CAAC,GAAG;QACP,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,EAAI,CAAC,CAAA;QAEtC,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;QAC1C,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;QAEtD,MAAM,sBAAsB,GAAG,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,iBAAi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;4HACsF;QACtH,GAAG,EAAE,uBAAuB;KAC7B,CAAC;IACF,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC;QACnB,WAAW,EAAE,4CAA4C;QACzD,GAAG,EAAE,8BAA8B;KACpC,CAAC;IACF,iBAAiB,EAAE,KAAK,CAAC,MAAM,CAAC;QAC9B,IAAI,EAAE,GAAG;QACT,GAAG,EAAE,8BAA8B;QACnC,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC;KACxC,CAAC;IACF,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC;QACnB,IAAI,EAAE,GAAG;QACT,GAAG,EAAE,oBAAoB;QACzB,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,IAAI;KACb,CAAC;CACH,AApCW,CAoCX;eAvCkB,IAAI","sourcesContent":["import initPrompt, {isPredefinedTemplate, templates, visibleTemplates} from '../prompts/init.js'\nimport initService from '../services/init.js'\nimport {Flags} from '@oclif/core'\nimport {globalFlags} from '@shopify/cli-kit/node/cli'\nimport Command from '@shopify/cli-kit/node/base-command'\nimport {resolvePath, cwd} from '@shopify/cli-kit/node/path'\nimport {AbortError} from '@shopify/cli-kit/node/error'\nimport {outputContent, outputToken} from '@shopify/cli-kit/node/output'\nimport {addPublicMetadata} from '@shopify/cli-kit/node/metadata'\n\nimport {PackageManager, packageManager, packageManagerFromUserAgent} from '@shopify/cli-kit/node/node-package-manager'\nimport {inferPackageManagerForGlobalCLI, installGlobalShopifyCLI} from '@shopify/cli-kit/node/is-global'\n\nexport default class Init extends Command {\n static summary?: string | undefined = 'Create a new app project'\n\n static flags = {\n ...globalFlags,\n name: Flags.string({\n char: 'n',\n env: 'SHOPIFY_FLAG_NAME',\n hidden: false,\n }),\n path: Flags.string({\n char: 'p',\n env: 'SHOPIFY_FLAG_PATH',\n parse: async (input) => resolvePath(input),\n default: async () => cwd(),\n hidden: false,\n }),\n template: Flags.string({\n description: `The app template. Accepts one of the following:\n - <${visibleTemplates.join('|')}>\n - Any GitHub repo with optional branch and subpath, e.g., https://github.com/Shopify/<repository>/[subpath]#[branch]`,\n env: 'SHOPIFY_FLAG_TEMPLATE',\n }),\n flavor: Flags.string({\n description: 'Which flavor of the given template to use.',\n env: 'SHOPIFY_FLAG_TEMPLATE_FLAVOR',\n }),\n 'package-manager': Flags.string({\n char: 'd',\n env: 'SHOPIFY_FLAG_PACKAGE_MANAGER',\n hidden: false,\n options: ['npm', 'yarn', 'pnpm', 'bun'],\n }),\n local: Flags.boolean({\n char: 'l',\n env: 'SHOPIFY_FLAG_LOCAL',\n default: false,\n hidden: true,\n }),\n }\n\n async run(): Promise<void> {\n const {flags} = await this.parse(Init)\n\n this.validateTemplateValue(flags.template)\n this.validateFlavorValue(flags.template, flags.flavor)\n\n const inferredPackageManager = this.inferPackageManager(flags['package-manager'])\n\n const promptAnswers = await initPrompt({\n name: flags.name,\n template: flags.template,\n flavor: flags.flavor,\n directory: flags.path,\n })\n\n if (promptAnswers.globalCLIResult.install) {\n await installGlobalShopifyCLI(inferredPackageManager)\n }\n\n await addPublicMetadata(() => ({\n cmd_create_app_template: promptAnswers.templateType,\n cmd_create_app_template_url: promptAnswers.template,\n }))\n\n await initService({\n name: promptAnswers.name,\n packageManager: inferredPackageManager,\n template: promptAnswers.template,\n local: flags.local,\n directory: flags.path,\n useGlobalCLI: promptAnswers.globalCLIResult.alreadyInstalled || promptAnswers.globalCLIResult.install,\n })\n }\n\n validateTemplateValue(template: string | undefined) {\n if (!template) {\n return\n }\n\n const url = this.parseURL(template)\n if (url && url.origin !== 'https://github.com')\n throw new AbortError(\n 'Only GitHub repository references are supported, ' +\n 'e.g., https://github.com/Shopify/<repository>/[subpath]#[branch]',\n )\n if (!url && !isPredefinedTemplate(template))\n throw new AbortError(\n outputContent`Only ${visibleTemplates\n .map((alias) => outputContent`${outputToken.yellow(alias)}`.value)\n .join(', ')} template aliases are supported`,\n )\n }\n\n validateFlavorValue(template: string | undefined, flavor: string | undefined) {\n if (!template) {\n if (flavor) {\n throw new AbortError(\n outputContent`The ${outputToken.yellow('--flavor')} flag requires the ${outputToken.yellow(\n '--template',\n )} flag to be set`,\n )\n } else {\n return\n }\n }\n\n if (!flavor) {\n return\n }\n\n if (!isPredefinedTemplate(template)) {\n throw new AbortError(\n outputContent`The ${outputToken.yellow('--flavor')} flag is not supported for custom templates`,\n )\n }\n\n const templateConfig = templates[template]\n\n if (!templateConfig.branches) {\n throw new AbortError(outputContent`The ${outputToken.yellow(template)} template does not support flavors`)\n }\n\n if (!templateConfig.branches.options[flavor]) {\n throw new AbortError(\n outputContent`Invalid option for ${outputToken.yellow('--flavor')}\\nThe ${outputToken.yellow(\n '--flavor',\n )} flag for ${outputToken.yellow(template)} accepts only ${Object.keys(templateConfig.branches.options)\n .map((alias) => outputContent`${outputToken.yellow(alias)}`.value)\n .join(', ')}`,\n )\n }\n }\n\n parseURL(url: string): URL | undefined {\n try {\n return new URL(url)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n return undefined\n }\n }\n\n inferPackageManager(optionsPackageManager: string | undefined): PackageManager {\n if (optionsPackageManager && packageManager.includes(optionsPackageManager as PackageManager)) {\n return optionsPackageManager as PackageManager\n }\n const usedPackageManager = packageManagerFromUserAgent()\n if (usedPackageManager !== 'unknown') return usedPackageManager\n\n const globalPackageManager = inferPackageManagerForGlobalCLI()\n if (globalPackageManager !== 'unknown') return globalPackageManager\n\n return 'npm'\n }\n}\n"]}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Init
|
|
3
|
+
} from "../chunk-ADG25CKO.js";
|
|
4
|
+
import {
|
|
5
|
+
errorHandler
|
|
6
|
+
} from "../chunk-CPDHSAO5.js";
|
|
7
|
+
import "../chunk-LKGDG6WW.js";
|
|
8
|
+
import {
|
|
9
|
+
init_default
|
|
10
|
+
} from "../chunk-ND5WSAZY.js";
|
|
11
|
+
import "../chunk-CKY5L2DS.js";
|
|
12
|
+
import "../chunk-4SXWHRL5.js";
|
|
13
|
+
import "../chunk-ASLSMEKR.js";
|
|
14
|
+
import "../chunk-5RH4B5Q7.js";
|
|
15
|
+
import "../chunk-H7CRO63U.js";
|
|
16
|
+
import "../chunk-TMGCRPEZ.js";
|
|
17
|
+
import "../chunk-BOIUUJSH.js";
|
|
18
|
+
import "../chunk-JP7Y3CTL.js";
|
|
19
|
+
import "../chunk-ZDCQCTOO.js";
|
|
20
|
+
import "../chunk-4DXNY52K.js";
|
|
21
|
+
import {
|
|
22
|
+
init_exports,
|
|
23
|
+
visibleTemplates
|
|
24
|
+
} from "../chunk-VMPTLMJN.js";
|
|
25
|
+
import {
|
|
26
|
+
AbortError,
|
|
27
|
+
outputContent,
|
|
28
|
+
outputToken
|
|
29
|
+
} from "../chunk-WLJ2CNLG.js";
|
|
30
|
+
import "../chunk-FBB6KUZG.js";
|
|
31
|
+
import "../chunk-YLEF4RUH.js";
|
|
32
|
+
import "../chunk-G6FN5VUE.js";
|
|
33
|
+
import "../chunk-UVY6LL5H.js";
|
|
34
|
+
import {
|
|
35
|
+
require_lib
|
|
36
|
+
} from "../chunk-7XQTD3L4.js";
|
|
37
|
+
import "../chunk-P4TVG45N.js";
|
|
38
|
+
import "../chunk-ZPB26OWQ.js";
|
|
39
|
+
import "../chunk-WCNR75S2.js";
|
|
40
|
+
import {
|
|
41
|
+
beforeEach,
|
|
42
|
+
describe,
|
|
43
|
+
globalExpect,
|
|
44
|
+
test,
|
|
45
|
+
vi
|
|
46
|
+
} from "../chunk-3JNB3A7C.js";
|
|
47
|
+
import "../chunk-3JLUTHGR.js";
|
|
48
|
+
import "../chunk-GXPKATXW.js";
|
|
49
|
+
import {
|
|
50
|
+
__toESM,
|
|
51
|
+
init_cjs_shims
|
|
52
|
+
} from "../chunk-M63RTPGR.js";
|
|
53
|
+
|
|
54
|
+
// src/commands/init.test.ts
|
|
55
|
+
init_cjs_shims();
|
|
56
|
+
var import_core = __toESM(require_lib(), 1);
|
|
57
|
+
vi.mock("../services/init");
|
|
58
|
+
vi.mock("@shopify/cli-kit/node/error-handler");
|
|
59
|
+
vi.mock("@oclif/core", async () => {
|
|
60
|
+
const actual = await vi.importActual("@oclif/core");
|
|
61
|
+
return {
|
|
62
|
+
...actual,
|
|
63
|
+
Errors: {
|
|
64
|
+
handle: vi.fn()
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
beforeEach(() => {
|
|
69
|
+
vi.spyOn(init_exports, "default").mockResolvedValue({
|
|
70
|
+
name: "name",
|
|
71
|
+
template: "http://test.es",
|
|
72
|
+
templateType: "custom",
|
|
73
|
+
globalCLIResult: { install: false, alreadyInstalled: false }
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
describe("create app command", () => {
|
|
77
|
+
test("executes correctly when no template flag receivec", async () => {
|
|
78
|
+
await Init.run();
|
|
79
|
+
globalExpect(init_default).toHaveBeenCalledOnce();
|
|
80
|
+
});
|
|
81
|
+
test.each(["remix"])("executes correctly when using %s as a template alias name", async (alias) => {
|
|
82
|
+
await Init.run(["--template", alias]);
|
|
83
|
+
globalExpect(init_default).toHaveBeenCalledOnce();
|
|
84
|
+
});
|
|
85
|
+
test("executes correctly when using a flavor for the remix template", async () => {
|
|
86
|
+
await Init.run(["--template", "remix", "--flavor", "javascript"]);
|
|
87
|
+
globalExpect(init_default).toHaveBeenCalledOnce();
|
|
88
|
+
});
|
|
89
|
+
test("executes correctly when using a non-visible template alias name", async () => {
|
|
90
|
+
await Init.run(["--template", "node"]);
|
|
91
|
+
globalExpect(init_default).toHaveBeenCalledOnce();
|
|
92
|
+
});
|
|
93
|
+
test("executes correctly when using a github url as a template alias name", async () => {
|
|
94
|
+
await Init.run(["--template", "https://github.com/myrepo"]);
|
|
95
|
+
globalExpect(init_default).toHaveBeenCalledOnce();
|
|
96
|
+
});
|
|
97
|
+
test("throw an error when using a non supported template alias name", async () => {
|
|
98
|
+
vi.mocked(errorHandler).mockImplementation(async () => {
|
|
99
|
+
});
|
|
100
|
+
await Init.run(["--template", "java"]);
|
|
101
|
+
const anyConfig = globalExpect.any(import_core.Config);
|
|
102
|
+
const expectedError = new AbortError(
|
|
103
|
+
outputContent`Only ${visibleTemplates.map((alias) => outputContent`${outputToken.yellow(alias)}`.value).join(", ")} template aliases are supported`
|
|
104
|
+
);
|
|
105
|
+
globalExpect(errorHandler).toHaveBeenCalledWith(expectedError, anyConfig);
|
|
106
|
+
});
|
|
107
|
+
test("throw an error when using a non github url repo", async () => {
|
|
108
|
+
await Init.run(["--template", "http://nongithub.com/myrepo"]);
|
|
109
|
+
const anyConfig = globalExpect.any(import_core.Config);
|
|
110
|
+
const expectedError = new AbortError(
|
|
111
|
+
"Only GitHub repository references are supported, e.g., https://github.com/Shopify/<repository>/[subpath]#[branch]"
|
|
112
|
+
);
|
|
113
|
+
globalExpect(errorHandler).toHaveBeenCalledWith(expectedError, anyConfig);
|
|
114
|
+
});
|
|
115
|
+
test("throw an error when using a flavor for a template that has no branches set up", async () => {
|
|
116
|
+
await Init.run(["--template", "node", "--flavor", "javascript"]);
|
|
117
|
+
const anyConfig = globalExpect.any(import_core.Config);
|
|
118
|
+
const expectedError = new AbortError(
|
|
119
|
+
outputContent`The ${outputToken.yellow("node")} template does not support flavors`
|
|
120
|
+
);
|
|
121
|
+
globalExpect(errorHandler).toHaveBeenCalledWith(expectedError, anyConfig);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
bugsnagApiKey,
|
|
3
|
+
defaultThemeKitAccessDomain,
|
|
4
|
+
environmentVariables,
|
|
5
|
+
pathConstants,
|
|
6
|
+
sessionConstants,
|
|
7
|
+
systemEnvironmentVariables
|
|
8
|
+
} from "./chunk-YLEF4RUH.js";
|
|
9
|
+
import "./chunk-G6FN5VUE.js";
|
|
10
|
+
import "./chunk-GXPKATXW.js";
|
|
11
|
+
import "./chunk-M63RTPGR.js";
|
|
12
|
+
export {
|
|
13
|
+
bugsnagApiKey,
|
|
14
|
+
defaultThemeKitAccessDomain,
|
|
15
|
+
environmentVariables,
|
|
16
|
+
pathConstants,
|
|
17
|
+
sessionConstants,
|
|
18
|
+
systemEnvironmentVariables
|
|
19
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fileExistsSync
|
|
3
|
+
} from "./chunk-WLJ2CNLG.js";
|
|
4
|
+
import "./chunk-FBB6KUZG.js";
|
|
5
|
+
import "./chunk-YLEF4RUH.js";
|
|
6
|
+
import {
|
|
7
|
+
cwd,
|
|
8
|
+
joinPath
|
|
9
|
+
} from "./chunk-G6FN5VUE.js";
|
|
10
|
+
import "./chunk-UVY6LL5H.js";
|
|
11
|
+
import {
|
|
12
|
+
require_lib
|
|
13
|
+
} from "./chunk-7XQTD3L4.js";
|
|
14
|
+
import "./chunk-P4TVG45N.js";
|
|
15
|
+
import "./chunk-ZPB26OWQ.js";
|
|
16
|
+
import "./chunk-WCNR75S2.js";
|
|
17
|
+
import "./chunk-3JLUTHGR.js";
|
|
18
|
+
import "./chunk-GXPKATXW.js";
|
|
19
|
+
import {
|
|
20
|
+
__toESM,
|
|
21
|
+
init_cjs_shims
|
|
22
|
+
} from "./chunk-M63RTPGR.js";
|
|
23
|
+
|
|
24
|
+
// ../cli-kit/src/public/node/custom-oclif-loader.ts
|
|
25
|
+
init_cjs_shims();
|
|
26
|
+
var import_core = __toESM(require_lib(), 1);
|
|
27
|
+
var ShopifyConfig = class extends import_core.Config {
|
|
28
|
+
constructor(options) {
|
|
29
|
+
const path = sniffForPath() ?? cwd();
|
|
30
|
+
if (fileExistsSync(joinPath(`${path}`, "package.json"))) {
|
|
31
|
+
options.pluginAdditions = {
|
|
32
|
+
core: ["@shopify/cli-hydrogen"],
|
|
33
|
+
path
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
super(options);
|
|
37
|
+
this["determinePriority"] = this.customPriority;
|
|
38
|
+
}
|
|
39
|
+
customPriority(commands) {
|
|
40
|
+
const oclifPlugins = this.pjson.oclif?.plugins ?? [];
|
|
41
|
+
const commandPlugins = commands.sort((aCommand, bCommand) => {
|
|
42
|
+
const pluginAliasA = aCommand.pluginAlias ?? "A-Cannot-Find-This";
|
|
43
|
+
const pluginAliasB = bCommand.pluginAlias ?? "B-Cannot-Find-This";
|
|
44
|
+
const aIndex = oclifPlugins.indexOf(pluginAliasA);
|
|
45
|
+
const bIndex = oclifPlugins.indexOf(pluginAliasB);
|
|
46
|
+
if (aCommand.pluginType === "core" && bCommand.pluginAlias === "@shopify/cli-hydrogen") {
|
|
47
|
+
return 1;
|
|
48
|
+
}
|
|
49
|
+
if (aCommand.pluginAlias === "@shopify/cli-hydrogen" && bCommand.pluginType === "core") {
|
|
50
|
+
return -1;
|
|
51
|
+
}
|
|
52
|
+
if (aCommand.pluginType === "core" && bCommand.pluginType === "core") {
|
|
53
|
+
return aIndex - bIndex;
|
|
54
|
+
}
|
|
55
|
+
if (bCommand.pluginType === "core" && aCommand.pluginType !== "core") {
|
|
56
|
+
return 1;
|
|
57
|
+
}
|
|
58
|
+
if (aCommand.pluginType === "core" && bCommand.pluginType !== "core") {
|
|
59
|
+
return -1;
|
|
60
|
+
}
|
|
61
|
+
if (aCommand.pluginType === "jit" && bCommand.pluginType !== "jit") {
|
|
62
|
+
return 1;
|
|
63
|
+
}
|
|
64
|
+
if (bCommand.pluginType === "jit" && aCommand.pluginType !== "jit") {
|
|
65
|
+
return -1;
|
|
66
|
+
}
|
|
67
|
+
return 0;
|
|
68
|
+
});
|
|
69
|
+
return commandPlugins[0];
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
function sniffForPath() {
|
|
73
|
+
const pathFlagIndex = process.argv.indexOf("--path");
|
|
74
|
+
if (pathFlagIndex === -1)
|
|
75
|
+
return;
|
|
76
|
+
const pathFlag = process.argv[pathFlagIndex + 1];
|
|
77
|
+
if (!pathFlag || pathFlag.startsWith("-"))
|
|
78
|
+
return;
|
|
79
|
+
return pathFlag;
|
|
80
|
+
}
|
|
81
|
+
export {
|
|
82
|
+
ShopifyConfig
|
|
83
|
+
};
|