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

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

No files matched your search

+19
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}`);