create-nodality 1.0.0-beta.7 → 1.0.0-beta.70
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 +66 -43
- package/package.json +3 -3
- package/readme.md +0 -0
- package/templates/index.html +0 -11
- package/templates/main.js +0 -5
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,86 +20,109 @@ function createProject(projectName) {
|
|
21
20
|
const srcPath = resolve(projectPath, "src");
|
22
21
|
mkdirSync(srcPath);
|
23
22
|
|
24
|
-
//
|
23
|
+
// index.html with import map pointing "nodality" to bundled ES 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
|
28
|
+
<meta charset="UTF-8" />
|
29
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
31
30
|
<title>${projectName}</title>
|
31
|
+
|
32
|
+
<script type="importmap">
|
33
|
+
{
|
34
|
+
"imports": {
|
35
|
+
"nodality": "/dist/lib.bundle.js"
|
36
|
+
}
|
37
|
+
}
|
38
|
+
</script>
|
32
39
|
</head>
|
33
40
|
<body>
|
34
41
|
<div id="mount"></div>
|
35
|
-
|
42
|
+
|
43
|
+
<script type="module" src="/src/app.js"></script>
|
36
44
|
</body>
|
37
45
|
</html>
|
38
46
|
`;
|
39
47
|
writeFileSync(resolve(projectPath, "index.html"), indexHtml.trim());
|
40
48
|
|
41
|
-
//
|
42
|
-
const
|
43
|
-
|
49
|
+
// app.js stays non-bundled with import from "nodality"
|
50
|
+
const appJs = `
|
51
|
+
|
52
|
+
import * as Nodality from "nodality";
|
44
53
|
|
45
|
-
|
54
|
+
const elements = [
|
55
|
+
{ type: "h1", text: "Hello" }
|
56
|
+
];
|
57
|
+
|
58
|
+
const nodes = [
|
59
|
+
{ op: "blast" }
|
60
|
+
];
|
61
|
+
|
62
|
+
new Des()
|
63
|
+
.nodes(nodes)
|
64
|
+
.add(elements)
|
46
65
|
.set({
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
})
|
51
|
-
.render('#mount');
|
66
|
+
mount: "#mount",
|
67
|
+
code: true,
|
68
|
+
});
|
52
69
|
`;
|
53
|
-
writeFileSync(resolve(srcPath, "
|
70
|
+
writeFileSync(resolve(srcPath, "app.js"), appJs.trim());
|
54
71
|
|
55
|
-
//
|
72
|
+
// webpack.config.js outputs nodality as ES module library
|
56
73
|
const webpackConfig = `
|
57
|
-
import path from
|
58
|
-
import { fileURLToPath } from
|
74
|
+
import path from "path";
|
75
|
+
import { fileURLToPath } from "url";
|
59
76
|
|
60
77
|
const __filename = fileURLToPath(import.meta.url);
|
61
78
|
const __dirname = path.dirname(__filename);
|
62
79
|
|
63
80
|
export default {
|
64
|
-
mode:
|
65
|
-
entry:
|
81
|
+
mode: "production",
|
82
|
+
entry: "nodality",
|
66
83
|
output: {
|
67
|
-
|
68
|
-
|
84
|
+
path: path.resolve(__dirname, "dist"),
|
85
|
+
filename: "lib.bundle.js",
|
86
|
+
library: {
|
87
|
+
type: "module",
|
88
|
+
},
|
89
|
+
environment: {
|
90
|
+
module: true,
|
91
|
+
},
|
92
|
+
clean: true,
|
93
|
+
},
|
94
|
+
experiments: {
|
95
|
+
outputModule: true,
|
69
96
|
},
|
70
97
|
module: {
|
71
98
|
rules: [
|
72
99
|
{
|
73
|
-
test: /\\.js$/,
|
100
|
+
test: /\\.m?js$/,
|
74
101
|
exclude: /node_modules/,
|
75
102
|
use: {
|
76
|
-
loader:
|
103
|
+
loader: "babel-loader",
|
77
104
|
options: {
|
78
|
-
presets: [
|
105
|
+
presets: ["@babel/preset-env"],
|
79
106
|
},
|
80
107
|
},
|
81
108
|
},
|
82
109
|
],
|
83
110
|
},
|
84
|
-
resolve: {
|
85
|
-
alias: {
|
86
|
-
nodality: path.resolve(__dirname, 'node_modules/nodality/dist/index.esm.js'),
|
87
|
-
},
|
88
|
-
},
|
89
111
|
};
|
90
112
|
`;
|
91
113
|
writeFileSync(resolve(projectPath, "webpack.config.js"), webpackConfig.trim());
|
92
114
|
|
93
|
-
//
|
115
|
+
// package.json
|
94
116
|
const pkg = {
|
95
117
|
name: projectName,
|
96
118
|
version: "1.0.0",
|
97
119
|
type: "module",
|
98
120
|
scripts: {
|
99
|
-
build: "webpack",
|
121
|
+
build: "webpack --config webpack.config.js",
|
100
122
|
start: "npx serve . -l 4000",
|
101
123
|
},
|
102
124
|
dependencies: {
|
103
|
-
nodality: "^1.0.0-beta.
|
125
|
+
nodality: "^1.0.0-beta.70",
|
104
126
|
},
|
105
127
|
devDependencies: {
|
106
128
|
webpack: "^5.0.0",
|
@@ -108,31 +130,32 @@ export default {
|
|
108
130
|
"babel-loader": "^9.0.0",
|
109
131
|
"@babel/core": "^7.0.0",
|
110
132
|
"@babel/preset-env": "^7.0.0",
|
133
|
+
serve: "^14.0.0",
|
111
134
|
},
|
112
135
|
};
|
113
136
|
writeFileSync(resolve(projectPath, "package.json"), JSON.stringify(pkg, null, 2));
|
114
137
|
|
115
|
-
// Install dependencies
|
116
138
|
console.log("Installing dependencies...");
|
117
139
|
execSync(`npm install`, { cwd: projectPath, stdio: "inherit" });
|
118
140
|
|
119
|
-
|
120
|
-
|
121
|
-
|
141
|
+
console.log("Building nodality bundle as ES module...");
|
142
|
+
execSync(`npm run build`, { cwd: projectPath, stdio: "inherit" });
|
143
|
+
|
144
|
+
const bold = "\x1b[1m";
|
145
|
+
const color1abc9c = "\x1b[38;5;37m";
|
146
|
+
const reset = "\x1b[0m";
|
122
147
|
|
123
|
-
console.log(
|
148
|
+
console.log(`\n${color1abc9c}${bold}%s${reset}\n`, `Project "${projectName}" is ready! 🎉`);
|
149
|
+
console.log("\nUsage:\n");
|
124
150
|
console.log(` cd ${projectName}`);
|
125
|
-
console.log(" npm run build # Rebuild
|
126
|
-
console.log(" npm start # Serve
|
151
|
+
console.log(" npm run build # Rebuild library bundle");
|
152
|
+
console.log(" npm start # Serve on http://localhost:4000\n");
|
127
153
|
}
|
128
154
|
|
129
|
-
// Parse CLI arguments
|
130
155
|
const args = process.argv.slice(2);
|
131
|
-
|
132
156
|
if (!args[0]) {
|
133
157
|
console.error("Usage: npm create nodality <project-name>");
|
134
158
|
process.exit(1);
|
135
159
|
}
|
136
160
|
|
137
|
-
// Create the project
|
138
161
|
createProject(args[0]);
|
package/package.json
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
{
|
2
2
|
"name": "create-nodality",
|
3
|
-
"version": "1.0.0-beta.
|
3
|
+
"version": "1.0.0-beta.70",
|
4
4
|
"description": "Project scaffolding tool for Nodality library",
|
5
5
|
"bin": {
|
6
|
-
"create-nodality": "
|
6
|
+
"create-nodality": "bin/index.js"
|
7
7
|
},
|
8
8
|
"type": "module",
|
9
9
|
"scripts": {
|
@@ -18,6 +18,6 @@
|
|
18
18
|
"author": "Filip Vabrousek",
|
19
19
|
"license": "MIT",
|
20
20
|
"dependencies": {
|
21
|
-
"nodality": "^1.0.0-beta.
|
21
|
+
"nodality": "^1.0.0-beta.70"
|
22
22
|
}
|
23
23
|
}
|
package/readme.md
DELETED
File without changes
|
package/templates/index.html
DELETED