@88code/byebyecode 1.1.13 → 1.1.15

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/bin/byebyecode.js +83 -19
  2. package/package.json +6 -6
package/bin/byebyecode.js CHANGED
@@ -181,19 +181,10 @@ function checkVersionAndNotify() {
181
181
  const noticeFile = path.join(configDir, '.update_notice');
182
182
 
183
183
  try {
184
- // 频率限制:每小时最多检查一次
185
- if (fs.existsSync(versionCheckFile)) {
186
- const lastCheck = parseInt(fs.readFileSync(versionCheckFile, 'utf8'));
187
- const hoursSinceCheck = (Date.now() - lastCheck) / (1000 * 60 * 60);
188
-
189
- if (hoursSinceCheck < 1) {
190
- // 如果已有待更新提示,显示它
191
- if (fs.existsSync(noticeFile)) {
192
- const notice = fs.readFileSync(noticeFile, 'utf8');
193
- console.error(notice);
194
- }
195
- return;
196
- }
184
+ // 每次都检查,但如果已有提示则显示
185
+ if (fs.existsSync(noticeFile)) {
186
+ const notice = fs.readFileSync(noticeFile, 'utf8');
187
+ console.error(notice);
197
188
  }
198
189
 
199
190
  // 记录检查时间
@@ -302,13 +293,86 @@ if (!packageName) {
302
293
  }
303
294
 
304
295
  const binaryName = platform === 'win32' ? 'byebyecode.exe' : 'byebyecode';
305
- const binaryPath = path.join(__dirname, '..', 'node_modules', packageName, binaryName);
296
+ // 步骤 3: 确定二进制文件路径
297
+ // 优先级:
298
+ // 1. ~/.claude/byebyecode/byebyecode (由 postinstall 安装或手动安装)
299
+ // 2. node_modules 中的对应包 (支持 npm/yarn/pnpm)
300
+
301
+ const globalConfigDir = path.join(os.homedir(), '.claude', 'byebyecode');
302
+ const globalBinaryPath = path.join(globalConfigDir, binaryName);
303
+
304
+ // 查找二进制文件的辅助函数 (支持 pnpm)
305
+ const findBinaryPathInNodeModules = () => {
306
+ const possiblePaths = [
307
+ // npm/yarn: nested in node_modules
308
+ path.join(__dirname, '..', 'node_modules', packageName, binaryName),
309
+ // pnpm: try require.resolve first
310
+ (() => {
311
+ try {
312
+ const packagePath = require.resolve(packageName + '/package.json');
313
+ return path.join(path.dirname(packagePath), binaryName);
314
+ } catch {
315
+ return null;
316
+ }
317
+ })(),
318
+ // pnpm: flat structure fallback with version detection
319
+ (() => {
320
+ const currentPath = __dirname;
321
+ const pnpmMatch = currentPath.match(/(.+\.pnpm)[\\/]([^\\//]+)[\\/]/);
322
+ if (pnpmMatch) {
323
+ const pnpmRoot = pnpmMatch[1];
324
+ const packageNameEncoded = packageName.replace('/', '+');
325
+
326
+ try {
327
+ // Try to find any version of the package
328
+ const pnpmContents = fs.readdirSync(pnpmRoot);
329
+ const packagePattern = new RegExp(`^${packageNameEncoded.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}@`);
330
+ const matchingPackage = pnpmContents.find(dir => packagePattern.test(dir));
331
+
332
+ if (matchingPackage) {
333
+ return path.join(pnpmRoot, matchingPackage, 'node_modules', packageName, binaryName);
334
+ }
335
+ } catch {
336
+ // Fallback to current behavior if directory reading fails
337
+ }
338
+ }
339
+ return null;
340
+ })()
341
+ ].filter(p => p !== null);
342
+
343
+ for (const testPath of possiblePaths) {
344
+ if (fs.existsSync(testPath)) {
345
+ return testPath;
346
+ }
347
+ }
348
+ return null;
349
+ };
350
+
351
+ let binaryPath;
352
+
353
+ // 1. 检查全局配置目录
354
+ if (fs.existsSync(globalBinaryPath)) {
355
+ binaryPath = globalBinaryPath;
356
+ } else {
357
+ // 2. 检查 node_modules
358
+ binaryPath = findBinaryPathInNodeModules();
359
+ }
306
360
 
307
- if (!fs.existsSync(binaryPath)) {
308
- console.error(`Error: Binary not found at ${binaryPath}`);
309
- console.error('This might indicate a failed installation or unsupported platform.');
310
- console.error('请尝试重新安装: npm install -g @88code/byebyecode');
361
+ if (!binaryPath || !fs.existsSync(binaryPath)) {
362
+ console.error(`Error: Binary not found for platform ${platformKey}`);
311
363
  console.error(`Expected package: ${packageName}`);
364
+ console.error(`Expected binary: ${binaryName}`);
365
+ console.error('');
366
+ console.error('Troubleshooting:');
367
+ console.error('1. Try reinstalling with force:');
368
+ console.error(' npm install -g @88code/byebyecode --force');
369
+ console.error('');
370
+ console.error('2. If using pnpm, try installing with --shamefully-hoist:');
371
+ console.error(' pnpm add -g @88code/byebyecode --shamefully-hoist');
372
+ console.error('');
373
+ console.error('3. Manually download the binary from GitHub Releases and place it at:');
374
+ console.error(` ${globalBinaryPath}`);
375
+
312
376
  process.exit(1);
313
377
  }
314
378
 
@@ -321,4 +385,4 @@ const result = spawnSync(binaryPath, process.argv.slice(2), {
321
385
  // 步骤 4: 执行完毕后,异步检查版本
322
386
  setImmediate(() => checkVersionAndNotify());
323
387
 
324
- process.exit(result.status || 0);
388
+ process.exitCode = result.status || 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@88code/byebyecode",
3
- "version": "1.1.13",
3
+ "version": "1.1.15",
4
4
  "description": "CCometixLine - High-performance Claude Code StatusLine tool",
5
5
  "bin": {
6
6
  "byebyecode": "./bin/byebyecode.js"
@@ -9,11 +9,11 @@
9
9
  "postinstall": "node scripts/postinstall.js"
10
10
  },
11
11
  "optionalDependencies": {
12
- "@88code/byebyecode-darwin-x64": "1.1.13",
13
- "@88code/byebyecode-darwin-arm64": "1.1.13",
14
- "@88code/byebyecode-linux-x64": "1.1.13",
15
- "@88code/byebyecode-linux-x64-musl": "1.1.13",
16
- "@88code/byebyecode-win32-x64": "1.1.13"
12
+ "@88code/byebyecode-darwin-x64": "1.1.15",
13
+ "@88code/byebyecode-darwin-arm64": "1.1.15",
14
+ "@88code/byebyecode-linux-x64": "1.1.15",
15
+ "@88code/byebyecode-linux-x64-musl": "1.1.15",
16
+ "@88code/byebyecode-win32-x64": "1.1.15"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",