netcore-blueprint 1.0.12 → 1.0.14
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 +8 -71
- package/package.json +1 -1
package/create.js
CHANGED
|
@@ -9,10 +9,7 @@ if (!projectName) {
|
|
|
9
9
|
process.exit(1);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
const formattedProjectName = projectName.charAt(0).toUpperCase() + projectName.slice(1);
|
|
14
|
-
|
|
15
|
-
const destinationPath = path.join(process.cwd(), formattedProjectName);
|
|
12
|
+
const destinationPath = path.join(process.cwd(), projectName);
|
|
16
13
|
const templateItems = [
|
|
17
14
|
"Blueprint.API.sln",
|
|
18
15
|
"Blueprint.API",
|
|
@@ -23,35 +20,29 @@ const templateItems = [
|
|
|
23
20
|
"gitignore" // Rename later
|
|
24
21
|
];
|
|
25
22
|
|
|
26
|
-
function
|
|
23
|
+
function copyFilesRecursively(src, dest) {
|
|
27
24
|
if (fs.lstatSync(src).isDirectory()) {
|
|
28
25
|
fs.mkdirSync(dest, { recursive: true });
|
|
29
26
|
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
30
27
|
for (let entry of entries) {
|
|
31
28
|
const srcPath = path.join(src, entry.name);
|
|
32
29
|
const destPath = path.join(dest, entry.name);
|
|
33
|
-
|
|
30
|
+
copyFilesRecursively(srcPath, destPath);
|
|
34
31
|
}
|
|
35
32
|
} else {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// Replace all occurrences of "Blueprint" with the new project name
|
|
39
|
-
const regex = new RegExp("Blueprint", "gi");
|
|
40
|
-
content = content.replace(regex, formattedProjectName);
|
|
41
|
-
|
|
42
|
-
fs.writeFileSync(dest, content);
|
|
33
|
+
fs.copyFileSync(src, dest);
|
|
43
34
|
}
|
|
44
35
|
}
|
|
45
36
|
|
|
46
37
|
// Ensure destination doesn't already exist
|
|
47
38
|
if (fs.existsSync(destinationPath)) {
|
|
48
|
-
console.error(`❌ Project directory "${
|
|
39
|
+
console.error(`❌ Project directory "${projectName}" already exists.`);
|
|
49
40
|
process.exit(1);
|
|
50
41
|
}
|
|
51
42
|
|
|
52
43
|
fs.mkdirSync(destinationPath, { recursive: true });
|
|
53
44
|
|
|
54
|
-
// Copy
|
|
45
|
+
// Copy template files without renaming
|
|
55
46
|
templateItems.forEach(item => {
|
|
56
47
|
const srcPath = path.join(__dirname, item);
|
|
57
48
|
let destPath = path.join(destinationPath, item);
|
|
@@ -62,65 +53,11 @@ templateItems.forEach(item => {
|
|
|
62
53
|
|
|
63
54
|
if (fs.existsSync(srcPath)) {
|
|
64
55
|
console.log(`✅ Copying ${item}...`);
|
|
65
|
-
|
|
56
|
+
copyFilesRecursively(srcPath, destPath);
|
|
66
57
|
} else {
|
|
67
58
|
console.error(`❌ Critical error: "${srcPath}" does not exist.`);
|
|
68
59
|
process.exit(1);
|
|
69
60
|
}
|
|
70
61
|
});
|
|
71
62
|
|
|
72
|
-
|
|
73
|
-
const renameItems = [
|
|
74
|
-
{ old: "Blueprint.API", new: `${formattedProjectName}.API` },
|
|
75
|
-
{ old: "Blueprint.Core", new: `${formattedProjectName}.Core` },
|
|
76
|
-
{ old: "Blueprint.Infra", new: `${formattedProjectName}.Infra` },
|
|
77
|
-
{ old: "Blueprint.Test", new: `${formattedProjectName}.Test` },
|
|
78
|
-
{ old: "Blueprint.API.sln", new: `${formattedProjectName}.sln` }
|
|
79
|
-
];
|
|
80
|
-
|
|
81
|
-
renameItems.forEach(({ old, new: newName }) => {
|
|
82
|
-
const oldPath = path.join(destinationPath, old);
|
|
83
|
-
const newPath = path.join(destinationPath, newName);
|
|
84
|
-
|
|
85
|
-
if (fs.existsSync(oldPath)) {
|
|
86
|
-
fs.renameSync(oldPath, newPath);
|
|
87
|
-
console.log(`🔄 Renamed ${old} -> ${newName}`);
|
|
88
|
-
} else {
|
|
89
|
-
console.warn(`⚠️ Warning: ${old} not found.`);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
console.log(`🎉 Project "${formattedProjectName}" created successfully at ${destinationPath}`);
|
|
94
|
-
|
|
95
|
-
// Update solution file to correct project references
|
|
96
|
-
const slnFilePath = path.join(destinationPath, `${formattedProjectName}.sln`);
|
|
97
|
-
if (fs.existsSync(slnFilePath)) {
|
|
98
|
-
let slnContent = fs.readFileSync(slnFilePath, 'utf8');
|
|
99
|
-
slnContent = slnContent.replace(/Blueprint\.API/g, `${formattedProjectName}.API`);
|
|
100
|
-
slnContent = slnContent.replace(/Blueprint\.Core/g, `${formattedProjectName}.Core`);
|
|
101
|
-
slnContent = slnContent.replace(/Blueprint\.Infra/g, `${formattedProjectName}.Infra`);
|
|
102
|
-
slnContent = slnContent.replace(/Blueprint\.Test/g, `${formattedProjectName}.Test`);
|
|
103
|
-
fs.writeFileSync(slnFilePath, slnContent);
|
|
104
|
-
console.log(`✅ Updated solution file references.`);
|
|
105
|
-
} else {
|
|
106
|
-
console.warn(`⚠️ Warning: Solution file not found.`);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Update project files (.csproj)
|
|
110
|
-
const updateProjectFiles = (dir) => {
|
|
111
|
-
fs.readdirSync(dir).forEach(file => {
|
|
112
|
-
const fullPath = path.join(dir, file);
|
|
113
|
-
if (fs.lstatSync(fullPath).isDirectory()) {
|
|
114
|
-
updateProjectFiles(fullPath);
|
|
115
|
-
} else if (file.endsWith('.csproj')) {
|
|
116
|
-
let content = fs.readFileSync(fullPath, 'utf8');
|
|
117
|
-
content = content.replace(/Blueprint/g, formattedProjectName);
|
|
118
|
-
fs.writeFileSync(fullPath, content);
|
|
119
|
-
console.log(`✅ Updated ${file}`);
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
updateProjectFiles(destinationPath);
|
|
125
|
-
|
|
126
|
-
console.log(`🚀 Project "${formattedProjectName}" is now fully configured.`);
|
|
63
|
+
console.log(`🎉 Project "${projectName}" created successfully at ${destinationPath}`);
|