@betterstart/cli 0.1.9 → 0.1.10

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 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) {
@@ -13629,26 +13641,27 @@ var initCommand = new Command3("init").description("Scaffold CMS into a new or e
13629
13641
  const cnaSpinner = p4.spinner();
13630
13642
  const displayName = projectPrompt.projectName === "." ? path37.basename(cwd) : projectPrompt.projectName;
13631
13643
  cnaSpinner.start(`Creating Next.js app: ${displayName}...`);
13644
+ const { bin, prefix } = createNextAppCommand(pm);
13645
+ const cnaArgs = [
13646
+ ...prefix,
13647
+ projectPrompt.projectName,
13648
+ "--yes",
13649
+ "--typescript",
13650
+ "--tailwind",
13651
+ "--app",
13652
+ "--no-git",
13653
+ "--no-import-alias",
13654
+ "--turbopack",
13655
+ `--use-${pm}`
13656
+ ];
13657
+ if (srcDir) cnaArgs.push("--src-dir");
13658
+ else cnaArgs.push("--no-src-dir");
13632
13659
  try {
13633
- const cnaArgs = [
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, {
13660
+ execFileSync4(bin, cnaArgs, {
13647
13661
  cwd,
13648
13662
  stdio: "pipe",
13649
13663
  timeout: 12e4
13650
13664
  });
13651
- cnaSpinner.stop(`Created ${displayName}`);
13652
13665
  } catch (err) {
13653
13666
  cnaSpinner.stop("Failed to create Next.js app");
13654
13667
  p4.log.error(err instanceof Error ? err.message : "create-next-app failed");
@@ -13660,6 +13673,24 @@ var initCommand = new Command3("init").description("Scaffold CMS into a new or e
13660
13673
  process.exit(1);
13661
13674
  }
13662
13675
  cwd = path37.resolve(cwd, projectPrompt.projectName);
13676
+ const hasPackageJson = fs32.existsSync(path37.join(cwd, "package.json"));
13677
+ const hasNextConfig = ["next.config.ts", "next.config.js", "next.config.mjs"].some(
13678
+ (f) => fs32.existsSync(path37.join(cwd, f))
13679
+ );
13680
+ if (!hasPackageJson || !hasNextConfig) {
13681
+ cnaSpinner.stop("Failed to create Next.js app");
13682
+ p4.log.error(
13683
+ "create-next-app completed but the project was not created. This can happen with nested npx calls."
13684
+ );
13685
+ const manualCmd = `npx create-next-app@latest ${projectPrompt.projectName} --typescript --tailwind --app`;
13686
+ p4.log.info(
13687
+ `Create the project manually:
13688
+ ${pc2.cyan(manualCmd)}
13689
+ Then run ${pc2.cyan("betterstart init")} inside it.`
13690
+ );
13691
+ process.exit(1);
13692
+ }
13693
+ cnaSpinner.stop(`Created ${displayName}`);
13663
13694
  project = detectProject(cwd);
13664
13695
  }
13665
13696
  const features = options.yes ? { includeEmail: true, preset: options.preset } : await promptFeatures(options.preset);