@shopify/create-app 3.58.2 → 3.59.1

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.
Files changed (82) hide show
  1. package/dist/chunk-3JLUTHGR.js +114 -0
  2. package/dist/chunk-3JNB3A7C.js +14080 -0
  3. package/dist/chunk-6IZ3YCE6.js +144 -0
  4. package/dist/chunk-7XQTD3L4.js +213522 -0
  5. package/dist/chunk-DJYDRQPG.js +30996 -0
  6. package/dist/chunk-DY2DAXN2.js +104 -0
  7. package/dist/chunk-F6KQQF76.js +7817 -0
  8. package/dist/chunk-FBB6KUZG.js +821 -0
  9. package/dist/chunk-G6FN5VUE.js +102 -0
  10. package/dist/chunk-GXPKATXW.js +194 -0
  11. package/dist/chunk-HCBGYFVF.js +99 -0
  12. package/dist/chunk-IL6UMTVA.js +62 -0
  13. package/dist/chunk-LKGDG6WW.js +87 -0
  14. package/dist/chunk-M63RTPGR.js +63 -0
  15. package/dist/chunk-OFS45IA7.js +2468 -0
  16. package/dist/chunk-P4TVG45N.js +900 -0
  17. package/dist/chunk-SSNXQGVF.js +11 -0
  18. package/dist/chunk-TDBGZYDD.js +45349 -0
  19. package/dist/chunk-TMGCRPEZ.js +4283 -0
  20. package/dist/chunk-UVY6LL5H.js +145 -0
  21. package/dist/chunk-VJ2TN2CW.js +72 -0
  22. package/dist/chunk-WCNR75S2.js +73 -0
  23. package/dist/chunk-WETZUTXU.js +18914 -0
  24. package/dist/chunk-WK5TEOA2.js +37 -0
  25. package/dist/chunk-X4SHWSZZ.js +3179 -0
  26. package/dist/chunk-YJIQMGQH.js +13764 -0
  27. package/dist/chunk-YLEF4RUH.js +144 -0
  28. package/dist/chunk-ZPB26OWQ.js +5605 -0
  29. package/dist/commands/init.js +31 -123
  30. package/dist/commands/init.test.js +123 -0
  31. package/dist/constants-K3R4N3N3.js +19 -0
  32. package/dist/custom-oclif-loader-2S5LB2FS.js +83 -0
  33. package/dist/del-A5YM6R3Y.js +2846 -0
  34. package/dist/devtools-KQM4GF6J.js +3685 -0
  35. package/dist/error-handler-N3GIE2DS.js +34 -0
  36. package/dist/hooks/postrun.js +108 -2
  37. package/dist/hooks/prerun.js +77 -2
  38. package/dist/index.js +22 -7
  39. package/dist/lib-76JUGQYQ.js +8 -0
  40. package/dist/local-NYXQXMB7.js +59 -0
  41. package/dist/magic-string.es-6WMSFIAX.js +1291 -0
  42. package/dist/multipart-parser-O2BQODS2.js +359 -0
  43. package/dist/node-package-manager-3J3VEQCR.js +68 -0
  44. package/dist/open-B7XFJJCK.js +290 -0
  45. package/dist/out-JZ52TJE3.js +5 -0
  46. package/dist/path-HO4HBKK5.js +28 -0
  47. package/dist/prompts/init.js +23 -118
  48. package/dist/prompts/init.test.js +115 -0
  49. package/dist/services/init.js +25 -139
  50. package/dist/services/init.test.js +18 -0
  51. package/dist/system-5VPAJEUM.js +25 -0
  52. package/dist/ui-D34IKHO6.js +49 -0
  53. package/dist/utils/template/cleanup.js +18 -19
  54. package/dist/utils/template/cleanup.test.js +74 -0
  55. package/dist/utils/template/npm.js +22 -58
  56. package/dist/utils/template/npm.test.js +153 -0
  57. package/dist/yoga.wasm +0 -0
  58. package/oclif.manifest.json +1 -1
  59. package/package.json +5 -6
  60. package/dist/commands/init.d.ts +0 -20
  61. package/dist/commands/init.js.map +0 -1
  62. package/dist/constants.d.ts +0 -1
  63. package/dist/constants.js +0 -2
  64. package/dist/constants.js.map +0 -1
  65. package/dist/hooks/postrun.d.ts +0 -1
  66. package/dist/hooks/postrun.js.map +0 -1
  67. package/dist/hooks/prerun.d.ts +0 -1
  68. package/dist/hooks/prerun.js.map +0 -1
  69. package/dist/index.d.ts +0 -2
  70. package/dist/index.js.map +0 -1
  71. package/dist/prompts/init.d.ts +0 -39
  72. package/dist/prompts/init.js.map +0 -1
  73. package/dist/services/init.d.ts +0 -9
  74. package/dist/services/init.js.map +0 -1
  75. package/dist/tsconfig.tsbuildinfo +0 -1
  76. package/dist/utils/template/cleanup.d.ts +0 -1
  77. package/dist/utils/template/cleanup.js.map +0 -1
  78. package/dist/utils/template/npm.d.ts +0 -12
  79. package/dist/utils/template/npm.js.map +0 -1
  80. package/dist/utils/versions.d.ts +0 -1
  81. package/dist/utils/versions.js +0 -21
  82. package/dist/utils/versions.js.map +0 -1
@@ -1,58 +1,22 @@
1
- import { installNodeModules } from '@shopify/cli-kit/node/node-package-manager';
2
- import { CLI_KIT_VERSION } from '@shopify/cli-kit/common/version';
3
- import { moduleDirectory, normalizePath } from '@shopify/cli-kit/node/path';
4
- import { findPathUp } from '@shopify/cli-kit/node/fs';
5
- import { platform } from 'os';
6
- export async function updateCLIDependencies({ packageJSON, local }) {
7
- packageJSON.dependencies = packageJSON.dependencies || {};
8
- packageJSON.dependencies['@shopify/cli'] = CLI_KIT_VERSION;
9
- packageJSON.dependencies['@shopify/app'] = CLI_KIT_VERSION;
10
- if (local) {
11
- const cliPath = await packagePath('cli');
12
- const appPath = await packagePath('app');
13
- const createAppPath = await packagePath('create-app');
14
- const cliKitPath = await packagePath('cli-kit');
15
- const pluginCloudflarePath = await packagePath('plugin-cloudflare');
16
- const didYouMeanPath = await packagePath('plugin-did-you-mean');
17
- // eslint-disable-next-line require-atomic-updates
18
- packageJSON.dependencies['@shopify/cli'] = cliPath;
19
- // eslint-disable-next-line require-atomic-updates
20
- packageJSON.dependencies['@shopify/app'] = appPath;
21
- const dependencyOverrides = {
22
- '@shopify/cli': cliPath,
23
- '@shopify/app': appPath,
24
- '@shopify/create-app': createAppPath,
25
- '@shopify/cli-kit': cliKitPath,
26
- '@shopify/plugin-did-you-mean': didYouMeanPath,
27
- '@shopify/plugin-cloudflare': pluginCloudflarePath,
28
- };
29
- packageJSON.overrides = packageJSON.overrides
30
- ? { ...packageJSON.overrides, ...dependencyOverrides }
31
- : dependencyOverrides;
32
- packageJSON.resolutions = packageJSON.resolutions
33
- ? { ...packageJSON.resolutions, ...dependencyOverrides }
34
- : dependencyOverrides;
35
- }
36
- return packageJSON;
37
- }
38
- async function packagePath(packageName) {
39
- const packageAbsolutePath = (await findPathUp(`packages/${packageName}`, {
40
- type: 'directory',
41
- cwd: moduleDirectory(import.meta.url),
42
- }));
43
- return `file:${packageAbsolutePath}`;
44
- }
45
- export async function getDeepInstallNPMTasks({ from, packageManager, }) {
46
- /**
47
- * Installation of dependencies using Yarn on Windows might lead
48
- * to "EPERM: operation not permitted, unlink" errors when Yarn tries
49
- * to access the cache. By limiting the network concurrency we mitigate the
50
- * error:
51
- *
52
- * Failing scenario: https://github.com/Shopify/cli/runs/7913938724
53
- * Reported issue: https://github.com/yarnpkg/yarn/issues/7212
54
- */
55
- const args = platform() === 'win32' && packageManager === 'yarn' ? ['--network-concurrency', '1'] : [];
56
- return installNodeModules({ directory: normalizePath(from), packageManager, args });
57
- }
58
- //# sourceMappingURL=npm.js.map
1
+ import {
2
+ getDeepInstallNPMTasks,
3
+ updateCLIDependencies
4
+ } from "../../chunk-IL6UMTVA.js";
5
+ import "../../chunk-SSNXQGVF.js";
6
+ import "../../chunk-YJIQMGQH.js";
7
+ import "../../chunk-TDBGZYDD.js";
8
+ import "../../chunk-FBB6KUZG.js";
9
+ import "../../chunk-YLEF4RUH.js";
10
+ import "../../chunk-G6FN5VUE.js";
11
+ import "../../chunk-UVY6LL5H.js";
12
+ import "../../chunk-7XQTD3L4.js";
13
+ import "../../chunk-P4TVG45N.js";
14
+ import "../../chunk-ZPB26OWQ.js";
15
+ import "../../chunk-WCNR75S2.js";
16
+ import "../../chunk-3JLUTHGR.js";
17
+ import "../../chunk-GXPKATXW.js";
18
+ import "../../chunk-M63RTPGR.js";
19
+ export {
20
+ getDeepInstallNPMTasks,
21
+ updateCLIDependencies
22
+ };
@@ -0,0 +1,153 @@
1
+ import {
2
+ getDeepInstallNPMTasks,
3
+ updateCLIDependencies
4
+ } from "../../chunk-IL6UMTVA.js";
5
+ import "../../chunk-SSNXQGVF.js";
6
+ import {
7
+ installNodeModules
8
+ } from "../../chunk-YJIQMGQH.js";
9
+ import {
10
+ inTemporaryDirectory,
11
+ mkdir,
12
+ readFile,
13
+ writeFile
14
+ } from "../../chunk-TDBGZYDD.js";
15
+ import "../../chunk-FBB6KUZG.js";
16
+ import "../../chunk-YLEF4RUH.js";
17
+ import {
18
+ joinPath,
19
+ moduleDirectory,
20
+ normalizePath
21
+ } from "../../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 {
28
+ describe,
29
+ globalExpect,
30
+ test,
31
+ vi
32
+ } from "../../chunk-3JNB3A7C.js";
33
+ import "../../chunk-3JLUTHGR.js";
34
+ import "../../chunk-GXPKATXW.js";
35
+ import {
36
+ init_cjs_shims
37
+ } from "../../chunk-M63RTPGR.js";
38
+
39
+ // src/utils/template/npm.test.ts
40
+ init_cjs_shims();
41
+ import { platform } from "os";
42
+ vi.mock("os");
43
+ vi.mock("@shopify/cli-kit/node/node-package-manager");
44
+ vi.mock("@shopify/cli-kit/common/version", () => ({ CLI_KIT_VERSION: "1.2.3" }));
45
+ describe("updateCLIDependencies", () => {
46
+ test("updates @shopify/cli and deletes @shopify/app if not using global CLI", async () => {
47
+ const mockPackageJSON = {};
48
+ const directory = moduleDirectory(import.meta.url);
49
+ await updateCLIDependencies({ packageJSON: mockPackageJSON, local: false, directory, useGlobalCLI: false });
50
+ globalExpect(mockPackageJSON.dependencies["@shopify/cli"]).toBe("1.2.3");
51
+ globalExpect(mockPackageJSON.dependencies["@shopify/app"]).toBeUndefined();
52
+ });
53
+ test("removes @shopify/cli and @shopify/app if using global CLI", async () => {
54
+ const mockPackageJSON = {};
55
+ const directory = moduleDirectory(import.meta.url);
56
+ await updateCLIDependencies({ packageJSON: mockPackageJSON, local: false, directory, useGlobalCLI: true });
57
+ globalExpect(mockPackageJSON.dependencies["@shopify/cli"]).toBeUndefined();
58
+ globalExpect(mockPackageJSON.dependencies["@shopify/app"]).toBeUndefined();
59
+ });
60
+ test("does not update overrides or resolutions if local is false", async () => {
61
+ const mockPackageJSON = { overrides: {}, resolutions: {} };
62
+ const directory = moduleDirectory(import.meta.url);
63
+ await updateCLIDependencies({ packageJSON: mockPackageJSON, local: false, directory, useGlobalCLI: false });
64
+ globalExpect(mockPackageJSON.overrides["@shopify/cli"]).toBeUndefined();
65
+ globalExpect(mockPackageJSON.overrides["@shopify/app"]).toBeUndefined();
66
+ globalExpect(mockPackageJSON.overrides["@shopify/cli-kit"]).toBeUndefined();
67
+ globalExpect(mockPackageJSON.resolutions["@shopify/cli"]).toBeUndefined();
68
+ globalExpect(mockPackageJSON.resolutions["@shopify/app"]).toBeUndefined();
69
+ globalExpect(mockPackageJSON.resolutions["@shopify/cli-kit"]).toBeUndefined();
70
+ });
71
+ test("updates overrides for @shopify/cli if local is true", async () => {
72
+ const mockPackageJSON = {};
73
+ const directory = moduleDirectory(import.meta.url);
74
+ await updateCLIDependencies({ packageJSON: mockPackageJSON, local: true, directory, useGlobalCLI: false });
75
+ const dependencyOveride = mockPackageJSON.overrides["@shopify/cli"];
76
+ const dependencyPath = joinPath(dependencyOveride.replace("file:", ""), "package.json");
77
+ const dependencyJSON = JSON.parse(await readFile(dependencyPath));
78
+ globalExpect(dependencyJSON.name).toBe("@shopify/cli");
79
+ });
80
+ test("updates resolutions for @shopify/cli if local is true", async () => {
81
+ const mockPackageJSON = {};
82
+ const directory = moduleDirectory(import.meta.url);
83
+ await updateCLIDependencies({ packageJSON: mockPackageJSON, local: true, directory, useGlobalCLI: false });
84
+ const dependencyResolution = mockPackageJSON.resolutions["@shopify/cli"];
85
+ const dependencyPath = joinPath(dependencyResolution.replace("file:", ""), "package.json");
86
+ const dependencyJSON = JSON.parse(await readFile(dependencyPath));
87
+ globalExpect(dependencyJSON.name).toBe("@shopify/cli");
88
+ });
89
+ test("updates dependency for @shopify/cli if local is true", async () => {
90
+ const mockPackageJSON = {};
91
+ const directory = moduleDirectory(import.meta.url);
92
+ await updateCLIDependencies({ packageJSON: mockPackageJSON, local: true, directory, useGlobalCLI: false });
93
+ const dependencyResolution = mockPackageJSON.dependencies["@shopify/cli"];
94
+ const dependencyPath = joinPath(dependencyResolution.replace("file:", ""), "package.json");
95
+ const dependencyJSON = JSON.parse(await readFile(dependencyPath));
96
+ globalExpect(dependencyJSON.name).toBe("@shopify/cli");
97
+ });
98
+ test("does not change existing values", async () => {
99
+ const mockPackageJSON = {
100
+ name: "",
101
+ author: "",
102
+ scripts: {},
103
+ dependencies: {
104
+ mock: "value"
105
+ },
106
+ devDependencies: {
107
+ mock: "value"
108
+ },
109
+ resolutions: {
110
+ mock: "value"
111
+ },
112
+ overrides: {
113
+ mock: "value"
114
+ }
115
+ };
116
+ const directory = moduleDirectory(import.meta.url);
117
+ await updateCLIDependencies({ packageJSON: mockPackageJSON, local: false, directory, useGlobalCLI: false });
118
+ globalExpect(mockPackageJSON.dependencies.mock).toBe("value");
119
+ globalExpect(mockPackageJSON.overrides.mock).toBe("value");
120
+ globalExpect(mockPackageJSON.resolutions.mock).toBe("value");
121
+ });
122
+ });
123
+ describe("getDeepInstallNPMTasks", () => {
124
+ async function mockAppFolder(callback) {
125
+ await inTemporaryDirectory(async (tmpDir) => {
126
+ await mkdir(joinPath(tmpDir, "web"));
127
+ await mkdir(joinPath(tmpDir, "web", "frontend"));
128
+ await Promise.all([
129
+ writeFile(joinPath(tmpDir, "package.json"), "{}"),
130
+ writeFile(joinPath(tmpDir, "web", "package.json"), "{}"),
131
+ writeFile(joinPath(tmpDir, "web", "frontend", "package.json"), "{}")
132
+ ]);
133
+ return callback(tmpDir);
134
+ });
135
+ }
136
+ const defaultArgs = {
137
+ packageManager: "npm",
138
+ didInstallEverything: () => {
139
+ }
140
+ };
141
+ test.each([["darwin"], ["win32"]])("each task installs dependencies when the os is %s", async (operativeSystem) => {
142
+ await mockAppFolder(async (tmpDir) => {
143
+ const expectedArgs = operativeSystem === "win32" ? ["--network-concurrency", "1"] : [];
144
+ vi.mocked(platform).mockReturnValue(operativeSystem);
145
+ await getDeepInstallNPMTasks({ ...defaultArgs, packageManager: "yarn", from: tmpDir });
146
+ globalExpect(installNodeModules).toHaveBeenCalledWith({
147
+ directory: `${normalizePath(tmpDir)}`,
148
+ packageManager: "yarn",
149
+ args: expectedArgs
150
+ });
151
+ });
152
+ });
153
+ });
package/dist/yoga.wasm ADDED
Binary file
@@ -98,5 +98,5 @@
98
98
  "summary": "Create a new app project"
99
99
  }
100
100
  },
101
- "version": "3.58.2"
101
+ "version": "3.59.1"
102
102
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopify/create-app",
3
- "version": "3.58.2",
3
+ "version": "3.59.1",
4
4
  "private": false,
5
5
  "description": "A CLI tool to create a new Shopify app.",
6
6
  "keywords": [
@@ -42,13 +42,11 @@
42
42
  "../../.eslintrc.cjs"
43
43
  ]
44
44
  },
45
- "dependencies": {
46
- "@oclif/core": "3.19.6",
47
- "@shopify/cli-kit": "3.58.2"
48
- },
45
+ "dependencies": {},
49
46
  "devDependencies": {
50
47
  "@types/node": "18.19.3",
51
- "vite": "^4.4.9",
48
+ "esbuild-plugin-copy": "^2.1.1",
49
+ "@vitest/coverage-istanbul": "^0.34.3",
52
50
  "vitest": "^0.34.3"
53
51
  },
54
52
  "engines": {
@@ -77,6 +75,7 @@
77
75
  },
78
76
  "scripts": {
79
77
  "build": "nx build",
78
+ "bundle": "nx bundle",
80
79
  "clean": "nx clean",
81
80
  "lint": "nx lint",
82
81
  "lint:fix": "nx lint:fix",
@@ -1,20 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- import Command from '@shopify/cli-kit/node/base-command';
3
- import { URL } from 'url';
4
- export default class Init extends Command {
5
- static summary?: string | undefined;
6
- static flags: {
7
- name: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
8
- path: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
9
- template: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
10
- flavor: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
11
- 'package-manager': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
12
- local: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
13
- 'no-color': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
14
- verbose: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
15
- };
16
- run(): Promise<void>;
17
- validateTemplateValue(template: string | undefined): void;
18
- validateFlavorValue(template: string | undefined, flavor: string | undefined): void;
19
- parseURL(url: string): URL | undefined;
20
- }
@@ -1 +0,0 @@
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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,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// 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 +0,0 @@
1
- export {};
package/dist/constants.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"","sourcesContent":[""]}
@@ -1 +0,0 @@
1
- export { hook as default } from '@shopify/cli-kit/node/hooks/postrun';
@@ -1 +0,0 @@
1
- {"version":3,"file":"postrun.js","sourceRoot":"","sources":["../../src/hooks/postrun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,IAAI,OAAO,EAAC,MAAM,qCAAqC,CAAA","sourcesContent":["export {hook as default} from '@shopify/cli-kit/node/hooks/postrun'\n"]}
@@ -1 +0,0 @@
1
- export { hook as default } from '@shopify/cli-kit/node/hooks/prerun';
@@ -1 +0,0 @@
1
- {"version":3,"file":"prerun.js","sourceRoot":"","sources":["../../src/hooks/prerun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,IAAI,OAAO,EAAC,MAAM,oCAAoC,CAAA","sourcesContent":["export {hook as default} from '@shopify/cli-kit/node/hooks/prerun'\n"]}
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- declare function runCreateAppCLI(development: boolean): Promise<void>;
2
- export default runCreateAppCLI;
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAA;AAEtD,KAAK,UAAU,eAAe,CAAC,WAAoB;IACjD,MAAM,YAAY,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG;QAC1B,WAAW;KACZ,CAAC,CAAA;AACJ,CAAC;AAED,eAAe,eAAe,CAAA","sourcesContent":["import {runCreateCLI} from '@shopify/cli-kit/node/cli'\n\nasync function runCreateAppCLI(development: boolean) {\n await runCreateCLI({\n moduleURL: import.meta.url,\n development,\n })\n}\n\nexport default runCreateAppCLI\n"]}
@@ -1,39 +0,0 @@
1
- interface InitOptions {
2
- name?: string;
3
- template?: string;
4
- flavor?: string;
5
- directory: string;
6
- }
7
- interface InitOutput {
8
- name: string;
9
- template: string;
10
- templateType: PredefinedTemplate | 'custom';
11
- }
12
- interface TemplateBranch {
13
- branch: string;
14
- label: string;
15
- }
16
- interface Template {
17
- url: string;
18
- label?: string;
19
- visible: boolean;
20
- branches?: {
21
- prompt: string;
22
- options: {
23
- [key: string]: TemplateBranch;
24
- };
25
- };
26
- }
27
- export declare const templates: {
28
- readonly remix: Template;
29
- readonly none: Template;
30
- readonly node: Template;
31
- readonly php: Template;
32
- readonly ruby: Template;
33
- };
34
- export type PredefinedTemplate = keyof typeof templates;
35
- export declare const allTemplates: readonly ("remix" | "none" | "node" | "php" | "ruby")[];
36
- export declare const visibleTemplates: readonly ("remix" | "none" | "node" | "php" | "ruby")[];
37
- declare const init: (options: InitOptions) => Promise<InitOutput>;
38
- export default init;
39
- export declare function isPredefinedTemplate(template: string): template is PredefinedTemplate;
@@ -1 +0,0 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/prompts/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iCAAiC,EAAC,MAAM,0BAA0B,CAAA;AAC1E,OAAO,EAAC,UAAU,EAAE,kBAAkB,EAAE,gBAAgB,EAAC,MAAM,0BAA0B,CAAA;AA8BzF,8DAA8D;AAC9D,wEAAwE;AACxE,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,KAAK,EAAE;QACL,GAAG,EAAE,uDAAuD;QAC5D,KAAK,EAAE,gCAAgC;QACvC,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE;YACR,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,CAAC,CAAA;AAC9D,CAAC","sourcesContent":["import {generateRandomNameForSubdirectory} from '@shopify/cli-kit/node/fs'\nimport {renderText, renderSelectPrompt, renderTextPrompt} from '@shopify/cli-kit/node/ui'\n\ninterface InitOptions {\n name?: string\n template?: string\n flavor?: string\n directory: string\n}\n\ninterface InitOutput {\n name: string\n template: string\n // e.g. 'remix'\n templateType: PredefinedTemplate | 'custom'\n}\n\ninterface TemplateBranch {\n branch: string\n label: string\n}\ninterface Template {\n url: string\n label?: string\n visible: boolean\n branches?: {\n prompt: string\n options: {[key: string]: TemplateBranch}\n }\n}\n\n// Eventually this list should be taken from a remote location\n// That way we don't have to update the CLI every time we add a template\nexport const templates = {\n remix: {\n url: 'https://github.com/Shopify/shopify-app-template-remix',\n label: 'Start with Remix (recommended)',\n visible: true,\n branches: {\n prompt: 'For your Remix template, which language do you want?',\n options: {\n javascript: {branch: 'javascript', label: 'JavaScript'},\n typescript: {branch: 'main', label: 'TypeScript'},\n },\n },\n } as Template,\n none: {\n url: 'https://github.com/Shopify/shopify-app-template-none',\n label: 'Start by adding your first extension',\n visible: true,\n } as Template,\n node: {\n url: 'https://github.com/Shopify/shopify-app-template-node',\n visible: false,\n } as Template,\n php: {\n url: 'https://github.com/Shopify/shopify-app-template-php',\n visible: false,\n } as Template,\n ruby: {\n url: 'https://github.com/Shopify/shopify-app-template-ruby',\n visible: false,\n } as Template,\n} as const\nexport type PredefinedTemplate = keyof typeof templates\n\nexport const allTemplates = Object.keys(templates) as Readonly<PredefinedTemplate[]>\nexport const visibleTemplates = allTemplates.filter((key) => templates[key].visible) as Readonly<PredefinedTemplate[]>\n\nconst templateOptionsInOrder = ['remix', 'none'] as const\n\nconst init = async (options: InitOptions): Promise<InitOutput> => {\n let name = options.name\n let template = options.template\n const flavor = options.flavor\n\n const defaults = {\n name: await generateRandomNameForSubdirectory({suffix: 'app', directory: options.directory}),\n template: templates.remix.url,\n } as const\n\n let welcomed = false\n\n if (!name) {\n renderText({text: '\\nWelcome. Let’s get started by naming your app project. You can change it later.'})\n welcomed = true\n name = await renderTextPrompt({\n message: 'Your project name?',\n defaultValue: defaults.name,\n validate: (value) => {\n if (value.length === 0) {\n return \"App name can't be empty\"\n }\n if (value.length > 30) {\n return 'Enter a shorter name (30 character max.)'\n }\n if (value.toLowerCase().includes('shopify')) {\n return \"App name can't include the word 'shopify'\"\n }\n },\n })\n }\n\n if (!template) {\n if (!welcomed) {\n renderText({text: '\\nWelcome. Let’s get started by choosing a template for your app project.'})\n welcomed = true\n }\n template = await renderSelectPrompt({\n choices: templateOptionsInOrder.map((key) => {\n return {\n label: templates[key].label || key,\n value: key,\n }\n }),\n message: 'Get started building your app:',\n defaultValue: allTemplates.find((key) => templates[key].url === defaults.template),\n })\n }\n\n const answers: InitOutput = {\n ...options,\n name,\n template,\n templateType: isPredefinedTemplate(template) ? template : 'custom',\n }\n\n let selectedUrl: string | undefined\n let branch: string | undefined\n if (answers.templateType !== 'custom') {\n const selectedTemplate = templates[answers.templateType]\n selectedUrl = selectedTemplate.url\n\n if (selectedTemplate.branches) {\n if (flavor) {\n branch = selectedTemplate.branches.options[flavor]?.branch\n } else {\n branch = await renderSelectPrompt({\n message: selectedTemplate.branches.prompt || 'Choose a flavor:',\n choices: Object.entries(selectedTemplate.branches.options).map(([_key, branch]) => ({\n value: branch.branch,\n label: branch.label,\n })),\n })\n }\n }\n }\n\n if (branch) {\n selectedUrl += `#${branch}`\n }\n\n answers.template = selectedUrl || answers.template || defaults.template\n\n return answers\n}\n\nexport default init\n\nexport function isPredefinedTemplate(template: string): template is PredefinedTemplate {\n return allTemplates.includes(template as PredefinedTemplate)\n}\n"]}
@@ -1,9 +0,0 @@
1
- interface InitOptions {
2
- name: string;
3
- directory: string;
4
- template: string;
5
- packageManager: string | undefined;
6
- local: boolean;
7
- }
8
- declare function init(options: InitOptions): Promise<void>;
9
- export default init;
@@ -1 +0,0 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/services/init.ts"],"names":[],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KAAK,EAAE,cAAc,EAAE,GAAG,EAAE,qBAAqB,EAAC,EAAC;YAC3D;gBACE,kCAAkC;gBAClC,EAAC,OAAO,EAAE,GAAG,2BAA2B,CAAC,cAAc,EAAE,aAAa,EAAE,QAAQ,CAAC,EAAE,EAAC;aACrF;SACF;KACF,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,mBAAmB,CAAC,qBAAyC;IACpE,IAAI,qBAAqB,IAAI,cAAc,CAAC,QAAQ,CAAC,qBAAuC,CAAC,EAAE;QAC7F,OAAO,qBAAuC,CAAA;KAC/C;IACD,MAAM,kBAAkB,GAAG,2BAA2B,EAAE,CAAA;IACxD,OAAO,kBAAkB,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,kBAAkB,CAAA;AACtE,CAAC;AAED,KAAK,UAAU,6BAA6B,CAAC,SAAiB,EAAE,IAAY;IAC1E,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,SAAS,CAAC,CAAA;IAC1C,IAAI,MAAM;QACR,MAAM,IAAI,UAAU,CAAC,iCAAiC,IAAI,oDAAoD,CAAC,CAAA;AACnH,CAAC;AAED,SAAS,iCAAiC,CAAC,SAAiB;IAC1D,OAAO,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;AAChG,CAAC;AAED,eAAe,IAAI,CAAA","sourcesContent":["import {getDeepInstallNPMTasks, updateCLIDependencies} from '../utils/template/npm.js'\nimport cleanup from '../utils/template/cleanup.js'\nimport {\n findUpAndReadPackageJson,\n packageManager,\n PackageManager,\n packageManagerFromUserAgent,\n UnknownPackageManagerError,\n writePackageJSON,\n} from '@shopify/cli-kit/node/node-package-manager'\nimport {renderSuccess, renderTasks, Task} from '@shopify/cli-kit/node/ui'\nimport {parseGitHubRepositoryReference} from '@shopify/cli-kit/node/github'\nimport {hyphenate} from '@shopify/cli-kit/common/string'\nimport {recursiveLiquidTemplateCopy} from '@shopify/cli-kit/node/liquid'\nimport {isShopify} from '@shopify/cli-kit/node/context/local'\nimport {downloadGitRepository, initializeGitRepository} from '@shopify/cli-kit/node/git'\nimport {\n appendFile,\n fileExists,\n fileExistsSync,\n inTemporaryDirectory,\n mkdir,\n moveFile,\n writeFile,\n} from '@shopify/cli-kit/node/fs'\nimport {joinPath} from '@shopify/cli-kit/node/path'\nimport {username} from '@shopify/cli-kit/node/os'\nimport {AbortError} from '@shopify/cli-kit/node/error'\nimport {formatPackageManagerCommand} from '@shopify/cli-kit/node/output'\n\ninterface InitOptions {\n name: string\n directory: string\n template: string\n packageManager: string | undefined\n local: boolean\n}\n\nasync function init(options: InitOptions) {\n const packageManager: PackageManager = inferPackageManager(options.packageManager)\n const hyphenizedName = hyphenate(options.name)\n const outputDirectory = joinPath(options.directory, hyphenizedName)\n const githubRepo = parseGitHubRepositoryReference(options.template)\n\n await ensureAppDirectoryIsAvailable(outputDirectory, hyphenizedName)\n\n await inTemporaryDirectory(async (tmpDir) => {\n const templateDownloadDir = joinPath(tmpDir, 'download')\n const templatePathDir = githubRepo.filePath\n ? joinPath(templateDownloadDir, githubRepo.filePath)\n : templateDownloadDir\n const templateScaffoldDir = joinPath(tmpDir, 'app')\n const repoUrl = githubRepo.branch ? `${githubRepo.baseURL}#${githubRepo.branch}` : githubRepo.baseURL\n\n await mkdir(templateDownloadDir)\n const tasks: Task<unknown>[] = [\n {\n title: `Downloading template from ${repoUrl}`,\n task: async () => {\n await downloadGitRepository({\n repoUrl,\n destination: templateDownloadDir,\n shallow: true,\n })\n },\n },\n ]\n\n tasks.push(\n {\n title: 'Parsing liquid',\n task: async () => {\n await recursiveLiquidTemplateCopy(templatePathDir, templateScaffoldDir, {\n dependency_manager: packageManager,\n app_name: options.name,\n })\n },\n },\n {\n title: 'Updating package.json',\n task: async () => {\n const packageJSON = (await findUpAndReadPackageJson(templateScaffoldDir)).content\n packageJSON.name = hyphenizedName\n packageJSON.author = (await username()) ?? ''\n packageJSON.private = true\n const workspacesFolders = ['extensions/*'].concat(detectAdditionalWorkspacesFolders(templateScaffoldDir))\n\n switch (packageManager) {\n case 'npm':\n case 'yarn':\n case 'bun':\n packageJSON.workspaces = workspacesFolders\n break\n case 'pnpm': {\n const workspacesContent = workspacesFolders.map((folder) => ` - '${folder}'`).join(`\\n`)\n await writeFile(joinPath(templateScaffoldDir, 'pnpm-workspace.yaml'), `packages:\\n${workspacesContent}`)\n // Ensure that the installation of dependencies doesn't fail when using\n // pnpm due to missing peerDependencies.\n await appendFile(joinPath(templateScaffoldDir, '.npmrc'), `auto-install-peers=true\\n`)\n break\n }\n case 'unknown':\n throw new UnknownPackageManagerError()\n }\n\n await updateCLIDependencies({packageJSON, local: options.local, directory: templateScaffoldDir})\n await writePackageJSON(templateScaffoldDir, packageJSON)\n },\n },\n )\n\n if (await isShopify()) {\n tasks.push({\n title: \"[Shopifolks-only] Configuring the project's NPM registry\",\n task: async () => {\n const npmrcPath = joinPath(templateScaffoldDir, '.npmrc')\n const npmrcContent = `@shopify:registry=https://registry.npmjs.org\\n`\n await appendFile(npmrcPath, npmrcContent)\n },\n })\n }\n\n tasks.push(\n {\n title: 'Installing dependencies',\n task: async () => {\n await getDeepInstallNPMTasks({from: templateScaffoldDir, packageManager})\n },\n },\n {\n title: 'Cleaning up',\n task: async () => {\n await cleanup(templateScaffoldDir)\n },\n },\n {\n title: 'Initializing a Git repository...',\n task: async () => {\n await initializeGitRepository(templateScaffoldDir)\n },\n },\n )\n\n await renderTasks(tasks)\n\n await moveFile(templateScaffoldDir, outputDirectory)\n })\n\n renderSuccess({\n headline: [{userInput: hyphenizedName}, 'is ready for you to build!'],\n nextSteps: [\n ['Run', {command: `cd ${hyphenizedName}`}],\n ['For extensions, run', {command: formatPackageManagerCommand(packageManager, 'generate extension')}],\n ['To see your app, run', {command: formatPackageManagerCommand(packageManager, 'dev')}],\n ],\n reference: [\n {link: {label: 'Shopify docs', url: 'https://shopify.dev'}},\n [\n 'For an overview of commands, run',\n {command: `${formatPackageManagerCommand(packageManager, 'shopify app', '--help')}`},\n ],\n ],\n })\n}\n\nfunction inferPackageManager(optionsPackageManager: string | undefined): PackageManager {\n if (optionsPackageManager && packageManager.includes(optionsPackageManager as PackageManager)) {\n return optionsPackageManager as PackageManager\n }\n const usedPackageManager = packageManagerFromUserAgent()\n return usedPackageManager === 'unknown' ? 'npm' : usedPackageManager\n}\n\nasync function ensureAppDirectoryIsAvailable(directory: string, name: string): Promise<void> {\n const exists = await fileExists(directory)\n if (exists)\n throw new AbortError(`\\nA directory with this name (${name}) already exists.\\nChoose a new name for your app.`)\n}\n\nfunction detectAdditionalWorkspacesFolders(directory: string) {\n return ['web', 'web/frontend'].filter((folder) => fileExistsSync(joinPath(directory, folder)))\n}\n\nexport default init\n"]}