netcore-blueprint 0.0.90 → 0.0.92
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.
- package/bin/create-assistant.js +10 -40
- package/lib/replacer.js +19 -0
- package/package.json +1 -1
package/bin/create-assistant.js
CHANGED
|
@@ -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
|
|
10
|
+
const sourceModuleName = "AiAssistantModule";
|
|
27
11
|
|
|
28
|
-
const
|
|
29
|
-
const
|
|
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
|
|
20
|
+
const destinationModulePath = path.join(destinationRoot, `${sourceModuleName}`);
|
|
37
21
|
|
|
38
22
|
// =======================
|
|
39
23
|
// Guards
|
|
40
24
|
// =======================
|
|
41
25
|
|
|
42
|
-
if (!fs.existsSync(
|
|
43
|
-
console.error(`❌ Source
|
|
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(
|
|
48
|
-
console.error(`❌ Destination
|
|
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
|
-
|
|
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);
|