diff --git a/app/src/lib/tauri/devStub.handlers.plugins.ts b/app/src/lib/tauri/devStub.handlers.plugins.ts index ae07f36..8f07eef 100644 --- a/app/src/lib/tauri/devStub.handlers.plugins.ts +++ b/app/src/lib/tauri/devStub.handlers.plugins.ts @@ -106,7 +106,7 @@ export function pluginStub(cmd: string, a: Args, ctx: PluginStubCtx): unknown | return null; case "plugin:app|version": - return "0.7.0"; + return typeof __APP_VERSION__ === "string" ? __APP_VERSION__ : "0.0.0"; case "plugin:app|name": return "Recrest"; case "plugin:app|tauri_version": diff --git a/app/src/vite-env.d.ts b/app/src/vite-env.d.ts index aeb0163..ff8bc14 100644 --- a/app/src/vite-env.d.ts +++ b/app/src/vite-env.d.ts @@ -3,3 +3,4 @@ declare const __GIT_SHA__: string; declare const __BUILD_TIME__: string; +declare const __APP_VERSION__: string; diff --git a/app/vite.config.ts b/app/vite.config.ts index 667c3a8..eb3afb8 100644 --- a/app/vite.config.ts +++ b/app/vite.config.ts @@ -11,6 +11,17 @@ import tsconfigPaths from "vite-tsconfig-paths"; const srcDir = fileURLToPath(new URL("./src", import.meta.url)); const repoRoot = path.resolve(fileURLToPath(new URL(".", import.meta.url)), ".."); +function appPackageVersion(): string { + try { + const pkg = JSON.parse( + readFileSync(fileURLToPath(new URL("./package.json", import.meta.url)), "utf8"), + ) as { version?: string }; + return pkg.version ?? "0.0.0"; + } catch { + return "0.0.0"; + } +} + function gitShortSha(): string { try { return execFileSync("git", ["rev-parse", "--short", "HEAD"], { @@ -101,6 +112,7 @@ export default defineConfig({ global: "globalThis", __GIT_SHA__: JSON.stringify(gitShortSha()), __BUILD_TIME__: JSON.stringify(new Date().toISOString()), + __APP_VERSION__: JSON.stringify(appPackageVersion()), }, optimizeDeps: { // Pre-bundle frequently-imported deps so the dev server's first load