aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/scripts/bump-tauri.ts
diff options
context:
space:
mode:
author苏向夜 <46275354+fu050409@users.noreply.github.com>2026-01-19 11:06:38 +0800
committerGitHub <noreply@github.com>2026-01-19 11:06:38 +0800
commitf5560d7e8abe4a41c5f959cb6eb888f6aef6ca65 (patch)
treef3675bdb552a79ddb4601ccf2f5ddd81eb47c9fb /scripts/bump-tauri.ts
parentee767338d6db510ef15d6b8cc11f6fb9a6215a43 (diff)
parentbdff2175a8470accdab030b3931406495c56074d (diff)
downloadDropOut-f5560d7e8abe4a41c5f959cb6eb888f6aef6ca65.tar.gz
DropOut-f5560d7e8abe4a41c5f959cb6eb888f6aef6ca65.zip
Merge branch 'main' into chore/migrate-repository
Diffstat (limited to 'scripts/bump-tauri.ts')
-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`);
+}