netcore-blueprint 1.0.10 → 1.0.12
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 +64 -10
- package/package.json +1 -1
package/create.js
CHANGED
|
@@ -9,7 +9,10 @@ if (!projectName) {
|
|
|
9
9
|
process.exit(1);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
// Ensure the first letter is uppercase
|
|
13
|
+
const formattedProjectName = projectName.charAt(0).toUpperCase() + projectName.slice(1);
|
|
14
|
+
|
|
15
|
+
const destinationPath = path.join(process.cwd(), formattedProjectName);
|
|
13
16
|
const templateItems = [
|
|
14
17
|
"Blueprint.API.sln",
|
|
15
18
|
"Blueprint.API",
|
|
@@ -32,12 +35,9 @@ function copyAndRename(src, dest) {
|
|
|
32
35
|
} else {
|
|
33
36
|
let content = fs.readFileSync(src, 'utf8');
|
|
34
37
|
|
|
35
|
-
//
|
|
36
|
-
const
|
|
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);
|
|
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
41
|
|
|
42
42
|
fs.writeFileSync(dest, content);
|
|
43
43
|
}
|
|
@@ -45,13 +45,13 @@ function copyAndRename(src, dest) {
|
|
|
45
45
|
|
|
46
46
|
// Ensure destination doesn't already exist
|
|
47
47
|
if (fs.existsSync(destinationPath)) {
|
|
48
|
-
console.error(`❌ Project directory "${
|
|
48
|
+
console.error(`❌ Project directory "${formattedProjectName}" already exists.`);
|
|
49
49
|
process.exit(1);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
fs.mkdirSync(destinationPath, { recursive: true });
|
|
53
53
|
|
|
54
|
-
// Copy template files
|
|
54
|
+
// Copy and rename template files
|
|
55
55
|
templateItems.forEach(item => {
|
|
56
56
|
const srcPath = path.join(__dirname, item);
|
|
57
57
|
let destPath = path.join(destinationPath, item);
|
|
@@ -69,4 +69,58 @@ templateItems.forEach(item => {
|
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
// Rename Directories & Solution File
|
|
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.`);
|