feat: 新增版本管理系统,重构 /health → /api/meta

This commit is contained in:
2026-05-24 23:32:19 +08:00
parent bc54f8352a
commit 7dc3a270ae
23 changed files with 450 additions and 111 deletions

View File

@@ -3,11 +3,13 @@ import { join, relative, sep } from "node:path";
import { fileURLToPath } from "node:url";
import { APP } from "../src/shared/app";
import { validateVersion } from "./bump-version-logic";
const projectRoot = fileURLToPath(new URL("..", import.meta.url));
const distWebDir = join(projectRoot, "dist/web");
const buildDir = join(projectRoot, ".build");
const executablePath = join(projectRoot, `dist/${APP.name}`);
const packageJsonPath = join(projectRoot, "package.json");
async function build() {
try {
@@ -62,6 +64,14 @@ async function codeGeneration() {
await rm(buildDir, { force: true, recursive: true });
await Bun.write(join(buildDir, ".gitkeep"), "");
const packageJson = (await Bun.file(packageJsonPath).json()) as { version: string };
const version = packageJson.version;
if (typeof version !== "string") {
console.error("package.json does not have a valid version field");
process.exit(1);
}
validateVersion(version);
const allFiles = await scanDir(distWebDir, "/");
const importLines: string[] = [];
const fileEntries: string[] = [];
@@ -106,9 +116,11 @@ async function codeGeneration() {
`import { parseRuntimeArgs } from "../src/server/config";`,
`import { staticAssets } from "./static-assets";`,
"",
`const APP_VERSION = "${version}" as const;`,
"",
`async function main() {`,
` const { configPath } = parseRuntimeArgs();`,
` await bootstrap({ configPath, mode: "production", staticAssets });`,
` await bootstrap({ configPath, mode: "production", staticAssets, version: APP_VERSION });`,
`}`,
"",
`void main().catch((error) => {`,