From 5b333e2246b98ea05f22c9d59402b8e0cee88186 Mon Sep 17 00:00:00 2001 From: claude-code-best Date: Mon, 4 May 2026 23:44:47 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BB=8E=20package.json=20?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E8=AF=BB=E5=8F=96=E7=89=88=E6=9C=AC=E5=8F=B7?= =?UTF-8?q?=EF=BC=8C=E9=81=BF=E5=85=8D=E7=89=88=E6=9C=AC=E6=BC=82=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.7 --- scripts/defines.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/defines.ts b/scripts/defines.ts index 6098d1733..3249e6809 100644 --- a/scripts/defines.ts +++ b/scripts/defines.ts @@ -1,13 +1,23 @@ +import { readFileSync } from 'node:fs' +import { resolve, dirname } from 'node:path' +import { fileURLToPath } from 'node:url' + +const __dirname = dirname(fileURLToPath(import.meta.url)) +const pkgPath = resolve(__dirname, '..', 'package.json') +const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8')) + /** * Shared MACRO define map used by both dev.ts (runtime -d flags) * and build.ts (Bun.build define option). * * Each value is a JSON-stringified expression that replaces the * corresponding MACRO.* identifier at transpile / bundle time. + * + * VERSION is read from package.json to avoid version drift. */ export function getMacroDefines(): Record { return { - 'MACRO.VERSION': JSON.stringify('2.1.888'), + 'MACRO.VERSION': JSON.stringify(pkg.version), 'MACRO.BUILD_TIME': JSON.stringify(new Date().toISOString()), 'MACRO.FEEDBACK_CHANNEL': JSON.stringify(''), 'MACRO.ISSUES_EXPLAINER': JSON.stringify(''),