refactor: update entry points and bootstrap logic

This commit is contained in:
oboard 2026-03-31 20:00:48 +08:00
parent 2c185b8470
commit 33c1de7c75
4 changed files with 40 additions and 28 deletions

View File

@ -15,9 +15,10 @@
"node": ">=24.0.0"
},
"scripts": {
"dev": "bun run ./src/dev-entry.ts",
"start": "bun run ./src/dev-entry.ts",
"version": "bun run ./src/dev-entry.ts --version"
"dev": "bun run ./src/bootstrap-entry.ts",
"start": "bun run ./src/bootstrap-entry.ts",
"version": "bun run ./src/bootstrap-entry.ts --version",
"dev:restore-check": "bun run ./src/dev-entry.ts"
},
"dependencies": {
"@alcalzone/ansi-tokenize": "*",

5
src/bootstrap-entry.ts Normal file
View File

@ -0,0 +1,5 @@
import { ensureBootstrapMacro } from './bootstrapMacro'
ensureBootstrapMacro()
await import('./entrypoints/cli.tsx')

29
src/bootstrapMacro.ts Normal file
View File

@ -0,0 +1,29 @@
import pkg from '../package.json'
type MacroConfig = {
VERSION: string
BUILD_TIME: string
PACKAGE_URL: string
NATIVE_PACKAGE_URL: string
VERSION_CHANGELOG: string
ISSUES_EXPLAINER: string
FEEDBACK_CHANNEL: string
}
const defaultMacro: MacroConfig = {
VERSION: pkg.version,
BUILD_TIME: '',
PACKAGE_URL: pkg.name,
NATIVE_PACKAGE_URL: pkg.name,
VERSION_CHANGELOG: '',
ISSUES_EXPLAINER:
'file an issue at https://github.com/anthropics/claude-code/issues',
FEEDBACK_CHANNEL: 'github',
}
export function ensureBootstrapMacro(): void {
if (!('MACRO' in globalThis)) {
;(globalThis as typeof globalThis & { MACRO: MacroConfig }).MACRO =
defaultMacro
}
}

View File

@ -1,32 +1,9 @@
import pkg from '../package.json'
import { existsSync, readdirSync, readFileSync } from 'fs'
import { dirname, extname, join, resolve } from 'path'
import { ensureBootstrapMacro } from './bootstrapMacro'
type MacroConfig = {
VERSION: string
BUILD_TIME: string
PACKAGE_URL: string
NATIVE_PACKAGE_URL: string
VERSION_CHANGELOG: string
ISSUES_EXPLAINER: string
FEEDBACK_CHANNEL: string
}
const defaultMacro: MacroConfig = {
VERSION: pkg.version,
BUILD_TIME: '',
PACKAGE_URL: pkg.name,
NATIVE_PACKAGE_URL: pkg.name,
VERSION_CHANGELOG: '',
ISSUES_EXPLAINER:
'file an issue at https://github.com/anthropics/claude-code/issues',
FEEDBACK_CHANNEL: 'github',
}
if (!('MACRO' in globalThis)) {
;(globalThis as typeof globalThis & { MACRO: MacroConfig }).MACRO =
defaultMacro
}
ensureBootstrapMacro()
type MissingImport = {
importer: string