-
-
Notifications
You must be signed in to change notification settings - Fork 528
Add Turborepo #2027
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
Merged
Add Turborepo #2027
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,9 @@ on: | |
- main | ||
pull_request: | ||
|
||
env: | ||
GITHUB_TOKEN: ${{ secrets.OPENAPI_TS_BOT_GITHUB_TOKEN }} | ||
|
||
concurrency: | ||
group: ci-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
@@ -20,7 +23,7 @@ jobs: | |
node-version: 22 | ||
- uses: pnpm/action-setup@v4 | ||
with: | ||
version: latest | ||
version: 9.14.4 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: Turborepo does require version-locking the package manager, which is the only annoyance I have with it. So this can be bumped any time! But sadly we can’t be as loosey-goosey with it as before. |
||
run_install: true | ||
- run: pnpm run lint | ||
test-node-versions: | ||
|
@@ -35,9 +38,8 @@ jobs: | |
node-version: ${{ matrix.node-version }} | ||
- uses: pnpm/action-setup@v4 | ||
with: | ||
version: latest | ||
version: 9.14.4 | ||
run_install: true | ||
- run: pnpm run build | ||
- run: pnpm test | ||
test-e2e: | ||
runs-on: ubuntu-latest | ||
|
@@ -48,7 +50,7 @@ jobs: | |
node-version: 22 | ||
- uses: pnpm/action-setup@v4 | ||
with: | ||
version: latest | ||
version: 9.14.4 | ||
run_install: true | ||
- run: pnpm exec playwright install --with-deps | ||
- run: pnpm run test-e2e | ||
|
@@ -61,9 +63,8 @@ jobs: | |
node-version: 22 | ||
- uses: pnpm/action-setup@v4 | ||
with: | ||
version: latest | ||
version: 9.14.4 | ||
run_install: true | ||
- run: pnpm run build | ||
- run: pnpm test | ||
test-windows: | ||
runs-on: windows-latest | ||
|
@@ -74,7 +75,6 @@ jobs: | |
node-version: 22 | ||
- uses: pnpm/action-setup@v4 | ||
with: | ||
version: latest | ||
version: 9.14.4 | ||
run_install: true | ||
- run: pnpm run build | ||
- run: pnpm test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
name: "Size Limit" | ||
|
||
on: | ||
pull_request: | ||
branches: [main] | ||
types: [opened, synchronize] | ||
|
||
env: | ||
GITHUB_TOKEN: ${{ secrets.OPENAPI_TS_BOT_GITHUB_TOKEN }} | ||
|
||
jobs: | ||
size-limit: | ||
permissions: | ||
|
@@ -17,7 +21,7 @@ jobs: | |
node-version: 22 | ||
- uses: pnpm/action-setup@v4 | ||
with: | ||
version: latest | ||
version: 9.14.4 | ||
run_install: true | ||
- uses: andresz1/[email protected] | ||
with: | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.DS_Store | ||
.turbo | ||
dist | ||
node_modules | ||
coverage | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,38 @@ | ||
# Contributing | ||
|
||
Contributions are welcome! T | ||
Contributions are welcome! | ||
|
||
## Setup | ||
|
||
This monorepo uses [pnpm workspaces](https://pnpm.io/) that lets packages pull from local versions rather than remote. After installing pnpm, running this command from the root will set everything up: | ||
This monorepo uses [pnpm workspaces](https://pnpm.io/) that lets packages pull from local versions rather than remote. It also uses [Turborepo](https://turbo.build/repo/docs) to run commands more easily. After installing pnpm, running the following commands from the root will set everything up: | ||
|
||
```sh | ||
pnpm i | ||
pnpm run build | ||
``` | ||
|
||
## Workspace vs local commands | ||
|
||
The “workspace“ is the root `package.json`. Running commands here will run on all packages. For example, running `pnpm run build` in the workspace root will build all packages. But running `cd packages/openapi-typescript && pnpm run build` will only build that one package. | ||
|
||
It’s worth noting that some packages depend on others in the monorepo. For example, `openapi-fetch` depends on `openapi-typescript` building built. `openapi-react-query` relies on `openapi-fetch` which relies on `openapi-typescript`. If running commands per-package, you’d have to manually build each package before the test suite could run. But running `pnpm run build` in the workspace root once will build all packages for you, so that you can run any test suite. | ||
|
||
> ![NOTE] | ||
> | ||
> Note that if any package changes, be sure to rebuild before running tests! Of course, CI will always do this, but in case you see differences between local vs CI, this is usually the culprit—a stale build. | ||
|
||
Again, Turborepo is there so that you don’t have to think about all the packages as much, if you’re just contributing to one. But these tips may help you troubleshoot if something unexpected happens. | ||
|
||
## Structure | ||
|
||
This monorepo has 2 main sections: the `docs/` that deploy to `openapi-ts.dev`, and `packages/` which are all the npm packages. Each npm package has its own `CONTRIBUTING.md` doc that describes setup needed for that package. | ||
|
||
``` | ||
┬── docs/ # openapi-ts.dev | ||
│ | ||
┬── docs/ | ||
└── packages/ | ||
├── openapi-fetch/ # openapi-fetch package | ||
├── openapi-fetch/ | ||
├── openapi-react-query/ | ||
├── openapi-typescript/ | ||
├── openapi-typescript-helpers/ | ||
│ # openapi-typescript package | ||
└── openapi-typescript/ # openapi-typescript package | ||
└── swr-openapi/ | ||
``` |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,14 +7,15 @@ | |
"name": "Drew Powers", | ||
"email": "[email protected]" | ||
}, | ||
"packageManager": "[email protected]", | ||
"scripts": { | ||
"build": "pnpm run -r --filter \"!*docs\" --aggregate-output build", | ||
"lint": "pnpm run -r --parallel --aggregate-output lint", | ||
"build": "turbo run build", | ||
"lint": "turbo run lint", | ||
"dev": "pnpm run -r --parallel --filter \"{packages/*}\" --aggregate-output dev", | ||
"format": "pnpm run -r --parallel --aggregate-output format", | ||
"test": "pnpm run -r --parallel --aggregate-output test", | ||
"test-e2e": "pnpm run -r --parallel --aggregate-output test-e2e", | ||
"size": "pnpm run build && size-limit", | ||
"format": "turbo run format", | ||
"test": "turbo run test", | ||
"test-e2e": "turbo run test-e2e", | ||
"size": "turbo run size-limit", | ||
"version": "pnpm run build && changeset version && pnpm i" | ||
}, | ||
"devDependencies": { | ||
|
@@ -27,6 +28,7 @@ | |
"del-cli": "^5.1.0", | ||
"prettier": "^3.4.1", | ||
"size-limit": "^11.1.6", | ||
"turbo": "^2.3.3", | ||
"typescript": "^5.7.2", | ||
"vitest": "^2.1.6" | ||
}, | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this was added because Turborepo adds a “shield” around env vars and doesn’t accidentally expose something sensitive, so you declare what to expose. But the flipside is it throws an error when this isn’t set. I may be missing a configuration setting, but until then, this was simpler.