refactor: align macro bootstrap with cli entry

This commit is contained in:
2026-04-03 13:59:27 +08:00
parent d7bb164a05
commit 4eb053eef5
2 changed files with 21 additions and 25 deletions

View File

@@ -1,16 +1,24 @@
import { feature } from 'bun:bundle';
const CLI_MACRO =
typeof MACRO !== 'undefined'
? MACRO
: {
VERSION: 'dev',
BUILD_TIME: '',
PACKAGE_URL: '@anthropic-ai/claude-code',
ISSUES_EXPLAINER:
'https://docs.anthropic.com/en/docs/claude-code/feedback',
FEEDBACK_CHANNEL: 'github',
};
// Define MACRO global for development (normally injected by bun build --define)
if (typeof MACRO === 'undefined') {
(globalThis as typeof globalThis & {
MACRO: {
VERSION: string
BUILD_TIME: string
PACKAGE_URL: string
ISSUES_EXPLAINER: string
FEEDBACK_CHANNEL: string
}
}).MACRO = {
VERSION: '2.1.88-dev',
BUILD_TIME: new Date().toISOString(),
PACKAGE_URL: 'claude-code-recover',
ISSUES_EXPLAINER:
'https://docs.anthropic.com/en/docs/claude-code/feedback',
FEEDBACK_CHANNEL: 'github',
};
}
// Bugfix for corepack auto-pinning, which adds yarnpkg to peoples' package.jsons
// eslint-disable-next-line custom-rules/no-top-level-side-effects
@@ -49,7 +57,7 @@ async function main(): Promise<void> {
if (args.length === 1 && (args[0] === '--version' || args[0] === '-v' || args[0] === '-V')) {
// MACRO.VERSION is inlined at build time
// biome-ignore lint/suspicious/noConsole:: intentional console output
console.log(`${CLI_MACRO.VERSION} (Claude Code)`);
console.log(`${MACRO.VERSION} (Claude Code)`);
return;
}