nextjs-starter-kit 0.1.5 → 0.1.6
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/bin/cli.js +29 -8
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { execSync } from "child_process";
|
|
3
|
-
import { existsSync, mkdirSync
|
|
3
|
+
import { existsSync, mkdirSync } from "fs";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import { fileURLToPath } from "url";
|
|
6
|
+
import os from "os";
|
|
6
7
|
|
|
7
8
|
const __filename = fileURLToPath(import.meta.url);
|
|
8
9
|
const __dirname = path.dirname(__filename);
|
|
@@ -10,6 +11,23 @@ const __dirname = path.dirname(__filename);
|
|
|
10
11
|
const projectName = process.argv[2] || "my-app";
|
|
11
12
|
const projectPath = path.resolve(process.cwd(), projectName);
|
|
12
13
|
|
|
14
|
+
function runCommand(command, options = {}) {
|
|
15
|
+
try {
|
|
16
|
+
execSync(command, { stdio: "inherit", ...options });
|
|
17
|
+
} catch (err) {
|
|
18
|
+
console.error(`❌ Failed to run command: ${command}`);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
execSync("pnpm -v", { stdio: "ignore" });
|
|
25
|
+
} catch {
|
|
26
|
+
console.error("❌ pnpm is not installed. Please install it first:");
|
|
27
|
+
console.error(" npm install -g pnpm");
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
|
|
13
31
|
if (existsSync(projectPath)) {
|
|
14
32
|
console.error(`❌ Folder "${projectName}" already exists.`);
|
|
15
33
|
process.exit(1);
|
|
@@ -18,15 +36,18 @@ if (existsSync(projectPath)) {
|
|
|
18
36
|
console.log(`🚀 Creating Next.js app in "${projectName}"...`);
|
|
19
37
|
mkdirSync(projectPath);
|
|
20
38
|
|
|
21
|
-
// Copy template files
|
|
22
39
|
const templateDir = path.join(__dirname, "../template");
|
|
23
|
-
|
|
40
|
+
if (os.platform() === "win32") {
|
|
41
|
+
runCommand(`xcopy "${templateDir}" "${projectPath}" /E /I /Q`);
|
|
42
|
+
} else {
|
|
43
|
+
runCommand(`cp -r ${templateDir}/. ${projectPath}`);
|
|
44
|
+
}
|
|
24
45
|
|
|
25
|
-
|
|
26
|
-
execSync("git init", { cwd: projectPath, stdio: "inherit" });
|
|
46
|
+
runCommand("git init", { cwd: projectPath });
|
|
27
47
|
|
|
28
|
-
// Install deps
|
|
29
48
|
console.log("📦 Installing dependencies...");
|
|
30
|
-
|
|
49
|
+
runCommand("pnpm install --shamefully-hoist", { cwd: projectPath });
|
|
31
50
|
|
|
32
|
-
console.log(
|
|
51
|
+
console.log(`\n✅ All done!`);
|
|
52
|
+
console.log(`👉 cd ${projectName}`);
|
|
53
|
+
console.log(`👉 pnpm dev (or npm run dev)\n`);
|