Skip to content

Commit

Permalink
chore: add script to remove stableVersion field from package.json files
Browse files Browse the repository at this point in the history
  • Loading branch information
cedoor committed Mar 18, 2024
1 parent a308626 commit 18e1270
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
"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",
"prettier": "prettier -c .",
"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"
},
Expand Down
26 changes: 26 additions & 0 deletions scripts/remove-stable-version-field.ts
Original file line number Diff line number Diff line change
@@ -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)
})

0 comments on commit 18e1270

Please sign in to comment.