Skip to content

Commit 91a9939

Browse files
authored
chore: switch to pnpm and fix peer dependencies (#345)
A somewhat reoccurring issue has been dependency updates introducing `peerDependency` misalignment that causes installation / run errors with tools like `npx`. Originally I was planning to address this by introducing new CI steps that checked for this, but instead I've decided to give `pnpm` a go. As far as I understand it has the strictest rules of the common package managers around dependency resolution, and therefore if it works with `pnpm` it'll probably work with everything else. Making this change surfaced a number of implicit dependency issues across the repository, and unintentional reliance on `jest` globals. I'd be fairly keen to additionally do away with the `lerna` dependency, as its now only used for publishing the packages, but that's probably a job for another day.
1 parent 39b5e3c commit 91a9939

Some content is hidden

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

42 files changed

+33471
-22556
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,41 +21,37 @@ jobs:
2121
with:
2222
fetch-depth: 0
2323

24+
- name: Install pnpm
25+
uses: pnpm/action-setup@v4
26+
2427
- name: Use Node.js ${{ matrix.node-version }}
2528
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
2629
with:
2730
registry-url: "https://registry.npmjs.org"
2831
node-version: ${{ matrix.node-version }}
29-
30-
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
31-
id: yarn-cache
32-
with:
33-
path: .yarn
34-
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
35-
restore-keys: |
36-
${{ runner.os }}-yarn-
32+
cache: 'pnpm'
3733

3834
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
3935
id: nextjs-cache
4036
with:
4137
path: packages/documentation/.next/cache
42-
key: ${{ runner.os }}-nextjs-${{ hashFiles('yarn.lock') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
38+
key: ${{ runner.os }}-nextjs-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
4339
restore-keys: |
44-
${{ runner.os }}-nextjs-${{ hashFiles('yarn.lock') }}-
40+
${{ runner.os }}-nextjs-${{ hashFiles('pnpm-lock.yaml') }}-
4541
46-
- run: corepack enable
42+
- run: pnpm install --frozen-lockfile
4743

48-
- run: yarn --immutable
44+
- run: pnpm ci-build
45+
- run: pnpm ci-test
46+
- run: pnpm ci-lint
4947

50-
- run: yarn ci-build
51-
- run: yarn ci-test
52-
- run: yarn ci-lint
48+
- run: pnpm install --frozen-lockfile
5349

54-
- run: yarn integration:generate
55-
- run: yarn integration:validate
50+
- run: pnpm integration:generate
51+
- run: pnpm integration:validate
5652

57-
- run: yarn e2e:generate
58-
- run: yarn e2e:validate
53+
- run: pnpm e2e:generate
54+
- run: pnpm e2e:validate
5955

6056
- name: Check for uncommitted changes
6157
run: ./scripts/assert-clean-working-directory.sh
@@ -71,13 +67,13 @@ jobs:
7167
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
7268
#
7369
# - name: Publish to NPM
74-
# run: echo 'publish release' #yarn lerna publish --no-private --force-publish --yes --conventional-commits
70+
# run: echo 'publish release' #pnpm lerna publish --no-private --force-publish --yes --conventional-commits
7571
# if: github.ref == 'refs/heads/main'
7672
# env:
7773
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
7874
#
7975
# - name: Publish to NPM (Alpha)
80-
# run: echo 'publish alpha release' #yarn lerna publish --no-private --force-publish --yes --conventional-commits --canary
76+
# run: echo 'publish alpha release' #pnpm lerna publish --no-private --force-publish --yes --conventional-commits --canary
8177
# if: github.ref != 'refs/heads/main'
8278
# env:
8379
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/publish-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
4343
- run: corepack enable
4444

45-
- run: yarn --immutable
45+
- run: pnpm install --frozen-lockfile
4646
- run: yarn ci-build
4747
- name: Publish documentation
4848
if: github.ref == 'refs/heads/main'

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
yarn lint-staged
1+
pnpm lint-staged

.yarnrc.yml

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

CONTRIBUTING.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ PR with a detailed description is fine too.
2828
[fnm](https://github.com/Schniz/fnm)
2929
2. Enable [corepack](https://nodejs.org/api/corepack.html) using `corepack
3030
enable`
31-
3. Install `devDependencies` using `yarn`
31+
3. Install `devDependencies` using `pnpm`
3232

3333
## Workflow
3434

@@ -37,34 +37,34 @@ See [package.json](./package.json) for available scripts.
3737
Main ones of interest are `build`, `test`, `lint`. E.g:
3838

3939
```shell
40-
yarn build
41-
yarn test
42-
yarn lint
43-
yarn format
40+
pnpm build
41+
pnpm test
42+
pnpm lint
43+
pnpm format
4444
```
4545

4646
To regenerate the integration tests:
4747

4848
```shell
49-
yarn integration:generate
49+
pnpm integration:generate
5050
```
5151

5252
And to build them / check the code output is valid:
5353

5454
```shell
55-
yarn integration:validate
55+
pnpm integration:validate
5656
```
5757

5858
There's also a `ci-pipeline` script that can be used as a pre-push check, e.g:
5959

6060
```shell
61-
yarn ci-pipeline && git push --force-with-lease
61+
pnpm ci-pipeline && git push --force-with-lease
6262
```
6363

6464
## Typescript Conventions
6565

6666
```shell
67-
yarn build
67+
pnpm build
6868
```
6969

7070
We strive for robust type safety, both in the library and the code it outputs.
@@ -77,8 +77,8 @@ in the fetch runtime [here][ts-ignore-example]
7777
## Linting / Formatting
7878

7979
```shell
80-
yarn lint
81-
yarn format
80+
pnpm lint
81+
pnpm format
8282
```
8383

8484
We use `biome` for formatting, and linting, largely sticking to the recommended rules.
@@ -87,8 +87,8 @@ The config can be seen here [./biome.json](./biome.json)
8787
## Testing
8888

8989
```shell
90-
yarn test
91-
yarn integration:generate && yarn integration:validate
90+
pnpm test
91+
pnpm integration:generate && pnpm integration:validate
9292
```
9393

9494
We have two types of testing in play:
@@ -123,9 +123,9 @@ assist:
123123

124124
```shell
125125
# Publish a pre-release, eg: 0.0.2-alpha.107
126-
yarn publish:alpha
126+
pnpm publish:alpha
127127
# Publish a release, eg: 0.0.1
128-
yarn publish:release
128+
pnpm publish:release
129129
```
130130

131131
These will build and test before asking for publish confirmation.

e2e/package.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,22 @@
1414
},
1515
"dependencies": {
1616
"@koa/router": "^13.1.1",
17-
"@nahkies/typescript-koa-runtime": "*",
17+
"@nahkies/typescript-axios-runtime": "workspace:*",
18+
"@nahkies/typescript-express-runtime": "workspace:*",
19+
"@nahkies/typescript-fetch-runtime": "workspace:*",
20+
"@nahkies/typescript-koa-runtime": "workspace:*",
21+
"axios": "^1.10.0",
22+
"express": "^5.1.0",
1823
"koa": "^3.0.0",
19-
"zod": "^3.25.74"
24+
"zod": "3.25.74"
2025
},
2126
"devDependencies": {
22-
"@nahkies/openapi-code-generator": "*",
27+
"@jest/globals": "^30.0.4",
28+
"@nahkies/openapi-code-generator": "workspace:*",
29+
"@types/express": "^5.0.3",
2330
"@types/koa": "^2.15.0",
2431
"@types/koa__router": "^12.0.4",
32+
"expect": "^30.0.4",
2533
"jest": "^30.0.4",
2634
"typescript": "~5.8.3"
2735
}

e2e/scripts/generate.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ set -e
44

55
SCHEMA_BUILDER=zod
66

7-
yarn openapi-code-generator \
7+
pnpm openapi-code-generator \
88
--input ./openapi.yaml \
99
--output ./src/generated/server/koa \
1010
--template typescript-koa \
1111
--schema-builder "$SCHEMA_BUILDER" \
1212
--extract-inline-schemas \
1313
--grouping-strategy first-tag
1414

15-
yarn openapi-code-generator \
15+
pnpm openapi-code-generator \
1616
--input ./openapi.yaml \
1717
--output ./src/generated/server/express \
1818
--template typescript-express \
1919
--schema-builder "$SCHEMA_BUILDER" \
2020
--extract-inline-schemas \
2121
--grouping-strategy first-tag
2222

23-
yarn openapi-code-generator \
23+
pnpm openapi-code-generator \
2424
--input ./openapi.yaml \
2525
--output ./src/generated/client/fetch \
2626
--template typescript-fetch \
@@ -29,7 +29,7 @@ yarn openapi-code-generator \
2929
--enable-runtime-response-validation \
3030
--override-specification-title "E2E Test Client"
3131

32-
yarn openapi-code-generator \
32+
pnpm openapi-code-generator \
3333
--input ./openapi.yaml \
3434
--output ./src/generated/client/axios \
3535
--template typescript-axios \

e2e/src/index.axios.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type {Server} from "node:http"
2-
import {beforeAll, describe, expect, it} from "@jest/globals"
2+
import {afterAll, beforeAll, describe, expect, it} from "@jest/globals"
33
import type {AxiosError} from "axios"
44
import {ApiClient} from "./generated/client/axios/client"
55
import {E2ETestClientServers} from "./generated/client/fetch/client"

e2e/src/index.fetch.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type {Server} from "node:http"
2-
import {beforeAll, describe, expect, it} from "@jest/globals"
2+
import {afterAll, beforeAll, describe, expect, it} from "@jest/globals"
33
import {ApiClient, E2ETestClientServers} from "./generated/client/fetch/client"
44
import {startServerFunctions} from "./index"
55
import {numberBetween} from "./test-utils"

integration-tests/typescript-angular/angular.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
33
"version": 1,
44
"cli": {
5-
"packageManager": "yarn"
5+
"packageManager": "pnpm"
66
},
77
"newProjectRoot": "projects",
88
"projects": {

0 commit comments

Comments
 (0)