Skip to content

Commit b1a80ab

Browse files
committed
Use pnpm with Volta for Node.js testing
- Add nodeModulesDir: "none" to deno.json to prevent Deno from using node_modules when package.json is present - Add pnpm-workspace.yaml for pnpm workspace configuration - Add package.json with Volta pinned versions and packageManager field - Update bdd/package.json to use workspace:* for local deps - Update CI to use pnpm/action-setup and actions/setup-node - Update README with Volta installation instructions
1 parent daf73d2 commit b1a80ab

File tree

8 files changed

+78
-30
lines changed

8 files changed

+78
-30
lines changed

.github/workflows/verify-node.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,22 @@ jobs:
1414
strategy:
1515
matrix:
1616
os: [ubuntu-latest, macos-latest]
17-
node: ['22', '24']
1817
runs-on: ${{ matrix.os }}
1918

2019
steps:
2120
- name: checkout
2221
uses: actions/checkout@v4
2322

23+
- name: setup pnpm
24+
uses: pnpm/action-setup@v4
25+
2426
- name: setup node
2527
uses: actions/setup-node@v4
2628
with:
27-
node-version: ${{ matrix.node }}
29+
node-version: 22
2830

2931
- name: install dependencies
30-
run: npm install
32+
run: pnpm install
3133

3234
- name: run tests
33-
run: npm test
35+
run: pnpm test

.github/workflows/verify-posix.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
uses: denoland/setup-deno@v2
2525
with:
2626
deno-version: v2.x
27+
2728
- name: reload dependencies
2829
run: deno cache --reload **/mod.ts
2930

README.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,26 @@ deno test --import-map v4.importmap.json -A
4646

4747
### Node.js Testing
4848

49-
Packages with Node.js support have a `package.json` with a `test` script. To run
50-
all Node.js tests across all packages:
49+
This repository uses [Volta](https://volta.sh/) to manage Node.js and pnpm
50+
versions. The versions are pinned in `package.json`.
51+
52+
#### Prerequisites
53+
54+
Install Volta if you haven't already:
5155

5256
```bash
53-
npm install
54-
npm test
57+
curl https://get.volta.sh | bash
5558
```
5659

57-
This runs `npm test --workspaces --if-present`, which executes the `test` script
58-
in each package that has one defined.
60+
Volta will automatically install the correct Node.js and pnpm versions when you
61+
run commands in this repository.
62+
63+
#### Running tests
64+
65+
```bash
66+
pnpm install
67+
pnpm test
68+
```
5969

6070
#### Adding Node.js support to a package
6171

@@ -76,14 +86,15 @@ in each package that has one defined.
7686
"test": "node --experimental-strip-types --test *.test.ts"
7787
},
7888
"dependencies": {
79-
"effection": "^3"
89+
"effection": "^3",
90+
"@effectionx/your-dependency": "workspace:*"
8091
}
8192
}
8293
```
8394

8495
2. Create platform-specific entry points (`mod.deno.ts`, `mod.node.ts`)
85-
3. Add the package to the root `package.json` workspaces array
86-
4. Run `npm install` to link the workspace
96+
3. Update the `deno.json` exports to point to the Deno-specific entry point
97+
4. Add the package to `pnpm-workspace.yaml`
8798

8899
## To publish a new project
89100

bdd/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
},
1616
"dependencies": {
1717
"effection": "^3",
18-
"@effectionx/test-adapter": "*"
18+
"@effectionx/test-adapter": "workspace:*"
1919
}
2020
}

deno.json

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"nodeModulesDir": "none",
23
"imports": {
34
"effection": "npm:effection@^3",
45
"@deno/dnt": "jsr:@deno/[email protected]",
@@ -7,24 +8,13 @@
78
"@std/fs": "jsr:@std/fs@^1"
89
},
910
"compilerOptions": {
10-
"lib": [
11-
"deno.ns",
12-
"dom.iterable",
13-
"dom"
14-
],
11+
"lib": ["deno.ns", "dom.iterable", "dom"],
1512
"jsx": "react-jsx",
1613
"jsxImportSource": "revolution"
1714
},
1815
"lint": {
19-
"rules": {
20-
"exclude": [
21-
"prefer-const",
22-
"require-yield"
23-
]
24-
},
25-
"exclude": [
26-
"tasks"
27-
]
16+
"rules": { "exclude": ["prefer-const", "require-yield"] },
17+
"exclude": ["tasks"]
2818
},
2919
"workspace": [
3020
"./context-api",

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22
"name": "effectionx",
33
"private": true,
44
"type": "module",
5-
"workspaces": ["bdd", "test-adapter"],
5+
"packageManager": "[email protected]",
66
"scripts": {
7-
"test": "npm test --workspaces --if-present"
7+
"test": "pnpm -r --if-present test"
88
},
99
"dependencies": {
1010
"effection": "^3"
11+
},
12+
"volta": {
13+
"node": "22.12.0",
14+
"pnpm": "9.15.9"
1115
}
1216
}

pnpm-lock.yaml

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
packages:
2+
- "bdd"
3+
- "test-adapter"

0 commit comments

Comments
 (0)