Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to pnpm + turborepo #612

Merged
merged 90 commits into from
Aug 28, 2023
Merged

Migrate to pnpm + turborepo #612

merged 90 commits into from
Aug 28, 2023

Conversation

webpro
Copy link
Contributor

@webpro webpro commented Jul 18, 2023

This monorepo is managed using Rush. The tool is opinionated and may work well
for certain projects and teams, yet it's not performing to our standards and
needs (which is also opinionated, lol). The main issue is that it's basically a
framework in front of everything. A framework works well, until it doesn't.

Let's follow widely used standards and the Unix philosophy a bit more: pick the
right tool for each job separately. So we can update and swap out tools
separately as the trend need arises.

Rush is also an extra unnecessary blocker/hurdle for using the latest versions of Node.js and pnpm.

What jobs?

  • Build and test packages
  • Format and lint source code
  • Cache results of builds and tests to save time and resources
  • Build and test packages, and only those affected in a pull request
  • Publish packages
  • Dependency management, e.g. to fixate versions of dependencies across packages

But how?

  • pnpm does a lot out of the box already (with this PR we go from v6 to v8 btw!)
  • turborepo seems great for caching and "affected packages" logic
  • changesets seems great for changelogs and publishing

Guide

  • Use more standards where possible, e.g. leverage "private": true for packages that should not be published.
  • Use exit code to define results in CI (not stderr + warnings allowed). Also see Allow warnings in test and lint commands #442.
  • Commands are run through the package manager (npm, pnpm, ...) based on the standardized package.json#scripts. When we replace a tool the commands don't change. You can run turbo build instead of pnpm build, but that's on you.
  • The rush build job had linting included, such commands/actions should be separated (unless significant performance gain or something).

TODO

  • Fix pactjs bin workarounds/issues e.g. in @kadena/client-examples
  • Enforce fixed version across monorepo for certain/all dependencies
  • Fix build of @kadena/client-examples
  • Implement alternative to packageTable.ts
  • Update docs
  • Revisit ESLint rules (warning vs error) (Allow warnings in test and lint commands #442)

TODO in follow-up PRs

  • Find out wat heft/rigs actually do for us
  • Look into version policies (e.g. to "group" packages)
  • Look into publishing with changesets
  • Propose flat packages/* structure

Misc.

pnpm run test --filter @kadena/react-ui
pnpm run build --filter @kadena/client-examples
pnpm -r run "/^format:(md|pkg|src)/"
pnpm recursive list --json | jq --arg cwd "$PWD" '[ .[] | { name, version, private, path: (.path | sub("^" + $cwd + "/"; "")) } ]' > workspace.json

@vercel
Copy link

vercel bot commented Jul 18, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

6 Ignored Deployments
Name Status Preview Comments Updated (UTC)
alpha-docs ⬜️ Ignored (Inspect) Visit Preview Aug 28, 2023 2:05pm
docs-storybook ⬜️ Ignored (Inspect) Visit Preview Aug 28, 2023 2:05pm
immutable-records ⬜️ Ignored (Inspect) Visit Preview Aug 28, 2023 2:05pm
react-ui ⬜️ Ignored (Inspect) Visit Preview Aug 28, 2023 2:05pm
tools ⬜️ Ignored (Inspect) Visit Preview Aug 28, 2023 2:05pm
transfer ⬜️ Ignored (Inspect) Aug 28, 2023 2:05pm

@webpro webpro force-pushed the chore/migrate-away-from-rush branch from 2d18fbb to 8c1b3cb Compare July 18, 2023 13:26
@webpro webpro force-pushed the chore/migrate-away-from-rush branch from 8c1b3cb to 21ef505 Compare July 18, 2023 13:30
@webpro webpro force-pushed the chore/migrate-away-from-rush branch from 21ef505 to 22e78bc Compare July 18, 2023 13:36
@webpro webpro force-pushed the chore/migrate-away-from-rush branch from 22e78bc to 39b6e1b Compare July 18, 2023 13:43
@webpro webpro force-pushed the chore/migrate-away-from-rush branch from 39b6e1b to 8b2b573 Compare July 18, 2023 13:45
@webpro webpro force-pushed the chore/migrate-away-from-rush branch from 8b2b573 to d365bb6 Compare July 18, 2023 13:50
@webpro webpro force-pushed the chore/migrate-away-from-rush branch from d365bb6 to 8419487 Compare July 18, 2023 13:53
# Conflicts:
#	common/config/rush/command-line.json
#	common/config/rush/repo-state.json
#	packages/apps/tools/src/pages/transactions/module-explorer/index.tsx
#	pnpm-lock.yaml
#	rush.json
# Conflicts:
#	common/config/rush/repo-state.json
#	packages/apps/graph-client/package.json
#	packages/apps/graph/package.json
#	pnpm-lock.yaml
@@ -5,6 +5,6 @@ Thanks for contributing to this project!
- Link to the related issue (if any)
- Add use cases, scenarios, images and screenshots
- Add documentation and tutorials
- Run `rush test` and `rush change`
- Run `pnpm install` and `pnpm test`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm missing a notion to add a changelog. How can a user add a changelog to the PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is handled in another PR: #712

Comment on lines +18 to +21
"engines": {
"node": ">=16",
"pnpm": ">=8"
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be only node LTS versions

Comment on lines +24 to +26
"target": "es2019",
"lib": ["es2019", "DOM"],
"skipLibCheck": true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current LTS of node is 16 and 18.
Does this affect that?

https://github.com/nodejs/Release#nodejs-release-working-group

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

16 is EOL in a few weeks so I think we're good

workspace.json Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a config file for the monorepo if I'm correct? Maybe to prevent wrong assumptions we can rename this, or cache it as a .workspace.json and regenerate when a packages is added (a simple ls ./packages/*/* would suffice)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed it to packages.json and added a script to update it

@webpro webpro mentioned this pull request Aug 24, 2023
# Conflicts:
#	.gitignore
#	common/config/rush/repo-state.json
#	packages/apps/docs/package.json
#	packages/apps/graph-client/package.json
#	packages/apps/graph/package.json
#	pnpm-lock.yaml
# Conflicts:
#	.github/workflows/ci.yml
#	common/autoinstallers/rush-command-packages/pnpm-lock.yaml
#	common/autoinstallers/rush-fix-versions/pnpm-lock.yaml
@webpro webpro merged commit e969f3c into main Aug 28, 2023
3 checks passed
@webpro webpro deleted the chore/migrate-away-from-rush branch August 28, 2023 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants