create-nodality 1.0.0-beta.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.
- package/bin/index.js +64 -0
- package/package.json +23 -0
- package/readme.md +0 -0
- package/templates/index.html +11 -0
- package/templates/main.js +5 -0
package/bin/index.js
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
import { mkdirSync, copyFileSync, existsSync, writeFileSync } from "fs";
|
4
|
+
import { resolve, dirname } from "path";
|
5
|
+
import { execSync } from "child_process";
|
6
|
+
import { fileURLToPath } from "url";
|
7
|
+
|
8
|
+
// Helper to get directory of current file (since using ES modules)
|
9
|
+
const __filename = fileURLToPath(import.meta.url);
|
10
|
+
const __dirname = dirname(__filename);
|
11
|
+
|
12
|
+
function copyTemplateFile(src, dest) {
|
13
|
+
copyFileSync(src, dest);
|
14
|
+
console.log(`Created ${dest}`);
|
15
|
+
}
|
16
|
+
|
17
|
+
function createProject(projectName) {
|
18
|
+
const projectPath = resolve(process.cwd(), projectName);
|
19
|
+
|
20
|
+
if (existsSync(projectPath)) {
|
21
|
+
console.error(`Folder ${projectName} already exists.`);
|
22
|
+
process.exit(1);
|
23
|
+
}
|
24
|
+
|
25
|
+
mkdirSync(projectPath);
|
26
|
+
|
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"));
|
31
|
+
|
32
|
+
// Create package.json
|
33
|
+
const pkg = {
|
34
|
+
name: projectName,
|
35
|
+
version: "1.0.0",
|
36
|
+
type: "module",
|
37
|
+
scripts: {
|
38
|
+
start: "serve ."
|
39
|
+
},
|
40
|
+
dependencies: {
|
41
|
+
nodality: "^1.0.0"
|
42
|
+
}
|
43
|
+
};
|
44
|
+
|
45
|
+
writeFileSync(resolve(projectPath, "package.json"), JSON.stringify(pkg, null, 2));
|
46
|
+
console.log("Created package.json");
|
47
|
+
|
48
|
+
// Install dependencies
|
49
|
+
console.log("Installing dependencies...");
|
50
|
+
execSync(`npm install`, { cwd: projectPath, stdio: "inherit" });
|
51
|
+
|
52
|
+
console.log("\nAll done! Run:\n");
|
53
|
+
console.log(` cd ${projectName}`);
|
54
|
+
console.log(" npm start\n");
|
55
|
+
}
|
56
|
+
|
57
|
+
const args = process.argv.slice(2);
|
58
|
+
|
59
|
+
if (!args[0]) {
|
60
|
+
console.error("Usage: npm create nodality <project-name>");
|
61
|
+
process.exit(1);
|
62
|
+
}
|
63
|
+
|
64
|
+
createProject(args[0]);
|
package/package.json
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
{
|
2
|
+
"name": "create-nodality",
|
3
|
+
"version": "1.0.0-beta.0",
|
4
|
+
"description": "Project scaffolding tool for Nodality library",
|
5
|
+
"bin": {
|
6
|
+
"create-nodality": "./bin/index.js"
|
7
|
+
},
|
8
|
+
"type": "module",
|
9
|
+
"scripts": {
|
10
|
+
"test": "echo \"No tests yet\""
|
11
|
+
},
|
12
|
+
"keywords": [
|
13
|
+
"nodality",
|
14
|
+
"scaffold",
|
15
|
+
"starter",
|
16
|
+
"create"
|
17
|
+
],
|
18
|
+
"author": "Filip Vabrousek",
|
19
|
+
"license": "MIT",
|
20
|
+
"dependencies": {
|
21
|
+
"nodality": "^1.0.0-beta.4"
|
22
|
+
}
|
23
|
+
}
|
package/readme.md
ADDED
File without changes
|