-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·37 lines (30 loc) · 1.03 KB
/
cli.js
File metadata and controls
executable file
·37 lines (30 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env node
const degit = require("degit");
const { execSync } = require("child_process");
const path = require("path");
const [, , projectName] = process.argv;
if (!projectName) {
console.error("❌ Please specify a project name:");
console.log(" Example:");
console.log(" npx create-reactw-app my-app");
process.exit(1);
}
const emitter = degit("hidaytrahman/template-rtw", {
cache: false,
force: true,
verbose: true,
});
console.log(`🚀 Creating a new RTW (React, Typescript with Webpack) app in ./${projectName}`);
emitter.clone(projectName).then(() => {
console.log("✅ Project cloned successfully!");
try {
console.log("📦 Installing dependencies...");
execSync(`cd ${projectName} && yarn`, { stdio: "inherit" });
console.log("🎉 All done!");
console.log(`👉 Get started with:\n cd ${projectName}\n yarn start`);
} catch (error) {
console.error("❌ Failed to install dependencies.");
}
}).catch((err) => {
console.error("❌ Error cloning the repository:", err);
});