create-nodality 1.0.0-beta.66 → 1.0.0-beta.68
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 +20 -78
- package/package.json +1 -1
- package/readme.md +0 -0
- package/release.sh +0 -11
- package/templates/index.html +0 -11
- package/templates/main.js +0 -5
package/bin/index.js
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
|
3
2
|
import { mkdirSync, writeFileSync, existsSync } from "fs";
|
4
3
|
import { resolve, dirname } from "path";
|
5
4
|
import { execSync } from "child_process";
|
6
5
|
import { fileURLToPath } from "url";
|
7
6
|
|
8
|
-
// Helper to get directory of current file (ESM compatible)
|
9
7
|
const __filename = fileURLToPath(import.meta.url);
|
10
8
|
const __dirname = dirname(__filename);
|
11
9
|
|
@@ -21,26 +19,26 @@ function createProject(projectName) {
|
|
21
19
|
const srcPath = resolve(projectPath, "src");
|
22
20
|
mkdirSync(srcPath);
|
23
21
|
|
24
|
-
//
|
22
|
+
// index.html
|
25
23
|
const indexHtml = `
|
26
24
|
<!DOCTYPE html>
|
27
25
|
<html lang="en">
|
28
26
|
<head>
|
29
|
-
<meta charset="UTF-8"
|
30
|
-
<meta name="viewport" content="width=device-width, initial-scale=1
|
27
|
+
<meta charset="UTF-8" />
|
28
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
31
29
|
<title>${projectName}</title>
|
32
30
|
</head>
|
33
31
|
<body>
|
34
32
|
<div id="mount"></div>
|
35
|
-
<script src="
|
33
|
+
<script type="module" src="src/app.js"></script>
|
36
34
|
</body>
|
37
35
|
</html>
|
38
36
|
`;
|
39
37
|
writeFileSync(resolve(projectPath, "index.html"), indexHtml.trim());
|
40
38
|
|
41
|
-
//
|
42
|
-
const
|
43
|
-
import { Des } from
|
39
|
+
// app.js — kept as-is, no bundling
|
40
|
+
const appJs = `
|
41
|
+
import { Des } from "nodality";
|
44
42
|
|
45
43
|
let elements = [
|
46
44
|
{
|
@@ -63,98 +61,42 @@ new Des()
|
|
63
61
|
code: true
|
64
62
|
});
|
65
63
|
`;
|
66
|
-
writeFileSync(resolve(srcPath, "
|
67
|
-
|
68
|
-
// Create webpack.config.js
|
69
|
-
const webpackConfig = `
|
70
|
-
import path from 'path';
|
71
|
-
import { fileURLToPath } from 'url';
|
72
|
-
|
73
|
-
const __filename = fileURLToPath(import.meta.url);
|
74
|
-
const __dirname = path.dirname(__filename);
|
75
|
-
|
76
|
-
export default {
|
77
|
-
mode: 'production',
|
78
|
-
entry: './src/index.js',
|
79
|
-
output: {
|
80
|
-
filename: 'bundle.js',
|
81
|
-
path: path.resolve(__dirname, 'dist'),
|
82
|
-
},
|
83
|
-
module: {
|
84
|
-
rules: [
|
85
|
-
{
|
86
|
-
test: /\\.js$/,
|
87
|
-
exclude: /node_modules/,
|
88
|
-
use: {
|
89
|
-
loader: 'babel-loader',
|
90
|
-
options: {
|
91
|
-
presets: ['@babel/preset-env'],
|
92
|
-
},
|
93
|
-
},
|
94
|
-
},
|
95
|
-
],
|
96
|
-
},
|
97
|
-
resolve: {
|
98
|
-
alias: {
|
99
|
-
nodality: path.resolve(__dirname, 'node_modules/nodality/dist/index.esm.js'),
|
100
|
-
},
|
101
|
-
},
|
102
|
-
};
|
103
|
-
`;
|
104
|
-
writeFileSync(resolve(projectPath, "webpack.config.js"), webpackConfig.trim());
|
64
|
+
writeFileSync(resolve(srcPath, "app.js"), appJs.trim());
|
105
65
|
|
106
|
-
//
|
66
|
+
// package.json
|
107
67
|
const pkg = {
|
108
68
|
name: projectName,
|
109
69
|
version: "1.0.0",
|
110
70
|
type: "module",
|
111
71
|
scripts: {
|
112
|
-
|
113
|
-
start: "npx serve . -l 4000",
|
72
|
+
start: "npx serve . -l 4000"
|
114
73
|
},
|
115
74
|
dependencies: {
|
116
|
-
nodality: "^1.0.0-beta.66"
|
75
|
+
nodality: "^1.0.0-beta.66"
|
117
76
|
},
|
118
77
|
devDependencies: {
|
119
|
-
|
120
|
-
|
121
|
-
"babel-loader": "^9.0.0",
|
122
|
-
"@babel/core": "^7.0.0",
|
123
|
-
"@babel/preset-env": "^7.0.0",
|
124
|
-
},
|
78
|
+
serve: "^14.0.0"
|
79
|
+
}
|
125
80
|
};
|
126
81
|
writeFileSync(resolve(projectPath, "package.json"), JSON.stringify(pkg, null, 2));
|
127
82
|
|
128
|
-
// Install dependencies
|
129
83
|
console.log("Installing dependencies...");
|
130
84
|
execSync(`npm install`, { cwd: projectPath, stdio: "inherit" });
|
131
85
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
// ANSI escape codes for green text and reset
|
86
|
+
const bold = '\x1b[1m';
|
87
|
+
const color1abc9c = '\x1b[38;5;37m';
|
88
|
+
const reset = '\x1b[0m';
|
138
89
|
|
139
|
-
|
140
|
-
|
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");
|
90
|
+
console.log(`\n${color1abc9c}${bold}%s${reset}\n`, `Your project "${projectName}" is ready! 🎉`);
|
91
|
+
console.log("\nUsage:\n");
|
146
92
|
console.log(` cd ${projectName}`);
|
147
|
-
console.log(" npm
|
148
|
-
console.log(" npm start # Serve your project on localhost:4000\n");
|
93
|
+
console.log(" npm start # Serve your project on http://localhost:4000");
|
149
94
|
}
|
150
95
|
|
151
|
-
// Parse CLI arguments
|
152
96
|
const args = process.argv.slice(2);
|
153
|
-
|
154
97
|
if (!args[0]) {
|
155
98
|
console.error("Usage: npm create nodality <project-name>");
|
156
99
|
process.exit(1);
|
157
100
|
}
|
158
101
|
|
159
|
-
|
160
|
-
createProject(args[0]);
|
102
|
+
createProject(args[0]);
|
package/package.json
CHANGED
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
|
package/templates/index.html
DELETED