@create-node-app/core 0.6.0 → 0.6.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.
- package/README.md +148 -0
- package/dist/index.cjs +158 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +160 -45
- package/dist/index.js.map +1 -1
- package/package.json +9 -14
package/dist/index.js
CHANGED
|
@@ -9,24 +9,29 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
9
9
|
import pc4 from "picocolors";
|
|
10
10
|
import envinfo from "envinfo";
|
|
11
11
|
import semver3 from "semver";
|
|
12
|
-
import {
|
|
12
|
+
import { execFileSync as execFileSync3 } from "child_process";
|
|
13
13
|
|
|
14
14
|
// installer.ts
|
|
15
|
-
import
|
|
15
|
+
import lodash2 from "lodash";
|
|
16
16
|
import path3 from "path";
|
|
17
17
|
import fs4 from "fs";
|
|
18
18
|
import pc3 from "picocolors";
|
|
19
19
|
import os3 from "os";
|
|
20
20
|
import semver2 from "semver";
|
|
21
|
-
import {
|
|
21
|
+
import { execFileSync as execFileSync2 } from "child_process";
|
|
22
22
|
|
|
23
23
|
// helpers.ts
|
|
24
|
-
import {
|
|
24
|
+
import { execFileSync } from "child_process";
|
|
25
25
|
import spawn from "cross-spawn";
|
|
26
26
|
import pc from "picocolors";
|
|
27
27
|
import semver from "semver";
|
|
28
28
|
import dns from "dns";
|
|
29
29
|
import { URL as URL2 } from "url";
|
|
30
|
+
|
|
31
|
+
// executable.ts
|
|
32
|
+
var resolveExecutable = (bin) => process.platform === "win32" ? `${bin}.cmd` : bin;
|
|
33
|
+
|
|
34
|
+
// helpers.ts
|
|
30
35
|
var shouldUseYarn = () => {
|
|
31
36
|
const { hasMinYarnPnp, hasMaxYarnPnp, yarnVersion } = checkYarnVersion();
|
|
32
37
|
if (!hasMinYarnPnp) {
|
|
@@ -63,6 +68,20 @@ var shouldUsePnpm = () => {
|
|
|
63
68
|
}
|
|
64
69
|
return true;
|
|
65
70
|
};
|
|
71
|
+
var shouldUseBun = () => {
|
|
72
|
+
const { hasMinBun, bunVersion } = checkBunVersion();
|
|
73
|
+
if (!hasMinBun) {
|
|
74
|
+
console.log(
|
|
75
|
+
pc.yellow(
|
|
76
|
+
`You are using bun version ${pc.bold(
|
|
77
|
+
bunVersion
|
|
78
|
+
)} which is not supported yet. To use bun, install v1.0.0 or higher. See https://bun.sh for instructions on how to install.`
|
|
79
|
+
)
|
|
80
|
+
);
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
};
|
|
66
85
|
var checkThatNpmCanReadCwd = () => {
|
|
67
86
|
const cwd = process.cwd();
|
|
68
87
|
let childOutput = null;
|
|
@@ -118,7 +137,7 @@ var checkPnpmVersion = () => {
|
|
|
118
137
|
let hasMinPnpm = false;
|
|
119
138
|
let pnpmVersion = null;
|
|
120
139
|
try {
|
|
121
|
-
pnpmVersion =
|
|
140
|
+
pnpmVersion = execFileSync(resolveExecutable("pnpm"), ["--version"]).toString().trim();
|
|
122
141
|
if (semver.valid(pnpmVersion)) {
|
|
123
142
|
hasMinPnpm = semver.gte(pnpmVersion, minPnpm);
|
|
124
143
|
} else {
|
|
@@ -131,6 +150,19 @@ var checkPnpmVersion = () => {
|
|
|
131
150
|
}
|
|
132
151
|
return { hasMinPnpm, pnpmVersion };
|
|
133
152
|
};
|
|
153
|
+
var checkBunVersion = () => {
|
|
154
|
+
const minBun = "1.0.0";
|
|
155
|
+
let hasMinBun = false;
|
|
156
|
+
let bunVersion = null;
|
|
157
|
+
try {
|
|
158
|
+
bunVersion = execFileSync(resolveExecutable("bun"), ["--version"]).toString().trim();
|
|
159
|
+
if (semver.valid(bunVersion)) {
|
|
160
|
+
hasMinBun = semver.gte(bunVersion, minBun);
|
|
161
|
+
}
|
|
162
|
+
} catch {
|
|
163
|
+
}
|
|
164
|
+
return { hasMinBun, bunVersion };
|
|
165
|
+
};
|
|
134
166
|
var checkYarnVersion = () => {
|
|
135
167
|
const minYarnPnp = "1.12.0";
|
|
136
168
|
const maxYarnPnp = "2.0.0";
|
|
@@ -138,7 +170,7 @@ var checkYarnVersion = () => {
|
|
|
138
170
|
let hasMaxYarnPnp = false;
|
|
139
171
|
let yarnVersion = null;
|
|
140
172
|
try {
|
|
141
|
-
yarnVersion =
|
|
173
|
+
yarnVersion = execFileSync(resolveExecutable("yarnpkg"), ["--version"]).toString().trim();
|
|
142
174
|
if (semver.valid(yarnVersion)) {
|
|
143
175
|
hasMinYarnPnp = semver.gte(yarnVersion, minYarnPnp);
|
|
144
176
|
hasMaxYarnPnp = semver.lt(yarnVersion, maxYarnPnp);
|
|
@@ -164,7 +196,7 @@ var checkNpmVersion = () => {
|
|
|
164
196
|
let hasMinNpm = false;
|
|
165
197
|
let npmVersion = null;
|
|
166
198
|
try {
|
|
167
|
-
npmVersion =
|
|
199
|
+
npmVersion = execFileSync(resolveExecutable("npm"), ["--version"]).toString().trim();
|
|
168
200
|
hasMinNpm = semver.gte(npmVersion, "6.0.0");
|
|
169
201
|
} catch {
|
|
170
202
|
}
|
|
@@ -178,7 +210,11 @@ var getProxy = () => {
|
|
|
178
210
|
return process.env.HTTPS_PROXY;
|
|
179
211
|
}
|
|
180
212
|
try {
|
|
181
|
-
const httpsProxy =
|
|
213
|
+
const httpsProxy = execFileSync(resolveExecutable("npm"), [
|
|
214
|
+
"config",
|
|
215
|
+
"get",
|
|
216
|
+
"https-proxy"
|
|
217
|
+
]).toString().trim();
|
|
182
218
|
return httpsProxy !== "null" ? httpsProxy : void 0;
|
|
183
219
|
} catch {
|
|
184
220
|
}
|
|
@@ -210,6 +246,8 @@ import merge from "lodash.merge";
|
|
|
210
246
|
import fs2 from "fs";
|
|
211
247
|
import os2 from "os";
|
|
212
248
|
import path2 from "path";
|
|
249
|
+
import { fileURLToPath } from "url";
|
|
250
|
+
import debug2 from "debug";
|
|
213
251
|
|
|
214
252
|
// git.ts
|
|
215
253
|
import os from "os";
|
|
@@ -219,6 +257,35 @@ import debug from "debug";
|
|
|
219
257
|
import { simpleGit } from "simple-git";
|
|
220
258
|
import * as fse from "fs-extra";
|
|
221
259
|
var log = debug("cna:git");
|
|
260
|
+
var formatRepositoryDownloadError = (error, url) => {
|
|
261
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
262
|
+
if (/not found|404|repository not found/i.test(message)) {
|
|
263
|
+
return [
|
|
264
|
+
`Error: Could not fetch template from '${url}'.`,
|
|
265
|
+
" \u2192 The URL returned HTTP 404 or the repository was not found. Please verify the URL is correct.",
|
|
266
|
+
" \u2192 Run 'npx create-awesome-node-app --list-templates' to see available templates."
|
|
267
|
+
].join("\n");
|
|
268
|
+
}
|
|
269
|
+
if (/403|authentication|permission denied|access denied/i.test(message)) {
|
|
270
|
+
return [
|
|
271
|
+
`Error: Could not fetch template from '${url}'.`,
|
|
272
|
+
" \u2192 Access denied (HTTP 403). Check that the repository is public or you have access.",
|
|
273
|
+
" \u2192 Run 'npx create-awesome-node-app --list-templates' to see available templates."
|
|
274
|
+
].join("\n");
|
|
275
|
+
}
|
|
276
|
+
if (/ECONNREFUSED|ENOTFOUND|ETIMEDOUT|network/i.test(message)) {
|
|
277
|
+
return [
|
|
278
|
+
`Error: Could not fetch template from '${url}'.`,
|
|
279
|
+
" \u2192 Could not reach the repository. Please check your internet connection.",
|
|
280
|
+
" \u2192 Run 'npx create-awesome-node-app --list-templates' to see available templates."
|
|
281
|
+
].join("\n");
|
|
282
|
+
}
|
|
283
|
+
return [
|
|
284
|
+
`Error: Could not fetch template from '${url}'.`,
|
|
285
|
+
` \u2192 ${message}`,
|
|
286
|
+
" \u2192 Run 'npx create-awesome-node-app --list-templates' to see available templates."
|
|
287
|
+
].join("\n");
|
|
288
|
+
};
|
|
222
289
|
var filterGit = (src) => {
|
|
223
290
|
return !/(\\|\/)\.git\b/.test(src);
|
|
224
291
|
};
|
|
@@ -233,6 +300,7 @@ var downloadRepository = async ({
|
|
|
233
300
|
cacheDir: optsCacheDir
|
|
234
301
|
}) => {
|
|
235
302
|
const absoluteTarget = path.isAbsolute(target) ? target : path.resolve(target);
|
|
303
|
+
const targetExistedBefore = fs.existsSync(absoluteTarget);
|
|
236
304
|
const isGithub = /^[^/]+\/[^/]+$/.test(url);
|
|
237
305
|
const gitUrl = isGithub ? `https://github.com/${url}` : url;
|
|
238
306
|
const id = targetId || Buffer.from(`${gitUrl}@${branch}`).toString("base64");
|
|
@@ -283,7 +351,15 @@ var downloadRepository = async ({
|
|
|
283
351
|
});
|
|
284
352
|
completedTargetIds.set(id, true);
|
|
285
353
|
} catch (error) {
|
|
286
|
-
|
|
354
|
+
if (!targetExistedBefore && fs.existsSync(absoluteTarget)) {
|
|
355
|
+
try {
|
|
356
|
+
fse.removeSync(absoluteTarget);
|
|
357
|
+
log("Cleaned up partially created directory: %s", absoluteTarget);
|
|
358
|
+
} catch (cleanupErr) {
|
|
359
|
+
log("Failed to clean up directory: %s", cleanupErr);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
throw new Error(formatRepositoryDownloadError(error, gitUrl));
|
|
287
363
|
} finally {
|
|
288
364
|
gitOperationMap.delete(id);
|
|
289
365
|
}
|
|
@@ -293,6 +369,8 @@ var downloadRepository = async ({
|
|
|
293
369
|
};
|
|
294
370
|
|
|
295
371
|
// paths.ts
|
|
372
|
+
var log2 = debug2("cna:paths");
|
|
373
|
+
var moduleDir = typeof __dirname !== "undefined" ? __dirname : path2.dirname(fileURLToPath(import.meta.url));
|
|
296
374
|
var solveValuesFromTemplateOrExtensionUrl = (templateOrExtension) => {
|
|
297
375
|
const url = new URL(templateOrExtension);
|
|
298
376
|
const ignorePackage = url.searchParams.get("ignorePackage") === "true";
|
|
@@ -346,30 +424,23 @@ var solveRepositoryPath = async ({
|
|
|
346
424
|
if (process.env.CNA_SKIP_GIT === "1") {
|
|
347
425
|
return { dir: target, subdir };
|
|
348
426
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
});
|
|
356
|
-
} catch {
|
|
357
|
-
}
|
|
427
|
+
await downloadRepository({
|
|
428
|
+
url,
|
|
429
|
+
branch: branch || "",
|
|
430
|
+
target,
|
|
431
|
+
targetId
|
|
432
|
+
});
|
|
358
433
|
return { dir: target, subdir };
|
|
359
434
|
};
|
|
360
435
|
var solveTemplateOrExtensionPath = async (templateOrExtension) => {
|
|
436
|
+
let parsed;
|
|
361
437
|
try {
|
|
362
|
-
|
|
363
|
-
if (protocol === "file:") {
|
|
364
|
-
const baseDir = pathname;
|
|
365
|
-
return { dir: baseDir, subdir, ignorePackage };
|
|
366
|
-
}
|
|
367
|
-
const gitData = await solveRepositoryPath({ url, branch, subdir });
|
|
368
|
-
return { dir: gitData.dir, subdir: gitData.subdir, ignorePackage };
|
|
438
|
+
parsed = solveValuesFromTemplateOrExtensionUrl(templateOrExtension);
|
|
369
439
|
} catch {
|
|
440
|
+
log2("Falling back to legacy template path for: %s", templateOrExtension);
|
|
370
441
|
return {
|
|
371
442
|
dir: path2.resolve(
|
|
372
|
-
|
|
443
|
+
moduleDir,
|
|
373
444
|
"..",
|
|
374
445
|
"templatesOrExtensions",
|
|
375
446
|
templateOrExtension
|
|
@@ -378,6 +449,12 @@ var solveTemplateOrExtensionPath = async (templateOrExtension) => {
|
|
|
378
449
|
ignorePackage: void 0
|
|
379
450
|
};
|
|
380
451
|
}
|
|
452
|
+
const { url, branch, subdir, protocol, pathname, ignorePackage } = parsed;
|
|
453
|
+
if (protocol === "file:") {
|
|
454
|
+
return { dir: pathname, subdir, ignorePackage };
|
|
455
|
+
}
|
|
456
|
+
const gitData = await solveRepositoryPath({ url, branch, subdir });
|
|
457
|
+
return { dir: gitData.dir, subdir: gitData.subdir, ignorePackage };
|
|
381
458
|
};
|
|
382
459
|
var getPackagePath = async (templateOrExtension, name = "package", ignorePackage = false) => {
|
|
383
460
|
const {
|
|
@@ -452,10 +529,10 @@ var loadPackages = async ({
|
|
|
452
529
|
const setup = await Promise.all(
|
|
453
530
|
templatesOrExtensions.map(async ({ url: templateOrExtension }) => {
|
|
454
531
|
try {
|
|
455
|
-
const
|
|
532
|
+
const template2 = requireIfExists(
|
|
456
533
|
await getPackagePath(templateOrExtension, "template.json")
|
|
457
534
|
);
|
|
458
|
-
return
|
|
535
|
+
return template2.package || {};
|
|
459
536
|
} catch {
|
|
460
537
|
return {};
|
|
461
538
|
}
|
|
@@ -508,12 +585,13 @@ var loadPackages = async ({
|
|
|
508
585
|
};
|
|
509
586
|
|
|
510
587
|
// loaders.ts
|
|
511
|
-
import _ from "underscore";
|
|
512
588
|
import fs3 from "fs";
|
|
513
589
|
import pc2 from "picocolors";
|
|
514
590
|
import { readdirp } from "readdirp";
|
|
515
591
|
import { dirname } from "path";
|
|
516
592
|
import { promisify } from "util";
|
|
593
|
+
import lodash from "lodash";
|
|
594
|
+
var { template } = lodash;
|
|
517
595
|
var writeFileAsync = promisify(fs3.writeFile);
|
|
518
596
|
var copyFileAsync = promisify(fs3.copyFile);
|
|
519
597
|
var SRC_PATH_PATTERN = "[src]/";
|
|
@@ -542,6 +620,11 @@ var batchedCopyFiles = async (operations) => {
|
|
|
542
620
|
try {
|
|
543
621
|
makeDirectory(dirname(operation.dest));
|
|
544
622
|
await copyFileAsync(operation.src, operation.dest);
|
|
623
|
+
try {
|
|
624
|
+
const srcStat = await promisify(fs3.stat)(operation.src);
|
|
625
|
+
await promisify(fs3.chmod)(operation.dest, srcStat.mode);
|
|
626
|
+
} catch {
|
|
627
|
+
}
|
|
545
628
|
if (operation.verbose) {
|
|
546
629
|
console.log(
|
|
547
630
|
pc2.green(
|
|
@@ -611,7 +694,7 @@ var batchedAppendFiles = async (operations) => {
|
|
|
611
694
|
var copyLoader = ({ root, templateDir, verbose, srcDir }) => async ({ path: path5 }) => {
|
|
612
695
|
const operations = [];
|
|
613
696
|
try {
|
|
614
|
-
const newPath = path5.replace(/.if-(npm|yarn|pnpm)$/, "").replace(SRC_PATH_PATTERN, getSrcDirPattern(srcDir));
|
|
697
|
+
const newPath = path5.replace(/.if-(npm|yarn|pnpm|bun)$/, "").replace(SRC_PATH_PATTERN, getSrcDirPattern(srcDir));
|
|
615
698
|
operations.push({
|
|
616
699
|
src: `${templateDir}/${path5}`,
|
|
617
700
|
dest: `${root}/${newPath}`,
|
|
@@ -628,7 +711,7 @@ var copyLoader = ({ root, templateDir, verbose, srcDir }) => async ({ path: path
|
|
|
628
711
|
var appendLoader = ({ root, templateDir, verbose, srcDir }) => async ({ path: path5 }) => {
|
|
629
712
|
const operations = [];
|
|
630
713
|
try {
|
|
631
|
-
const newPath = path5.replace(/.append$/, "").replace(/.if-(npm|yarn|pnpm)$/, "").replace(SRC_PATH_PATTERN, getSrcDirPattern(srcDir));
|
|
714
|
+
const newPath = path5.replace(/.append$/, "").replace(/.if-(npm|yarn|pnpm|bun)$/, "").replace(SRC_PATH_PATTERN, getSrcDirPattern(srcDir));
|
|
632
715
|
operations.push({
|
|
633
716
|
src: `${templateDir}/${path5}`,
|
|
634
717
|
dest: `${root}/${newPath}`,
|
|
@@ -659,8 +742,8 @@ var templateLoader = ({
|
|
|
659
742
|
const filePath = `${templateDir}/${path5}`;
|
|
660
743
|
const file = await promisify(fs3.readFile)(filePath, "utf8");
|
|
661
744
|
const fileMode = (await promisify(fs3.stat)(filePath)).mode;
|
|
662
|
-
const newFile =
|
|
663
|
-
const newPath = path5.replace(/.template$/, "").replace(/.append$/, "").replace(/.if-(npm|yarn|pnpm)$/, "").replace(SRC_PATH_PATTERN, getSrcDirPattern(srcDir));
|
|
745
|
+
const newFile = template(file);
|
|
746
|
+
const newPath = path5.replace(/.template$/, "").replace(/.append$/, "").replace(/.if-(npm|yarn|pnpm|bun)$/, "").replace(SRC_PATH_PATTERN, getSrcDirPattern(srcDir));
|
|
664
747
|
operations.push({
|
|
665
748
|
path: `${root}/${newPath}`,
|
|
666
749
|
content: newFile({
|
|
@@ -690,6 +773,7 @@ var fileLoader = ({
|
|
|
690
773
|
verbose,
|
|
691
774
|
useYarn,
|
|
692
775
|
usePnpm,
|
|
776
|
+
useBun,
|
|
693
777
|
srcDir = DEFAULT_SRC_PATH,
|
|
694
778
|
runCommand,
|
|
695
779
|
installCommand,
|
|
@@ -712,6 +796,7 @@ var fileLoader = ({
|
|
|
712
796
|
verbose,
|
|
713
797
|
useYarn: !!useYarn,
|
|
714
798
|
usePnpm: !!usePnpm,
|
|
799
|
+
useBun: !!useBun,
|
|
715
800
|
mode,
|
|
716
801
|
srcDir,
|
|
717
802
|
runCommand,
|
|
@@ -735,6 +820,7 @@ var loadFiles = async ({
|
|
|
735
820
|
verbose,
|
|
736
821
|
useYarn = false,
|
|
737
822
|
usePnpm = false,
|
|
823
|
+
useBun = false,
|
|
738
824
|
srcDir = DEFAULT_SRC_PATH,
|
|
739
825
|
runCommand,
|
|
740
826
|
installCommand,
|
|
@@ -765,7 +851,7 @@ var loadFiles = async ({
|
|
|
765
851
|
/\byarn\.lock$/,
|
|
766
852
|
/\bpnpm-lock\.yaml$/
|
|
767
853
|
];
|
|
768
|
-
const skipManager = usePnpm ? [/\.if-npm\./, /\.if-yarn\./] : useYarn ? [/\.if-npm\./, /\.if-pnpm\./] : [/\.if-yarn\./, /\.if-pnpm\./];
|
|
854
|
+
const skipManager = usePnpm ? [/\.if-npm\./, /\.if-yarn\./, /\.if-bun\./] : useYarn ? [/\.if-npm\./, /\.if-pnpm\./, /\.if-bun\./] : useBun ? [/\.if-yarn\./, /\.if-pnpm\./] : [/\.if-yarn\./, /\.if-pnpm\./, /\.if-bun\./];
|
|
769
855
|
const shouldSkip = (p) => [...skipGlobs, ...skipManager].some((rgx) => rgx.test(p));
|
|
770
856
|
for await (const entry of readdirp(templateDir, {
|
|
771
857
|
type: "files",
|
|
@@ -785,6 +871,7 @@ var loadFiles = async ({
|
|
|
785
871
|
verbose,
|
|
786
872
|
useYarn,
|
|
787
873
|
usePnpm,
|
|
874
|
+
useBun,
|
|
788
875
|
srcDir,
|
|
789
876
|
runCommand,
|
|
790
877
|
installCommand,
|
|
@@ -820,7 +907,8 @@ var loadFiles = async ({
|
|
|
820
907
|
};
|
|
821
908
|
|
|
822
909
|
// installer.ts
|
|
823
|
-
var
|
|
910
|
+
var { isEmpty } = lodash2;
|
|
911
|
+
var install = async (root, useYarn = false, usePnpm = false, useBun = false, dependencies = [], verbose = false, isOnline = true, isDevDependencies = false) => {
|
|
824
912
|
let command;
|
|
825
913
|
let args;
|
|
826
914
|
if (useYarn) {
|
|
@@ -849,6 +937,17 @@ var install = async (root, useYarn = false, usePnpm = false, dependencies = [],
|
|
|
849
937
|
args.push("--save");
|
|
850
938
|
}
|
|
851
939
|
args.push(...dependencies);
|
|
940
|
+
} else if (useBun) {
|
|
941
|
+
command = "bun";
|
|
942
|
+
if (dependencies.length > 0) {
|
|
943
|
+
args = ["add"];
|
|
944
|
+
if (isDevDependencies) {
|
|
945
|
+
args.push("--dev");
|
|
946
|
+
}
|
|
947
|
+
args.push(...dependencies);
|
|
948
|
+
} else {
|
|
949
|
+
args = ["install"];
|
|
950
|
+
}
|
|
852
951
|
} else {
|
|
853
952
|
command = "npm";
|
|
854
953
|
args = ["install", "--loglevel", "error"];
|
|
@@ -863,7 +962,7 @@ var install = async (root, useYarn = false, usePnpm = false, dependencies = [],
|
|
|
863
962
|
args.push("--verbose");
|
|
864
963
|
}
|
|
865
964
|
try {
|
|
866
|
-
|
|
965
|
+
execFileSync2(resolveExecutable(command), args, {
|
|
867
966
|
cwd: root,
|
|
868
967
|
stdio: "inherit"
|
|
869
968
|
});
|
|
@@ -872,8 +971,9 @@ var install = async (root, useYarn = false, usePnpm = false, dependencies = [],
|
|
|
872
971
|
}
|
|
873
972
|
};
|
|
874
973
|
var runCommandInProjectDir = async (root, command, args = [], successMessage = "Operation completed successfully.", errorMessage = "Operation failed.") => {
|
|
974
|
+
const [executable, ...baseArgs] = command === "npm run" ? ["npm", "run"] : command === "pnpm run" ? ["pnpm", "run"] : command === "bun run" ? ["bun", "run"] : [command];
|
|
875
975
|
try {
|
|
876
|
-
|
|
976
|
+
execFileSync2(resolveExecutable(executable), [...baseArgs, ...args], {
|
|
877
977
|
cwd: root,
|
|
878
978
|
stdio: "ignore"
|
|
879
979
|
});
|
|
@@ -901,6 +1001,7 @@ var run = async ({
|
|
|
901
1001
|
verbose = false,
|
|
902
1002
|
useYarn = false,
|
|
903
1003
|
usePnpm = false,
|
|
1004
|
+
useBun = false,
|
|
904
1005
|
templatesOrExtensions = [],
|
|
905
1006
|
dependencies = [],
|
|
906
1007
|
devDependencies = [],
|
|
@@ -910,7 +1011,7 @@ var run = async ({
|
|
|
910
1011
|
...customOptions
|
|
911
1012
|
}) => {
|
|
912
1013
|
const isOnline = useYarn ? await checkIfOnline(useYarn) : true;
|
|
913
|
-
if (
|
|
1014
|
+
if (isEmpty(templatesOrExtensions)) {
|
|
914
1015
|
console.log();
|
|
915
1016
|
console.log(
|
|
916
1017
|
pc3.yellow(
|
|
@@ -930,6 +1031,7 @@ var run = async ({
|
|
|
930
1031
|
verbose,
|
|
931
1032
|
useYarn,
|
|
932
1033
|
usePnpm,
|
|
1034
|
+
useBun,
|
|
933
1035
|
runCommand,
|
|
934
1036
|
installCommand,
|
|
935
1037
|
...customOptions
|
|
@@ -947,6 +1049,7 @@ var run = async ({
|
|
|
947
1049
|
root,
|
|
948
1050
|
useYarn,
|
|
949
1051
|
usePnpm,
|
|
1052
|
+
useBun,
|
|
950
1053
|
dependencies,
|
|
951
1054
|
verbose,
|
|
952
1055
|
isOnline,
|
|
@@ -960,6 +1063,7 @@ var run = async ({
|
|
|
960
1063
|
root,
|
|
961
1064
|
useYarn,
|
|
962
1065
|
usePnpm,
|
|
1066
|
+
useBun,
|
|
963
1067
|
devDependencies,
|
|
964
1068
|
verbose,
|
|
965
1069
|
isOnline,
|
|
@@ -1084,13 +1188,15 @@ var createApp = async ({
|
|
|
1084
1188
|
console.log();
|
|
1085
1189
|
const useYarn = customOptions.packageManager === "yarn" && shouldUseYarn();
|
|
1086
1190
|
const usePnpm = customOptions.packageManager === "pnpm" && shouldUsePnpm();
|
|
1087
|
-
const
|
|
1088
|
-
const
|
|
1191
|
+
const useBun = customOptions.packageManager === "bun" && shouldUseBun();
|
|
1192
|
+
const runCommand = useYarn ? "yarn" : usePnpm ? "pnpm run" : useBun ? "bun run" : "npm run";
|
|
1193
|
+
const installCommand = useYarn ? "yarn" : usePnpm ? "pnpm install" : useBun ? "bun install" : "npm install";
|
|
1089
1194
|
const { packageJson, dependencies, devDependencies } = await loadPackages({
|
|
1090
1195
|
templatesOrExtensions,
|
|
1091
1196
|
appName,
|
|
1092
1197
|
usePnpm,
|
|
1093
1198
|
useYarn,
|
|
1199
|
+
useBun,
|
|
1094
1200
|
runCommand,
|
|
1095
1201
|
ignorePackage
|
|
1096
1202
|
});
|
|
@@ -1100,7 +1206,7 @@ var createApp = async ({
|
|
|
1100
1206
|
);
|
|
1101
1207
|
const originalDirectory = process.cwd();
|
|
1102
1208
|
process.chdir(root);
|
|
1103
|
-
if (!useYarn && !checkThatNpmCanReadCwd()) {
|
|
1209
|
+
if (!useYarn && !useBun && !checkThatNpmCanReadCwd()) {
|
|
1104
1210
|
process.exit(1);
|
|
1105
1211
|
}
|
|
1106
1212
|
if (!semver2.satisfies(process.version, ">=18.0.0")) {
|
|
@@ -1113,7 +1219,7 @@ Please update to Node 18 or higher for a better, fully supported experience.
|
|
|
1113
1219
|
)
|
|
1114
1220
|
);
|
|
1115
1221
|
}
|
|
1116
|
-
if (!useYarn) {
|
|
1222
|
+
if (!useYarn && !useBun) {
|
|
1117
1223
|
const npmInfo = checkNpmVersion();
|
|
1118
1224
|
if (!npmInfo.hasMinNpm) {
|
|
1119
1225
|
if (npmInfo.npmVersion) {
|
|
@@ -1131,7 +1237,11 @@ Please update to npm 3 or higher for a better, fully supported experience.
|
|
|
1131
1237
|
if (useYarn) {
|
|
1132
1238
|
let yarnUsesDefaultRegistry = true;
|
|
1133
1239
|
try {
|
|
1134
|
-
yarnUsesDefaultRegistry =
|
|
1240
|
+
yarnUsesDefaultRegistry = execFileSync2(resolveExecutable("yarnpkg"), [
|
|
1241
|
+
"config",
|
|
1242
|
+
"get",
|
|
1243
|
+
"registry"
|
|
1244
|
+
]).toString().trim() === "https://registry.yarnpkg.com";
|
|
1135
1245
|
} catch {
|
|
1136
1246
|
}
|
|
1137
1247
|
if (false) {
|
|
@@ -1149,6 +1259,7 @@ Please update to npm 3 or higher for a better, fully supported experience.
|
|
|
1149
1259
|
verbose,
|
|
1150
1260
|
useYarn,
|
|
1151
1261
|
usePnpm,
|
|
1262
|
+
useBun,
|
|
1152
1263
|
templatesOrExtensions,
|
|
1153
1264
|
dependencies,
|
|
1154
1265
|
devDependencies,
|
|
@@ -1203,7 +1314,11 @@ var checkForLatestVersion = async (packageName) => {
|
|
|
1203
1314
|
return null;
|
|
1204
1315
|
} catch {
|
|
1205
1316
|
try {
|
|
1206
|
-
return
|
|
1317
|
+
return execFileSync3(resolveExecutable("npm"), [
|
|
1318
|
+
"view",
|
|
1319
|
+
packageName,
|
|
1320
|
+
"version"
|
|
1321
|
+
]).toString().trim();
|
|
1207
1322
|
} catch {
|
|
1208
1323
|
}
|
|
1209
1324
|
}
|
|
@@ -1214,7 +1329,7 @@ var printEnvInfo = async () => {
|
|
|
1214
1329
|
const info = await envinfo.run(
|
|
1215
1330
|
{
|
|
1216
1331
|
System: ["OS", "CPU", "Memory", "Shell"],
|
|
1217
|
-
Binaries: ["Node", "npm", "pnpm", "Yarn", "Watchman"],
|
|
1332
|
+
Binaries: ["Node", "npm", "pnpm", "Yarn", "Bun", "Watchman"],
|
|
1218
1333
|
Browsers: ["Chrome", "Edge", "Internet Explorer", "Firefox", "Safari"]
|
|
1219
1334
|
},
|
|
1220
1335
|
{
|