From 18e12705737e01e34840eaa11ff781c973418cd4 Mon Sep 17 00:00:00 2001 From: cedoor Date: Mon, 18 Mar 2024 16:26:41 +0000 Subject: [PATCH] chore: add script to remove stableVersion field from package.json files --- package.json | 3 ++- scripts/remove-stable-version-field.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 scripts/remove-stable-version-field.ts diff --git a/package.json b/package.json index 22d893701..ebeec795d 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "test:library": "jest packages/${0}", "test:circuits": "yarn workspace @zk-kit/circuits test", "test:contracts": "yarn workspace imt.sol test:coverage", - "version:bump": "yarn workspace @zk-kit/${0} version ${1} && NO_HOOK=1 git commit -am \"chore(${0}): v${1}\" && git tag ${0}-v${1}", + "version:bump": "yarn workspace @zk-kit/${0} version ${1} && yarn remove:stable-version-field ${0} && NO_HOOK=1 git commit -am \"chore(${0}): v${1}\" && git tag ${0}-v${1}", "version:publish": "yarn workspaces foreach -A --no-private npm publish --tolerate-republish --access public", "version:release": "changelogithub", "lint": "eslint . --ext .js,.ts && yarn workspace imt.sol lint", @@ -23,6 +23,7 @@ "prettier:write": "prettier -w .", "benchmarks": "rimraf benchmarks/results && ts-node benchmarks/index.ts", "docs": "typedoc --cname zkkit.pse.dev --githubPages true", + "remove:stable-version-field": "ts-node scripts/remove-stable-version-field.ts ${0} && yarn prettier:write", "precommit": "lint-staged", "postinstall": "husky install" }, diff --git a/scripts/remove-stable-version-field.ts b/scripts/remove-stable-version-field.ts new file mode 100644 index 000000000..c34fe73ed --- /dev/null +++ b/scripts/remove-stable-version-field.ts @@ -0,0 +1,26 @@ +import { existsSync, readFileSync, writeFileSync } from "node:fs" + +async function main() { + const projectDirectory = `packages/${process.argv[2]}` + + let filePath = `${projectDirectory}/package.json` + + if (existsSync(`${projectDirectory}/contracts/package.json`)) { + filePath = `${projectDirectory}/contracts/package.json` + } + + const content = JSON.parse(readFileSync(filePath, "utf8")) + + if (content.stableVersion) { + delete content.stableVersion + } + + writeFileSync(filePath, JSON.stringify(content, null, 4), "utf8") +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error) + process.exit(1) + })