chore: update publish script
This commit is contained in:
parent
9ad8f71d7c
commit
b6543bd87f
@ -8,9 +8,9 @@
|
|||||||
"web:dev": "vite",
|
"web:dev": "vite",
|
||||||
"web:build": "tsc && vite build",
|
"web:build": "tsc && vite build",
|
||||||
"web:serve": "vite preview",
|
"web:serve": "vite preview",
|
||||||
"prepare": "husky install",
|
|
||||||
"predev": "node scripts/pre-dev.mjs",
|
"predev": "node scripts/pre-dev.mjs",
|
||||||
"postversion": "node scripts/post-version.mjs"
|
"publish": "node scripts/publish.mjs",
|
||||||
|
"prepare": "husky install"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/react": "^11.7.0",
|
"@emotion/react": "^11.7.0",
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
import fs from "fs-extra";
|
|
||||||
import { createRequire } from "module";
|
|
||||||
import { execSync } from "child_process";
|
|
||||||
|
|
||||||
const require = createRequire(import.meta.url);
|
|
||||||
|
|
||||||
// update the tauri conf version
|
|
||||||
async function resolveVersion() {
|
|
||||||
const { version } = require("../package.json");
|
|
||||||
const tauri = require("../src-tauri/tauri.conf.json");
|
|
||||||
|
|
||||||
tauri.package.version = version;
|
|
||||||
|
|
||||||
await fs.writeFile(
|
|
||||||
"./src-tauri/tauri.conf.json",
|
|
||||||
JSON.stringify(tauri, undefined, 2)
|
|
||||||
);
|
|
||||||
execSync("git add ./src-tauri/tauri.conf.json");
|
|
||||||
execSync(`git commit -m v${version} --no-verify`);
|
|
||||||
execSync(`git push`);
|
|
||||||
execSync(`git push origin v${version}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
resolveVersion();
|
|
41
scripts/publish.mjs
Normal file
41
scripts/publish.mjs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import fs from "fs-extra";
|
||||||
|
import { createRequire } from "module";
|
||||||
|
import { execSync } from "child_process";
|
||||||
|
|
||||||
|
const require = createRequire(import.meta.url);
|
||||||
|
|
||||||
|
async function resolvePublish() {
|
||||||
|
const flag = process.argv[2] ?? "patch";
|
||||||
|
const packageJson = require("../package.json");
|
||||||
|
const tauriJson = require("../src-tauri/tauri.conf.json");
|
||||||
|
|
||||||
|
let [a, b, c] = packageJson.version.split(".").map(Number);
|
||||||
|
|
||||||
|
if (flag === "major") a += 1;
|
||||||
|
else if (flag === "minor") b += 1;
|
||||||
|
else if (flag === "patch") c += 1;
|
||||||
|
else throw new Error(`invalid flag "${flag}"`);
|
||||||
|
|
||||||
|
const nextVersion = `${a}.${b}.${c}`;
|
||||||
|
packageJson.version = nextVersion;
|
||||||
|
tauriJson.package.version = nextVersion;
|
||||||
|
|
||||||
|
await fs.writeFile(
|
||||||
|
"./package.json",
|
||||||
|
JSON.stringify(packageJson, undefined, 2)
|
||||||
|
);
|
||||||
|
await fs.writeFile(
|
||||||
|
"./src-tauri/tauri.conf.json",
|
||||||
|
JSON.stringify(tauriJson, undefined, 2)
|
||||||
|
);
|
||||||
|
|
||||||
|
execSync("git add ./package.json");
|
||||||
|
execSync("git add ./src-tauri/tauri.conf.json");
|
||||||
|
execSync(`git commit -m "v${nextVersion}"`);
|
||||||
|
execSync(`git tag -a v${nextVersion} -m "v${nextVersion}"`);
|
||||||
|
execSync(`git push`);
|
||||||
|
execSync(`git push origin v${nextVersion}`);
|
||||||
|
console.log(`Publish Successfully...`);
|
||||||
|
}
|
||||||
|
|
||||||
|
resolvePublish();
|
Loading…
Reference in New Issue
Block a user