Skip to content

Commit

Permalink
Merge pull request #679 from semaphore-protocol/chore/stable-version-…
Browse files Browse the repository at this point in the history
…script

Add script to remove stableVersion field
  • Loading branch information
cedoor authored Mar 4, 2024
2 parents 6ad2a79 + fbe6b66 commit 3dc31e5
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
"prettier": "prettier -c .",
"prettier:write": "prettier -w .",
"docs": "typedoc --cname js.semaphore.pse.dev --githubPages true",
"version:bump": "yarn workspaces foreach -A --no-private version -d ${0} && yarn version apply --all && git commit -am \"chore: v${0}\" && git tag v${0}",
"version:bump": "yarn workspaces foreach -A --no-private version -d ${0} && yarn version apply --all && yarn remove:stable-version-field && git commit -am \"chore: v${0}\" && git tag v${0}",
"version:publish": "yarn build:libraries && yarn clean:cli-templates && yarn workspaces foreach -A --no-private npm publish --tolerate-republish --access public",
"version:release": "changelogithub",
"clean": "ts-node scripts/clean-apps.ts && ts-node scripts/clean-packages.ts && yarn clean:cli-templates && rimraf node_modules",
"clean:cli-templates": "ts-node scripts/clean-cli-templates.ts",
"remove:stable-version-field": "ts-node scripts/remove-stable-version-field.ts && yarn prettier:write",
"commit": "cz",
"precommit": "lint-staged",
"postinstall": "husky install"
Expand Down
4 changes: 2 additions & 2 deletions scripts/clean-apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ const gitIgnored = [
]

async function main() {
const apps = readdirSync(folderName, { withFileTypes: true })
const folders = readdirSync(folderName, { withFileTypes: true })
.filter((file) => file.isDirectory())
.map((dir) => dir.name)

apps.map((app) => gitIgnored.map((f) => rmSync(`${folderName}/${app}/${f}`, { recursive: true, force: true })))
folders.map((app) => gitIgnored.map((f) => rmSync(`${folderName}/${app}/${f}`, { recursive: true, force: true })))
}

main()
Expand Down
4 changes: 2 additions & 2 deletions scripts/clean-cli-templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ const gitIgnored = [
"web-app/.next"
]

const packages = ["cli-template-monorepo-ethers", "cli-template-monorepo-subgraph"]
const folders = ["cli-template-monorepo-ethers", "cli-template-monorepo-subgraph"]

async function main() {
packages.map((pkg) =>
folders.map((pkg) =>
gitIgnored.map((f) => rmSync(`${folderName}/${pkg}/apps/${f}`, { recursive: true, force: true }))
)
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/clean-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const folderName = "packages"
const gitIgnored = ["node_modules", "dist", "build", "ptau", "artifacts", "typechain-types", "cache"]

async function main() {
const apps = readdirSync(folderName, { withFileTypes: true })
const folders = readdirSync(folderName, { withFileTypes: true })
.filter((file) => file.isDirectory())
.map((dir) => dir.name)

apps.map((app) => gitIgnored.map((f) => rmSync(`${folderName}/${app}/${f}`, { recursive: true, force: true })))
folders.map((app) => gitIgnored.map((f) => rmSync(`${folderName}/${app}/${f}`, { recursive: true, force: true })))

rmSync(`${folderName}/circuit/main`, { recursive: true, force: true })
rmSync(`${folderName}/circuit/test`, { recursive: true, force: true })
Expand Down
27 changes: 27 additions & 0 deletions scripts/remove-stable-version-field.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { readFileSync, readdirSync, writeFileSync } from "node:fs"

const folderName = "packages"

async function main() {
const filePaths = readdirSync(folderName, { withFileTypes: true })
.filter((file) => file.isDirectory())
.map((dir) => (dir.name === "contracts" ? `${dir.name}/contracts` : dir.name))
.map((name) => `${folderName}/${name}/package.json`)

for (const filePath of filePaths) {
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 3dc31e5

Please sign in to comment.