netcore-blueprint 1.0.8 → 1.0.10
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/create.js +42 -22
- package/gitignore +12 -0
- package/package.json +3 -2
package/create.js
CHANGED
|
@@ -1,52 +1,72 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const fs = require(
|
|
4
|
-
const path = require(
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
5
|
|
|
6
6
|
const projectName = process.argv[2];
|
|
7
|
-
|
|
8
7
|
if (!projectName) {
|
|
9
8
|
console.error("❌ Please specify the project name.");
|
|
10
9
|
process.exit(1);
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
const destinationPath = path.join(process.cwd(), projectName);
|
|
13
|
+
const templateItems = [
|
|
14
|
+
"Blueprint.API.sln",
|
|
15
|
+
"Blueprint.API",
|
|
16
|
+
"Blueprint.Core",
|
|
17
|
+
"Blueprint.Infra",
|
|
18
|
+
"Blueprint.Test",
|
|
19
|
+
"README.md",
|
|
20
|
+
"gitignore" // Rename later
|
|
21
|
+
];
|
|
19
22
|
|
|
20
|
-
/**
|
|
21
|
-
* Recursively copy directory contents and rename project references
|
|
22
|
-
*/
|
|
23
23
|
function copyAndRename(src, dest) {
|
|
24
24
|
if (fs.lstatSync(src).isDirectory()) {
|
|
25
25
|
fs.mkdirSync(dest, { recursive: true });
|
|
26
26
|
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
27
|
-
|
|
28
27
|
for (let entry of entries) {
|
|
29
28
|
const srcPath = path.join(src, entry.name);
|
|
30
|
-
const destPath = path.join(dest, entry.name
|
|
29
|
+
const destPath = path.join(dest, entry.name);
|
|
31
30
|
copyAndRename(srcPath, destPath);
|
|
32
31
|
}
|
|
33
32
|
} else {
|
|
34
|
-
let content = fs.readFileSync(src,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
let content = fs.readFileSync(src, 'utf8');
|
|
34
|
+
|
|
35
|
+
// Ensure projectName follows PascalCase format
|
|
36
|
+
const projectNamePascalCase = projectName.charAt(0).toUpperCase() + projectName.slice(1);
|
|
37
|
+
|
|
38
|
+
// Replace "Blueprint.API" first, then "Blueprint" (case-insensitive)
|
|
39
|
+
content = content.replace(/Blueprint\.API/gi, `${projectNamePascalCase}.API`);
|
|
40
|
+
content = content.replace(/Blueprint/gi, projectNamePascalCase);
|
|
41
|
+
|
|
42
|
+
fs.writeFileSync(dest, content);
|
|
38
43
|
}
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
// Ensure destination doesn't already exist
|
|
42
47
|
if (fs.existsSync(destinationPath)) {
|
|
43
|
-
console.error(`❌ Project directory "${
|
|
48
|
+
console.error(`❌ Project directory "${projectName}" already exists.`);
|
|
44
49
|
process.exit(1);
|
|
45
50
|
}
|
|
46
51
|
|
|
47
52
|
fs.mkdirSync(destinationPath, { recursive: true });
|
|
48
53
|
|
|
49
|
-
// Copy
|
|
50
|
-
|
|
54
|
+
// Copy template files
|
|
55
|
+
templateItems.forEach(item => {
|
|
56
|
+
const srcPath = path.join(__dirname, item);
|
|
57
|
+
let destPath = path.join(destinationPath, item);
|
|
58
|
+
|
|
59
|
+
if (item === "gitignore") {
|
|
60
|
+
destPath = path.join(destinationPath, ".gitignore"); // Rename to .gitignore
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (fs.existsSync(srcPath)) {
|
|
64
|
+
console.log(`✅ Copying ${item}...`);
|
|
65
|
+
copyAndRename(srcPath, destPath);
|
|
66
|
+
} else {
|
|
67
|
+
console.error(`❌ Critical error: "${srcPath}" does not exist.`);
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
51
71
|
|
|
52
|
-
console.log(`🎉 Project "${
|
|
72
|
+
console.log(`🎉 Project "${projectName}" created successfully at ${destinationPath}`);
|
package/gitignore
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "netcore-blueprint",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "A custom .NET Core project blueprint",
|
|
5
5
|
"main": "create.js",
|
|
6
6
|
"bin": {
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"Blueprint.Core/**",
|
|
20
20
|
"Blueprint.Infra/**",
|
|
21
21
|
"Blueprint.Test/**",
|
|
22
|
-
"README.md"
|
|
22
|
+
"README.md",
|
|
23
|
+
"gitignore"
|
|
23
24
|
]
|
|
24
25
|
}
|