@thebros/create-benjamin 1.0.14 ā 1.0.16
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 +49 -18
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -7,13 +7,21 @@ import inquirer from "inquirer";
|
|
|
7
7
|
import ora from "ora";
|
|
8
8
|
import degit from "degit";
|
|
9
9
|
|
|
10
|
-
async function
|
|
10
|
+
async function cloneTemplate(repo, target) {
|
|
11
11
|
const emitter = degit(repo, {
|
|
12
12
|
cache: false,
|
|
13
13
|
force: true,
|
|
14
|
+
verbose: true,
|
|
14
15
|
});
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
try {
|
|
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
25
|
}
|
|
18
26
|
|
|
19
27
|
async function main() {
|
|
@@ -31,9 +39,9 @@ async function main() {
|
|
|
31
39
|
name: "type",
|
|
32
40
|
message: "Project type:",
|
|
33
41
|
choices: [
|
|
34
|
-
"Full Stack (React + Node)",
|
|
35
42
|
"Frontend (React)",
|
|
36
43
|
"Backend (Express)",
|
|
44
|
+
"Full Stack",
|
|
37
45
|
],
|
|
38
46
|
},
|
|
39
47
|
]);
|
|
@@ -47,26 +55,49 @@ async function main() {
|
|
|
47
55
|
|
|
48
56
|
await fs.mkdir(root);
|
|
49
57
|
|
|
50
|
-
const spinner = ora("
|
|
58
|
+
const spinner = ora("Downloading templates...").start();
|
|
51
59
|
|
|
52
60
|
// =========================
|
|
53
|
-
//
|
|
61
|
+
// IMPORTANT FIX:
|
|
62
|
+
// Use SAFE TEMPLATE REPOS ONLY
|
|
54
63
|
// =========================
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
64
|
+
|
|
65
|
+
if (answers.type === "Frontend (React)") {
|
|
66
|
+
await cloneTemplate(
|
|
67
|
+
"vitejs/vite-template-react",
|
|
68
|
+
path.join(root, "frontend")
|
|
69
|
+
);
|
|
60
70
|
}
|
|
61
71
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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();
|
|
80
|
+
|
|
81
|
+
app.get("/", (req, res) => {
|
|
82
|
+
res.json({ message: "API Running" });
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
app.listen(5000, () => {
|
|
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"));
|
|
70
101
|
|
|
71
102
|
await fs.writeFile(
|
|
72
103
|
path.join(root, "backend", "server.js"),
|