Skip to content

Commit

Permalink
chore(cli): create a script to remove unnecessary files in monorepo t…
Browse files Browse the repository at this point in the history
…emplates
  • Loading branch information
vplasencia committed Apr 7, 2023
1 parent 02d1395 commit 02658c0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"build:libraries": "yarn workspaces foreach -t --no-private run build",
"compile:contracts": "yarn workspace contracts compile",
"download:snark-artifacts": "rimraf snark-artifacts && ts-node scripts/download-snark-artifacts.ts",
"remove:template-files": "ts-node scripts/remove-template-files.ts",
"test": "yarn test:libraries && yarn test:contracts",
"test:libraries": "jest --coverage",
"test:contracts": "yarn workspace contracts test:coverage",
Expand All @@ -18,7 +19,7 @@
"prettier:write": "prettier -w .",
"docs": "yarn workspaces foreach --no-private run docs",
"version:bump": "yarn workspaces foreach --no-private version -d ${0} && yarn version apply --all && git commit -am \"chore: v${0}\" && git tag v${0}",
"version:publish": "yarn build:libraries && yarn workspaces foreach --no-private npm publish --tolerate-republish --access public",
"version:publish": "yarn build:libraries && yarn remove:template-files && yarn workspaces foreach --no-private npm publish --tolerate-republish --access public",
"version:release": "changelogithub",
"commit": "cz",
"precommit": "lint-staged",
Expand Down
24 changes: 24 additions & 0 deletions scripts/remove-template-files.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { rmSync } from "fs"

async function main() {
const templates = ["cli-template-monorepo-ethers", "cli-template-monorepo-subgraph"]
const files: string[] = [
"contracts/build",
"contracts/cache",
"contracts/node_modules",
"web-app/node_modules",
"web-app/.next",
"web-app/next-env.d.ts"
]

templates.map((template) =>
files.map((file) => rmSync(`packages/${template}/apps/${file}`, { recursive: true, force: true }))
)
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})

0 comments on commit 02658c0

Please sign in to comment.