aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/scripts/bump-tauri.ts
diff options
context:
space:
mode:
author简律纯 <i@jyunko.cn>2026-01-20 13:44:21 +0800
committerGitHub <noreply@github.com>2026-01-20 13:44:21 +0800
commit7338b8627833018a0e3c05c3c4f3cc7fc182e8d2 (patch)
tree23e39e5603aadc10d6b2d7efad063c68f357a860 /scripts/bump-tauri.ts
parentdbf781a35b96252e0199fec4337515651e49a8f6 (diff)
parentcf6cd6ba667b35e352b705946420cf4acab2b004 (diff)
downloadDropOut-7338b8627833018a0e3c05c3c4f3cc7fc182e8d2.tar.gz
DropOut-7338b8627833018a0e3c05c3c4f3cc7fc182e8d2.zip
[Chore] branch: Sync with main (#75)
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`);
+}