create-nodality-vue 1.0.0-beta.0 → 1.0.0-beta.1

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.
Files changed (2) hide show
  1. package/bin/index.js +74 -0
  2. package/package.json +1 -1
package/bin/index.js ADDED
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { mkdirSync, writeFileSync, existsSync, copyFileSync } from "fs";
4
+ import { resolve, dirname } from "path";
5
+ import { execSync } from "child_process";
6
+ import { fileURLToPath } from "url";
7
+
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = dirname(__filename);
10
+
11
+ function copyTemplate(templatePath, destinationPath) {
12
+ copyFileSync(resolve(__dirname, "../templates", templatePath), destinationPath);
13
+ }
14
+
15
+ function createVueProject(projectName) {
16
+ const projectPath = resolve(process.cwd(), projectName);
17
+
18
+ if (existsSync(projectPath)) {
19
+ console.error(`Folder ${projectName} already exists.`);
20
+ process.exit(1);
21
+ }
22
+
23
+ mkdirSync(projectPath);
24
+ mkdirSync(resolve(projectPath, "src"));
25
+ mkdirSync(resolve(projectPath, "src/components"));
26
+
27
+ // Copy templates
28
+ copyTemplate("index.html", resolve(projectPath, "index.html"));
29
+ copyTemplate("src/main.js", resolve(projectPath, "src/main.js"));
30
+ copyTemplate("src/App.vue", resolve(projectPath, "src/App.vue"));
31
+ copyTemplate("src/components/HelloWorld.vue", resolve(projectPath, "src/components/HelloWorld.vue"));
32
+ copyTemplate("vite.config.js", resolve(projectPath, "vite.config.js"));
33
+
34
+ // Create package.json
35
+ const pkg = {
36
+ name: projectName,
37
+ version: "1.0.0",
38
+ type: "module",
39
+ scripts: {
40
+ dev: "vite",
41
+ build: "vite build",
42
+ serve: "vite preview",
43
+ },
44
+ dependencies: {
45
+ vue: "^3.0.0",
46
+ nodality: "^1.0.0-beta.4",
47
+ },
48
+ devDependencies: {
49
+ vite: "^4.0.0",
50
+ "@vitejs/plugin-vue": "^4.0.0",
51
+ },
52
+ };
53
+ writeFileSync(resolve(projectPath, "package.json"), JSON.stringify(pkg, null, 2));
54
+
55
+ // Install dependencies
56
+ console.log("Installing dependencies...");
57
+ execSync(npm install, { cwd: projectPath, stdio: "inherit" });
58
+
59
+ console.log(`\nDone! To start your app:
60
+ cd ${projectName}
61
+ npm run dev # Start development server
62
+ npm run build # Build for production
63
+ npm run serve # Preview production build
64
+ `);
65
+ }
66
+
67
+ // Parse CLI arguments
68
+ const args = process.argv.slice(2);
69
+ if (!args[0]) {
70
+ console.error("Usage: npm create nodality-vue <project-name>");
71
+ process.exit(1);
72
+ }
73
+
74
+ createVueProject(args[0]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nodality-vue",
3
- "version": "1.0.0-beta.0",
3
+ "version": "1.0.0-beta.1",
4
4
  "description": "A scaffolding tool for creating Vue.js projects integrated with Nodality.",
5
5
  "main": "bin/index.js",
6
6
  "bin": {