create-base-react-app 2.0.1 → 2.0.3

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 (2) hide show
  1. package/index.js +37 -89
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -5,12 +5,9 @@ import path from "path";
5
5
 
6
6
  const args = process.argv.slice(2);
7
7
 
8
- const projectName =
9
- args.find((arg) => !arg.startsWith("--")) || ".";
8
+ const projectName = args.find((arg) => !arg.startsWith("--")) || ".";
10
9
 
11
- const flags = args.filter((arg) =>
12
- arg.startsWith("--"),
13
- );
10
+ const flags = args.filter((arg) => arg.startsWith("--"));
14
11
 
15
12
  const isTS = flags.includes("--ts");
16
13
  const isJS = flags.includes("--js");
@@ -18,17 +15,10 @@ const isJS = flags.includes("--js");
18
15
  const useTypeScript = isTS || !isJS;
19
16
 
20
17
  const projectPath =
21
- projectName === "."
22
- ? process.cwd()
23
- : path.join(process.cwd(), projectName);
24
-
25
- if (
26
- projectName !== "." &&
27
- fs.existsSync(projectPath)
28
- ) {
29
- console.error(
30
- `Error: The folder '${projectName}' already exists!`,
31
- );
18
+ projectName === "." ? process.cwd() : path.join(process.cwd(), projectName);
19
+
20
+ if (projectName !== "." && fs.existsSync(projectPath)) {
21
+ console.error(`Error: The folder '${projectName}' already exists!`);
32
22
 
33
23
  process.exit(1);
34
24
  }
@@ -39,9 +29,7 @@ if (projectName !== ".") {
39
29
 
40
30
  console.log(
41
31
  `Creating ${
42
- useTypeScript
43
- ? "React + TypeScript"
44
- : "React + JavaScript"
32
+ useTypeScript ? "React + TypeScript" : "React + JavaScript"
45
33
  } app in ${projectPath}...`,
46
34
  );
47
35
 
@@ -55,19 +43,12 @@ const runCommand = (command) =>
55
43
  try {
56
44
  runCommand("npm init -y");
57
45
 
58
- const packageJsonPath = path.join(
59
- projectPath,
60
- "package.json",
61
- );
46
+ const packageJsonPath = path.join(projectPath, "package.json");
62
47
 
63
- const packageJson = JSON.parse(
64
- fs.readFileSync(packageJsonPath, "utf-8"),
65
- );
48
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
66
49
 
67
50
  packageJson.name =
68
- projectName === "."
69
- ? path.basename(projectPath)
70
- : projectName;
51
+ projectName === "." ? path.basename(projectPath) : projectName;
71
52
 
72
53
  packageJson.private = true;
73
54
 
@@ -98,13 +79,10 @@ try {
98
79
  "@types/react": "^19.2.14",
99
80
  "@types/react-dom": "^19.2.3",
100
81
  "@vitejs/plugin-react": "^6.0.1",
101
- "babel-plugin-react-compiler":
102
- "^1.0.0",
82
+ "babel-plugin-react-compiler": "^1.0.0",
103
83
  eslint: "^10.3.0",
104
- "eslint-plugin-react-hooks":
105
- "^7.1.1",
106
- "eslint-plugin-react-refresh":
107
- "^0.5.2",
84
+ "eslint-plugin-react-hooks": "^7.1.1",
85
+ "eslint-plugin-react-refresh": "^0.5.2",
108
86
  globals: "^17.6.0",
109
87
  tailwindcss: "^4.1.7",
110
88
  typescript: "~6.0.2",
@@ -120,34 +98,23 @@ try {
120
98
  "@types/react": "^19.2.14",
121
99
  "@types/react-dom": "^19.2.3",
122
100
  "@vitejs/plugin-react": "^6.0.1",
123
- "babel-plugin-react-compiler":
124
- "^1.0.0",
101
+ "babel-plugin-react-compiler": "^1.0.0",
125
102
  eslint: "^10.3.0",
126
- "eslint-plugin-react-hooks":
127
- "^7.1.1",
128
- "eslint-plugin-react-refresh":
129
- "^0.5.2",
103
+ "eslint-plugin-react-hooks": "^7.1.1",
104
+ "eslint-plugin-react-refresh": "^0.5.2",
130
105
  globals: "^17.6.0",
131
106
  tailwindcss: "^4.1.7",
132
107
  vite: "^8.0.12",
133
108
  };
134
109
  }
135
110
 
136
- fs.writeFileSync(
137
- packageJsonPath,
138
- JSON.stringify(packageJson, null, 2),
139
- );
111
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
140
112
 
141
- ["public", "src", "src/assets"].forEach(
142
- (dir) => {
143
- fs.mkdirSync(
144
- path.join(projectPath, dir),
145
- {
146
- recursive: true,
147
- },
148
- );
149
- },
150
- );
113
+ ["public", "src", "src/assets"].forEach((dir) => {
114
+ fs.mkdirSync(path.join(projectPath, dir), {
115
+ recursive: true,
116
+ });
117
+ });
151
118
 
152
119
  const files = useTypeScript
153
120
  ? {
@@ -412,9 +379,7 @@ dist
412
379
  `,
413
380
 
414
381
  "README.md": `# ${
415
- useTypeScript
416
- ? "React + TypeScript"
417
- : "React + JavaScript"
382
+ useTypeScript ? "React + TypeScript" : "React + JavaScript"
418
383
  } + Vite
419
384
 
420
385
  Modern React starter powered by:
@@ -432,10 +397,7 @@ Modern React starter powered by:
432
397
  ...files,
433
398
  ...sharedFiles,
434
399
  }).forEach(([filePath, content]) => {
435
- fs.writeFileSync(
436
- path.join(projectPath, filePath),
437
- content,
438
- );
400
+ fs.writeFileSync(path.join(projectPath, filePath), content);
439
401
  });
440
402
 
441
403
  try {
@@ -443,9 +405,7 @@ Modern React starter powered by:
443
405
  stdio: "ignore",
444
406
  });
445
407
 
446
- console.log(
447
- "Bun is installed. Running 'bun install'...",
448
- );
408
+ console.log("Bun is installed. Running 'bun install'...");
449
409
 
450
410
  runCommand("bun install");
451
411
  } catch {
@@ -456,42 +416,30 @@ Modern React starter powered by:
456
416
  runCommand("bun install");
457
417
  }
458
418
 
459
- ["bun.lock", "bun.lockb"].forEach(
460
- (file) => {
461
- const lockPath = path.join(
462
- projectPath,
463
- file,
464
- );
419
+ ["bun.lock", "bun.lockb"].forEach((file) => {
420
+ const lockPath = path.join(projectPath, file);
465
421
 
466
- if (fs.existsSync(lockPath)) {
467
- fs.unlinkSync(lockPath);
468
- }
469
- },
470
- );
422
+ if (fs.existsSync(lockPath)) {
423
+ fs.unlinkSync(lockPath);
424
+ }
425
+ });
471
426
 
472
- runCommand(
473
- "npm install --package-lock-only",
474
- );
427
+ runCommand("npm install --package-lock-only");
475
428
 
476
429
  console.log("");
477
- console.log(
478
- "Project setup complete!",
479
- );
430
+ console.log("Project setup complete!");
480
431
  console.log("");
481
432
 
482
433
  if (projectName === ".") {
483
- console.log("Run:");
484
- console.log("npm run dev");
434
+ console.log("starting dev server...");
435
+ runCommand("npm run dev");
485
436
  } else {
486
437
  console.log("Run:");
487
438
  console.log(`cd ${projectName}`);
488
439
  console.log("npm run dev");
489
440
  }
490
441
  } catch (error) {
491
- console.error(
492
- "Error setting up project:",
493
- error,
494
- );
442
+ console.error("Error setting up project:", error);
495
443
 
496
444
  process.exit(1);
497
- }
445
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-base-react-app",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "main": "index.js",
5
5
  "bin": {
6
6
  "create-react-js-tailwind": "./index.js"