Skip to content

Commit 81e7e11

Browse files
authored
feat: Switch to pnpm for build (#497)
Applied the requested change from @sedghi on this. * feat: Switch to pnpm for build * fix: pnpm version specified twice * fix GHSA-px68-xx5g-48q5 * fix: Node versions 20 and later now * Update pinned versions to fix a moderate security issue * .claude ignore * fix: Update to pnpm 11 for better security * fix: pnpm supply chain recommendations * Update to node 22.13 or later for testing
1 parent a8e2d33 commit 81e7e11

15 files changed

Lines changed: 6218 additions & 5142 deletions

.github/workflows/lint-and-format.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,27 @@ on:
77
jobs:
88
lint-and-format:
99
runs-on: ubuntu-latest
10+
env:
11+
PNPM_CONFIG_FROZEN_LOCKFILE: "true"
1012

1113
steps:
1214
- name: Checkout repository
1315
uses: actions/checkout@v4
1416

17+
- name: Setup pnpm
18+
uses: pnpm/action-setup@v4
19+
1520
- name: Setup Node.js
1621
uses: actions/setup-node@v4
1722
with:
18-
node-version: 18
23+
node-version: 24
24+
cache: pnpm
1925

2026
- name: Install packages
21-
run: yarn install --frozen-lockfile
27+
run: pnpm install
2228

2329
- name: Run ESLint
24-
run: yarn lint
30+
run: pnpm lint
2531

2632
- name: Check Prettier formatting
27-
run: yarn format:check
33+
run: pnpm format:check

.github/workflows/pnpm-audit.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: pnpm audit
2+
3+
on:
4+
push:
5+
paths:
6+
- "pnpm-lock.yaml"
7+
pull_request:
8+
paths:
9+
- "pnpm-lock.yaml"
10+
11+
jobs:
12+
audit:
13+
runs-on: ubuntu-latest
14+
env:
15+
PNPM_CONFIG_FROZEN_LOCKFILE: "true"
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Setup pnpm
22+
uses: pnpm/action-setup@v4
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: 22
28+
cache: pnpm
29+
30+
- name: Install packages
31+
run: pnpm install
32+
33+
- name: Audit (fail on high or critical)
34+
run: pnpm audit --audit-level=high

.github/workflows/publish-package.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,33 @@ jobs:
1515
publish-package:
1616
runs-on: ubuntu-latest
1717
environment: publish
18+
env:
19+
PNPM_CONFIG_FROZEN_LOCKFILE: "true"
1820

1921
steps:
2022
- name: Checkout repository
2123
uses: actions/checkout@v4
2224
with:
2325
persist-credentials: false
2426

27+
- name: Setup pnpm
28+
uses: pnpm/action-setup@v4
29+
2530
- name: Setup Node.js
2631
uses: actions/setup-node@v4
2732
with:
2833
node-version: 24
2934
registry-url: 'https://registry.npmjs.org'
35+
cache: pnpm
3036

3137
- name: Install packages
32-
uses: bahmutov/npm-install@v1
38+
run: pnpm install
3339

3440
- name: Run tests
35-
run: npm run test
41+
run: pnpm test
3642

3743
- name: Run build
38-
run: npm run build
44+
run: pnpm build
3945

4046
- name: Semantic release
4147
uses: cycjimmy/semantic-release-action@v6

.github/workflows/tests.yml

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,52 @@ on:
77
jobs:
88
test:
99
runs-on: ubuntu-latest
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
node-version: [22, 24]
14+
env:
15+
PNPM_CONFIG_FROZEN_LOCKFILE: "true"
1016

1117
steps:
1218
- name: Checkout repository
1319
uses: actions/checkout@v4
1420

21+
- name: Setup pnpm
22+
uses: pnpm/action-setup@v4
23+
1524
- name: Setup Node.js
1625
uses: actions/setup-node@v4
1726
with:
18-
node-version: 18
27+
node-version: ${{ matrix.node-version }}
28+
cache: pnpm
1929

2030
- name: Install packages
21-
run: yarn install --frozen-lockfile
31+
run: pnpm install
2232

2333
- name: Run tests
24-
run: yarn test
34+
run: pnpm test
35+
36+
build:
37+
runs-on: ubuntu-latest
38+
env:
39+
PNPM_CONFIG_FROZEN_LOCKFILE: "true"
40+
41+
steps:
42+
- name: Checkout repository
43+
uses: actions/checkout@v4
44+
45+
- name: Setup pnpm
46+
uses: pnpm/action-setup@v4
47+
48+
- name: Setup Node.js
49+
uses: actions/setup-node@v4
50+
with:
51+
node-version: 24
52+
cache: pnpm
53+
54+
- name: Install packages
55+
run: pnpm install
56+
57+
- name: Build
58+
run: pnpm run build

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
1+
.claude
22
*.sw*
33
*~
44

55
node_modules
66
.idea
77
*.iml
88
yarn-error.log
9+
pnpm-debug.log
910
.DS_Store
1011
build
12+
examples/js/dcmjs*
1113
*.code-workspace

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pnpm exec lint-staged

.npmrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
save-exact=true
2+
# Supply-chain / install policy (minimumReleaseAge, trustPolicy, allowBuilds, …): pnpm-workspace.yaml
3+
# In GitHub Actions, workflows set PNPM_CONFIG_FROZEN_LOCKFILE=true so `pnpm install`
4+
# fails when pnpm-lock.yaml is out of date with package.json. Locally, run
5+
# `pnpm run install:update-lockfile` after dependency changes.

README.md

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,41 @@ _Parts of DICOM that dcmjs *will not* focus on:_
5656

5757
## In Node
5858

59-
```None
60-
// To install latest _stable_ release
61-
npm install --save dcmjs
59+
Add **dcmjs** to your application (pnpm):
6260

63-
// To install latest code merged to master
64-
npm install --save dcmjs@dev
61+
```bash
62+
pnpm add dcmjs # latest stable release
63+
pnpm add dcmjs@dev # latest code merged to master
6564
```
6665

66+
The same versions can be installed with `npm install` or Yarn in **your** project; those clients are fine for consuming the published package. **Building this repository** is pnpm-only (see below).
67+
6768
## For Developers
6869

69-
```None
70+
Building and testing this repository requires **[pnpm](https://pnpm.io/)** and **Node.js 22.13 or newer** (pnpm 11 and this repo’s tooling expect that baseline; Rollup’s dependency chain expects a modern `crypto` global). CI runs tests on Node 22 and 24, and runs the production Rollup build on Node 24. The pnpm version is pinned under `packageManager` in `package.json`. Enable [Corepack](https://nodejs.org/api/corepack.html) (`corepack enable`) and use pnpm for every install and script:
71+
72+
```bash
73+
corepack enable
7074
git clone https://github.com/dcmjs-org/dcmjs
7175
cd dcmjs
72-
npm install
73-
npm run build
74-
npm test
76+
pnpm install
77+
pnpm run build
78+
pnpm test
79+
```
80+
81+
Other common tasks:
82+
83+
```bash
84+
pnpm run build:examples # Rollup build + copy bundles into examples/js
85+
pnpm run lint # ESLint (writes fixes)
86+
pnpm run format # Prettier (writes)
87+
pnpm run format:check # Prettier (check only)
7588
```
7689

90+
**Yarn is no longer supported** for working in this repo: there is no `yarn.lock`, and installs, builds, and CI are aligned with `pnpm-lock.yaml` only. Use pnpm so dependency resolution matches lockfile and automation.
91+
92+
After changing dependencies in `package.json`, refresh the lockfile with `pnpm run install:update-lockfile` (or `pnpm install --no-frozen-lockfile`) before opening a PR.
93+
7794
## For Maintainers and Contributors
7895

7996
Publish new version automatically from commit:
@@ -94,8 +111,9 @@ It is advised to use the git-cz, i.e.:
94111

95112
- install git-cz
96113

97-
```
98-
npm install -g git-cz
114+
```bash
115+
pnpm add -g git-cz
116+
# or: npm install -g git-cz
99117
```
100118

101119
- how to commit
@@ -122,13 +140,13 @@ When DICOM standards are updated or new tags need to be added:
122140

123141
1. **Generate the dictionary from DICOM standards** (downloads latest PS3.6 and PS3.7 XML from dicom.nema.org):
124142
```bash
125-
npm run generate-dictionary
143+
pnpm run generate-dictionary
126144
```
127145
This creates/updates `generate/dictionary.js` with the latest tag definitions.
128146

129147
2. **Pack the dictionary into optimized format**:
130148
```bash
131-
npm run pack-dictionary
149+
pnpm run pack-dictionary
132150
```
133151
This generates the optimized `src/dictionary.fast.js` used at runtime.
134152

@@ -168,7 +186,7 @@ Tests are written using the [Jest](https://jestjs.io) testing framework and live
168186

169187
Pull requests should either update existing tests or add new tests in order to ensure good test coverage of the changes being made.
170188

171-
To run all tests use `npm run test`. To only run specific tests use Jest's [`.only`](https://www.testim.io/blog/unit-testing-best-practices/) feature. If you're using VS Code, an extension such as [`firsttris.vscode-jest-runner`](https://marketplace.visualstudio.com/items?itemName=firsttris.vscode-jest-runner) can be used to step through specific tests in the debugger.
189+
To run all tests use `pnpm test`. To only run specific tests use Jest's [`.only`](https://www.testim.io/blog/unit-testing-best-practices/) feature. If you're using VS Code, an extension such as [`firsttris.vscode-jest-runner`](https://marketplace.visualstudio.com/items?itemName=firsttris.vscode-jest-runner) can be used to step through specific tests in the debugger.
172190

173191
Read all about unit testing best practices [here](https://www.testim.io/blog/unit-testing-best-practices/).
174192

netlify.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
# This is where we will look for package.json/.nvmrc/etc.
1111
base = ""
1212
publish = "examples/"
13-
command = "npm run build:examples"
14-
environment = { NODE_VERSION = "18.18.0" }
13+
command = "pnpm run build:examples"
14+
environment = { NODE_VERSION = "24" }
1515

1616
# Deploy Preview context: all deploys generated from a pull/merge request will
1717
# inherit these settings.
1818
[context.deploy-preview]
1919
base = ""
2020
publish = "examples/"
21-
command = "npm run build:examples"
22-
environment = { NODE_VERSION = "18.18.0" }
21+
command = "pnpm run build:examples"
22+
environment = { NODE_VERSION = "24" }

0 commit comments

Comments
 (0)