@thebros/create-benjamin 1.0.16 ā 1.0.17
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/index.js +11 -80
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -7,25 +7,18 @@ import inquirer from "inquirer";
|
|
|
7
7
|
import ora from "ora";
|
|
8
8
|
import degit from "degit";
|
|
9
9
|
|
|
10
|
-
async function
|
|
10
|
+
async function cloneRepo(repo, target) {
|
|
11
11
|
const emitter = degit(repo, {
|
|
12
12
|
cache: false,
|
|
13
13
|
force: true,
|
|
14
14
|
verbose: true,
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
await emitter.clone(target);
|
|
19
|
-
} catch (err) {
|
|
20
|
-
console.log("\nā Failed to clone template:");
|
|
21
|
-
console.log("š Make sure this is a VALID template repo");
|
|
22
|
-
console.log("š Example: username/repo (NOT expressjs/express)\n");
|
|
23
|
-
throw err;
|
|
24
|
-
}
|
|
17
|
+
await emitter.clone(target);
|
|
25
18
|
}
|
|
26
19
|
|
|
27
20
|
async function main() {
|
|
28
|
-
console.log(chalk.cyan("\nš Benjamin
|
|
21
|
+
console.log(chalk.cyan("\nš Benjamin CLI Generator\n"));
|
|
29
22
|
|
|
30
23
|
const answers = await inquirer.prompt([
|
|
31
24
|
{
|
|
@@ -34,16 +27,6 @@ async function main() {
|
|
|
34
27
|
message: "Project name:",
|
|
35
28
|
default: "my-app",
|
|
36
29
|
},
|
|
37
|
-
{
|
|
38
|
-
type: "list",
|
|
39
|
-
name: "type",
|
|
40
|
-
message: "Project type:",
|
|
41
|
-
choices: [
|
|
42
|
-
"Frontend (React)",
|
|
43
|
-
"Backend (Express)",
|
|
44
|
-
"Full Stack",
|
|
45
|
-
],
|
|
46
|
-
},
|
|
47
30
|
]);
|
|
48
31
|
|
|
49
32
|
const root = path.join(process.cwd(), answers.projectName);
|
|
@@ -55,73 +38,21 @@ async function main() {
|
|
|
55
38
|
|
|
56
39
|
await fs.mkdir(root);
|
|
57
40
|
|
|
58
|
-
const spinner = ora("
|
|
59
|
-
|
|
60
|
-
// =========================
|
|
61
|
-
// IMPORTANT FIX:
|
|
62
|
-
// Use SAFE TEMPLATE REPOS ONLY
|
|
63
|
-
// =========================
|
|
64
|
-
|
|
65
|
-
if (answers.type === "Frontend (React)") {
|
|
66
|
-
await cloneTemplate(
|
|
67
|
-
"vitejs/vite-template-react",
|
|
68
|
-
path.join(root, "frontend")
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (answers.type === "Backend (Express)") {
|
|
73
|
-
await fs.mkdir(path.join(root, "backend"));
|
|
74
|
-
|
|
75
|
-
await fs.writeFile(
|
|
76
|
-
path.join(root, "backend", "server.js"),
|
|
77
|
-
`
|
|
78
|
-
const express = require("express");
|
|
79
|
-
const app = express();
|
|
41
|
+
const spinner = ora("Cloning backend template...").start();
|
|
80
42
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
console.log("Server running on port 5000");
|
|
87
|
-
});
|
|
88
|
-
`
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (answers.type === "Full Stack") {
|
|
93
|
-
// Frontend (safe template)
|
|
94
|
-
await cloneTemplate(
|
|
95
|
-
"vitejs/vite-template-react",
|
|
96
|
-
path.join(root, "frontend")
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
// Backend
|
|
100
|
-
await fs.mkdir(path.join(root, "backend"));
|
|
101
|
-
|
|
102
|
-
await fs.writeFile(
|
|
103
|
-
path.join(root, "backend", "server.js"),
|
|
104
|
-
`
|
|
105
|
-
const express = require("express");
|
|
106
|
-
const app = express();
|
|
107
|
-
|
|
108
|
-
app.get("/", (req, res) => {
|
|
109
|
-
res.json({ message: "API Running" });
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
app.listen(5000, () => {
|
|
113
|
-
console.log("Server running on 5000");
|
|
114
|
-
});
|
|
115
|
-
`
|
|
116
|
-
);
|
|
117
|
-
}
|
|
43
|
+
// ā
YOUR REPO FIXED HERE
|
|
44
|
+
await cloneRepo(
|
|
45
|
+
"github:Benjamin-bit1/inventory-backend#main",
|
|
46
|
+
path.join(root, "backend")
|
|
47
|
+
);
|
|
118
48
|
|
|
119
|
-
spinner.succeed("
|
|
49
|
+
spinner.succeed("Backend cloned successfully");
|
|
120
50
|
|
|
121
51
|
console.log(chalk.green("\nā
Done!\n"));
|
|
122
52
|
|
|
123
53
|
console.log(`
|
|
124
54
|
cd ${answers.projectName}
|
|
55
|
+
cd backend
|
|
125
56
|
npm install
|
|
126
57
|
npm run dev
|
|
127
58
|
`);
|