@m4vi/create-vrt-tmp 1.0.0 → 1.0.2
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/README.md +1 -1
- package/index.js +52 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -1 +1,52 @@
|
|
|
1
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
import { execSync } from "child_process";
|
|
7
|
+
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
|
|
11
|
+
const projectName = process.argv[2] || "vrt-app";
|
|
12
|
+
const targetDir = path.join(process.cwd(), projectName);
|
|
13
|
+
|
|
14
|
+
if (fs.existsSync(targetDir)) {
|
|
15
|
+
console.error(`Directory ${projectName} already exists`);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const templateDir = path.join(__dirname, "template");
|
|
20
|
+
|
|
21
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
22
|
+
|
|
23
|
+
function copyDir(src, dest) {
|
|
24
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
25
|
+
const files = fs.readdirSync(src);
|
|
26
|
+
files.forEach((file) => {
|
|
27
|
+
const srcPath = path.join(src, file);
|
|
28
|
+
const destPath = path.join(dest, file);
|
|
29
|
+
if (fs.statSync(srcPath).isDirectory()) {
|
|
30
|
+
copyDir(srcPath, destPath);
|
|
31
|
+
} else {
|
|
32
|
+
fs.copyFileSync(srcPath, destPath);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
copyDir(templateDir, targetDir);
|
|
38
|
+
process.chdir(targetDir);
|
|
39
|
+
|
|
40
|
+
console.log(`\nCreating project in ${targetDir}\n`);
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
console.log("Installing dependencies...\n");
|
|
44
|
+
execSync("npm install", { stdio: "inherit" });
|
|
45
|
+
console.log(`\nProject created successfully!\n`);
|
|
46
|
+
console.log(`To start developing:\n`);
|
|
47
|
+
console.log(` cd ${projectName}`);
|
|
48
|
+
console.log(` npm run dev\n`);
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.error("Failed to install dependencies", error);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|