@zidanpro/create-nui-fivem 4.0.2 ā 4.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.
- package/bin/index.js +27 -20
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -4,41 +4,48 @@ const fs = require("fs");
|
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const ora = require("ora").default;
|
|
6
6
|
|
|
7
|
-
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
7
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
8
8
|
|
|
9
9
|
const projectName = process.argv[2];
|
|
10
10
|
|
|
11
11
|
const targetDir = projectName
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
? path.resolve(process.cwd(), projectName)
|
|
13
|
+
: process.cwd();
|
|
14
14
|
|
|
15
15
|
const templateDir = path.join(__dirname, "../template");
|
|
16
16
|
|
|
17
17
|
(async () => {
|
|
18
|
-
|
|
18
|
+
const spinner = ora("š Starting project creation...").start();
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
await sleep(500);
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
spinner.text = "š Preparing workspace...";
|
|
23
|
+
await sleep(500);
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
if (!fs.existsSync(templateDir)) {
|
|
26
|
+
spinner.fail("Template directory not found.");
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
if (projectName && !fs.existsSync(targetDir)) {
|
|
31
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
32
|
+
}
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
spinner.text = "š¦ Copying template...";
|
|
35
|
+
await sleep(800);
|
|
33
36
|
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
fs.cpSync(templateDir, targetDir, {
|
|
38
|
+
recursive: true,
|
|
39
|
+
});
|
|
36
40
|
|
|
37
|
-
|
|
41
|
+
spinner.text = "⨠Finishing setup...";
|
|
42
|
+
await sleep(500);
|
|
38
43
|
|
|
39
|
-
|
|
44
|
+
spinner.succeed("Project created successfully!");
|
|
40
45
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
console.log("\nš Next steps:\n");
|
|
47
|
+
|
|
48
|
+
console.log(`cd ${projectName || "."}`);
|
|
49
|
+
console.log(" npm install");
|
|
50
|
+
console.log(" npm run dev\n");
|
|
44
51
|
})();
|