aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/scripts
diff options
context:
space:
mode:
author苏向夜 <fu050409@163.com>2026-01-18 16:57:52 +0800
committer苏向夜 <fu050409@163.com>2026-01-18 16:57:52 +0800
commit7f9d73a7d304bd6287be74cb4095100363abe84d (patch)
tree7d57a2ebb9b7ee5f90c156fbd7ae1f8f861d86dc /scripts
parentf5e2c9b9291be3a646c407a86d8f5fdc76cecd9f (diff)
downloadDropOut-7f9d73a7d304bd6287be74cb4095100363abe84d.tar.gz
DropOut-7f9d73a7d304bd6287be74cb4095100363abe84d.zip
chore: add tauri version bump script
Diffstat (limited to 'scripts')
-rw-r--r--scripts/bump-tauri.ts52
1 files changed, 52 insertions, 0 deletions
diff --git a/scripts/bump-tauri.ts b/scripts/bump-tauri.ts
new file mode 100644
index 0000000..0cf6aea
--- /dev/null
+++ b/scripts/bump-tauri.ts
@@ -0,0 +1,52 @@
+import fs from "node:fs";
+import path from "node:path";
+import consola from "consola";
+import toml from "toml";
+
+const tauriJsonPath = path.join(
+ __dirname,
+ "..",
+ "src-tauri",
+ "tauri.conf.json",
+);
+consola.debug("tauriJsonPath:", tauriJsonPath);
+const tauriTomlPath = path.join(__dirname, "..", "src-tauri", "Cargo.toml");
+consola.debug("tauriTomlPath:", tauriTomlPath);
+
+const getCurrentVersion = () => {
+ const tauriJsonData = fs.readFileSync(tauriJsonPath, "utf8");
+ const tauriJson = JSON.parse(tauriJsonData);
+ const version = tauriJson.version;
+ if (!version) throw new Error("Version field not found in tauri.conf.json");
+ return version;
+};
+
+const getBumpVersion = () => {
+ const tauriTomlData = fs.readFileSync(tauriTomlPath, "utf8");
+ const tauriToml = toml.parse(tauriTomlData);
+ const version = tauriToml.package.version;
+ if (!version) throw new Error("Version field not found in Cargo.toml");
+ return version;
+};
+
+const replaceVersion = (content: string, version: string) => {
+ const newJson = content.replace(
+ /"version": "[^"]+"/,
+ `"version": "${version}"`,
+ );
+ return newJson;
+};
+
+const tauriJsonData = fs.readFileSync(tauriJsonPath, "utf8");
+const currentVersion = getCurrentVersion();
+const bumpVersion = getBumpVersion();
+consola.debug("currentVersion:", currentVersion);
+consola.debug("bumpVersion:", bumpVersion);
+
+if (currentVersion !== bumpVersion) {
+ const replacedData = replaceVersion(tauriJsonData, bumpVersion);
+ consola.info(`Bumped version from ${currentVersion} to ${bumpVersion}`);
+ fs.writeFileSync(tauriJsonPath, replacedData);
+} else {
+ consola.info(`Version ${currentVersion} is already up-to-date`);
+}