chore: add pre-build script to sync tauri.conf.json version with cargo.toml

This commit is contained in:
HorizonCode 2025-07-07 10:14:49 +02:00
parent 047ef0b049
commit 9f75a32502
4 changed files with 31 additions and 8 deletions

View File

@ -8,6 +8,7 @@
"@elron/svelte-audio-store": "1.0.0",
"@fontsource/sora": "^5.2.6",
"@fontsource/space-mono": "^5.2.8",
"@iarna/toml": "^2.2.5",
"@number-flow/svelte": "^0.3.9",
"@tailwindcss/typography": "0.5.16",
"@tauri-apps/api": "2.6.0",
@ -161,6 +162,8 @@
"@humanwhocodes/retry": ["@humanwhocodes/retry@0.4.3", "", {}, "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ=="],
"@iarna/toml": ["@iarna/toml@2.2.5", "", {}, "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg=="],
"@internationalized/date": ["@internationalized/date@3.8.2", "", { "dependencies": { "@swc/helpers": "^0.5.0" } }, "sha512-/wENk7CbvLbkUvX1tu0mwq49CVkkWpkXubGel6birjRPyo6uQ4nQpnq5xZu823zRCwwn82zgHrvgF1vZyvmVgA=="],
"@isaacs/cliui": ["@isaacs/cliui@8.0.2", "", { "dependencies": { "string-width": "^5.1.2", "string-width-cjs": "npm:string-width@^4.2.0", "strip-ansi": "^7.0.1", "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", "wrap-ansi": "^8.1.0", "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" } }, "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA=="],

View File

@ -5,14 +5,14 @@
"type": "module",
"scripts": {
"debug": "bun run tauri dev",
"dev": "vite dev",
"build": "vite build",
"build": "bun ./scripts/sync-version.ts && bun run tauri:build",
"vite:dev": "vite dev",
"vite:build": "vite build",
"tauri:build": "tauri build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"tauri": "tauri",
"update-logo": "bun run tauri icon ./static/logo.png",
"tauri:update-logo": "bun run tauri icon ./static/logo.png",
"format": "prettier --write .",
"lint": "prettier --check . && eslint ."
},
@ -22,6 +22,7 @@
"@elron/svelte-audio-store": "1.0.0",
"@fontsource/sora": "^5.2.6",
"@fontsource/space-mono": "^5.2.8",
"@iarna/toml": "^2.2.5",
"@number-flow/svelte": "^0.3.9",
"@tailwindcss/typography": "0.5.16",
"@tauri-apps/api": "2.6.0",

19
scripts/sync-version.ts Normal file
View File

@ -0,0 +1,19 @@
import fs from 'fs';
import path from 'path';
import * as toml from '@iarna/toml';
import { cwd } from 'process';
const cargoTomlPath = path.join(cwd(), 'src-tauri', 'Cargo.toml');
const tauriConfPath = path.join(cwd(), 'src-tauri', 'tauri.conf.json');
const cargoToml = fs.readFileSync(cargoTomlPath, 'utf8');
const cargo = toml.parse(cargoToml) as Record<string, string>;
const version = cargo.package['version'];
if (!version) throw new Error('Could not find version in Cargo.toml');
const tauriConf = JSON.parse(fs.readFileSync(tauriConfPath, 'utf8'));
tauriConf.version = version;
fs.writeFileSync(tauriConfPath, JSON.stringify(tauriConf, null, 2));
console.log(`✅ Synced tauri.conf.json version to ${version}`);

View File

@ -1,12 +1,12 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "ezpplauncher",
"version": "0.1.0",
"version": "3.0.0-beta.1",
"identifier": "farm.ezpp.launcher",
"build": {
"beforeDevCommand": "bun run dev",
"beforeDevCommand": "bun run vite:dev",
"devUrl": "http://localhost:1420",
"beforeBuildCommand": "bun run build",
"beforeBuildCommand": "bun run vite:build",
"frontendDist": "../build"
},
"app": {