Use bump package instead of custom script
This commit is contained in:
13
bump.config.ts
Normal file
13
bump.config.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { defineConfig } from "bumpp";
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
release: "patch",
|
||||||
|
commit: false,
|
||||||
|
tag: false,
|
||||||
|
push: false,
|
||||||
|
files: [
|
||||||
|
"package.json",
|
||||||
|
"src-tauri/tauri.conf.json",
|
||||||
|
"src-tauri/Cargo.toml"
|
||||||
|
]
|
||||||
|
});
|
@@ -16,9 +16,7 @@
|
|||||||
"preinstall": "npx only-allow pnpm",
|
"preinstall": "npx only-allow pnpm",
|
||||||
"postinstall": "nuxt prepare",
|
"postinstall": "nuxt prepare",
|
||||||
"lint": "eslint . --fix",
|
"lint": "eslint . --fix",
|
||||||
"bump:patch": "tsx scripts/bump.ts patch && eslint package.json src-tauri/tauri.conf.json src-tauri/Cargo.toml --fix",
|
"bump": "bumpp",
|
||||||
"bump:minor": "tsx scripts/bump.ts minor && eslint package.json src-tauri/tauri.conf.json src-tauri/Cargo.toml --fix",
|
|
||||||
"bump:major": "tsx scripts/bump.ts major && eslint package.json src-tauri/tauri.conf.json src-tauri/Cargo.toml --fix",
|
|
||||||
"tauri": "tauri",
|
"tauri": "tauri",
|
||||||
"tauri:dev": "tauri dev",
|
"tauri:dev": "tauri dev",
|
||||||
"tauri:build": "tauri build",
|
"tauri:build": "tauri build",
|
||||||
@@ -40,6 +38,7 @@
|
|||||||
"@unocss/nuxt": "^0.61.0",
|
"@unocss/nuxt": "^0.61.0",
|
||||||
"@vueuse/core": "^10.11.0",
|
"@vueuse/core": "^10.11.0",
|
||||||
"@vueuse/nuxt": "^10.11.0",
|
"@vueuse/nuxt": "^10.11.0",
|
||||||
|
"bumpp": "^9.4.1",
|
||||||
"eslint": "8.57.0",
|
"eslint": "8.57.0",
|
||||||
"internal-ip": "^8.0.0",
|
"internal-ip": "^8.0.0",
|
||||||
"nuxt": "^3.12.2",
|
"nuxt": "^3.12.2",
|
||||||
|
@@ -1,44 +0,0 @@
|
|||||||
import { readFileSync, writeFileSync } from "node:fs";
|
|
||||||
import { parse, stringify } from "@iarna/toml";
|
|
||||||
|
|
||||||
type BumpMethod = "patch" | "minor" | "major";
|
|
||||||
|
|
||||||
const bumpVersion = (currentVersion: string) => {
|
|
||||||
const method = <BumpMethod>process.argv[2] || "patch";
|
|
||||||
|
|
||||||
const parts = currentVersion.split(".");
|
|
||||||
let major = Number.parseInt(parts[0], 10);
|
|
||||||
let minor = Number.parseInt(parts[1], 10);
|
|
||||||
let patch = Number.parseInt(parts[2], 10);
|
|
||||||
|
|
||||||
if (method === "patch") {
|
|
||||||
patch += 1;
|
|
||||||
} else if (method === "minor") {
|
|
||||||
minor += 1;
|
|
||||||
patch = 0;
|
|
||||||
} else if (method === "major") {
|
|
||||||
major += 1;
|
|
||||||
minor = 0;
|
|
||||||
patch = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const newVersion = `${major}.${minor}.${patch}`;
|
|
||||||
|
|
||||||
console.log(`Version bumped to ${newVersion}`);
|
|
||||||
|
|
||||||
return newVersion;
|
|
||||||
};
|
|
||||||
|
|
||||||
const packageJson = JSON.parse(readFileSync("./package.json", "utf-8"));
|
|
||||||
const tauriConfig = JSON.parse(readFileSync("./src-tauri/tauri.conf.json", "utf-8"));
|
|
||||||
const tauriToml = parse(readFileSync("./src-tauri/Cargo.toml", "utf-8"));
|
|
||||||
|
|
||||||
packageJson.version = bumpVersion(packageJson.version);
|
|
||||||
tauriConfig.version = bumpVersion(tauriConfig.version);
|
|
||||||
|
|
||||||
// @ts-expect-error No interface for parsed TOML
|
|
||||||
tauriToml.package.version = bumpVersion(tauriToml.package.version);
|
|
||||||
|
|
||||||
writeFileSync("./package.json", JSON.stringify(packageJson, null, "\t"));
|
|
||||||
writeFileSync("./src-tauri/tauri.conf.json", JSON.stringify(tauriConfig, null, "\t"));
|
|
||||||
writeFileSync("./src-tauri/Cargo.toml", stringify(tauriToml));
|
|
Reference in New Issue
Block a user