Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/src/lib/tauri/devStub.handlers.plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
1 change: 1 addition & 0 deletions app/src/vite-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@

declare const __GIT_SHA__: string;
declare const __BUILD_TIME__: string;
declare const __APP_VERSION__: string;
12 changes: 12 additions & 0 deletions app/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"], {
Expand Down Expand Up @@ -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
Expand Down
Loading