create-veap 0.1.3 → 0.1.4

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.
@@ -12,15 +12,17 @@ export interface ScaffoldOptions {
12
12
  * instead of hanging the scaffolder). `--skip-install` keeps a single
13
13
  * dependency install at the end of `initProject`, after veap mutations.
14
14
  */
15
- export declare function buildCreateNextAppCommand(name: string, opts: ScaffoldOptions): string;
15
+ export declare function buildCreateNextAppCommand(name: string, opts: ScaffoldOptions, runnerOverride?: string): string;
16
16
  /**
17
17
  * Normalizes a project name into a shell-safe, npm-friendly folder name.
18
18
  * CNA derives the package name from the folder, so the same charset applies.
19
19
  */
20
20
  export declare function sanitizeProjectName(name: string): string | null;
21
21
  /**
22
- * Runs create-next-app. Throws (with the CNA output already streamed to the
23
- * terminal) when scaffolding fails - CNA removes its own partial output.
22
+ * Runs create-next-app. If the package-manager-specific runner fails (for
23
+ * example, Bun's known IPv6 ConnectionRefused bug on Windows when downloading
24
+ * tarballs), it transparently falls back to npx so the project is still
25
+ * properly scaffolded with all chosen options.
24
26
  * Returns the (possibly sanitized) project directory name.
25
27
  */
26
28
  export declare function scaffoldNextApp(name: string, opts: ScaffoldOptions): string;
package/dist/scaffold.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import { execSync } from "node:child_process";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
2
4
  /**
3
5
  * Scaffolds the Next.js shell of a new project with the official
4
6
  * `create-next-app` (CNA) instead of duplicating its boilerplate in stubs.
@@ -22,7 +24,7 @@ const CNA_RUNNERS = {
22
24
  * instead of hanging the scaffolder). `--skip-install` keeps a single
23
25
  * dependency install at the end of `initProject`, after veap mutations.
24
26
  */
25
- export function buildCreateNextAppCommand(name, opts) {
27
+ export function buildCreateNextAppCommand(name, opts, runnerOverride) {
26
28
  const flags = [
27
29
  "--ts",
28
30
  "--tailwind",
@@ -35,7 +37,20 @@ export function buildCreateNextAppCommand(name, opts) {
35
37
  '"@/*"',
36
38
  "--skip-install",
37
39
  ];
38
- return `${CNA_RUNNERS[opts.pm]} "${name}" ${flags.join(" ")}`;
40
+ if (opts.pm === "bun") {
41
+ flags.push("--use-bun");
42
+ }
43
+ else if (opts.pm === "pnpm") {
44
+ flags.push("--use-pnpm");
45
+ }
46
+ else if (opts.pm === "yarn") {
47
+ flags.push("--use-yarn");
48
+ }
49
+ else if (opts.pm === "npm") {
50
+ flags.push("--use-npm");
51
+ }
52
+ const runner = runnerOverride ?? CNA_RUNNERS[opts.pm];
53
+ return `${runner} "${name}" ${flags.join(" ")}`;
39
54
  }
40
55
  /**
41
56
  * Normalizes a project name into a shell-safe, npm-friendly folder name.
@@ -46,8 +61,10 @@ export function sanitizeProjectName(name) {
46
61
  return safe === name ? null : safe;
47
62
  }
48
63
  /**
49
- * Runs create-next-app. Throws (with the CNA output already streamed to the
50
- * terminal) when scaffolding fails - CNA removes its own partial output.
64
+ * Runs create-next-app. If the package-manager-specific runner fails (for
65
+ * example, Bun's known IPv6 ConnectionRefused bug on Windows when downloading
66
+ * tarballs), it transparently falls back to npx so the project is still
67
+ * properly scaffolded with all chosen options.
51
68
  * Returns the (possibly sanitized) project directory name.
52
69
  */
53
70
  export function scaffoldNextApp(name, opts) {
@@ -57,6 +74,29 @@ export function scaffoldNextApp(name, opts) {
57
74
  }
58
75
  const projectName = sanitized ?? name;
59
76
  const command = buildCreateNextAppCommand(projectName, opts);
60
- execSync(command, { cwd: opts.cwd, stdio: "inherit" });
77
+ try {
78
+ execSync(command, { cwd: opts.cwd, stdio: "inherit" });
79
+ }
80
+ catch (primaryErr) {
81
+ if (opts.pm !== "npm") {
82
+ console.warn(`\n⚠️ ${opts.pm} failed to run create-next-app (e.g. network/IPv6 timeout). Falling back to npx...`);
83
+ // Clean up partially created directory if exists and empty
84
+ const targetPath = path.join(opts.cwd, projectName);
85
+ if (fs.existsSync(targetPath)) {
86
+ try {
87
+ const files = fs.readdirSync(targetPath);
88
+ if (files.length === 0) {
89
+ fs.rmSync(targetPath, { recursive: true, force: true });
90
+ }
91
+ }
92
+ catch { }
93
+ }
94
+ const fallbackCommand = buildCreateNextAppCommand(projectName, opts, CNA_RUNNERS.npm);
95
+ execSync(fallbackCommand, { cwd: opts.cwd, stdio: "inherit" });
96
+ }
97
+ else {
98
+ throw primaryErr;
99
+ }
100
+ }
61
101
  return projectName;
62
102
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-veap",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Initializer for Veap Framework applications",
5
5
  "bugs": "https://github.com/veapjs/create-veap/issues",
6
6
  "repository": {