@shopify/create-app 3.94.3 → 4.1.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.
Files changed (58) hide show
  1. package/README.md +2 -2
  2. package/dist/analytics-RYQKQ4DG.js +39 -0
  3. package/dist/analytics-ZSO2XN53.js +33 -0
  4. package/dist/chunk-32DG2OXV.js +110 -0
  5. package/dist/chunk-6OOTYTVB.js +1133 -0
  6. package/dist/chunk-7OFS6B2C.js +12 -0
  7. package/dist/chunk-A6TJPMVH.js +661 -0
  8. package/dist/{chunk-NIYBO6HO.js → chunk-ACS6S42W.js} +3 -3
  9. package/dist/{chunk-BRNDLYPU.js → chunk-BMI6QCMV.js} +3617 -10143
  10. package/dist/chunk-C5OLLQWI.js +5620 -0
  11. package/dist/chunk-CEGG2EWP.js +104 -0
  12. package/dist/chunk-DJW2W7VA.js +21 -0
  13. package/dist/{chunk-LI75HRH4.js → chunk-DWGHKWV5.js} +1 -1
  14. package/dist/chunk-JCETIRLI.js +30 -0
  15. package/dist/chunk-JT5MT2JE.js +371 -0
  16. package/dist/chunk-MIECGF3H.js +264 -0
  17. package/dist/{chunk-IFG7N3S2.js → chunk-OO33NRTL.js} +8 -12671
  18. package/dist/chunk-PES3XMQM.js +70 -0
  19. package/dist/chunk-PVHOBK32.js +1771 -0
  20. package/dist/chunk-RB7BXTZQ.js +6106 -0
  21. package/dist/{chunk-HUNONZYG.js → chunk-S4YEA2XG.js} +43774 -43785
  22. package/dist/chunk-SWITKWBS.js +78 -0
  23. package/dist/{chunk-KKIDWI27.js → chunk-TS6LOJXS.js} +47 -12
  24. package/dist/chunk-TVUF42MB.js +55 -0
  25. package/dist/chunk-UX6FRPFM.js +11555 -0
  26. package/dist/{chunk-CXPWSYGC.js → chunk-X2WZCKNE.js} +4 -14
  27. package/dist/conf-store-R26LOTXD.js +54 -0
  28. package/dist/custom-oclif-loader-354VAVF4.js +54 -0
  29. package/dist/deprecations-JWETMJFF.js +55 -0
  30. package/dist/environments-VKYG7DMX.js +26 -0
  31. package/dist/error-handler-YXGIUGKI.js +37 -0
  32. package/dist/fs-HPLMOQQD.js +109 -0
  33. package/dist/hooks/postrun.js +6 -9
  34. package/dist/hooks/prerun.js +12 -25
  35. package/dist/{http-proxy-node16-U5VBDLS3.js → http-proxy-node16-XB2DSBCB.js} +3 -2
  36. package/dist/index.js +9175 -10612
  37. package/dist/is-global-OXCPPXM7.js +21 -0
  38. package/dist/latest-version-3PFKLJZM.js +7713 -0
  39. package/dist/lib-HWIFANCM.js +11 -0
  40. package/dist/{local-6XZDLEBK.js → local-6ARTMTVE.js} +3 -10
  41. package/dist/metadata-Z65VJ53L.js +20 -0
  42. package/dist/{node-package-manager-JVAQNYVX.js → node-package-manager-Q3Y2FSRM.js} +17 -7
  43. package/dist/notifications-system-2HPAOE4P.js +40 -0
  44. package/dist/output-MCH67S5U.js +51 -0
  45. package/dist/{path-NQ6GZ2WO.js → path-EOPO7QNL.js} +2 -2
  46. package/dist/{prettier-67WYXU6J.js → prettier-UAG5TKE4.js} +2 -2
  47. package/dist/system-YW6RJ2KQ.js +47 -0
  48. package/dist/tsconfig.tsbuildinfo +1 -1
  49. package/dist/typescript-TKTDYKKG.js +6 -0
  50. package/dist/{ui-7HBWZC7M.js → ui-AYUE37Z3.js} +15 -6
  51. package/dist/{chunk-PWU6XFUQ.js → upgrade-DNAT5W4B.js} +77 -125
  52. package/dist/version-2J64V5CP.js +8 -0
  53. package/dist/version-V77ZX5N2.js +30 -0
  54. package/oclif.manifest.json +63 -66
  55. package/package.json +5 -5
  56. package/dist/chunk-HYOIEQ5O.js +0 -14117
  57. package/dist/error-handler-WFIT65SZ.js +0 -25
  58. package/dist/lib-PPI2FZOR.js +0 -8
@@ -0,0 +1,104 @@
1
+ import {
2
+ outputDebug
3
+ } from "./chunk-BMI6QCMV.js";
4
+ import {
5
+ init_cjs_shims
6
+ } from "./chunk-PKR7KJ6P.js";
7
+
8
+ // ../cli-kit/dist/public/node/tree-kill.js
9
+ init_cjs_shims();
10
+ import { spawn } from "child_process";
11
+ function treeKill(pid = process.pid, killSignal = "SIGTERM", killRoot = !0, callback) {
12
+ adaptedTreeKill(pid, killSignal, killRoot, callback ?? ((error) => {
13
+ error && outputDebug(`Failed to kill process ${pid}: ${error}`);
14
+ }));
15
+ }
16
+ function adaptedTreeKill(pid, killSignal, killRoot, callback) {
17
+ let rootPid = typeof pid == "number" ? pid.toString() : pid;
18
+ if (!/^\d+$/.test(rootPid))
19
+ if (callback) {
20
+ callback(new Error("pid must be a number"));
21
+ return;
22
+ } else
23
+ throw new Error("pid must be a number");
24
+ let tree = {};
25
+ tree[rootPid] = [];
26
+ let pidsToProcess = /* @__PURE__ */ new Set();
27
+ switch (pidsToProcess.add(rootPid), process.platform) {
28
+ case "win32": {
29
+ spawn("taskkill", ["/pid", rootPid, "/T", "/F"]).on("close", (code) => {
30
+ callback && (code === 0 ? callback() : callback(new Error(`taskkill exited with code ${code}`)));
31
+ });
32
+ break;
33
+ }
34
+ case "darwin":
35
+ buildProcessTree(rootPid, tree, pidsToProcess, function(parentPid) {
36
+ return spawn("pgrep", ["-lfP", parentPid]);
37
+ }, function() {
38
+ killAll(tree, killSignal, rootPid, killRoot, callback);
39
+ });
40
+ break;
41
+ default:
42
+ buildProcessTree(rootPid, tree, pidsToProcess, function(parentPid) {
43
+ return spawn("ps", ["-o", "pid command", "--no-headers", "--ppid", parentPid]);
44
+ }, function() {
45
+ killAll(tree, killSignal, rootPid, killRoot, callback);
46
+ });
47
+ break;
48
+ }
49
+ }
50
+ function killAll(tree, killSignal, rootPid, killRoot, callback) {
51
+ let killed = /* @__PURE__ */ new Set();
52
+ try {
53
+ Object.keys(tree).forEach(function(pid) {
54
+ tree[pid].forEach(function(pidpid) {
55
+ killed.has(pidpid) || (killPid(pidpid, killSignal), killed.add(pidpid));
56
+ }), pid === rootPid && killRoot && !killed.has(pid) && (killPid(pid, killSignal), killed.add(pid));
57
+ });
58
+ } catch (err) {
59
+ if (callback) {
60
+ callback(err);
61
+ return;
62
+ } else
63
+ throw err;
64
+ }
65
+ callback && callback();
66
+ }
67
+ function killPid(pid, killSignal) {
68
+ try {
69
+ process.kill(parseInt(pid, 10), killSignal);
70
+ } catch (err) {
71
+ if (err.code !== "ESRCH")
72
+ throw err;
73
+ }
74
+ }
75
+ function buildProcessTree(parentPid, tree, pidsToProcess, spawnChildProcessesList, cb) {
76
+ let ps = spawnChildProcessesList(parentPid), allData = "";
77
+ ps.stdout?.on("data", function(data) {
78
+ let dataStr = data.toString("ascii");
79
+ allData += dataStr;
80
+ });
81
+ let onClose = (code) => {
82
+ if (pidsToProcess.delete(parentPid), code !== 0) {
83
+ if (pidsToProcess.size === 0) {
84
+ cb();
85
+ return;
86
+ }
87
+ return;
88
+ }
89
+ allData.trim().split(`
90
+ `).forEach(function(line) {
91
+ let match = line.match(/^(\d+)\s(.*)$/);
92
+ if (match) {
93
+ let pid = match[1], cmd = match[2];
94
+ tree[parentPid].push(pid), tree[pid] = [], outputDebug(`Killing process ${pid}: ${cmd}`), pidsToProcess.add(pid), buildProcessTree(pid, tree, pidsToProcess, spawnChildProcessesList, cb);
95
+ }
96
+ });
97
+ };
98
+ ps.on("close", onClose);
99
+ }
100
+
101
+ export {
102
+ treeKill
103
+ };
104
+ //# sourceMappingURL=chunk-CEGG2EWP.js.map
@@ -0,0 +1,21 @@
1
+ import {
2
+ __commonJS,
3
+ init_cjs_shims
4
+ } from "./chunk-PKR7KJ6P.js";
5
+
6
+ // ../../node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js
7
+ var require_has_flag = __commonJS({
8
+ "../../node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js"(exports, module) {
9
+ "use strict";
10
+ init_cjs_shims();
11
+ module.exports = (flag, argv = process.argv) => {
12
+ let prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--", position = argv.indexOf(prefix + flag), terminatorPosition = argv.indexOf("--");
13
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
14
+ };
15
+ }
16
+ });
17
+
18
+ export {
19
+ require_has_flag
20
+ };
21
+ //# sourceMappingURL=chunk-DJW2W7VA.js.map
@@ -13859,4 +13859,4 @@ export {
13859
13859
  debugApis,
13860
13860
  init_prettier
13861
13861
  };
13862
- //# sourceMappingURL=chunk-LI75HRH4.js.map
13862
+ //# sourceMappingURL=chunk-DWGHKWV5.js.map
@@ -0,0 +1,30 @@
1
+ import {
2
+ init_cjs_shims
3
+ } from "./chunk-PKR7KJ6P.js";
4
+
5
+ // ../cli-kit/dist/private/node/context/deprecations-store.js
6
+ init_cjs_shims();
7
+ var deprecationsStore = {
8
+ nextDeprecationDate: void 0
9
+ };
10
+ function getNextDeprecationDate() {
11
+ return deprecationsStore.nextDeprecationDate;
12
+ }
13
+ function setNextDeprecationDate(dates) {
14
+ if (dates.length < 1)
15
+ return;
16
+ let earliestFutureDateTime = earliestDateTimeAfter(Date.now(), dates);
17
+ if (!earliestFutureDateTime)
18
+ return;
19
+ let nextDeprecationDate = getNextDeprecationDate();
20
+ (!nextDeprecationDate || earliestFutureDateTime < nextDeprecationDate.getTime()) && (deprecationsStore.nextDeprecationDate = new Date(earliestFutureDateTime));
21
+ }
22
+ function earliestDateTimeAfter(afterTime, dates) {
23
+ return dates.map((date) => date.getTime()).sort().find((time) => time > afterTime);
24
+ }
25
+
26
+ export {
27
+ getNextDeprecationDate,
28
+ setNextDeprecationDate
29
+ };
30
+ //# sourceMappingURL=chunk-JCETIRLI.js.map
@@ -0,0 +1,371 @@
1
+ import {
2
+ cacheRetrieve,
3
+ cacheRetrieveOrRepopulate
4
+ } from "./chunk-RB7BXTZQ.js";
5
+ import {
6
+ AbortController,
7
+ exec
8
+ } from "./chunk-C5OLLQWI.js";
9
+ import {
10
+ runWithTimer
11
+ } from "./chunk-SWITKWBS.js";
12
+ import {
13
+ AbortError,
14
+ BugError
15
+ } from "./chunk-MIECGF3H.js";
16
+ import {
17
+ require_semver
18
+ } from "./chunk-6OOTYTVB.js";
19
+ import {
20
+ fileExists,
21
+ fileExistsSync,
22
+ findPathUp,
23
+ glob,
24
+ inferPackageManagerForGlobalCLI,
25
+ outputContent,
26
+ outputDebug,
27
+ outputToken,
28
+ readFile,
29
+ writeFile
30
+ } from "./chunk-BMI6QCMV.js";
31
+ import {
32
+ dirname,
33
+ joinPath
34
+ } from "./chunk-ACS6S42W.js";
35
+ import {
36
+ __toESM,
37
+ init_cjs_shims
38
+ } from "./chunk-PKR7KJ6P.js";
39
+
40
+ // ../cli-kit/dist/public/node/node-package-manager.js
41
+ init_cjs_shims();
42
+
43
+ // ../cli-kit/dist/public/common/json.js
44
+ init_cjs_shims();
45
+ function parseJSON(jsonString, context) {
46
+ try {
47
+ return JSON.parse(jsonString);
48
+ } catch (error) {
49
+ let errorMessage = error instanceof Error ? error.message : String(error), contextMessage = context ? ` from ${context}` : "";
50
+ throw new AbortError(`Failed to parse JSON${contextMessage}.
51
+ ${errorMessage}`);
52
+ }
53
+ }
54
+
55
+ // ../cli-kit/dist/public/node/node-package-manager.js
56
+ var import_semver = __toESM(require_semver(), 1), yarnLockfile = "yarn.lock", npmLockfile = "package-lock.json", pnpmLockfile = "pnpm-lock.yaml", bunLockfile = "bun.lockb", modernBunLockfile = "bun.lock", pnpmWorkspaceFile = "pnpm-workspace.yaml", lockfiles = [yarnLockfile, pnpmLockfile, npmLockfile, bunLockfile, modernBunLockfile], lockfilesByManager = {
57
+ yarn: [yarnLockfile],
58
+ npm: [npmLockfile],
59
+ pnpm: [pnpmLockfile],
60
+ bun: [bunLockfile, modernBunLockfile],
61
+ homebrew: [],
62
+ unknown: []
63
+ }, packageManager = ["yarn", "npm", "pnpm", "bun", "homebrew", "unknown"], UnknownPackageManagerError = class extends AbortError {
64
+ constructor() {
65
+ super("Unknown package manager");
66
+ }
67
+ }, PackageJsonNotFoundError = class extends AbortError {
68
+ constructor(directory) {
69
+ super(outputContent`The directory ${outputToken.path(directory)} doesn't have a package.json.`);
70
+ }
71
+ }, FindUpAndReadPackageJsonNotFoundError = class extends BugError {
72
+ constructor(directory) {
73
+ super(outputContent`Couldn't find a a package.json traversing directories from ${outputToken.path(directory)}`);
74
+ }
75
+ };
76
+ function packageManagerFromUserAgent(env = process.env) {
77
+ return env.npm_config_user_agent?.includes("yarn") ? "yarn" : env.npm_config_user_agent?.includes("pnpm") ? "pnpm" : env.npm_config_user_agent?.includes("bun") ? "bun" : env.npm_config_user_agent?.includes("npm") ? "npm" : "unknown";
78
+ }
79
+ function hasBunLockfileSync(directory) {
80
+ return fileExistsSync(joinPath(directory, bunLockfile)) || fileExistsSync(joinPath(directory, modernBunLockfile));
81
+ }
82
+ function normalizePackageManagerForProject(packageManager2) {
83
+ switch (packageManager2) {
84
+ case "yarn":
85
+ case "npm":
86
+ case "pnpm":
87
+ case "bun":
88
+ return packageManager2;
89
+ case "homebrew":
90
+ case "unknown":
91
+ return "npm";
92
+ }
93
+ }
94
+ function packageManagerBinaryCommand(packageManager2, binary, ...binaryArgs) {
95
+ switch (packageManager2) {
96
+ case "npm":
97
+ return { command: "npm", args: ["exec", "--", binary, ...binaryArgs] };
98
+ case "pnpm":
99
+ return { command: "pnpm", args: ["exec", binary, ...binaryArgs] };
100
+ case "yarn":
101
+ return { command: "yarn", args: ["run", binary, ...binaryArgs] };
102
+ case "bun":
103
+ return { command: "bun", args: ["x", binary, ...binaryArgs] };
104
+ }
105
+ }
106
+ async function getPackageManager(fromDirectory) {
107
+ let current = fromDirectory;
108
+ for (outputDebug(outputContent`Looking for a lockfile in ${outputToken.path(current)}...`); ; ) {
109
+ if (fileExistsSync(joinPath(current, yarnLockfile)))
110
+ return "yarn";
111
+ if (fileExistsSync(joinPath(current, pnpmLockfile)) || fileExistsSync(joinPath(current, pnpmWorkspaceFile)))
112
+ return "pnpm";
113
+ if (hasBunLockfileSync(current))
114
+ return "bun";
115
+ if (fileExistsSync(joinPath(current, npmLockfile)))
116
+ return "npm";
117
+ let parent = dirname(current);
118
+ if (parent === current)
119
+ break;
120
+ current = parent;
121
+ }
122
+ let pm = packageManagerFromUserAgent();
123
+ return pm !== "unknown" ? pm : "npm";
124
+ }
125
+ async function packageManagerBinaryCommandForDirectory(fromDirectory, binary, ...binaryArgs) {
126
+ let packageManager2 = normalizePackageManagerForProject(await getPackageManager(fromDirectory));
127
+ return packageManagerBinaryCommand(packageManager2, binary, ...binaryArgs);
128
+ }
129
+ async function installNPMDependenciesRecursively(options) {
130
+ let packageJsons = await glob(joinPath(options.directory, "**/package.json"), {
131
+ ignore: [joinPath(options.directory, "node_modules/**/package.json")],
132
+ cwd: options.directory,
133
+ onlyFiles: !0,
134
+ deep: options.deep
135
+ }), abortController = new AbortController();
136
+ try {
137
+ await Promise.all(packageJsons.map(async (packageJsonPath) => {
138
+ let directory = dirname(packageJsonPath);
139
+ await installNodeModules({
140
+ directory,
141
+ packageManager: options.packageManager,
142
+ stdout: void 0,
143
+ stderr: void 0,
144
+ signal: abortController.signal,
145
+ args: []
146
+ });
147
+ }));
148
+ } catch (error) {
149
+ throw abortController.abort(), error;
150
+ }
151
+ }
152
+ async function installNodeModules(options) {
153
+ let execOptions = {
154
+ cwd: options.directory,
155
+ stdin: void 0,
156
+ stdout: options.stdout,
157
+ stderr: options.stderr,
158
+ signal: options.signal
159
+ }, args = ["install"];
160
+ options.args && (args = args.concat(options.args)), await runWithTimer("cmd_all_timing_network_ms")(async () => {
161
+ await exec(options.packageManager, args, execOptions);
162
+ });
163
+ }
164
+ async function getPackageName(packageJsonPath) {
165
+ return (await readAndParsePackageJson(packageJsonPath)).name;
166
+ }
167
+ async function getPackageVersion(packageJsonPath) {
168
+ return (await readAndParsePackageJson(packageJsonPath)).version;
169
+ }
170
+ async function getDependencies(packageJsonPath) {
171
+ let packageJsonContent = await readAndParsePackageJson(packageJsonPath), dependencies = packageJsonContent.dependencies ?? {}, devDependencies = packageJsonContent.devDependencies ?? {};
172
+ return { ...dependencies, ...devDependencies };
173
+ }
174
+ async function usesWorkspaces(appDirectory) {
175
+ let packageJsonPath = joinPath(appDirectory, "package.json"), packageJsonContent = await readAndParsePackageJson(packageJsonPath), pnpmWorkspacePath = joinPath(appDirectory, pnpmWorkspaceFile);
176
+ return !!packageJsonContent.workspaces || fileExists(pnpmWorkspacePath);
177
+ }
178
+ async function checkForNewVersion(dependency, currentVersion, { cacheExpiryInHours = 0 } = {}) {
179
+ let getLatestVersion = async () => (outputDebug(outputContent`Checking if there's a version of ${dependency} newer than ${currentVersion}`), getLatestNPMPackageVersion(dependency)), cacheKey = `npm-package-${dependency}`, lastVersion;
180
+ try {
181
+ lastVersion = await cacheRetrieveOrRepopulate(cacheKey, getLatestVersion, cacheExpiryInHours * 3600 * 1e3);
182
+ } catch {
183
+ return;
184
+ }
185
+ if (lastVersion && new import_semver.SemVer(currentVersion).compare(lastVersion) < 0)
186
+ return lastVersion;
187
+ }
188
+ function checkForCachedNewVersion(dependency, currentVersion) {
189
+ let cacheKey = `npm-package-${dependency}`, lastVersion = cacheRetrieve(cacheKey)?.value;
190
+ if (lastVersion && new import_semver.SemVer(currentVersion).compare(lastVersion) < 0)
191
+ return lastVersion;
192
+ }
193
+ function versionSatisfies(version, requirements) {
194
+ return (0, import_semver.satisfies)(version, requirements);
195
+ }
196
+ async function readAndParsePackageJson(packageJsonPath) {
197
+ if (!await fileExists(packageJsonPath))
198
+ throw new PackageJsonNotFoundError(dirname(packageJsonPath));
199
+ return parseJSON(await readFile(packageJsonPath), packageJsonPath);
200
+ }
201
+ async function addNPMDependenciesIfNeeded(dependencies, options) {
202
+ outputDebug(outputContent`Adding the following dependencies if needed:
203
+ ${outputToken.json(dependencies)}
204
+ With options:
205
+ ${outputToken.json(options)}
206
+ `);
207
+ let packageJsonPath = joinPath(options.directory, "package.json");
208
+ if (!await fileExists(packageJsonPath))
209
+ throw new PackageJsonNotFoundError(options.directory);
210
+ let existingDependencies = Object.keys(await getDependencies(packageJsonPath)), dependenciesToAdd = dependencies.filter((dep) => !existingDependencies.includes(dep.name));
211
+ dependenciesToAdd.length !== 0 && await addNPMDependencies(dependenciesToAdd, options);
212
+ }
213
+ async function addNPMDependencies(dependencies, options) {
214
+ let dependenciesWithVersion = dependencies.map((dep) => dep.version ? `${dep.name}@${dep.version}` : dep.name);
215
+ switch (options.stdout?.write(`Installing ${dependenciesWithVersion.join(" ")} with ${options.packageManager}`), options.packageManager) {
216
+ case "npm":
217
+ for (let dep of dependenciesWithVersion)
218
+ await installDependencies(options, argumentsToAddDependenciesWithNPM(dep, options.type));
219
+ break;
220
+ case "yarn":
221
+ await installDependencies(options, argumentsToAddDependenciesWithYarn(dependenciesWithVersion, options.type, !!options.addToRootDirectory));
222
+ break;
223
+ case "pnpm":
224
+ await installDependencies(options, argumentsToAddDependenciesWithPNPM(dependenciesWithVersion, options.type, !!options.addToRootDirectory));
225
+ break;
226
+ case "bun":
227
+ await installDependencies(options, argumentsToAddDependenciesWithBun(dependenciesWithVersion, options.type)), await installDependencies(options, ["install"]);
228
+ break;
229
+ case "homebrew":
230
+ throw new AbortError("Homebrew can't be used to install project dependencies. Use npm, yarn, pnpm, or bun.");
231
+ case "unknown":
232
+ throw new UnknownPackageManagerError();
233
+ }
234
+ }
235
+ async function installDependencies(options, args) {
236
+ return runWithTimer("cmd_all_timing_network_ms")(async () => exec(options.packageManager, args, {
237
+ cwd: options.directory,
238
+ stdout: options.stdout,
239
+ stderr: options.stderr,
240
+ signal: options.signal
241
+ }));
242
+ }
243
+ async function addNPMDependenciesWithoutVersionIfNeeded(dependencies, options) {
244
+ await addNPMDependenciesIfNeeded(dependencies.map((dependency) => ({ name: dependency, version: void 0 })), options);
245
+ }
246
+ function argumentsToAddDependenciesWithNPM(dependency, type) {
247
+ let command = ["install"];
248
+ switch (command = command.concat(dependency), type) {
249
+ case "dev":
250
+ command.push("--save-dev");
251
+ break;
252
+ case "peer":
253
+ command.push("--save-peer");
254
+ break;
255
+ case "prod":
256
+ command.push("--save-prod");
257
+ break;
258
+ }
259
+ return dependency.match(/@\d/g) && command.push("--save-exact"), command;
260
+ }
261
+ function argumentsToAddDependenciesWithYarn(dependencies, type, addAtRoot = !1) {
262
+ let command = ["add"];
263
+ switch (addAtRoot && command.push("-W"), command = command.concat(dependencies), type) {
264
+ case "dev":
265
+ command.push("--dev");
266
+ break;
267
+ case "peer":
268
+ command.push("--peer");
269
+ break;
270
+ case "prod":
271
+ command.push("--prod");
272
+ break;
273
+ }
274
+ return command;
275
+ }
276
+ function argumentsToAddDependenciesWithPNPM(dependencies, type, addAtRoot = !1) {
277
+ let command = ["add"];
278
+ switch (addAtRoot && command.push("-w"), command = command.concat(dependencies), type) {
279
+ case "dev":
280
+ command.push("--save-dev");
281
+ break;
282
+ case "peer":
283
+ command.push("--save-peer");
284
+ break;
285
+ case "prod":
286
+ command.push("--save-prod");
287
+ break;
288
+ }
289
+ return command;
290
+ }
291
+ function argumentsToAddDependenciesWithBun(dependencies, type) {
292
+ let command = ["add"];
293
+ switch (command = command.concat(dependencies), type) {
294
+ case "dev":
295
+ command.push("--development");
296
+ break;
297
+ case "peer":
298
+ command.push("--optional");
299
+ break;
300
+ case "prod":
301
+ break;
302
+ }
303
+ return command;
304
+ }
305
+ async function findUpAndReadPackageJson(fromDirectory) {
306
+ let packageJsonPath = await findPathUp("package.json", { cwd: fromDirectory, type: "file" });
307
+ if (packageJsonPath) {
308
+ let packageJson = parseJSON(await readFile(packageJsonPath), packageJsonPath);
309
+ return { path: packageJsonPath, content: packageJson };
310
+ } else
311
+ throw new FindUpAndReadPackageJsonNotFoundError(fromDirectory);
312
+ }
313
+ async function addResolutionOrOverride(directory, dependencies) {
314
+ let packageManager2 = await getPackageManager(directory), packageJsonPath = joinPath(directory, "package.json"), packageJsonContent = await readAndParsePackageJson(packageJsonPath);
315
+ packageManager2 === "yarn" && (packageJsonContent.resolutions = packageJsonContent.resolutions ? { ...packageJsonContent.resolutions, ...dependencies } : dependencies), (packageManager2 === "npm" || packageManager2 === "pnpm" || packageManager2 === "bun") && (packageJsonContent.overrides = packageJsonContent.overrides ? { ...packageJsonContent.overrides, ...dependencies } : dependencies), await writeFile(packageJsonPath, JSON.stringify(packageJsonContent, null, 2));
316
+ }
317
+ async function getLatestNPMPackageVersion(name) {
318
+ return outputDebug(outputContent`Getting the latest version of NPM package: ${outputToken.raw(name)}`), runWithTimer("cmd_all_timing_network_ms")(async () => {
319
+ let { default: latestVersion } = await import("./latest-version-3PFKLJZM.js");
320
+ return latestVersion(name);
321
+ });
322
+ }
323
+ async function writePackageJSON(directory, packageJSON) {
324
+ outputDebug(outputContent`JSON-encoding and writing content to package.json at ${outputToken.path(directory)}...`);
325
+ let packagePath = joinPath(directory, "package.json");
326
+ await writeFile(packagePath, JSON.stringify(packageJSON, null, 2));
327
+ }
328
+ function inferPackageManager(optionsPackageManager, env = process.env) {
329
+ if (optionsPackageManager && packageManager.includes(optionsPackageManager))
330
+ return optionsPackageManager;
331
+ let usedPackageManager = packageManagerFromUserAgent(env);
332
+ if (usedPackageManager !== "unknown")
333
+ return usedPackageManager;
334
+ let globalPackageManager = inferPackageManagerForGlobalCLI();
335
+ return globalPackageManager !== "unknown" ? globalPackageManager : "npm";
336
+ }
337
+
338
+ export {
339
+ yarnLockfile,
340
+ npmLockfile,
341
+ pnpmLockfile,
342
+ bunLockfile,
343
+ pnpmWorkspaceFile,
344
+ lockfiles,
345
+ lockfilesByManager,
346
+ packageManager,
347
+ UnknownPackageManagerError,
348
+ PackageJsonNotFoundError,
349
+ FindUpAndReadPackageJsonNotFoundError,
350
+ packageManagerFromUserAgent,
351
+ getPackageManager,
352
+ packageManagerBinaryCommandForDirectory,
353
+ installNPMDependenciesRecursively,
354
+ installNodeModules,
355
+ getPackageName,
356
+ getPackageVersion,
357
+ getDependencies,
358
+ usesWorkspaces,
359
+ checkForNewVersion,
360
+ checkForCachedNewVersion,
361
+ versionSatisfies,
362
+ readAndParsePackageJson,
363
+ addNPMDependenciesIfNeeded,
364
+ addNPMDependencies,
365
+ addNPMDependenciesWithoutVersionIfNeeded,
366
+ findUpAndReadPackageJson,
367
+ addResolutionOrOverride,
368
+ writePackageJSON,
369
+ inferPackageManager
370
+ };
371
+ //# sourceMappingURL=chunk-JT5MT2JE.js.map