Skip to content

Commit 006467c

Browse files
Kabidoye-17claude
andauthored
chore: migrate from yarn 1 to pnpm with supply chain hardening (#182)
* chore: migrate from yarn 1 to pnpm with supply chain hardening - Pin packageManager to pnpm@10.23.0 - Migrate resolutions -> pnpm.overrides - Add pnpm-workspace.yaml with minimumReleaseAge (7d) and trustPolicy=no-downgrade - Record husky in ignoredBuiltDependencies (git-hooks only; safe to block in CI) - Add explicit tslib devDep (previously phantom via yarn hoisting) - Update CircleCI: bump to cimg/node:22.14.0, corepack bootstrap, cache pnpm store - Update publish workflow: pnpm/action-setup + pnpm install/build - Update CONTRIBUTING (pnpm) and README (npm install for consumers) - Delete yarn.lock; commit pnpm-lock.yaml (versions preserved via pnpm import) Published package: intentionally no preinstall guard. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * ci: raise Node heap for jest --coverage test step The Node 22 container exposes a jest-worker OOM on render.test.ts — that suite instantiates every renderer, and --coverage adds ts-jest instrumentation on top, blowing past Node's default old-space around 2 GB. Bumping to 4 GB fits the worker; scoped to the CI step so it does not affect local runs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs(readme): list npm, yarn, and pnpm install commands Avoid constraining consumers to a single package manager. The library is installable identically under any of them; documenting all three removes the mental translation step for yarn/pnpm consumers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: pin pnpm binary integrity hash in packageManager Corepack accepts a "<manager>@<version>+<algo>.<hash>" form. Without the hash, corepack downloads whatever the registry serves for pnpm@10.23.0; with it, any tarball that does not hash-match is refused. Zero-cost tightening of the supply-chain surface — same version, now cryptographically pinned. Frozen install verified. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 744693f commit 006467c

8 files changed

Lines changed: 6925 additions & 8032 deletions

File tree

.circleci/config.yml

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 2
33
defaults: &defaults
44
working_directory: ~/repo
55
docker:
6-
- image: circleci/node:12.21
6+
- image: cimg/node:22.14.0
77

88
jobs:
99
test:
@@ -13,34 +13,47 @@ jobs:
1313

1414
- restore_cache:
1515
keys:
16-
- v1-dependencies-{{arch}}-{{ checksum "package.json" }}
17-
- v1-dependencies-{{arch}}-
16+
- v2-pnpm-{{arch}}-{{ checksum "pnpm-lock.yaml" }}
17+
- v2-pnpm-{{arch}}-
18+
19+
- run:
20+
name: Install pnpm via corepack
21+
command: |
22+
command -v corepack >/dev/null 2>&1 || sudo npm install -g corepack
23+
sudo corepack enable
24+
sudo corepack prepare --activate
1825
1926
- run:
2027
name: Verify Socket Firewall registry is active
2128
command: |
22-
REGISTRY=$(npm config get registry)
23-
echo "npm registry: $REGISTRY"
24-
echo "$REGISTRY" | grep -q socket-firewall-registry || { echo "FAIL: npm not routed through Socket Firewall"; exit 1; }
29+
REGISTRY=$(pnpm config get registry)
30+
echo "pnpm registry: $REGISTRY"
31+
echo "$REGISTRY" | grep -q socket-firewall-registry || { echo "FAIL: pnpm not routed through Socket Firewall"; exit 1; }
2532
26-
- run: yarn install
33+
- run: pnpm install --frozen-lockfile
2734

2835
- save_cache:
29-
key: v1-dependencies-{{arch}}-{{ checksum "package.json" }}
36+
key: v2-pnpm-{{arch}}-{{ checksum "pnpm-lock.yaml" }}
3037
paths:
3138
- node_modules
39+
- ~/.local/share/pnpm/store
3240

3341
- run:
3442
name: Check format
35-
command: yarn format:check
43+
command: pnpm run format:check
3644

3745
- run:
3846
name: Run linter
39-
command: yarn lint
47+
command: pnpm run lint
4048

4149
- run:
4250
name: Run tests
43-
command: yarn test:ci
51+
command: pnpm run test:ci
52+
environment:
53+
# Node 22 exposes a jest+ts-jest+coverage OOM on the render.test.ts
54+
# entry point (all renderers instantiated with instrumentation).
55+
# Raise old-space from the default so the worker fits.
56+
NODE_OPTIONS: --max-old-space-size=4096
4457

4558
workflows:
4659
version: 2

.github/workflows/publish.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# CAVEAT: This repo currently publishes via semantic-release (see `npm run semantic-release`
1+
# CAVEAT: This repo currently publishes via semantic-release (see `pnpm run semantic-release`
22
# in package.json and the `release` job in .circleci/config.yml). semantic-release cannot emit
33
# `npm stage publish`, so this staged-publishing workflow is NOT yet wired into the live release
44
# path. Before adopting it, the semantic-release flow must be reconciled with OIDC staged
@@ -48,13 +48,14 @@ jobs:
4848
steps:
4949
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5050
with: { persist-credentials: false }
51+
- uses: pnpm/action-setup@7088e561eb65bb68695d245aa206f005ef30921d # v4.1.0
5152
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
5253
with:
5354
node-version-file: '.nvmrc'
5455
registry-url: 'https://registry.npmjs.org'
5556
package-manager-cache: false
56-
- run: yarn install --frozen-lockfile
57-
- run: yarn build
57+
- run: pnpm install --frozen-lockfile
58+
- run: pnpm run build
5859
- run: npm install -g npm@11.15.0 # npm CLI: staged publishing needs npm >= 11.15.0
5960
- name: Resolve dist-tag (a prerelease must never go to `latest`)
6061
id: disttag

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ This project is a Rollup-based TypeScript NodeJS library. To get the source and
2424
```bash
2525
git clone git@github.com:intercom/contentful-typescript-codegen.git
2626
cd contentful-typescript-codegen
27-
yarn install
27+
pnpm install
2828
```
2929

3030
To ensure everything is set up correctly:
3131

3232
```bash
33-
yarn test
33+
pnpm test
3434
```
3535

3636
### Project structure

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@ ensure that breaking changes to our Content Types don't cause an outage, and bec
1414
## Usage
1515

1616
```sh
17+
# npm
18+
npm install --save-dev contentful-typescript-codegen
19+
20+
# yarn
1721
yarn add --dev contentful-typescript-codegen
22+
23+
# pnpm
24+
pnpm add --save-dev contentful-typescript-codegen
1825
```
1926

2027
Then, add the following to your `package.json`:

package.json

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@
77
"type": "git",
88
"url": "https://github.com/intercom/contentful-typescript-codegen"
99
},
10-
"resolutions": {
11-
"braces": "3.0.3",
12-
"ansi-regex": "3.0.1",
13-
"minimist": "1.2.6",
14-
"micromatch": "4.0.8",
15-
"cross-spawn": "7.0.6"
10+
"packageManager": "pnpm@10.23.0+sha512.21c4e5698002ade97e4efe8b8b4a89a8de3c85a37919f957e7a0f30f38fbc5bbdd05980ffe29179b2fb6e6e691242e098d945d1601772cad0fef5fb6411e2a4b",
11+
"pnpm": {
12+
"overrides": {
13+
"braces": "3.0.3",
14+
"ansi-regex": "3.0.1",
15+
"minimist": "1.2.6",
16+
"micromatch": "4.0.8",
17+
"cross-spawn": "7.0.6"
18+
},
19+
"ignoredBuiltDependencies": [
20+
"husky"
21+
]
1622
},
1723
"version": "0.0.1-development",
1824
"main": "dist/contentful-typescript-codegen.js",
@@ -25,12 +31,12 @@
2531
"build": "tsc --module commonjs && rollup -c rollup.config.ts && chmod +x dist/contentful-typescript-codegen.js",
2632
"commit": "git-cz",
2733
"format": "prettier --write \"**/*.ts\"",
28-
"format:check": "npm run format -- --check",
34+
"format:check": "pnpm run format -- --check",
2935
"lint": "tslint --project tsconfig.json -t codeFrame 'src/**/*.ts' 'test/**/*.ts'",
3036
"start": "rollup -c rollup.config.ts -w",
3137
"test": "jest --coverage",
3238
"test:ci": "jest --coverage --max-workers=2 --ci",
33-
"test:prod": "npm run lint && npm run test -- --no-cache",
39+
"test:prod": "pnpm run lint && pnpm run test -- --no-cache",
3440
"test:watch": "jest --coverage --watch",
3541
"semantic-release": "semantic-release"
3642
},
@@ -73,6 +79,7 @@
7379
"semantic-release": "^17.4.7",
7480
"ts-jest": "^26.0.0",
7581
"ts-node": "^10.6.0",
82+
"tslib": "^2.8.1",
7683
"tslint": "^5.18.0",
7784
"tslint-config-prettier": "^1.18.0",
7885
"tslint-config-standard": "^8.0.1",

0 commit comments

Comments
 (0)