update version hook

This commit is contained in:
2023-09-22 20:27:59 +02:00
parent e7a52221d2
commit 074f1da48d
5 changed files with 29 additions and 17 deletions

20
src/tools/version.ts Normal file
View File

@@ -0,0 +1,20 @@
import {readFile, writeFile} from "fs/promises"
import {fileURLToPath} from "url"
import * as path from "path"
import {format} from "prettier"
const projectDir = path.resolve(fileURLToPath(import.meta.url), "..", "..", "..")
const {version} = JSON.parse(await readFile(path.join(projectDir, "package.json"), "utf8"))
const tauriConfigPath = path.join(projectDir, "src-tauri", "tauri.conf.json")
const tauriConfig = JSON.parse(await readFile(tauriConfigPath, "utf8"))
tauriConfig.package.version = version
await writeFile(tauriConfigPath, await format(JSON.stringify(tauriConfig), {parser: "json"}))
const cargoTomlPath = path.join(projectDir, "src-tauri", "Cargo.toml")
const cargoToml = await readFile(cargoTomlPath, "utf8")
const modified = cargoToml.replace(/^\s*version\s*=\s*"\d\.\d.\d"\s*$/m, `version = "${version}"`)
await writeFile(cargoTomlPath, modified)