create-nodality 1.0.0-beta.7 → 1.0.0

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 +17 -91
  2. package/package.json +2 -2
package/bin/index.js CHANGED
@@ -1,14 +1,19 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { mkdirSync, writeFileSync, existsSync } from "fs";
3
+ import { mkdirSync, copyFileSync, existsSync, writeFileSync } from "fs";
4
4
  import { resolve, dirname } from "path";
5
5
  import { execSync } from "child_process";
6
6
  import { fileURLToPath } from "url";
7
7
 
8
- // Helper to get directory of current file (ESM compatible)
8
+ // Helper to get directory of current file (since using ES modules)
9
9
  const __filename = fileURLToPath(import.meta.url);
10
10
  const __dirname = dirname(__filename);
11
11
 
12
+ function copyTemplateFile(src, dest) {
13
+ copyFileSync(src, dest);
14
+ console.log(`Created ${dest}`);
15
+ }
16
+
12
17
  function createProject(projectName) {
13
18
  const projectPath = resolve(process.cwd(), projectName);
14
19
 
@@ -18,77 +23,11 @@ function createProject(projectName) {
18
23
  }
19
24
 
20
25
  mkdirSync(projectPath);
21
- const srcPath = resolve(projectPath, "src");
22
- mkdirSync(srcPath);
23
-
24
- // Create index.html
25
- const indexHtml = `
26
- <!DOCTYPE html>
27
- <html lang="en">
28
- <head>
29
- <meta charset="UTF-8">
30
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
31
- <title>${projectName}</title>
32
- </head>
33
- <body>
34
- <div id="mount"></div>
35
- <script src="dist/bundle.js"></script>
36
- </body>
37
- </html>
38
- `;
39
- writeFileSync(resolve(projectPath, "index.html"), indexHtml.trim());
40
-
41
- // Create index.js
42
- const indexJs = `
43
- import { Text } from 'nodality';
44
26
 
45
- new Text('Hello, Nodality!')
46
- .set({
47
- size: 'S1',
48
- color: '#1abc9c',
49
- font: 'Arial',
50
- })
51
- .render('#mount');
52
- `;
53
- writeFileSync(resolve(srcPath, "index.js"), indexJs.trim());
54
-
55
- // Create webpack.config.js
56
- const webpackConfig = `
57
- import path from 'path';
58
- import { fileURLToPath } from 'url';
59
-
60
- const __filename = fileURLToPath(import.meta.url);
61
- const __dirname = path.dirname(__filename);
62
-
63
- export default {
64
- mode: 'production',
65
- entry: './src/index.js',
66
- output: {
67
- filename: 'bundle.js',
68
- path: path.resolve(__dirname, 'dist'),
69
- },
70
- module: {
71
- rules: [
72
- {
73
- test: /\\.js$/,
74
- exclude: /node_modules/,
75
- use: {
76
- loader: 'babel-loader',
77
- options: {
78
- presets: ['@babel/preset-env'],
79
- },
80
- },
81
- },
82
- ],
83
- },
84
- resolve: {
85
- alias: {
86
- nodality: path.resolve(__dirname, 'node_modules/nodality/dist/index.esm.js'),
87
- },
88
- },
89
- };
90
- `;
91
- writeFileSync(resolve(projectPath, "webpack.config.js"), webpackConfig.trim());
27
+ // Copy template files
28
+ const templatePath = resolve(__dirname, "../templates");
29
+ copyTemplateFile(resolve(templatePath, "index.html"), resolve(projectPath, "index.html"));
30
+ copyTemplateFile(resolve(templatePath, "main.js"), resolve(projectPath, "main.js"));
92
31
 
93
32
  // Create package.json
94
33
  const pkg = {
@@ -96,37 +35,25 @@ export default {
96
35
  version: "1.0.0",
97
36
  type: "module",
98
37
  scripts: {
99
- build: "webpack",
100
- start: "npx serve . -l 4000",
38
+ start: "serve ."
101
39
  },
102
40
  dependencies: {
103
- nodality: "^1.0.0-beta.4",
104
- },
105
- devDependencies: {
106
- webpack: "^5.0.0",
107
- "webpack-cli": "^5.0.0",
108
- "babel-loader": "^9.0.0",
109
- "@babel/core": "^7.0.0",
110
- "@babel/preset-env": "^7.0.0",
111
- },
41
+ nodality: "^1.0.0"
42
+ }
112
43
  };
44
+
113
45
  writeFileSync(resolve(projectPath, "package.json"), JSON.stringify(pkg, null, 2));
46
+ console.log("Created package.json");
114
47
 
115
48
  // Install dependencies
116
49
  console.log("Installing dependencies...");
117
50
  execSync(`npm install`, { cwd: projectPath, stdio: "inherit" });
118
51
 
119
- // Build project
120
- console.log("Building with Webpack...");
121
- execSync(`npx webpack`, { cwd: projectPath, stdio: "inherit" });
122
-
123
52
  console.log("\nAll done! Run:\n");
124
53
  console.log(` cd ${projectName}`);
125
- console.log(" npm run build # Rebuild your project");
126
- console.log(" npm start # Serve your project on localhost:4000\n");
54
+ console.log(" npm start\n");
127
55
  }
128
56
 
129
- // Parse CLI arguments
130
57
  const args = process.argv.slice(2);
131
58
 
132
59
  if (!args[0]) {
@@ -134,5 +61,4 @@ if (!args[0]) {
134
61
  process.exit(1);
135
62
  }
136
63
 
137
- // Create the project
138
64
  createProject(args[0]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nodality",
3
- "version": "1.0.0-beta.7",
3
+ "version": "1.0.0",
4
4
  "description": "Project scaffolding tool for Nodality library",
5
5
  "bin": {
6
6
  "create-nodality": "./bin/index.js"
@@ -18,6 +18,6 @@
18
18
  "author": "Filip Vabrousek",
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "nodality": "^1.0.0-beta.4"
21
+ "nodality": "^1.0.0"
22
22
  }
23
23
  }