create-nodality 1.0.90 → 1.0.92
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 +43 -28
- package/package.json +1 -1
- package/release.sh +11 -0
- package/.github/workflows/blank.yml +0 -23
- package/LICENSE +0 -21
- package/README.md +0 -2
package/bin/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { mkdirSync, writeFileSync, existsSync
|
|
3
|
+
import { mkdirSync, writeFileSync, existsSync } from "fs";
|
|
4
4
|
import { resolve } from "path";
|
|
5
5
|
import { execSync } from "child_process";
|
|
6
6
|
|
|
@@ -12,14 +12,14 @@ function createProject(projectName) {
|
|
|
12
12
|
process.exit(1);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
// Create folders
|
|
16
15
|
mkdirSync(projectPath);
|
|
17
16
|
const srcPath = resolve(projectPath, "src");
|
|
18
17
|
mkdirSync(srcPath);
|
|
19
18
|
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
// Root dev index.html — used during `npm run dev` (live-server serves
|
|
20
|
+
// upload/, but the root file is also kept as a development fallback
|
|
21
|
+
// pointing at src/app.js via the node_modules importmap).
|
|
22
|
+
const indexHtml = `<!DOCTYPE html>
|
|
23
23
|
<html lang="en">
|
|
24
24
|
<head>
|
|
25
25
|
<meta charset="UTF-8">
|
|
@@ -41,16 +41,16 @@ function createProject(projectName) {
|
|
|
41
41
|
<!-- User app -->
|
|
42
42
|
<script type="module" src="src/app.js"></script>
|
|
43
43
|
</body>
|
|
44
|
-
</html
|
|
45
|
-
|
|
46
|
-
writeFileSync(resolve(projectPath, "index.html"), indexHtml.trim());
|
|
44
|
+
</html>`;
|
|
45
|
+
writeFileSync(resolve(projectPath, "index.html"), indexHtml);
|
|
47
46
|
|
|
48
|
-
//
|
|
49
|
-
|
|
50
|
-
import { Des } from "nodality";
|
|
47
|
+
// src/app.js — the user's source. On first `npm run prerender`
|
|
48
|
+
// the CLI clones this into upload/pages/<name>.js as the SSG entry.
|
|
49
|
+
const appJs = `import { Des } from "nodality";
|
|
51
50
|
|
|
52
51
|
const elements = [
|
|
53
|
-
{ type: "h1", text: "Hello" }
|
|
52
|
+
{ type: "h1", text: "Hello" },
|
|
53
|
+
{ type: "nav" }
|
|
54
54
|
];
|
|
55
55
|
|
|
56
56
|
const nodes = [
|
|
@@ -64,12 +64,13 @@ new Des()
|
|
|
64
64
|
mount: "#mount",
|
|
65
65
|
code: true,
|
|
66
66
|
});
|
|
67
|
-
|
|
68
|
-
writeFileSync(resolve(srcPath, "app.js"), appJs
|
|
67
|
+
`;
|
|
68
|
+
writeFileSync(resolve(srcPath, "app.js"), appJs);
|
|
69
69
|
|
|
70
|
-
//
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
// webpack outputs the bundle into upload/ so dev (live-server upload)
|
|
71
|
+
// and prerender both see the same lib.bundle.js. clean:false so the
|
|
72
|
+
// build does not wipe the SSG index.html / pages/ that live alongside.
|
|
73
|
+
const webpackConfig = `import path from "path";
|
|
73
74
|
import { fileURLToPath } from "url";
|
|
74
75
|
|
|
75
76
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -79,12 +80,12 @@ export default {
|
|
|
79
80
|
mode: "production",
|
|
80
81
|
entry: "nodality", // bundle Nodality only
|
|
81
82
|
output: {
|
|
82
|
-
path: path.resolve(__dirname, "
|
|
83
|
+
path: path.resolve(__dirname, "upload"),
|
|
83
84
|
filename: "lib.bundle.js",
|
|
84
85
|
library: { type: "module" }, // ESM output
|
|
85
86
|
environment: { module: true },
|
|
86
|
-
clean:
|
|
87
|
-
publicPath: "
|
|
87
|
+
clean: false, // upload/ holds index.html + pages/ — do not wipe
|
|
88
|
+
publicPath: "./",
|
|
88
89
|
},
|
|
89
90
|
experiments: { outputModule: true },
|
|
90
91
|
module: {
|
|
@@ -97,18 +98,18 @@ export default {
|
|
|
97
98
|
],
|
|
98
99
|
},
|
|
99
100
|
};
|
|
100
|
-
|
|
101
|
-
writeFileSync(resolve(projectPath, "webpack.config.js"), webpackConfig
|
|
101
|
+
`;
|
|
102
|
+
writeFileSync(resolve(projectPath, "webpack.config.js"), webpackConfig);
|
|
102
103
|
|
|
103
|
-
// package.json
|
|
104
104
|
const pkg = {
|
|
105
105
|
name: projectName,
|
|
106
106
|
version: "1.0.0",
|
|
107
107
|
type: "module",
|
|
108
108
|
scripts: {
|
|
109
109
|
build: "webpack --config webpack.config.js",
|
|
110
|
+
prerender: "nodality prerender",
|
|
110
111
|
watch: "webpack --watch --config webpack.config.js",
|
|
111
|
-
start: "live-server
|
|
112
|
+
start: "live-server upload --port=4000 --watch=upload",
|
|
112
113
|
dev: "npm-run-all --parallel watch start"
|
|
113
114
|
},
|
|
114
115
|
dependencies: {
|
|
@@ -128,6 +129,16 @@ export default {
|
|
|
128
129
|
};
|
|
129
130
|
writeFileSync(resolve(projectPath, "package.json"), JSON.stringify(pkg, null, 2));
|
|
130
131
|
|
|
132
|
+
const nodalityConfig = {
|
|
133
|
+
origin: `https://${projectName}.example.com`,
|
|
134
|
+
uploadDir: "upload",
|
|
135
|
+
tolerateAsyncErrors: false
|
|
136
|
+
};
|
|
137
|
+
writeFileSync(
|
|
138
|
+
resolve(projectPath, "nodality.config.json"),
|
|
139
|
+
JSON.stringify(nodalityConfig, null, 2)
|
|
140
|
+
);
|
|
141
|
+
|
|
131
142
|
console.log("Installing dependencies...");
|
|
132
143
|
execSync(`npm install`, { cwd: projectPath, stdio: "inherit" });
|
|
133
144
|
|
|
@@ -141,12 +152,16 @@ export default {
|
|
|
141
152
|
console.log(`\n${color1abc9c}${bold}%s${reset}\n`, `Project "${projectName}" is ready! 🎉`);
|
|
142
153
|
console.log("\nUsage:\n");
|
|
143
154
|
console.log(` cd ${projectName}`);
|
|
144
|
-
console.log(" npm run build # Rebuild library bundle");
|
|
145
|
-
console.log(" npm run
|
|
146
|
-
console.log(" npm
|
|
155
|
+
console.log(" npm run build # Rebuild library bundle into upload/");
|
|
156
|
+
console.log(" npm run prerender # First run bootstraps upload/, then renders static HTML");
|
|
157
|
+
console.log(" npm run dev # Start dev server (live-server on upload/) with watch");
|
|
158
|
+
console.log(" npm start # Serve upload/ without watch");
|
|
159
|
+
console.log("");
|
|
160
|
+
console.log(
|
|
161
|
+
` Edit ${color1abc9c}nodality.config.json${reset} to set your public origin before running prerender.`
|
|
162
|
+
);
|
|
147
163
|
}
|
|
148
164
|
|
|
149
|
-
// Get project name from CLI args
|
|
150
165
|
const args = process.argv.slice(2);
|
|
151
166
|
if (!args[0]) {
|
|
152
167
|
console.error("Usage: npm create nodality <project-name>");
|
package/package.json
CHANGED
package/release.sh
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
next_version=33
|
|
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,23 +0,0 @@
|
|
|
1
|
-
name: Publish create-nodality
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
workflow_dispatch: # <-- allows manual trigger
|
|
5
|
-
push:
|
|
6
|
-
tags:
|
|
7
|
-
- 'v*.*.*'
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
publish:
|
|
11
|
-
runs-on: ubuntu-latest
|
|
12
|
-
steps:
|
|
13
|
-
- uses: actions/checkout@v4
|
|
14
|
-
|
|
15
|
-
- uses: actions/setup-node@v4
|
|
16
|
-
with:
|
|
17
|
-
node-version: '18.20.0'
|
|
18
|
-
registry-url: 'https://registry.npmjs.org'
|
|
19
|
-
|
|
20
|
-
- name: Publish to NPM
|
|
21
|
-
env:
|
|
22
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
23
|
-
run: npm publish --access public
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 NodalityJS
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/README.md
DELETED