devbonzai 2.1.7 → 2.1.8
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/cli.js +40 -0
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -11,6 +11,29 @@ const IGNORE_FILE_CONTENT = fs.readFileSync(
|
|
|
11
11
|
const RECEIVER_JS_CONTENT = fs.readFileSync(
|
|
12
12
|
path.join(__dirname, 'templates', 'receiver.js'), 'utf8'
|
|
13
13
|
);
|
|
14
|
+
const CONFIG_JS_CONTENT = fs.readFileSync(
|
|
15
|
+
path.join(__dirname, 'templates', 'config.js'), 'utf8'
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
// Helper function to recursively copy directory
|
|
19
|
+
function copyDirectory(src, dest) {
|
|
20
|
+
if (!fs.existsSync(dest)) {
|
|
21
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
25
|
+
|
|
26
|
+
for (const entry of entries) {
|
|
27
|
+
const srcPath = path.join(src, entry.name);
|
|
28
|
+
const destPath = path.join(dest, entry.name);
|
|
29
|
+
|
|
30
|
+
if (entry.isDirectory()) {
|
|
31
|
+
copyDirectory(srcPath, destPath);
|
|
32
|
+
} else {
|
|
33
|
+
fs.copyFileSync(srcPath, destPath);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
14
37
|
|
|
15
38
|
async function main() {
|
|
16
39
|
const currentDir = process.cwd();
|
|
@@ -32,6 +55,23 @@ async function main() {
|
|
|
32
55
|
// Make it executable
|
|
33
56
|
fs.chmodSync(receiverPath, '755');
|
|
34
57
|
|
|
58
|
+
// Write config.js
|
|
59
|
+
console.log('📝 Writing config.js...');
|
|
60
|
+
const configPath = path.join(bonzaiDir, 'config.js');
|
|
61
|
+
fs.writeFileSync(configPath, CONFIG_JS_CONTENT);
|
|
62
|
+
|
|
63
|
+
// Copy handlers directory
|
|
64
|
+
console.log('📝 Copying handlers directory...');
|
|
65
|
+
const handlersSrc = path.join(__dirname, 'templates', 'handlers');
|
|
66
|
+
const handlersDest = path.join(bonzaiDir, 'handlers');
|
|
67
|
+
copyDirectory(handlersSrc, handlersDest);
|
|
68
|
+
|
|
69
|
+
// Copy utils directory
|
|
70
|
+
console.log('📝 Copying utils directory...');
|
|
71
|
+
const utilsSrc = path.join(__dirname, 'templates', 'utils');
|
|
72
|
+
const utilsDest = path.join(bonzaiDir, 'utils');
|
|
73
|
+
copyDirectory(utilsSrc, utilsDest);
|
|
74
|
+
|
|
35
75
|
// Write .ignore file in bonzai directory
|
|
36
76
|
const ignoreTargetPath = path.join(bonzaiDir, '.ignore');
|
|
37
77
|
|