Files
TeyvatGuide/scripts/auto-dev.ts
BTMuli 55a35471b6 🧑‍💻 调整Sentry数据
2025-12-31 14:19:10 +08:00

40 lines
1.3 KiB
TypeScript

/**
* 本地调试脚本
* @since Beta v0.9.1
*/
import { resolve } from "path";
import { fileURLToPath } from "node:url";
import pkgJson from "../package.json" with { type: "json" };
import { execSync } from "child_process";
import { parse, stringify } from "envfile";
import { readFileSync, writeFileSync } from "fs";
import { existsSync } from "node:fs";
const __dirname = resolve(fileURLToPath(import.meta.url), "../");
// 获取版本
const pkgVersion = pkgJson.version;
// 获取提交哈希
const commitHash = execSync("git rev-parse --short HEAD").toString().trim();
// 构建 Release 字符串
const release = `TeyvatGuide@${pkgVersion}`;
console.log(`🍄 gen sentry dev release ${release}`);
// 修改 .env.development.local
const envPath = resolve(__dirname, "../.env.development.local");
if (!existsSync(envPath)) {
writeFileSync(envPath, `VITE_SENTRY_RELEASE=${release}`, "utf-8");
} else {
const envRead = parse(readFileSync(envPath, "utf-8"));
envRead.VITE_SENTRY_RELEASE = release;
envRead.VITE_COMMIT_HASH = commitHash;
envRead.VITE_BUILD_TIME = Math.floor(Date.now() / 1000).toString();
writeFileSync(envPath, stringify(envRead), "utf-8");
}
console.log("✅ .env.development.local updated!");
// 执行 tauri dev
execSync("pnpm tauri dev --exit-on-panic", { stdio: "inherit" });