netcore-blueprint 0.0.49 → 0.0.50

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/bin/copy-module.js +29 -31
  2. package/package.json +1 -1
@@ -6,8 +6,8 @@ const { execSync } = require('child_process');
6
6
 
7
7
  // =====================================================
8
8
  // Param = Source Module Name (also base for new module)
9
- // Example: copy-module Order
10
- // Will create: OrderModule
9
+ // Example: copy-module __MODULE__
10
+ // Will create: __MODULE__Module
11
11
  // =====================================================
12
12
 
13
13
  const sourceModuleName = process.argv[2];
@@ -15,7 +15,7 @@ const force = process.argv.includes('--force');
15
15
 
16
16
  if (!sourceModuleName) {
17
17
  console.error("❌ Usage: copy-module <SourceModuleName>");
18
- console.error(" Example: copy-module Order");
18
+ console.error(" Example: copy-module __MODULE__");
19
19
  process.exit(1);
20
20
  }
21
21
 
@@ -23,20 +23,10 @@ if (!sourceModuleName) {
23
23
  const modulesPath = process.cwd();
24
24
 
25
25
  const templateRoot = path.join(modulesPath, sourceModuleName);
26
- const targetModuleRoot = path.join(
27
- modulesPath,
28
- '..',
29
- 'BlueprintTemplate',
30
- 'Modules',
31
- `${sourceModuleName}Module`
32
- );
26
+ const targetModuleRoot = path.join(modulesPath, '..', 'BlueprintTemplate', 'Modules', `${sourceModuleName}Module`);
33
27
 
34
28
  const solutionFile = findSolutionFileFixed(modulesPath);
35
29
 
36
- // =====================================================
37
- // Safety checks
38
- // =====================================================
39
-
40
30
  if (!fs.existsSync(templateRoot)) {
41
31
  console.error(`❌ Source module folder not found: ${templateRoot}`);
42
32
  process.exit(1);
@@ -70,20 +60,28 @@ console.log(`🧩 Solution: ${solutionFile}`);
70
60
  fs.mkdirSync(targetModuleRoot, { recursive: true });
71
61
 
72
62
  // =====================================================
73
- // 2. Copy projects from template (NO dotnet new)
63
+ // 2. Create projects
74
64
  // =====================================================
75
65
 
76
66
  const projects = [
77
- { name: `${sourceModuleName}Module.API` },
78
- { name: `${sourceModuleName}Module.Core` },
79
- { name: `${sourceModuleName}Module.Infrastructure` },
67
+ { name: `${sourceModuleName}Module.API`, type: 'classlib' },
68
+ { name: `${sourceModuleName}Module.Core`, type: 'classlib' },
69
+ { name: `${sourceModuleName}Module.Infrastructure`, type: 'classlib' },
80
70
  ];
81
71
 
82
72
  projects.forEach(p => {
83
- console.log(`📦 Copying project from template: ${p.name}`);
73
+ console.log(`📦 Creating project: ${p.name}`);
74
+
75
+ execSync(`dotnet new ${p.type} -n ${p.name}`, {
76
+ cwd: targetModuleRoot,
77
+ stdio: 'inherit'
78
+ });
84
79
 
85
80
  const projectPath = path.join(targetModuleRoot, p.name);
86
- fs.mkdirSync(projectPath, { recursive: true });
81
+
82
+ // =====================================================
83
+ // 3. Copy template files (no csproj)
84
+ // =====================================================
87
85
 
88
86
  const templateSubFolder = getTemplateSubFolder(p.name, templateRoot);
89
87
 
@@ -97,7 +95,7 @@ projects.forEach(p => {
97
95
  });
98
96
 
99
97
  // =====================================================
100
- // 3. Add projects to solution
98
+ // 4. Add projects to solution
101
99
  // =====================================================
102
100
 
103
101
  projects.forEach(p => {
@@ -107,21 +105,12 @@ projects.forEach(p => {
107
105
  `${p.name}.csproj`
108
106
  );
109
107
 
110
- if (!fs.existsSync(csproj)) {
111
- console.warn(`⚠️ csproj not found, skipping: ${csproj}`);
112
- return;
113
- }
114
-
115
108
  console.log(`➕ Adding to solution: ${csproj}`);
116
109
  execSync(`dotnet sln "${solutionFile}" add "${csproj}"`, {
117
110
  stdio: 'inherit'
118
111
  });
119
112
  });
120
113
 
121
- // =====================================================
122
- // 4. Restore & Build
123
- // =====================================================
124
-
125
114
  console.log('🔄 Restoring NuGet packages...');
126
115
  execSync(`dotnet restore "${solutionFile}"`, { stdio: 'inherit' });
127
116
 
@@ -153,11 +142,19 @@ function copyRecursive(src, dest) {
153
142
  }
154
143
 
155
144
  const entries = fs.readdirSync(src, { withFileTypes: true });
145
+ console.log(`📄 TruongDX8 src: ${src}`);
146
+ console.log(`📄 TruongDX8 dest: ${dest}`);
156
147
 
157
148
  for (const entry of entries) {
149
+ console.log(`📄 TruongDX8 Item: ${entry.name}`);
158
150
  const srcPath = path.join(src, entry.name);
159
151
  const destPath = path.join(dest, entry.name);
160
152
 
153
+ // Do NOT overwrite .csproj generated by dotnet new
154
+ // if (entry.isFile() && entry.name.endsWith('.csproj')) {
155
+ // continue;
156
+ // }
157
+
161
158
  if (entry.isDirectory()) {
162
159
  copyRecursive(srcPath, destPath);
163
160
  } else {
@@ -167,7 +164,8 @@ function copyRecursive(src, dest) {
167
164
  }
168
165
 
169
166
  function findSolutionFileFixed(startDir) {
170
- const root = path.dirname(startDir);
167
+ // startDir = .../Modules/SomeModule
168
+ const root = path.dirname(startDir);
171
169
  const blueprintTemplate = path.join(root, 'BlueprintTemplate');
172
170
 
173
171
  if (!fs.existsSync(blueprintTemplate)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "netcore-blueprint",
3
- "version": "0.0.49",
3
+ "version": "0.0.50",
4
4
  "description": "A custom project blueprint",
5
5
  "main": "create.js",
6
6
  "bin": {