netcore-blueprint 1.0.12 → 1.0.13
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 +7 -64
- 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",
|
|
@@ -35,9 +32,9 @@ function copyAndRename(src, dest) {
|
|
|
35
32
|
} else {
|
|
36
33
|
let content = fs.readFileSync(src, 'utf8');
|
|
37
34
|
|
|
38
|
-
//
|
|
39
|
-
|
|
40
|
-
content = content.replace(
|
|
35
|
+
// Rename Solution and Project Names
|
|
36
|
+
content = content.replace(/Blueprint\.API/g, projectName.toUpperCase());
|
|
37
|
+
content = content.replace(/Blueprint/g, projectName.toUpperCase());
|
|
41
38
|
|
|
42
39
|
fs.writeFileSync(dest, content);
|
|
43
40
|
}
|
|
@@ -45,13 +42,13 @@ function copyAndRename(src, dest) {
|
|
|
45
42
|
|
|
46
43
|
// Ensure destination doesn't already exist
|
|
47
44
|
if (fs.existsSync(destinationPath)) {
|
|
48
|
-
console.error(`❌ Project directory "${
|
|
45
|
+
console.error(`❌ Project directory "${projectName}" already exists.`);
|
|
49
46
|
process.exit(1);
|
|
50
47
|
}
|
|
51
48
|
|
|
52
49
|
fs.mkdirSync(destinationPath, { recursive: true });
|
|
53
50
|
|
|
54
|
-
// Copy
|
|
51
|
+
// Copy template files
|
|
55
52
|
templateItems.forEach(item => {
|
|
56
53
|
const srcPath = path.join(__dirname, item);
|
|
57
54
|
let destPath = path.join(destinationPath, item);
|
|
@@ -69,58 +66,4 @@ templateItems.forEach(item => {
|
|
|
69
66
|
}
|
|
70
67
|
});
|
|
71
68
|
|
|
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.`);
|
|
69
|
+
console.log(`🎉 Project "${projectName}" created successfully at ${destinationPath}`);
|