Skip to content

Commit e08052c

Browse files
committed
feat: set up turborepo
1 parent 9487848 commit e08052c

File tree

58 files changed

+1319
-2037
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1319
-2037
lines changed

.github/workflows/ci-hermes-client-api-types.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.github/workflows/ci-typescript.yml renamed to .github/workflows/ci-turbo.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: JS/TS checks
1+
name: Turbo test
22
on:
33
pull_request:
44
paths:
@@ -31,13 +31,5 @@ jobs:
3131
name: Install pnpm
3232
with:
3333
run_install: true
34-
- name: Build
35-
run: pnpm exec lerna run build
3634
- name: Test
37-
run: pnpm exec lerna run test
38-
- name: Lint
39-
run: pnpm exec lerna run lint
40-
- name: Generate ABIs
41-
run: pnpm exec lerna run generate-abi
42-
- name: Check ABIs
43-
run: pnpm exec lerna run check-abi
35+
run: pnpm turbo test --ui stream

.github/workflows/publish-js.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ jobs:
2121
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
2222
env:
2323
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
24-
- run: pnpm exec lerna run build --no-private
24+
- run: pnpm turbo build
2525
- run: pnpm exec lerna publish from-package --no-private --no-git-tag-version --yes

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ __pycache__
2222
.vercel
2323
.direnv
2424
.next
25+
.turbo/

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
pnpm-lock.yaml
22
patches/
3+
.turbo/
34

45
# These apps have their own prettier config that uses a later version of
56
# prettier

Dockerfile.node

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ USER pyth
1616

1717
FROM builder-base AS builder
1818
ARG package
19-
RUN pnpm exec lerna run build --scope="$package" --include-dependencies
19+
RUN pnpm turbo build --filter $package
2020
RUN pnpm deploy --filter $package --prod /srv/$package
2121

2222

README.md

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,21 +75,41 @@ Integration tests run in Tilt (via the `tilt ci` command). The Tilt CI workflow
7575

7676
### Typescript Monorepo
7777

78-
All of the typescript / javascript packages in this repository are part of a lerna monorepo.
79-
This setup allows each package to reference the current version of the others.
80-
You can install dependencies using `pnpm i` from the repository root.
81-
You can build all of the packages using `pnpm exec lerna run build` and test with `pnpm exec lerna run test`.
82-
83-
Lerna has some common failure modes that you may encounter:
84-
85-
1. `pnpm i` fails with a typescript compilation error about a missing package.
86-
This error likely means that the failing package has a `prepare` entry compiling the typescript in its `package.json`.
87-
Fix this error by moving that logic to the `prepublishOnly` entry.
88-
2. The software builds locally but fails in CI, or vice-versa.
89-
This error likely means that some local build caches need to be cleaned.
90-
The build error may not indicate that this is a caching issue, e.g., it may appear that the packages are being built in the wrong order.
91-
Delete `node_modules/`, `lib/` and `tsconfig.tsbuildinfo` from each package's subdirectory. then try again.
92-
3. `pnpm i` fails due to wrong node version. Make sure to be using `v18`. Node version `v21` is not supported and known to cause issues.
78+
All of the typescript / javascript packages in this repository are part of a
79+
[turborepo](https://turbo.build/repo/docs) monorepo.
80+
81+
#### Setting up
82+
83+
If you use nix and direnv, just cd to the project directory and `direnv allow`.
84+
85+
If you use nix but not direnv, just cd to the project directory and enter a nix
86+
development shell with `nix develop`.
87+
88+
If you don't use nix at all, then install the required system packages:
89+
90+
- [Node.js](https://nodejs.org/en) -- match the version to `.nvmrc`; you can use
91+
[nvm](https://github.com/nvm-sh/nvm) to manage your Node.js version.
92+
- [pnpm](https://pnpm.io/) -- match the version to the version specified in
93+
`package.json`; you can experiment with
94+
[corepack](https://nodejs.org/api/corepack.html) to manage your pnpm version
95+
for you.
96+
97+
#### Common tasks
98+
99+
The following tasks are the most common ways to interact with the monorepo.
100+
Thanks to [turborepo](https://turbo.build/repo/docs), these tasks will
101+
coordinate building any needed dependencies, and task execution will be cached
102+
and will only re-run as necessary. For any of the following tasks, you can pass
103+
[any valid `turbo run` option](https://turbo.build/repo/docs/reference/run)
104+
after `--`, for instance you could run `pnpm test -- --concurrency 2`.
105+
106+
- `pnpm test`: Run all unit tests, integration tests, linting, and format
107+
checks, as well as whatever other code checks any packages support.
108+
- `pnpm fix`: Run auto fixes, including reformatting code and auto-fixing lint
109+
rules where possible.
110+
- `pnpm start:dev`: Start all development servers in parallel.
111+
- `pnpm start:prod`: Run production builds and start production mode servers in
112+
parallel.
93113

94114
## Audit / Feature Status
95115

apps/api-reference/package.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,14 @@
88
},
99
"scripts": {
1010
"build": "next build",
11-
"fix": "pnpm fix:lint && pnpm fix:format",
1211
"fix:format": "prettier --write .",
1312
"fix:lint": "eslint --fix .",
14-
"pull:env": "VERCEL_ORG_ID=team_BKQrg3JJFLxZyTqpuYtIY0rj VERCEL_PROJECT_ID=prj_gbljYVzp0m5EpCuOF6nZpM4WMFM6 vercel env pull",
15-
"start:dev": "next dev",
16-
"start:prod": "next start",
17-
"test": "tsc && jest",
13+
"pull:env": "[ $VERCEL ] || VERCEL_ORG_ID=team_BKQrg3JJFLxZyTqpuYtIY0rj VERCEL_PROJECT_ID=prj_gbljYVzp0m5EpCuOF6nZpM4WMFM6 vercel env pull",
14+
"start:dev": "next dev --port 3002",
15+
"start:prod": "next start --port 3002",
1816
"test:format": "jest --selectProjects format",
1917
"test:lint": "jest --selectProjects lint",
20-
"test:types": "tsc",
21-
"test:unit": "jest --selectProjects unit --passWithNoTests"
18+
"test:types": "tsc"
2219
},
2320
"dependencies": {
2421
"@amplitude/analytics-browser": "^2.9.0",

apps/api-reference/turbo.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"$schema": "https://turbo.build/schema.json",
3+
"extends": ["//"],
4+
"tasks": {
5+
"build": {
6+
"dependsOn": ["pull:env", "^build"],
7+
"outputs": [".next/**", "!.next/cache/**"]
8+
},
9+
"pull:env": {
10+
"outputs": [".env.local"],
11+
"cache": false
12+
},
13+
"start:dev": {
14+
"dependsOn": ["pull:env"],
15+
"persistent": true,
16+
"cache": false
17+
},
18+
"start:prod": {
19+
"dependsOn": ["build"],
20+
"persistent": true,
21+
"cache": false
22+
}
23+
}
24+
}

apps/hermes/client/js/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
lib/
2+
src/zodSchemas.ts
3+
schema.json

apps/hermes/client/js/package.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,14 @@
2020
"access": "public"
2121
},
2222
"scripts": {
23-
"test": "jest --testPathIgnorePatterns=.*.e2e.test.ts --passWithNoTests",
24-
"test:e2e": "jest --testPathPattern=.*.e2e.test.ts",
25-
"build": "tsc",
26-
"generate-hermes-api-types": "openapi-zod-client https://hermes.pyth.network/docs/openapi.json --output src/zodSchemas.ts && prettier --write src/zodSchemas.ts",
27-
"check-hermes-api-types": "git diff --exit-code src/zodSchemas.ts",
23+
"build:typescript": "tsc",
24+
"build:schemas": "openapi-zod-client ./schema.json --output src/zodSchemas.ts",
25+
"pull:schema": "curl -o schema.json -z schema.json https://hermes.pyth.network/docs/openapi.json",
2826
"example": "pnpm run build && node lib/examples/HermesClient.js",
2927
"format": "prettier --write \"src/**/*.ts\"",
30-
"lint": "eslint src/",
31-
"prepublishOnly": "pnpm run build && pnpm test && pnpm run lint",
32-
"preversion": "pnpm run lint",
28+
"test:lint": "eslint src/",
29+
"prepublishOnly": "pnpm run build && pnpm run test:lint",
30+
"preversion": "pnpm run test:lint",
3331
"version": "pnpm run format && git add -A src"
3432
},
3533
"keywords": [

0 commit comments

Comments
 (0)