Skip to content

Commit ddc811d

Browse files
chore: migrate npm to pnpm across CI, Docker, and scripts (#555)
1 parent 8eee70f commit ddc811d

26 files changed

Lines changed: 6782 additions & 11174 deletions

.changeset/bright-clocks-jam.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"nostream": patch
3+
---
4+
5+
Migrate project tooling from npm to pnpm across CI workflows, Docker setup, hooks, and contributor commands.

.github/workflows/changesets.yml

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

24+
- uses: pnpm/action-setup@v4
25+
2426
- uses: actions/setup-node@v3
2527
with:
2628
node-version-file: .nvmrc
27-
cache: npm
29+
cache: pnpm
2830

2931
- name: Install package dependencies
30-
run: npm ci
32+
run: pnpm install --frozen-lockfile
3133

3234
- run: git config user.name "github-actions[bot]"
3335
- run: git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
3436

3537
- name: Create Release Pull Request
3638
uses: changesets/action@v1
3739
with:
38-
version: npm run changeset:version
40+
version: pnpm run changeset:version
3941
createGithubReleases: true
4042
title: "chore: release new version 🚀"
4143
commit: "chore: version packages"

.github/workflows/checks.yml

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ jobs:
2020
uses: actions/checkout@v3
2121
with:
2222
fetch-depth: 0
23+
- uses: pnpm/action-setup@v4
2324
- uses: actions/setup-node@v3
2425
with:
2526
node-version-file: .nvmrc
26-
cache: npm
27+
cache: pnpm
2728
- name: Install package dependencies
28-
run: npm ci
29+
run: pnpm install --frozen-lockfile
2930
- name: Run commitlint
3031
uses: wagoid/commitlint-github-action@v5
3132
lint:
@@ -34,30 +35,32 @@ jobs:
3435
steps:
3536
- name: Checkout
3637
uses: actions/checkout@v3
38+
- uses: pnpm/action-setup@v4
3739
- uses: actions/setup-node@v3
3840
with:
3941
node-version-file: .nvmrc
40-
cache: npm
42+
cache: pnpm
4143
- name: Install package dependencies
42-
run: npm ci
44+
run: pnpm install --frozen-lockfile
4345
- name: Run Biome
44-
run: npm run lint
46+
run: pnpm run lint
4547
- name: Run Knip
46-
run: npm run knip
48+
run: pnpm run check:deps
4749
build-check:
4850
name: Build check
4951
runs-on: ubuntu-latest
5052
steps:
5153
- name: Checkout
5254
uses: actions/checkout@v3
55+
- uses: pnpm/action-setup@v4
5356
- uses: actions/setup-node@v3
5457
with:
5558
node-version-file: .nvmrc
56-
cache: npm
59+
cache: pnpm
5760
- name: Install package dependencies
58-
run: npm ci
61+
run: pnpm install --frozen-lockfile
5962
- name: Run build check
60-
run: npm run build:check
63+
run: pnpm run build:check
6164
test-units-and-cover:
6265
name: Unit Tests And Coverage
6366
runs-on: ubuntu-latest
@@ -68,16 +71,17 @@ jobs:
6871
steps:
6972
- name: Checkout
7073
uses: actions/checkout@v3
74+
- uses: pnpm/action-setup@v4
7175
- uses: actions/setup-node@v3
7276
with:
7377
node-version-file: .nvmrc
74-
cache: npm
78+
cache: pnpm
7579
- name: Install package dependencies
76-
run: npm ci
80+
run: pnpm install --frozen-lockfile
7781
- name: Run unit tests
78-
run: npm run test:unit
82+
run: pnpm run test:unit
7983
- name: Run coverage for unit tests
80-
run: npm run cover:unit
84+
run: pnpm run cover:unit
8185
if: ${{ always() }}
8286
- uses: actions/upload-artifact@v4
8387
name: Upload coverage report for unit tests
@@ -103,11 +107,12 @@ jobs:
103107
steps:
104108
- name: Checkout
105109
uses: actions/checkout@v3
110+
- uses: pnpm/action-setup@v4
106111
- uses: actions/setup-node@v3
107112
with:
108113
node-version-file: .nvmrc
109114
- name: Run integration tests
110-
run: npm run docker:test:integration
115+
run: pnpm run docker:test:integration
111116
- name: Generate Cucumber report annotations
112117
uses: deblockt/cucumber-report-annotations-action@v1.7
113118
if: ${{ always() }}
@@ -116,7 +121,7 @@ jobs:
116121
access-token: ${{ secrets.GITHUB_TOKEN }}
117122
path: .test-reports/integration/report.json
118123
- name: Run coverage for integration tests
119-
run: npm run docker:cover:integration
124+
run: pnpm run docker:cover:integration
120125
- name: Coveralls
121126
uses: coverallsapp/github-action@master
122127
if: ${{ always() }}
@@ -151,11 +156,12 @@ jobs:
151156
uses: actions/checkout@v3
152157
with:
153158
fetch-depth: 0
159+
- uses: pnpm/action-setup@v4
154160
- uses: actions/setup-node@v3
155161
with:
156162
node-version-file: .nvmrc
157-
cache: npm
163+
cache: pnpm
158164
- name: Install package dependencies
159-
run: npm ci
165+
run: pnpm install --frozen-lockfile
160166
- name: Check for changeset
161-
run: npx changeset status --since origin/${{ github.base_ref }}
167+
run: pnpm exec changeset status --since origin/${{ github.base_ref }}

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ npm-debug.log*
1313

1414
# Dependency directories
1515
node_modules/
16+
package-lock.json
1617

1718
# TypeScript cache
1819
*.tsbuildinfo
1920

20-
# Optional npm cache directory
21+
# Optional package manager cache directories
2122
.npm
23+
.pnpm-store
24+
pnpm-debug.log*
2225

2326
# Caches
2427
.eslintcache

.husky/commit-msg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env sh
22
. "$(dirname -- "$0")/_/husky.sh"
33

4-
npx --no -- commitlint --edit ${1}
4+
pnpm exec commitlint --edit "${1}"

.husky/pre-commit

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env sh
22
. "$(dirname -- "$0")/_/husky.sh"
33

4-
npm run lint
5-
npm run build:check
6-
npm run test:unit
4+
pnpm run lint
5+
pnpm run build:check
6+
pnpm run test:unit

CONFIGURATION.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,16 @@ The schema ships with a small, query-driven set of indexes. The most important o
9494
Run the read-only benchmark against your own database to confirm the planner is using the expected indexes and to record baseline latencies:
9595

9696
```sh
97-
npm run db:benchmark
98-
npm run db:benchmark -- --runs 5 --kind 1 --limit 500
97+
pnpm db:benchmark
98+
pnpm db:benchmark --runs 5 --kind 1 --limit 500
9999
```
100100

101101
The `db:benchmark` script loads the local `.env` file automatically (via `node --env-file-if-exists=.env`), using the same `DB_HOST`/`DB_PORT`/`DB_USER`/`DB_PASSWORD`/`DB_NAME` variables as the relay. The benchmark issues only `EXPLAIN (ANALYZE, BUFFERS)` and `SELECT` statements — it never writes. Flags: `--runs <n>` (default 3), `--kind <n>` (default 1 / `TEXT_NOTE`; pass `0` for SET_METADATA), `--limit <n>` (default 500), `--horizon-days <n>` (default 7), `--help`.
102102

103103
For a full before/after proof of the index impact (seeds a throwaway dataset, drops and recreates the indexes, and prints a BEFORE/AFTER table), use:
104104

105105
```sh
106-
npm run db:verify-index-impact
106+
pnpm db:verify-index-impact
107107
```
108108

109109
The hot-path index migration (`20260420_120000_add_hot_path_indexes.js`) uses `CREATE INDEX CONCURRENTLY`, so it can be applied to a running relay without taking `ACCESS EXCLUSIVE` locks on the `events` or `invoices` tables.

CONTRIBUTING.md

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ cd nostream
4343
Install dependencies (this also sets up Husky pre-commit hooks automatically):
4444

4545
```
46-
npm install
46+
corepack enable
47+
pnpm install
4748
```
4849

4950
> **Important:** Pre-commit hooks installed by Husky run linting and formatting checks on every
@@ -96,7 +97,7 @@ SECRET=aaabbbccc...dddeeefff
9697
Run migrations (at least once and after pulling new changes):
9798

9899
```
99-
NODE_OPTIONS="-r dotenv/config" npm run db:migrate
100+
pnpm db:migrate
100101
```
101102

102103
Create the `.nostr` folder and copy the default settings file:
@@ -109,19 +110,19 @@ cp resources/default-settings.yaml .nostr/settings.yaml
109110
Start in development mode:
110111

111112
```
112-
npm run dev
113+
pnpm dev
113114
```
114115

115116
Or start in production mode:
116117

117118
```
118-
npm run start
119+
pnpm start
119120
```
120121

121122
To clean up build, coverage, and test reports:
122123

123124
```
124-
npm run clean
125+
pnpm clean
125126
```
126127

127128
## Tests
@@ -131,10 +132,10 @@ npm run clean
131132
Run code quality checks with Biome:
132133

133134
```
134-
npm run lint
135-
npm run lint:fix
136-
npm run format
137-
npm run format:check
135+
pnpm lint
136+
pnpm lint:fix
137+
pnpm format
138+
pnpm check:format
138139
```
139140

140141
### Unit tests
@@ -148,19 +149,19 @@ cd /path/to/nostream
148149
Run unit tests:
149150

150151
```
151-
npm run test:unit
152+
pnpm test:unit
152153
```
153154

154155
Run unit tests in watch mode:
155156

156157
```
157-
npm run test:unit:watch
158+
pnpm test:unit:watch
158159
```
159160

160161
Get unit test coverage:
161162

162163
```
163-
npm run cover:unit
164+
pnpm cover:unit
164165
```
165166

166167
Open the unit test report:
@@ -186,13 +187,13 @@ cd /path/to/nostream
186187
Run integration tests:
187188

188189
```
189-
npm run docker:test:integration
190+
pnpm docker:test:integration
190191
```
191192

192193
Get integration test coverage:
193194

194195
```
195-
npm run docker:cover:integration
196+
pnpm docker:cover:integration
196197
```
197198

198199
### Integration tests (Standalone)
@@ -222,7 +223,7 @@ DB_MAX_POOL_SIZE=2
222223
Run the integration tests:
223224

224225
```
225-
npm run test:integration
226+
pnpm test:integration
226227
```
227228

228229
Open the integration test report:
@@ -234,7 +235,7 @@ open .test-reports/integration/report.html
234235
Get integration test coverage:
235236

236237
```
237-
npm run cover:integration
238+
pnpm cover:integration
238239
```
239240

240241
Open the integration test coverage report:
@@ -252,7 +253,7 @@ event flood (spam) attacks. This is used to verify relay resilience and prevent
252253

253254
```bash
254255
# Simulates 5,000 idle "zombie" connections + 100 events/sec spam
255-
npm run test:load -- --zombies 5000 --spam-rate 100
256+
pnpm test:load --zombies 5000 --spam-rate 100
256257
```
257258

258259
### Analyzing Memory (Heap Snapshots)
@@ -299,10 +300,10 @@ To observe client and subscription counts in real-time during a test, you can in
299300
Run dead code and dependency analysis before opening a pull request:
300301

301302
```
302-
npm run knip
303+
pnpm check:deps
303304
```
304305

305-
`npm run lint` now runs Biome.
306+
`pnpm lint` now runs Biome.
306307

307308
## Pull Request Process
308309

@@ -323,7 +324,7 @@ Every pull request that changes behavior, adds a feature, or fixes a bug **must
323324
To add a changeset:
324325

325326
```bash
326-
npx changeset
327+
pnpm exec changeset
327328
```
328329

329330
This interactive prompt will ask you to:
@@ -338,7 +339,7 @@ If your PR **only** updates documentation, CI/CD configuration, or test coverage
338339
production source code untouched — an empty changeset is acceptable:
339340

340341
```bash
341-
npx changeset --empty
342+
pnpm exec changeset --empty
342343
```
343344

344345
Commit the generated `.changeset/*.md` file with your PR. This satisfies CI without producing a
@@ -362,6 +363,6 @@ This applies to PRs that exclusively contain:
362363
Run Biome checks before opening a pull request:
363364

364365
```
365-
npm run lint
366-
npm run format:check
366+
pnpm lint
367+
pnpm check:format
367368
```

0 commit comments

Comments
 (0)