Add global version bump script
This commit is contained in:
@@ -16,6 +16,9 @@
|
|||||||
"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: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"
|
||||||
@@ -28,6 +31,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@antfu/eslint-config": "^2.21.1",
|
"@antfu/eslint-config": "^2.21.1",
|
||||||
|
"@iarna/toml": "^2.2.5",
|
||||||
"@iconify-json/heroicons-solid": "^1.1.11",
|
"@iconify-json/heroicons-solid": "^1.1.11",
|
||||||
"@nuxt/eslint": "^0.3.13",
|
"@nuxt/eslint": "^0.3.13",
|
||||||
"@tauri-apps/cli": ">=2.0.0-beta.20",
|
"@tauri-apps/cli": ">=2.0.0-beta.20",
|
||||||
|
8
pnpm-lock.yaml
generated
8
pnpm-lock.yaml
generated
@@ -24,6 +24,9 @@ importers:
|
|||||||
'@antfu/eslint-config':
|
'@antfu/eslint-config':
|
||||||
specifier: ^2.21.1
|
specifier: ^2.21.1
|
||||||
version: 2.21.1(@unocss/eslint-plugin@0.61.0(eslint@8.57.0)(typescript@5.4.5))(@vue/compiler-sfc@3.4.29)(eslint-plugin-format@0.1.0(eslint@8.57.0))(eslint@8.57.0)(typescript@5.4.5)
|
version: 2.21.1(@unocss/eslint-plugin@0.61.0(eslint@8.57.0)(typescript@5.4.5))(@vue/compiler-sfc@3.4.29)(eslint-plugin-format@0.1.0(eslint@8.57.0))(eslint@8.57.0)(typescript@5.4.5)
|
||||||
|
'@iarna/toml':
|
||||||
|
specifier: ^2.2.5
|
||||||
|
version: 2.2.5
|
||||||
'@iconify-json/heroicons-solid':
|
'@iconify-json/heroicons-solid':
|
||||||
specifier: ^1.1.11
|
specifier: ^1.1.11
|
||||||
version: 1.1.11
|
version: 1.1.11
|
||||||
@@ -815,6 +818,9 @@ packages:
|
|||||||
'@humanwhocodes/object-schema@2.0.3':
|
'@humanwhocodes/object-schema@2.0.3':
|
||||||
resolution: {integrity: sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==}
|
resolution: {integrity: sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==}
|
||||||
|
|
||||||
|
'@iarna/toml@2.2.5':
|
||||||
|
resolution: {integrity: sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==}
|
||||||
|
|
||||||
'@iconify-json/heroicons-solid@1.1.11':
|
'@iconify-json/heroicons-solid@1.1.11':
|
||||||
resolution: {integrity: sha512-Nzhjs8voo4d+gcrfhlY/F0bRonEmLHT1+DeD2nYubvAF151pxXPqTS9bRB49Hqpdxl1l9LS2VTPtQPRypj/csQ==}
|
resolution: {integrity: sha512-Nzhjs8voo4d+gcrfhlY/F0bRonEmLHT1+DeD2nYubvAF151pxXPqTS9bRB49Hqpdxl1l9LS2VTPtQPRypj/csQ==}
|
||||||
|
|
||||||
@@ -6002,6 +6008,8 @@ snapshots:
|
|||||||
|
|
||||||
'@humanwhocodes/object-schema@2.0.3': {}
|
'@humanwhocodes/object-schema@2.0.3': {}
|
||||||
|
|
||||||
|
'@iarna/toml@2.2.5': {}
|
||||||
|
|
||||||
'@iconify-json/heroicons-solid@1.1.11':
|
'@iconify-json/heroicons-solid@1.1.11':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@iconify/types': 2.0.0
|
'@iconify/types': 2.0.0
|
||||||
|
43
scripts/bump.ts
Normal file
43
scripts/bump.ts
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
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;
|
||||||
|
if (method === "minor")
|
||||||
|
minor += 1;
|
||||||
|
if (method === "major")
|
||||||
|
major += 1;
|
||||||
|
|
||||||
|
if (patch >= 10) {
|
||||||
|
patch = 0;
|
||||||
|
minor += 1;
|
||||||
|
if (minor >= 10) {
|
||||||
|
minor = 0;
|
||||||
|
major += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${major}.${minor}.${patch}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
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);
|
||||||
|
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