bonzai-burn 1.0.7 ā 1.0.9
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/package.json +3 -2
- package/payload-bonzai/config.json +4 -0
- package/payload-bonzai/specs.md +8 -0
- package/src/btrim.js +10 -37
- package/src/index.js +10 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bonzai-burn",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "Git branch-based cleanup tool with btrim and brevert commands",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"node": ">=16.0.0"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
|
-
"src"
|
|
22
|
+
"src",
|
|
23
|
+
"payload-bonzai"
|
|
23
24
|
]
|
|
24
25
|
}
|
package/src/btrim.js
CHANGED
|
@@ -12,30 +12,8 @@ const BONZAI_DIR = 'bonzai';
|
|
|
12
12
|
const SPECS_FILE = 'specs.md';
|
|
13
13
|
const CONFIG_FILE = 'config.json';
|
|
14
14
|
|
|
15
|
-
// Template folder in the package
|
|
16
|
-
const TEMPLATE_DIR = join(__dirname, '..', 'bonzai');
|
|
17
|
-
|
|
18
|
-
function getTemplate(filename) {
|
|
19
|
-
const templatePath = join(TEMPLATE_DIR, filename);
|
|
20
|
-
if (fs.existsSync(templatePath)) {
|
|
21
|
-
return fs.readFileSync(templatePath, 'utf-8');
|
|
22
|
-
}
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const DEFAULT_SPECS = `# Bonzai Specs
|
|
27
|
-
|
|
28
|
-
Define your cleanup requirements below. btrim will follow these instructions.
|
|
29
|
-
|
|
30
|
-
## Requirements:
|
|
31
|
-
- Remove unused imports
|
|
32
|
-
- Delete files matching pattern "*.tmp"
|
|
33
|
-
- Clean up console.log statements
|
|
34
|
-
`;
|
|
35
|
-
|
|
36
|
-
const DEFAULT_CONFIG = {
|
|
37
|
-
headlessClaude: true
|
|
38
|
-
};
|
|
15
|
+
// Template folder in the package (ships as payload-bonzai, copied as bonzai)
|
|
16
|
+
const TEMPLATE_DIR = join(__dirname, '..', 'payload-bonzai');
|
|
39
17
|
|
|
40
18
|
function initializeBonzai() {
|
|
41
19
|
const bonzaiPath = join(process.cwd(), BONZAI_DIR);
|
|
@@ -44,22 +22,19 @@ function initializeBonzai() {
|
|
|
44
22
|
|
|
45
23
|
// Check if bonzai/ folder exists
|
|
46
24
|
if (!fs.existsSync(bonzaiPath)) {
|
|
47
|
-
// Create bonzai/ folder
|
|
48
25
|
fs.mkdirSync(bonzaiPath, { recursive: true });
|
|
49
26
|
console.log(`š Created ${BONZAI_DIR}/ folder`);
|
|
50
27
|
}
|
|
51
28
|
|
|
52
|
-
//
|
|
29
|
+
// Copy specs.md from package template
|
|
53
30
|
if (!fs.existsSync(specsPath)) {
|
|
54
|
-
|
|
55
|
-
fs.writeFileSync(specsPath, specsContent);
|
|
31
|
+
fs.copyFileSync(join(TEMPLATE_DIR, SPECS_FILE), specsPath);
|
|
56
32
|
console.log(`š Created ${BONZAI_DIR}/${SPECS_FILE}`);
|
|
57
33
|
}
|
|
58
34
|
|
|
59
|
-
//
|
|
35
|
+
// Copy config.json from package template
|
|
60
36
|
if (!fs.existsSync(configPath)) {
|
|
61
|
-
|
|
62
|
-
fs.writeFileSync(configPath, configContent);
|
|
37
|
+
fs.copyFileSync(join(TEMPLATE_DIR, CONFIG_FILE), configPath);
|
|
63
38
|
console.log(`āļø Created ${BONZAI_DIR}/${CONFIG_FILE}`);
|
|
64
39
|
console.log(`\nā ļø Please edit ${BONZAI_DIR}/${SPECS_FILE} to define your cleanup rules before running btrim.\n`);
|
|
65
40
|
process.exit(0);
|
|
@@ -77,14 +52,12 @@ function ensureBonzaiDir() {
|
|
|
77
52
|
}
|
|
78
53
|
|
|
79
54
|
if (!fs.existsSync(specsPath)) {
|
|
80
|
-
|
|
81
|
-
fs.writeFileSync(specsPath, specsContent);
|
|
55
|
+
fs.copyFileSync(join(TEMPLATE_DIR, SPECS_FILE), specsPath);
|
|
82
56
|
console.log(`š Created ${BONZAI_DIR}/${SPECS_FILE} - edit this file to define your cleanup specs\n`);
|
|
83
57
|
}
|
|
84
58
|
|
|
85
59
|
if (!fs.existsSync(configPath)) {
|
|
86
|
-
|
|
87
|
-
fs.writeFileSync(configPath, configContent);
|
|
60
|
+
fs.copyFileSync(join(TEMPLATE_DIR, CONFIG_FILE), configPath);
|
|
88
61
|
console.log(`āļø Created ${BONZAI_DIR}/${CONFIG_FILE}\n`);
|
|
89
62
|
}
|
|
90
63
|
|
|
@@ -94,9 +67,9 @@ function ensureBonzaiDir() {
|
|
|
94
67
|
function loadConfig(configPath) {
|
|
95
68
|
try {
|
|
96
69
|
const content = fs.readFileSync(configPath, 'utf-8');
|
|
97
|
-
return
|
|
70
|
+
return JSON.parse(content);
|
|
98
71
|
} catch {
|
|
99
|
-
return
|
|
72
|
+
return { headlessClaude: true };
|
|
100
73
|
}
|
|
101
74
|
}
|
|
102
75
|
|
package/src/index.js
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { existsSync, mkdirSync,
|
|
3
|
-
import { join } from 'path';
|
|
2
|
+
import { existsSync, mkdirSync, copyFileSync } from 'fs';
|
|
3
|
+
import { join, dirname } from 'path';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
4
5
|
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const DEFAULT_SPECS = `# Bonzai Specs
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = dirname(__filename);
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
## Example:
|
|
13
|
-
- Remove unused imports
|
|
14
|
-
- Delete files matching pattern "*.tmp"
|
|
15
|
-
- Clean up console.log statements
|
|
16
|
-
`;
|
|
9
|
+
const BONZAI_DIR = 'bonzai';
|
|
10
|
+
const TEMPLATE_DIR = join(__dirname, '..', 'payload-bonzai');
|
|
17
11
|
|
|
18
12
|
function init() {
|
|
19
13
|
const currentDir = process.cwd();
|
|
20
14
|
const bonzaiPath = join(currentDir, BONZAI_DIR);
|
|
21
|
-
const specsPath = join(bonzaiPath, SPECS_FILE);
|
|
22
15
|
|
|
23
16
|
if (existsSync(bonzaiPath)) {
|
|
24
17
|
console.log(`š ${BONZAI_DIR}/ already exists`);
|
|
@@ -26,8 +19,9 @@ function init() {
|
|
|
26
19
|
}
|
|
27
20
|
|
|
28
21
|
mkdirSync(bonzaiPath, { recursive: true });
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
copyFileSync(join(TEMPLATE_DIR, 'specs.md'), join(bonzaiPath, 'specs.md'));
|
|
23
|
+
copyFileSync(join(TEMPLATE_DIR, 'config.json'), join(bonzaiPath, 'config.json'));
|
|
24
|
+
console.log(`š Created ${BONZAI_DIR}/ folder with specs.md and config.json`);
|
|
31
25
|
console.log(`š Edit ${BONZAI_DIR}/specs.md to define your cleanup rules`);
|
|
32
26
|
console.log(`š„ Run 'btrim' to start a cleanup session`);
|
|
33
27
|
}
|