netcore-blueprint 1.0.19 → 1.0.21

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 +33 -10
  2. package/package.json +1 -1
package/create.js CHANGED
@@ -3,6 +3,7 @@
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
5
 
6
+ // Get the project name from command-line arguments
6
7
  const projectName = process.argv[2];
7
8
  if (!projectName) {
8
9
  console.error("❌ Please specify the project name.");
@@ -12,17 +13,21 @@ if (!projectName) {
12
13
  const templatePath = path.join(__dirname, "BlueprintTemplate"); // Copy from BlueprintTemplate
13
14
  const destinationPath = path.join(process.cwd(), projectName);
14
15
 
15
- function copyFilesRecursively(src, dest) {
16
+ // Function to copy and rename files
17
+ function copyAndRenameFiles(src, dest, oldName, newName) {
16
18
  if (fs.lstatSync(src).isDirectory()) {
17
19
  fs.mkdirSync(dest, { recursive: true });
18
20
  const entries = fs.readdirSync(src, { withFileTypes: true });
21
+
19
22
  for (let entry of entries) {
20
- const srcPath = path.join(src, entry.name);
21
- const destPath = path.join(dest, entry.name);
22
- copyFilesRecursively(srcPath, destPath);
23
+ let srcPath = path.join(src, entry.name);
24
+ let destPath = path.join(dest, entry.name.replace(new RegExp(oldName, 'g'), newName));
25
+ copyAndRenameFiles(srcPath, destPath, oldName, newName);
23
26
  }
24
27
  } else {
25
- fs.copyFileSync(src, dest);
28
+ let content = fs.readFileSync(src, 'utf8');
29
+ content = content.replace(new RegExp(oldName, 'g'), newName); // Replace occurrences of Blueprint
30
+ fs.writeFileSync(dest, content, 'utf8');
26
31
  }
27
32
  }
28
33
 
@@ -34,18 +39,36 @@ if (fs.existsSync(destinationPath)) {
34
39
 
35
40
  fs.mkdirSync(destinationPath, { recursive: true });
36
41
 
37
- // Copy everything inside BlueprintTemplate
42
+ // Copy and rename all files
38
43
  fs.readdirSync(templatePath).forEach(item => {
39
44
  const srcPath = path.join(templatePath, item);
40
- let destPath = path.join(destinationPath, item);
45
+ let destPath = path.join(destinationPath, item.replace(/Blueprint/g, projectName));
41
46
 
42
47
  if (item === "gitignore") {
43
- destPath = path.join(destinationPath, ".gitignore"); // Rename to .gitignore
48
+ destPath = path.join(destinationPath, ".gitignore"); // Rename gitignore
44
49
  }
45
50
 
46
- console.log(`✅ Copying ${item}...`);
47
- copyFilesRecursively(srcPath, destPath);
51
+ console.log(`✅ Copying and renaming ${item}...`);
52
+ copyAndRenameFiles(srcPath, destPath, "Blueprint", projectName);
48
53
  });
49
54
 
50
55
  console.log(`🎉 Project "${projectName}" created successfully at ${destinationPath}`);
51
56
  console.log(`📌 Open "${projectName}.sln" in Visual Studio to get started!`);
57
+
58
+ // Initialize Git and commit the first commit
59
+ try {
60
+ process.chdir(destinationPath); // Move into project directory
61
+
62
+ console.log("🚀 Initializing Git repository...");
63
+ execSync('git init', { stdio: 'inherit' });
64
+
65
+ console.log("📂 Adding all files...");
66
+ execSync('git add .', { stdio: 'inherit' });
67
+
68
+ console.log("✅ Creating first commit...");
69
+ execSync('git commit -m "Initial commit from netcore-blueprint"', { stdio: 'inherit' });
70
+
71
+ console.log("🎉 Git repository initialized successfully!");
72
+ } catch (error) {
73
+ console.error("❌ Failed to initialize Git:", error);
74
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "netcore-blueprint",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "description": "A custom .NET Core project blueprint",
5
5
  "main": "create.js",
6
6
  "bin": {