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.
Files changed (3) hide show
  1. package/create.js +42 -22
  2. package/gitignore +12 -0
  3. 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("fs");
4
- const path = require("path");
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 upperProjectName = projectName.toUpperCase();
14
- const destinationPath = path.join(process.cwd(), upperProjectName);
15
-
16
- // Define template folder and files to rename
17
- const templateDir = path.join(__dirname, "template"); // Store your template inside a 'template' folder
18
- const filesToRename = ["Blueprint.API.sln", "README.md"]; // Files that contain references to update
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.replace(/Blueprint/g, upperProjectName));
29
+ const destPath = path.join(dest, entry.name);
31
30
  copyAndRename(srcPath, destPath);
32
31
  }
33
32
  } else {
34
- let content = fs.readFileSync(src, "utf8");
35
- content = content.replace(/Blueprint\.API/g, `${upperProjectName}.API`);
36
- content = content.replace(/Blueprint/g, upperProjectName);
37
- fs.writeFileSync(dest, content, "utf8");
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 "${upperProjectName}" already exists.`);
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 all template files and rename them dynamically
50
- copyAndRename(templateDir, destinationPath);
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 "${upperProjectName}" created at ${destinationPath}`);
72
+ console.log(`🎉 Project "${projectName}" created successfully at ${destinationPath}`);
package/gitignore ADDED
@@ -0,0 +1,12 @@
1
+ bin
2
+ obj
3
+ _nugetLib
4
+ /.vs
5
+ /.vscode
6
+ /debug.log
7
+
8
+ # Ignore all .cache files
9
+ *.cache
10
+
11
+ # Ignore all AssemblyInfo.cs files
12
+ **/AssemblyInfo.cs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "netcore-blueprint",
3
- "version": "1.0.8",
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
  }