netcore-blueprint 0.0.89 → 0.0.91

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.
@@ -12,7 +12,7 @@ How to use the app
12
12
 
13
13
  3. Mock Data
14
14
  - Tools → NuGet Package Manager → Package Manager Console
15
- - Default project: catalog.Infra
15
+ - Default project: Shared.Infrastructure
16
16
  - Xóa Migration cũ
17
17
  - Add-Migration SeedInitialData
18
18
  - Update-Database
@@ -2,71 +2,41 @@
2
2
 
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
- const { buildReplaceMap, copyAndRenameFiles } = require('../lib/replacer');
6
-
7
- // =======================
8
- // Args
9
- // =======================
10
- // Usage:
11
- // create-assistant BlogWriter
12
- // =======================
13
-
14
- const newAssistantName = process.argv[2];
15
-
16
- if (!newAssistantName) {
17
- console.error("❌ Usage: create-assistant <AssistantName>");
18
- console.error(" Example: create-assistant BlogWriter");
19
- process.exit(1);
20
- }
21
5
 
22
6
  // =======================
23
7
  // Template source
24
8
  // =======================
25
9
 
26
- const sourceAssistantName = "AIAssistantModule";
10
+ const sourceModuleName = "AiAssistantModule";
27
11
 
28
- const assistantsTemplateRoot = path.join(__dirname, "..", "Modules");
29
- const sourceAssistantPath = path.join(assistantsTemplateRoot, sourceAssistantName);
12
+ const modulesTemplateRoot = path.join(__dirname, "..", "Modules");
13
+ const sourceModulePath = path.join(modulesTemplateRoot, `${sourceModuleName}`);
30
14
 
31
15
  // =======================
32
16
  // Destination
33
17
  // =======================
34
18
 
35
19
  const destinationRoot = process.cwd();
36
- const destinationAssistantPath = path.join(destinationRoot, newAssistantName);
20
+ const destinationModulePath = destinationRoot;
37
21
 
38
22
  // =======================
39
23
  // Guards
40
24
  // =======================
41
25
 
42
- if (!fs.existsSync(sourceAssistantPath)) {
43
- console.error(`❌ Source assistant not found: ${sourceAssistantPath}`);
26
+ if (!fs.existsSync(sourceModulePath)) {
27
+ console.error(`❌ Source module not found: ${sourceModulePath}`);
44
28
  process.exit(1);
45
29
  }
46
30
 
47
- if (fs.existsSync(destinationAssistantPath)) {
48
- console.error(`❌ Destination assistant already exists: ${destinationAssistantPath}`);
31
+ if (fs.existsSync(destinationModulePath)) {
32
+ console.error(`❌ Destination module already exists: ${destinationModulePath}`);
49
33
  process.exit(1);
50
34
  }
51
35
 
52
- // =======================
53
- // Replace Map
54
- // =======================
55
-
56
-
57
- const replaceMap = buildReplaceMap({
58
- sourceModuleName: sourceAssistantName,
59
- newModuleName: newAssistantName
60
- });
61
-
62
- console.log(`📦 Creating assistant: ${newAssistantName}`);
63
- console.log(`📁 From template: ${sourceAssistantPath}`);
64
- console.log(`📁 To: ${destinationAssistantPath}`);
36
+ console.log(`📦 Creating assistant module`);
65
37
 
66
38
  // =======================
67
39
  // Run
68
40
  // =======================
69
41
 
70
- copyAndRenameFiles(sourceAssistantPath, destinationAssistantPath, replaceMap);
71
-
72
- console.log(`🎉 Assistant "${newAssistantName}" created successfully!`);
42
+ createModule(sourceModulePath, destinationModulePath);
package/lib/replacer.js CHANGED
@@ -48,6 +48,25 @@ function copyAndRenameFiles(src, dest, replaceMap) {
48
48
  }
49
49
  }
50
50
 
51
+ function createModule(src, dest) {
52
+ const stat = fs.lstatSync(src);
53
+
54
+ if (stat.isDirectory()) {
55
+ fs.mkdirSync(dest, { recursive: true });
56
+
57
+ const entries = fs.readdirSync(src, { withFileTypes: true });
58
+
59
+ for (const entry of entries) {
60
+ const srcPath = path.join(src, entry.name);
61
+ const destPath = path.join(dest, entry.name);
62
+
63
+ createModule(srcPath, destPath);
64
+ }
65
+ } else {
66
+ fs.copyFileSync(src, dest);
67
+ }
68
+ }
69
+
51
70
  function findSolutionFileFixed(startDir, targetFolder) {
52
71
  // startDir = .../Modules/SomeModule
53
72
  const root = path.dirname(startDir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "netcore-blueprint",
3
- "version": "0.0.89",
3
+ "version": "0.0.91",
4
4
  "description": "A custom project blueprint",
5
5
  "main": "create.js",
6
6
  "bin": {