devbonzai 2.1.1 → 2.1.2

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 CHANGED
@@ -4,18 +4,30 @@ const fs = require('fs');
4
4
  const path = require('path');
5
5
  const { spawn, exec } = require('child_process');
6
6
 
7
- // Read templates at runtime from the templates directory
8
- const IGNORE_FILE_CONTENT = fs.readFileSync(
9
- path.join(__dirname, 'templates', 'ignore.txt'), 'utf8'
10
- );
11
- const RECEIVER_JS_CONTENT = fs.readFileSync(
12
- path.join(__dirname, 'templates', 'receiver.js'), 'utf8'
13
- );
7
+ // Helper to copy directory recursively
8
+ function copyDirSync(src, dest) {
9
+ if (!fs.existsSync(dest)) {
10
+ fs.mkdirSync(dest, { recursive: true });
11
+ }
12
+
13
+ const entries = fs.readdirSync(src, { withFileTypes: true });
14
+
15
+ for (const entry of entries) {
16
+ const srcPath = path.join(src, entry.name);
17
+ const destPath = path.join(dest, entry.name);
18
+
19
+ if (entry.isDirectory()) {
20
+ copyDirSync(srcPath, destPath);
21
+ } else {
22
+ fs.copyFileSync(srcPath, destPath);
23
+ }
24
+ }
25
+ }
14
26
 
15
27
  async function main() {
16
28
  const currentDir = process.cwd();
17
29
  const bonzaiDir = path.join(currentDir, 'bonzai');
18
- const receiverPath = path.join(bonzaiDir, 'receiver.js');
30
+ const templatesDir = path.join(__dirname, 'templates');
19
31
 
20
32
  console.log('🚀 Setting up local file server...');
21
33
 
@@ -25,21 +37,14 @@ async function main() {
25
37
  fs.mkdirSync(bonzaiDir);
26
38
  }
27
39
 
28
- // Write receiver.js to current directory (root level)
29
- console.log('📝 Writing receiver.js...');
30
- fs.writeFileSync(receiverPath, RECEIVER_JS_CONTENT);
40
+ // Copy all template files to bonzai directory
41
+ console.log('📝 Copying server files...');
42
+ copyDirSync(templatesDir, bonzaiDir);
31
43
 
32
- // Make it executable
44
+ // Make receiver.js executable
45
+ const receiverPath = path.join(bonzaiDir, 'receiver.js');
33
46
  fs.chmodSync(receiverPath, '755');
34
47
 
35
- // Write .ignore file in bonzai directory
36
- const ignoreTargetPath = path.join(bonzaiDir, '.ignore');
37
-
38
- if (!fs.existsSync(ignoreTargetPath)) {
39
- console.log('📝 Writing .ignore file...');
40
- fs.writeFileSync(ignoreTargetPath, IGNORE_FILE_CONTENT);
41
- }
42
-
43
48
  console.log('📦 Installing dependencies...');
44
49
 
45
50
  // Check if package.json exists in bonzai directory
@@ -53,7 +58,7 @@ async function main() {
53
58
  name: "bonzai-server",
54
59
  version: "1.0.0",
55
60
  description: "Dependencies for devbonzai file server",
56
- main: "../receiver.js",
61
+ main: "receiver.js",
57
62
  scripts: {
58
63
  test: "echo \"Error: no test specified\" && exit 1"
59
64
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devbonzai",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "Quickly set up a local file server in any repository for browser-based file access",
5
5
  "main": "cli.js",
6
6
  "bin": {