bonzai-burn 1.0.1 ā 1.0.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/dist/postinstall.d.ts +2 -0
- package/dist/postinstall.js +58 -0
- package/package.json +3 -2
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const BONZAI_DIR = 'bonzai';
|
|
7
|
+
const SPECS_FILE = 'specs.md';
|
|
8
|
+
const DEFAULT_SPECS = `# Bonzai Specs
|
|
9
|
+
|
|
10
|
+
Define your cleanup requirements below. btrim will follow these instructions.
|
|
11
|
+
|
|
12
|
+
## Example:
|
|
13
|
+
- Remove unused imports
|
|
14
|
+
- Delete files matching pattern "*.tmp"
|
|
15
|
+
- Clean up console.log statements
|
|
16
|
+
`;
|
|
17
|
+
function findProjectRoot() {
|
|
18
|
+
// npm sets INIT_CWD to the directory where npm was invoked
|
|
19
|
+
const initCwd = process.env.INIT_CWD;
|
|
20
|
+
if (initCwd && (0, fs_1.existsSync)((0, path_1.join)(initCwd, 'package.json'))) {
|
|
21
|
+
return initCwd;
|
|
22
|
+
}
|
|
23
|
+
// Fallback: try to find project root from cwd
|
|
24
|
+
let current = process.cwd();
|
|
25
|
+
// If we're in node_modules, go up to find project root
|
|
26
|
+
if (current.includes('node_modules')) {
|
|
27
|
+
const nodeModulesIndex = current.lastIndexOf('node_modules');
|
|
28
|
+
const projectRoot = current.substring(0, nodeModulesIndex - 1);
|
|
29
|
+
if ((0, fs_1.existsSync)((0, path_1.join)(projectRoot, 'package.json'))) {
|
|
30
|
+
return projectRoot;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
function postinstall() {
|
|
36
|
+
const projectRoot = findProjectRoot();
|
|
37
|
+
if (!projectRoot) {
|
|
38
|
+
// Silently exit if we can't find project root (e.g., global install)
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const bonzaiPath = (0, path_1.join)(projectRoot, BONZAI_DIR);
|
|
42
|
+
const specsPath = (0, path_1.join)(bonzaiPath, SPECS_FILE);
|
|
43
|
+
// Don't overwrite existing setup
|
|
44
|
+
if ((0, fs_1.existsSync)(bonzaiPath)) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
(0, fs_1.mkdirSync)(bonzaiPath, { recursive: true });
|
|
49
|
+
(0, fs_1.writeFileSync)(specsPath, DEFAULT_SPECS);
|
|
50
|
+
console.log(`\nš Created ${BONZAI_DIR}/ folder with specs.md`);
|
|
51
|
+
console.log(`š Edit ${BONZAI_DIR}/specs.md to define your cleanup rules`);
|
|
52
|
+
console.log(`š„ Run 'btrim' to start a cleanup session\n`);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
// Silently fail - don't break the install
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
postinstall();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bonzai-burn",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Git branch-based cleanup tool with btrim and brevert commands",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
12
|
"build": "tsc",
|
|
13
|
-
"prepublishOnly": "npm run build"
|
|
13
|
+
"prepublishOnly": "npm run build",
|
|
14
|
+
"postinstall": "node dist/postinstall.js"
|
|
14
15
|
},
|
|
15
16
|
"keywords": [
|
|
16
17
|
"git",
|