@winston.wan/burn-your-money 2.0.3 → 2.0.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.
Files changed (2) hide show
  1. package/install.js +66 -9
  2. package/package.json +2 -2
package/install.js CHANGED
@@ -42,11 +42,29 @@ function checkDependencies() {
42
42
  execSync('jq --version', { stdio: 'ignore' });
43
43
  success("jq is installed");
44
44
  } catch (e) {
45
- warning("jq not found! It is required for the statusline script.");
46
- log(" Please install jq manually:", colors.yellow);
47
- log(" Windows: winget install jqlang.jq", colors.yellow);
48
- log(" macOS: brew install jq", colors.yellow);
49
- log(" Linux: sudo apt-get install jq", colors.yellow);
45
+ warning("jq not found! Attempting valid auto-installation...");
46
+
47
+ try {
48
+ if (os.platform() === 'win32') {
49
+ log("Attempting to install jq via winget...", colors.cyan);
50
+ // silent install might need admin, but let's try
51
+ execSync('winget install jqlang.jq --accept-source-agreements --accept-package-agreements', { stdio: 'inherit' });
52
+ success("jq installed successfully!");
53
+ } else if (os.platform() === 'darwin') {
54
+ log("Attempting to install jq via brew...", colors.cyan);
55
+ execSync('brew install jq', { stdio: 'inherit' });
56
+ success("jq installed successfully!");
57
+ } else {
58
+ // Linux: too many variants (apt, dnf, pacman...), just warn
59
+ throw new Error("Linux auto-install not supported");
60
+ }
61
+ } catch (installError) {
62
+ error("Auto-installation failed.");
63
+ log(" Please install jq manually:", colors.yellow);
64
+ log(" Windows: winget install jqlang.jq", colors.yellow);
65
+ log(" macOS: brew install jq", colors.yellow);
66
+ log(" Linux: sudo apt-get install jq", colors.yellow);
67
+ }
50
68
  }
51
69
 
52
70
  // Check for Claude Code (informational only)
@@ -78,7 +96,7 @@ function installScripts() {
78
96
  log("Installing scripts...", colors.cyan);
79
97
  const home = getHomeDir();
80
98
  const srcDir = path.join(__dirname, 'src');
81
-
99
+
82
100
  const files = [
83
101
  { src: 'statusline.sh', dest: path.join(home, '.claude', 'statusline.sh') },
84
102
  { src: 'token-history.sh', dest: path.join(home, '.claude', 'scripts', 'token-history.sh') }
@@ -121,10 +139,49 @@ function configureSettings() {
121
139
  // accessing existing wsl path if needed? No, standard path is fine.
122
140
  // The previous implementation used `~/.claude/statusline.sh`.
123
141
  // Claude might process `~`? Let's stick to what the bash script did: `~/.claude/statusline.sh`
124
-
142
+
143
+ // Configure command based on platform
144
+ let commandEnv = "~/.claude/statusline.sh";
145
+
146
+ if (os.platform() === 'win32') {
147
+ // On Windows, expand home directory and ensure forward slashes
148
+ const scriptPath = path.join(home, '.claude', 'statusline.sh').replace(/\\/g, '/');
149
+
150
+ // Robust bash detection: try Git Bash first, then fallback to 'bash'
151
+ let bashPath = 'bash';
152
+ // Common Git Bash locations
153
+ const gitBashPaths = [
154
+ 'C:/Program Files/Git/bin/bash.exe',
155
+ 'C:/Program Files/Git/cmd/bash.exe',
156
+ 'C:/Program Files (x86)/Git/bin/bash.exe',
157
+ 'C:/Program Files (x86)/Git/cmd/bash.exe'
158
+ ];
159
+
160
+ let foundBash = false;
161
+ for (const p of gitBashPaths) {
162
+ if (fs.existsSync(p)) {
163
+ bashPath = `"${p}"`;
164
+ foundBash = true;
165
+ break;
166
+ }
167
+ }
168
+
169
+ if (!foundBash) {
170
+ // Warn if we are falling back to potentially broken 'bash' (WSL default)
171
+ try {
172
+ execSync('bash --version', { stdio: 'ignore' });
173
+ } catch (e) {
174
+ warning("Warning: 'bash' command seems broken on this system.");
175
+ log(" Recommend installing Git Bash: https://git-scm.com/download/win", colors.yellow);
176
+ }
177
+ }
178
+
179
+ commandEnv = `${bashPath} "${scriptPath}"`;
180
+ }
181
+
125
182
  settings.statusLine = {
126
183
  type: "command",
127
- command: "~/.claude/statusline.sh"
184
+ command: commandEnv
128
185
  };
129
186
 
130
187
  try {
@@ -143,7 +200,7 @@ function main() {
143
200
  createDirectories();
144
201
  installScripts();
145
202
  configureSettings();
146
-
203
+
147
204
  log("\nāœ… Installation complete!", colors.green);
148
205
  log("Please restart Claude Code to see the status bar.\n", colors.cyan);
149
206
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@winston.wan/burn-your-money",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "šŸ’ø Burn Your Money - å®žę—¶ę˜¾ē¤ŗ Claude Code ēš„ token ę¶ˆč€—ļ¼Œēœ‹ē€ä½ ēš„é’±åŒ…ē‡ƒēƒ§ļ¼",
5
5
  "main": "src/statusline.sh",
6
6
  "bin": {
@@ -29,4 +29,4 @@
29
29
  "url": "https://github.com/winston-wwzhen/burn-your-money/issues"
30
30
  },
31
31
  "homepage": "https://github.com/winston-wwzhen/burn-your-money#readme"
32
- }
32
+ }