netcore-blueprint 0.0.13 → 0.0.14

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.
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env node
2
-
3
1
  const fs = require('fs');
4
2
  const path = require('path');
5
3
 
@@ -10,26 +8,43 @@ if (!newModuleName) {
10
8
  }
11
9
 
12
10
  const sourceModuleName = "ItemModule";
11
+ const templatePath = path.join(__dirname, "..", "BlueprintTemplate");
12
+ const destinationRoot = process.cwd(); // project root
13
13
 
14
- const sourcePath = path.join(__dirname, "..", "BlueprintTemplate", "ItemModule");
15
- const destinationPath = path.join(process.cwd(), newModuleName);
16
-
17
- if (!fs.existsSync(sourcePath)) {
18
- console.error(`❌ Source module not found: ${sourcePath}`);
14
+ if (!fs.existsSync(templatePath)) {
15
+ console.error(`❌ BlueprintTemplate not found: ${templatePath}`);
19
16
  process.exit(1);
20
17
  }
21
18
 
22
- if (fs.existsSync(destinationPath)) {
23
- console.error(`❌ Destination module already exists: ${destinationPath}`);
19
+ // Find all ItemModule.* folders
20
+ const sourceFolders = fs.readdirSync(templatePath, { withFileTypes: true })
21
+ .filter(d => d.isDirectory() && d.name.startsWith(sourceModuleName));
22
+
23
+ if (sourceFolders.length === 0) {
24
+ console.error(`❌ No ItemModule templates found in: ${templatePath}`);
24
25
  process.exit(1);
25
26
  }
26
27
 
27
- copyAndRenameFiles(sourcePath, destinationPath, sourceModuleName, newModuleName);
28
+ for (const dir of sourceFolders) {
29
+ const srcPath = path.join(templatePath, dir.name);
30
+ const destName = dir.name.replace(
31
+ new RegExp(sourceModuleName, 'g'),
32
+ newModuleName
33
+ );
34
+ const destPath = path.join(destinationRoot, destName);
28
35
 
29
- console.log(`🎉 Module "${newModuleName}" created successfully!`);
36
+ if (fs.existsSync(destPath)) {
37
+ console.error(`❌ Destination already exists: ${destPath}`);
38
+ process.exit(1);
39
+ }
30
40
 
41
+ console.log(`📦 Copying ${dir.name} -> ${destName}`);
42
+ copyAndRenameFiles(srcPath, destPath, sourceModuleName, newModuleName);
43
+ }
44
+
45
+ console.log(`🎉 Module "${newModuleName}" created successfully!`);
31
46
 
32
- // ===== CORE LOGIC (reuse from old script) =====
47
+ // ===== CORE LOGIC =====
33
48
 
34
49
  function copyAndRenameFiles(src, dest, oldName, newName) {
35
50
  if (fs.lstatSync(src).isDirectory()) {
@@ -45,10 +60,7 @@ function copyAndRenameFiles(src, dest, oldName, newName) {
45
60
  }
46
61
  } else {
47
62
  let content = fs.readFileSync(src, 'utf8');
48
-
49
- // Replace namespace + class + references
50
63
  content = content.replace(new RegExp(oldName, 'g'), newName);
51
-
52
64
  fs.writeFileSync(dest, content, 'utf8');
53
65
  }
54
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "netcore-blueprint",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "A custom project blueprint",
5
5
  "main": "create.js",
6
6
  "bin": {