devbonzai 2.1.2 → 2.1.4

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,30 +4,18 @@ const fs = require('fs');
4
4
  const path = require('path');
5
5
  const { spawn, exec } = require('child_process');
6
6
 
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
- }
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
+ );
26
14
 
27
15
  async function main() {
28
16
  const currentDir = process.cwd();
29
17
  const bonzaiDir = path.join(currentDir, 'bonzai');
30
- const templatesDir = path.join(__dirname, 'templates');
18
+ const receiverPath = path.join(bonzaiDir, 'receiver.js');
31
19
 
32
20
  console.log('🚀 Setting up local file server...');
33
21
 
@@ -37,14 +25,21 @@ async function main() {
37
25
  fs.mkdirSync(bonzaiDir);
38
26
  }
39
27
 
40
- // Copy all template files to bonzai directory
41
- console.log('📝 Copying server files...');
42
- copyDirSync(templatesDir, bonzaiDir);
28
+ // Write receiver.js to current directory (root level)
29
+ console.log('📝 Writing receiver.js...');
30
+ fs.writeFileSync(receiverPath, RECEIVER_JS_CONTENT);
43
31
 
44
- // Make receiver.js executable
45
- const receiverPath = path.join(bonzaiDir, 'receiver.js');
32
+ // Make it executable
46
33
  fs.chmodSync(receiverPath, '755');
47
34
 
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
+
48
43
  console.log('📦 Installing dependencies...');
49
44
 
50
45
  // Check if package.json exists in bonzai directory
@@ -58,7 +53,7 @@ async function main() {
58
53
  name: "bonzai-server",
59
54
  version: "1.0.0",
60
55
  description: "Dependencies for devbonzai file server",
61
- main: "receiver.js",
56
+ main: "../receiver.js",
62
57
  scripts: {
63
58
  test: "echo \"Error: no test specified\" && exit 1"
64
59
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devbonzai",
3
- "version": "2.1.2",
3
+ "version": "2.1.4",
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": {