netcore-blueprint 1.0.11 → 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.
Files changed (2) hide show
  1. package/create.js +46 -10
  2. 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
- const destinationPath = path.join(process.cwd(), projectName);
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,9 +35,9 @@ function copyAndRename(src, dest) {
32
35
  } else {
33
36
  let content = fs.readFileSync(src, 'utf8');
34
37
 
35
- // Replace "Blueprint" with the new project name (case-insensitive)
38
+ // Replace all occurrences of "Blueprint" with the new project name
36
39
  const regex = new RegExp("Blueprint", "gi");
37
- content = content.replace(regex, projectName);
40
+ content = content.replace(regex, formattedProjectName);
38
41
 
39
42
  fs.writeFileSync(dest, content);
40
43
  }
@@ -42,7 +45,7 @@ function copyAndRename(src, dest) {
42
45
 
43
46
  // Ensure destination doesn't already exist
44
47
  if (fs.existsSync(destinationPath)) {
45
- console.error(`❌ Project directory "${projectName}" already exists.`);
48
+ console.error(`❌ Project directory "${formattedProjectName}" already exists.`);
46
49
  process.exit(1);
47
50
  }
48
51
 
@@ -68,11 +71,11 @@ templateItems.forEach(item => {
68
71
 
69
72
  // Rename Directories & Solution File
70
73
  const renameItems = [
71
- { old: "Blueprint.API", new: `${projectName}.API` },
72
- { old: "Blueprint.Core", new: `${projectName}.Core` },
73
- { old: "Blueprint.Infra", new: `${projectName}.Infra` },
74
- { old: "Blueprint.Test", new: `${projectName}.Test` },
75
- { old: "Blueprint.API.sln", new: `${projectName}.sln` }
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` }
76
79
  ];
77
80
 
78
81
  renameItems.forEach(({ old, new: newName }) => {
@@ -87,4 +90,37 @@ renameItems.forEach(({ old, new: newName }) => {
87
90
  }
88
91
  });
89
92
 
90
- console.log(`🎉 Project "${projectName}" created successfully at ${destinationPath}`);
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.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "netcore-blueprint",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "A custom .NET Core project blueprint",
5
5
  "main": "create.js",
6
6
  "bin": {