@betterstart/cli 0.1.9 → 0.1.11
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/cli.js +47 -19
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -7630,6 +7630,18 @@ function runCommand(pm, script) {
|
|
|
7630
7630
|
return `npm run ${script}`;
|
|
7631
7631
|
}
|
|
7632
7632
|
}
|
|
7633
|
+
function createNextAppCommand(pm) {
|
|
7634
|
+
switch (pm) {
|
|
7635
|
+
case "pnpm":
|
|
7636
|
+
return { bin: "pnpm", prefix: ["create", "next-app@latest"] };
|
|
7637
|
+
case "yarn":
|
|
7638
|
+
return { bin: "yarn", prefix: ["create", "next-app@latest"] };
|
|
7639
|
+
case "bun":
|
|
7640
|
+
return { bin: "bunx", prefix: ["create-next-app@latest"] };
|
|
7641
|
+
default:
|
|
7642
|
+
return { bin: "npx", prefix: ["create-next-app@latest"] };
|
|
7643
|
+
}
|
|
7644
|
+
}
|
|
7633
7645
|
|
|
7634
7646
|
// src/generators/post-generate.ts
|
|
7635
7647
|
function loadEnvFile(cwd) {
|
|
@@ -13626,31 +13638,30 @@ var initCommand = new Command3("init").description("Scaffold CMS into a new or e
|
|
|
13626
13638
|
}
|
|
13627
13639
|
pm = pmChoice;
|
|
13628
13640
|
}
|
|
13629
|
-
const cnaSpinner = p4.spinner();
|
|
13630
13641
|
const displayName = projectPrompt.projectName === "." ? path37.basename(cwd) : projectPrompt.projectName;
|
|
13631
|
-
|
|
13642
|
+
const { bin, prefix } = createNextAppCommand(pm);
|
|
13643
|
+
const cnaArgs = [
|
|
13644
|
+
...prefix,
|
|
13645
|
+
projectPrompt.projectName,
|
|
13646
|
+
"--yes",
|
|
13647
|
+
"--typescript",
|
|
13648
|
+
"--tailwind",
|
|
13649
|
+
"--app",
|
|
13650
|
+
"--no-git",
|
|
13651
|
+
"--no-import-alias",
|
|
13652
|
+
"--turbopack",
|
|
13653
|
+
`--use-${pm}`
|
|
13654
|
+
];
|
|
13655
|
+
if (srcDir) cnaArgs.push("--src-dir");
|
|
13656
|
+
else cnaArgs.push("--no-src-dir");
|
|
13657
|
+
p4.log.step(`Creating Next.js app: ${pc2.cyan(displayName)}`);
|
|
13632
13658
|
try {
|
|
13633
|
-
|
|
13634
|
-
"create-next-app@latest",
|
|
13635
|
-
projectPrompt.projectName,
|
|
13636
|
-
"--typescript",
|
|
13637
|
-
"--tailwind",
|
|
13638
|
-
"--app",
|
|
13639
|
-
"--no-git",
|
|
13640
|
-
"--no-import-alias",
|
|
13641
|
-
"--turbopack",
|
|
13642
|
-
`--use-${pm}`
|
|
13643
|
-
];
|
|
13644
|
-
if (srcDir) cnaArgs.push("--src-dir");
|
|
13645
|
-
else cnaArgs.push("--no-src-dir");
|
|
13646
|
-
execFileSync4("npx", cnaArgs, {
|
|
13659
|
+
execFileSync4(bin, cnaArgs, {
|
|
13647
13660
|
cwd,
|
|
13648
|
-
stdio: "
|
|
13661
|
+
stdio: "inherit",
|
|
13649
13662
|
timeout: 12e4
|
|
13650
13663
|
});
|
|
13651
|
-
cnaSpinner.stop(`Created ${displayName}`);
|
|
13652
13664
|
} catch (err) {
|
|
13653
|
-
cnaSpinner.stop("Failed to create Next.js app");
|
|
13654
13665
|
p4.log.error(err instanceof Error ? err.message : "create-next-app failed");
|
|
13655
13666
|
p4.log.info(
|
|
13656
13667
|
`You can create the project manually:
|
|
@@ -13660,6 +13671,23 @@ var initCommand = new Command3("init").description("Scaffold CMS into a new or e
|
|
|
13660
13671
|
process.exit(1);
|
|
13661
13672
|
}
|
|
13662
13673
|
cwd = path37.resolve(cwd, projectPrompt.projectName);
|
|
13674
|
+
const hasPackageJson = fs32.existsSync(path37.join(cwd, "package.json"));
|
|
13675
|
+
const hasNextConfig = ["next.config.ts", "next.config.js", "next.config.mjs"].some(
|
|
13676
|
+
(f) => fs32.existsSync(path37.join(cwd, f))
|
|
13677
|
+
);
|
|
13678
|
+
if (!hasPackageJson || !hasNextConfig) {
|
|
13679
|
+
p4.log.error(
|
|
13680
|
+
"create-next-app completed but the project was not created. This can happen with nested npx calls."
|
|
13681
|
+
);
|
|
13682
|
+
const manualCmd = `npx create-next-app@latest ${projectPrompt.projectName} --typescript --tailwind --app`;
|
|
13683
|
+
p4.log.info(
|
|
13684
|
+
`Create the project manually:
|
|
13685
|
+
${pc2.cyan(manualCmd)}
|
|
13686
|
+
Then run ${pc2.cyan("betterstart init")} inside it.`
|
|
13687
|
+
);
|
|
13688
|
+
process.exit(1);
|
|
13689
|
+
}
|
|
13690
|
+
p4.log.success(`Created ${displayName} Next.js project`);
|
|
13663
13691
|
project = detectProject(cwd);
|
|
13664
13692
|
}
|
|
13665
13693
|
const features = options.yes ? { includeEmail: true, preset: options.preset } : await promptFeatures(options.preset);
|