Skip to content

Commit 0ec397c

Browse files
committed
build: migrate from yarn to npm
1 parent 45a118e commit 0ec397c

13 files changed

Lines changed: 13893 additions & 7899 deletions

File tree

.github/workflows/sanity.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,12 @@ jobs:
3232
uses: actions/setup-node@v4
3333
with:
3434
node-version: ${{ matrix.node-version }}
35-
cache: 'yarn'
35+
cache: 'npm'
3636
- name: Install dependencies
37-
run: yarn install --frozen-lockfile
37+
run: npm ci
3838
- name: Install MongoDB driver ${{ matrix.mongodb-driver }}
3939
run: |
40-
npm install mongodb@${MONGODB_DRIVER_VERSION} --no-save --no-audit --legacy-peer-deps
41-
rm -f package-lock.json npm-shrinkwrap.json
40+
npm install mongodb@${MONGODB_DRIVER_VERSION} --no-save --no-package-lock --no-audit --legacy-peer-deps
4241
- name: Start MongoDB ${{ matrix.mongo-server }}
4342
run: docker compose up -d
4443
- name: Wait for MongoDB to accept connections
@@ -51,15 +50,15 @@ jobs:
5150
done
5251
echo "MongoDB failed to start" >&2
5352
exit 1
54-
- run: yarn typecheck
55-
- run: yarn test
53+
- run: npm run typecheck
54+
- run: npm test
5655
- name: Upload coverage
5756
if: matrix.node-version == '22.x' && matrix.mongodb-driver == '6' && matrix.mongo-server == '6.0'
58-
run: yarn cov:send
57+
run: npm run cov:send
5958
env:
6059
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
6160
- name: Build artifacts
62-
run: yarn build
61+
run: npm run build
6362
- name: Tear down MongoDB
6463
if: always()
6564
run: docker compose down -v

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ node_modules
66
src/**.js
77
coverage
88
*.log
9-
package-lock.json
109
.eslintcache
1110
example/.env
1211
docker/tls/*

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env sh
22
[ "${HUSKY-}" = "0" ] && exit 0
33

4-
yarn lint-staged
4+
npx lint-staged

AGENTS.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ Welcome! This file keeps lightweight coordination notes for anyone (human or AI)
66

77
1. Follow `docs/PLANS.md` for the prioritized maintenance backlog.
88
2. When picking up a task, append a short status note under the relevant section in `docs/PLANS.md` (e.g. `- [started YYYY-MM-DD] <task>`), then remove or update it when you finish.
9-
3. Build pipeline now uses `tsdown` for dual ESM/CJS bundles into `dist/` plus `tsc` for typed transpilation (`yarn build` and `yarn typecheck`). Local sanity checks confirm `yarn build`, `yarn test:lint`, and `yarn test:prettier` pass (lint only warns on crypto key_size/iv_size/at_size camelCase). Full `yarn test` still needs a running MongoDB (e.g., docker compose up) until tests migrate to mongodb-memory-server.
9+
3. Build pipeline now uses `tsdown` for dual ESM/CJS bundles into `dist/` plus `tsc` for typed transpilation (`npm run build` and `npm run typecheck`). Local sanity checks confirm `npm run build`, `npm run test:lint`, and `npm run test:prettier` pass (lint only warns on crypto key_size/iv_size/at_size camelCase). Full `npm test` still needs a running MongoDB (e.g., docker compose up) until tests migrate to mongodb-memory-server.
1010

1111
## Workflow Expectations
1212

13-
- Run `yarn install && yarn build && yarn test` locally before opening or updating a PR unless the change is docs-only.
13+
- Run `npm ci && npm run build && npm test` locally before opening or updating a PR unless the change is docs-only.
1414
- Record any assumptions, surprises, or TODOs at the bottom of the touched file(s) in `// TODO(agent): ...` comments or in `docs/PLANS.md`.
1515
- When working on a task, always follow PLAN, EDIT and REVIEW steps.
1616
- When working on a task, always check if CHANGELOG.md or README.md need updates. If encounter breaking changes, add a note to CHANGELOG.md and also create separate migration docs if needed.
@@ -23,3 +23,5 @@ Welcome! This file keeps lightweight coordination notes for anyone (human or AI)
2323
- For complex changes, request a human review to ensure the change aligns with project goals and also ask for clarification on any ambiguous points in the plan.
2424

2525
Thanks for helping keep the project healthy!
26+
27+
// TODO(agent): Husky install failed in this sandbox because `.git/config` was not writable; rerun `npm install` in a normal checkout to populate hooks.

MIGRATION_V4.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,14 @@
22

33
To migrate the library from V3 to V4, re-install the dependencies.
44

5-
If you are using `npm`
5+
Use your package manager (npm example shown):
66

77
```
88
npm uninstall connect-mongo
99
npm uninstall @types/connect-mongo
1010
npm install connect-mongo
1111
```
1212

13-
If you are using `yarn`
14-
15-
```
16-
yarn remove connect-mongo
17-
yarn remove @types/connect-mongo
18-
yarn add connect-mongo
19-
```
20-
2113
Next step is to import the dependencies
2214

2315
Javascript:

README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ MongoDB session store for [Connect](https://github.com/senchalabs/connect) and [
3939

4040
```
4141
npm install connect-mongo
42-
yarn add connect-mongo
4342
```
4443

4544
* Install `mongodb` alongside `connect-mongo`; it is a required peer dependency so you pick the driver version that matches your cluster.
@@ -308,14 +307,14 @@ One of the following options should be provided. If more than one option are pro
308307
## Development
309308

310309
```
311-
yarn install
310+
npm install
312311
docker compose up -d
313-
yarn watch:test
312+
npm run watch:test
314313
```
315314

316315
### TLS & SRV fixtures
317316

318-
- Generate local certificates once with `yarn tls:setup` (drops files in `docker/tls`).
317+
- Generate local certificates once with `npm run tls:setup` (drops files in `docker/tls`).
319318
- Launch the optional TLS container with `docker compose -f docker-compose.yaml -f docker-compose.tls.yaml --profile tls up -d`.
320319
- Copy `example/.env.example` to `example/.env` and point `MONGO_URL` to the TLS port (`mongodb://root:example@127.0.0.1:27443/example-db?authSource=admin`). Add `MONGO_TLS_CA_FILE=../docker/tls/ca.crt` so the driver trusts the self-signed CA. Set `MONGO_TLS_CERT_KEY_FILE=../docker/tls/client.pem` if you need mutual TLS.
321320
- To exercise SRV/TLS against a managed cluster (Atlas, DocumentDB, CosmosDB), set `MONGO_URL` to your `mongodb+srv://` string and either `MONGO_TLS_CA_FILE` or `NODE_EXTRA_CA_CERTS` to the provider CA bundle. The example scripts automatically reuse those settings in every variant (plain JS, Mongoose, and TS).
@@ -325,12 +324,12 @@ yarn watch:test
325324
```
326325
# from the repo root
327326
cp example/.env.example example/.env
328-
yarn link
327+
npm link
329328
cd example
330-
yarn link "connect-mongo" # optional if you want live code from this checkout
331-
yarn install
332-
yarn start:js
333-
# or yarn start:mongoose / yarn start:ts
329+
npm link "connect-mongo" # optional if you want live code from this checkout
330+
npm install
331+
npm run start:js
332+
# or npm run start:mongoose / npm run start:ts
334333
```
335334

336335
After the first run you can edit `example/.env` to swap between the local docker fixture, the TLS profile, or any `mongodb+srv://` cluster without changing the code.
@@ -340,7 +339,7 @@ After the first run you can edit `example/.env` to swap between the local docker
340339
Until the GitHub release workflow lands, do the manual flow:
341340

342341
1. Bump version, update `CHANGELOG.md` and README. Commit and push.
343-
2. Run `yarn test && yarn build` (build uses `tsdown` to emit dual ESM/CJS bundles to `dist/`).
342+
2. Run `npm test && npm run build` (build uses `tsdown` to emit dual ESM/CJS bundles to `dist/`).
344343
3. Publish: `npm publish`
345344
4. Tag: `git tag vX.Y.Z && git push --tags`
346345

docs/PLANS.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88

99
- Tooling & CI
1010
- Rework integration helpers: replace the broken `check-cli`/`diff-integration-tests`, document a safe reset workflow, and migrate `test:integration` to mongodb-memory-server.
11-
- CI matrix should cover MongoDB driver ranges via temp `yarn add --no-lockfile --dev mongodb@x`, exercise MongoDB 7.x containers with health checks, and always run `docker compose down` in a finally step.
12-
- Expand coverage for crypto, autoRemove, touchAfter, and transformId using mongodb-memory-server; continue the started live-Mongo upgrade compat test (5.1.0 ➜ current) exposed as `yarn test:compat`.
11+
- CI matrix should cover MongoDB driver ranges via temp `npm install mongodb@x --no-save --no-package-lock`, exercise MongoDB 7.x containers with health checks, and always run `docker compose down` in a finally step.
12+
- Expand coverage for crypto, autoRemove, touchAfter, and transformId using mongodb-memory-server; continue the started live-Mongo upgrade compat test (5.1.0 ➜ current) exposed as `npm run test:compat`.
1313
- Automate releases with standard-version + GitHub Actions to build, test, publish, upload coverage, and tag.
14+
- [done 2025-11-24] Migrate tooling from yarn to npm.
1415

1516
- Docs & Community
1617
- Refresh README badges/compatibility matrix to match supported Node 20/22/24, MongoDB server 4.4–8.0, driver >=5<8, and express support; link to CI results.

example/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ SESSION_SECRET=connect-mongo-example-secret
77
# SESSION_CRYPTO_SECRET=replace-with-a-long-secret
88
# MONGO_MAX_POOL_SIZE=10
99

10-
# TLS flags (after running `yarn tls:setup`)
10+
# TLS flags (after running `npm run tls:setup`)
1111
# MONGO_TLS_CA_FILE=../docker/tls/ca.crt
1212
# MONGO_TLS_CERT_KEY_FILE=../docker/tls/client.pem
1313
# MONGO_TLS_ALLOW_INVALID_CERTIFICATES=false

0 commit comments

Comments
 (0)