create-nodality 1.0.0-beta.65 → 1.0.0-beta.67

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 CHANGED
@@ -5,7 +5,6 @@ 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)
9
8
  const __filename = fileURLToPath(import.meta.url);
10
9
  const __dirname = dirname(__filename);
11
10
 
@@ -21,26 +20,27 @@ function createProject(projectName) {
21
20
  const srcPath = resolve(projectPath, "src");
22
21
  mkdirSync(srcPath);
23
22
 
24
- // Create index.html
23
+ // index.html loads the bundled library and the app.js module
25
24
  const indexHtml = `
26
25
  <!DOCTYPE html>
27
26
  <html lang="en">
28
27
  <head>
29
- <meta charset="UTF-8">
30
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
28
+ <meta charset="UTF-8" />
29
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
31
30
  <title>${projectName}</title>
32
31
  </head>
33
32
  <body>
34
33
  <div id="mount"></div>
35
- <script src="dist/bundle.js"></script>
34
+ <script src="dist/bundle-library.js"></script>
35
+ <script type="module" src="src/app.js"></script>
36
36
  </body>
37
37
  </html>
38
38
  `;
39
39
  writeFileSync(resolve(projectPath, "index.html"), indexHtml.trim());
40
40
 
41
- // Create index.js
42
- const indexJs = `
43
- import { Des } from 'nodality';
41
+ // app.js: user app code, importing from global NodalityLib (UMD global)
42
+ const appJs = `
43
+ /* Note: NodalityLib is exposed as a global by the bundled library.js */
44
44
 
45
45
  let elements = [
46
46
  {
@@ -55,6 +55,9 @@ let nodes = [
55
55
  }
56
56
  ];
57
57
 
58
+ // Use NodalityLib global exported by bundle-library.js
59
+ const { Des } = window.NodalityLib;
60
+
58
61
  new Des()
59
62
  .nodes(nodes)
60
63
  .add(elements)
@@ -63,9 +66,18 @@ new Des()
63
66
  code: true
64
67
  });
65
68
  `;
66
- writeFileSync(resolve(srcPath, "index.js"), indexJs.trim());
69
+ writeFileSync(resolve(srcPath, "app.js"), appJs.trim());
70
+
71
+ // library.js imports nodality package and is bundled by webpack
72
+ const libraryJs = `
73
+ import { Des } from 'nodality';
74
+
75
+ // Export Des and any other needed exports globally
76
+ export { Des };
77
+ `;
78
+ writeFileSync(resolve(srcPath, "library.js"), libraryJs.trim());
67
79
 
68
- // Create webpack.config.js
80
+ // webpack.config.js: bundle library.js as UMD global named NodalityLib
69
81
  const webpackConfig = `
70
82
  import path from 'path';
71
83
  import { fileURLToPath } from 'url';
@@ -75,10 +87,15 @@ const __dirname = path.dirname(__filename);
75
87
 
76
88
  export default {
77
89
  mode: 'production',
78
- entry: './src/index.js',
90
+ entry: './src/library.js',
79
91
  output: {
80
- filename: 'bundle.js',
92
+ filename: 'bundle-library.js',
81
93
  path: path.resolve(__dirname, 'dist'),
94
+ globalObject: 'this',
95
+ library: {
96
+ name: 'NodalityLib',
97
+ type: 'umd',
98
+ },
82
99
  },
83
100
  module: {
84
101
  rules: [
@@ -94,16 +111,11 @@ export default {
94
111
  },
95
112
  ],
96
113
  },
97
- resolve: {
98
- alias: {
99
- nodality: path.resolve(__dirname, 'node_modules/nodality/dist/index.esm.js'),
100
- },
101
- },
102
114
  };
103
115
  `;
104
116
  writeFileSync(resolve(projectPath, "webpack.config.js"), webpackConfig.trim());
105
117
 
106
- // Create package.json
118
+ // package.json with dependencies & scripts
107
119
  const pkg = {
108
120
  name: projectName,
109
121
  version: "1.0.0",
@@ -113,7 +125,7 @@ export default {
113
125
  start: "npx serve . -l 4000",
114
126
  },
115
127
  dependencies: {
116
- nodality: "^1.0.0-beta.65",
128
+ nodality: "^1.0.0-beta.66",
117
129
  },
118
130
  devDependencies: {
119
131
  webpack: "^5.0.0",
@@ -125,36 +137,29 @@ export default {
125
137
  };
126
138
  writeFileSync(resolve(projectPath, "package.json"), JSON.stringify(pkg, null, 2));
127
139
 
128
- // Install dependencies
129
140
  console.log("Installing dependencies...");
130
141
  execSync(`npm install`, { cwd: projectPath, stdio: "inherit" });
131
142
 
132
- // Build project
133
- console.log("Building with Webpack...");
143
+ console.log("Building library bundle...");
134
144
  execSync(`npx webpack`, { cwd: projectPath, stdio: "inherit" });
135
145
 
146
+ const bold = '\x1b[1m';
147
+ const color1abc9c = '\x1b[38;5;37m';
148
+ const reset = '\x1b[0m';
136
149
 
137
- // ANSI escape codes for green text and reset
150
+ console.log(`\n${color1abc9c}${bold}%s${reset}\n`, `Your project "${projectName}" is ready! 🎉`);
138
151
 
139
- const bold = '\x1b[1m';
140
- const color1abc9c = '\x1b[38;5;37m';
141
- const reset = '\x1b[0m';
142
-
143
- console.log(`\n${color1abc9c}${bold}%s${reset}\n`, `Your project "${projectName}" is ready! 🎉`);
144
-
145
- console.log("\nAll done! Run:\n");
152
+ console.log("\nUsage:\n");
146
153
  console.log(` cd ${projectName}`);
147
- console.log(" npm run build # Rebuild your project");
148
- console.log(" npm start # Serve your project on localhost:4000\n");
154
+ console.log(" npm run build # Rebuild Nodality library bundle");
155
+ console.log(" npm start # Serve your project on http://localhost:4000");
156
+ console.log("\nNote: Your app.js uses the global window.NodalityLib exported by the bundled library.\n");
149
157
  }
150
158
 
151
- // Parse CLI arguments
152
159
  const args = process.argv.slice(2);
153
-
154
160
  if (!args[0]) {
155
161
  console.error("Usage: npm create nodality <project-name>");
156
162
  process.exit(1);
157
163
  }
158
164
 
159
- // Create the project
160
165
  createProject(args[0]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nodality",
3
- "version": "1.0.0-beta.65",
3
+ "version": "1.0.0-beta.67",
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.65"
21
+ "nodality": "^1.0.0-beta.66"
22
22
  }
23
23
  }
package/readme.md DELETED
File without changes
package/release.sh DELETED
@@ -1,11 +0,0 @@
1
- next_version=32
2
- full_version="1.0.0-beta.${next_version}"
3
-
4
- # ✅ Update package version to full beta version
5
- sed -i '' -E "s/(\"version\": \")1\.0\.0-beta\.[0-9]+\"/\1${full_version}\"/" package.json
6
-
7
- # ✅ Update nodality dependency in package.json to ^1.0.0-beta.xx
8
- sed -i '' -E "s/(\"nodality\": \")\^1\.0\.0-beta\.[0-9]+\"/\1\\^${full_version}\"/" package.json
9
-
10
- # ✅ Update hardcoded nodality version in bin/index.js
11
- sed -i '' -E "s/(nodality: \\\")\^1\.0\.0-beta\.[0-9]+(\\\")/\1\\^${full_version}\2/" bin/index.js
@@ -1,11 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <title>Nodality App</title>
6
- </head>
7
- <body>
8
- <div id="mount"></div>
9
- <script type="module" src="./main.js"></script>
10
- </body>
11
- </html>
package/templates/main.js DELETED
@@ -1,5 +0,0 @@
1
- import { Text } from "nodality";
2
-
3
- new Text("Hello")
4
- .set({})
5
- .render("#mount");