Skip to content

Commit d293765

Browse files
B4nanclaude
andauthored
chore: migrate to pnpm and enable minimum release age (#616)
## Summary Pilot of the org-wide supply-chain hardening + pnpm migration plan (first of ~14 repos). This PR migrates `apify-shared-js` from npm workspaces to pnpm workspaces and adds a 1-day minimum release age guard at two layers so newly-published package versions cannot be installed for 24h after they hit the registry. - **pnpm layer** — `minimumReleaseAge: 1440` in `pnpm-workspace.yaml` blocks `pnpm install` on versions < 1 day old - **Renovate layer** — `minimumReleaseAge: "1 day"` delays PR creation until the version has aged - **Internal allowlist** — `@apify/*` and `@crawlee/*` (plus `apify`, `apify-client`, `crawlee`, `got-scraping`) are excluded at both layers so internal releases ship immediately ## Changes - `package.json`: drop `"workspaces"` (moved to `pnpm-workspace.yaml`); set `packageManager` to `pnpm@10.24.0`; add `rimraf` as explicit devDep (was previously relying on npm transitive hoisting — pnpm's hoisted linker does not link undeclared transitive bins); replace `devEngines` with `npx only-allow pnpm` preinstall hook - `lerna.json`: `npmClient: "pnpm"` so `lerna run ...` invokes pnpm - `pnpm-workspace.yaml`: pnpm config moved here from `.npmrc`; `node-linker=hoisted` keeps a flat `node_modules` for the same debugging ergonomics as npm - `packages/*/package.json` scripts: `npm run X` → `pnpm X` - CI workflows: use the shared `apify/workflows/pnpm-install` composite (with pnpm-store caching). Node test matrix dropped to **[20, 22, 24]** — Node 16 is dropped because pnpm 10 needs ≥18, and Node 18 is dropped because the test runner was bumped to **vitest 4**, which declares `engines.node: ^20 || ^22 || >=24`. `engines.node` in the published packages is unchanged (no major bumps) - `release` workflow: `pull: '--rebase --autostash'` on the bot push step to avoid non-fast-forward rejection if another commit lands while CI is running - `renovate.json`: `minimumReleaseAge: "1 day"`, `internalChecksFilter: "strict"`, internal allowlist; drop old npm constraint - `CONTRIBUTING.md` + `CLAUDE.md`: updated command examples Pilot for the remaining ~13 repos in the same migration. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 89ab996 commit d293765

26 files changed

Lines changed: 9509 additions & 15917 deletions

File tree

.github/workflows/publish_to_npm.yaml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,16 @@ jobs:
2727
with:
2828
node-version: 24
2929
registry-url: 'https://registry.npmjs.org'
30-
cache: 'npm'
31-
cache-dependency-path: 'package-lock.json'
32-
- name: Update NPM
33-
run: npm install -g npm@latest
34-
- name: Install dependencies
35-
run: npm ci --no-audit
30+
- name: Install pnpm and dependencies
31+
uses: apify/workflows/pnpm-install@main
3632
- name: Build module
37-
run: npm run build
33+
run: pnpm build
3834
- name: Publish to NPM
3935
run: |
4036
git checkout -- .
41-
npx lerna publish --contents dist --yes
42-
npm i --no-audit # reinstall to have updated lock file
43-
npx lerna ls --json | node scripts/sync-root-changelog.ts
37+
pnpm exec lerna publish --contents dist --yes
38+
pnpm install --no-frozen-lockfile # reinstall to have updated lock file
39+
pnpm exec lerna ls --json | node scripts/sync-root-changelog.ts
4440
env:
4541
GH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
4642
GIT_AUTHOR_NAME: Apify Release Bot
@@ -53,3 +49,4 @@ jobs:
5349
author_name: Apify Release Bot
5450
author_email: noreply@apify.com
5551
message: 'chore: update root lock file and changelog [skip ci]'
52+
pull: '--rebase --autostash'

.github/workflows/test_and_release.yaml

Lines changed: 16 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,50 +15,37 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
node-version: [ 18, 20, 22 ]
18+
node-version: [ 20, 22, 24 ]
1919

2020
steps:
2121
- uses: actions/checkout@v6
2222
- name: Use Node.js ${{ matrix.node-version }}
2323
uses: actions/setup-node@v6
2424
with:
2525
node-version: ${{ matrix.node-version }}
26-
- name: Cache node_modules
27-
uses: actions/cache@v5
28-
with:
29-
path: '**/node_modules'
30-
key: ${{ runner.os }}-${{ matrix.node-version }}-modules-${{ hashFiles('**/package-lock.json') }}
31-
- name: Update NPM
32-
run: npm install --no-audit -g npm@9
33-
if: matrix.node-version < 18
34-
- name: Install Dependencies
35-
run: npm ci --no-audit
26+
- name: Install pnpm and dependencies
27+
uses: apify/workflows/pnpm-install@main
3628
- name: Run Tests
37-
run: npm test
29+
run: pnpm test
3830

3931
build:
4032
name: Build
4133
runs-on: ubuntu-latest
4234

4335
steps:
4436
- uses: actions/checkout@v6
45-
- name: Use Node.js
37+
- name: Use Node.js 24
4638
uses: actions/setup-node@v6
4739
with:
4840
node-version: 24
49-
- name: Cache node_modules
50-
uses: actions/cache@v5
51-
with:
52-
path: '**/node_modules'
53-
key: ${{ runner.os }}-${{ matrix.node-version }}-modules-${{ hashFiles('**/package-lock.json') }}
54-
- name: Install Dependencies
55-
run: npm ci --no-audit
56-
- run: npm run build
41+
- name: Install pnpm and dependencies
42+
uses: apify/workflows/pnpm-install@main
43+
- run: pnpm build
5744

5845
- name: Check build consistency
5946
run: |
6047
git diff --exit-code || {
61-
echo -e "Some files changed after running npm run build! Please build the project locally and commit the changes.";
48+
echo -e "Some files changed after running pnpm build! Please build the project locally and commit the changes.";
6249
exit 1;
6350
}
6451
@@ -68,18 +55,13 @@ jobs:
6855

6956
steps:
7057
- uses: actions/checkout@v6
71-
- name: Use Node.js
58+
- name: Use Node.js 24
7259
uses: actions/setup-node@v6
7360
with:
7461
node-version: 24
75-
- name: Cache node_modules
76-
uses: actions/cache@v5
77-
with:
78-
path: '**/node_modules'
79-
key: ${{ runner.os }}-${{ matrix.node-version }}-modules-${{ hashFiles('**/package-lock.json') }}
80-
- name: Install Dependencies
81-
run: npm ci --no-audit
82-
- run: npm run lint
62+
- name: Install pnpm and dependencies
63+
uses: apify/workflows/pnpm-install@main
64+
- run: pnpm lint
8365

8466
publish:
8567
name: Publish to NPM
@@ -93,15 +75,12 @@ jobs:
9375
- uses: actions/setup-node@v6
9476
with:
9577
node-version: 24
96-
- name: Cache node_modules
97-
uses: actions/cache@v5
98-
with:
99-
path: '**/node_modules'
100-
key: ${{ runner.os }}-${{ matrix.node-version }}-modules-${{ hashFiles('**/package-lock.json') }}
78+
- name: Install pnpm and dependencies
79+
uses: apify/workflows/pnpm-install@main
10180
- name: Check for changes
10281
id: changed_packages
10382
run: |
104-
echo "changed_packages=$(npx lerna changed -p | wc -l | xargs)" | tee -a $GITHUB_OUTPUT
83+
echo "changed_packages=$(pnpm exec lerna changed -p | wc -l | xargs)" | tee -a $GITHUB_OUTPUT
10584
- name: Execute publish workflow
10685
if: steps.changed_packages.outputs.changed_packages != '0'
10786
uses: apify/workflows/execute-workflow@main

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ logs
1111
pids
1212
.idea
1313
yarn.lock
14+
.yarn
1415
packages/*/package-lock.json
15-
.npmrc
1616

17+
.npmrc
1718
.vscode

CLAUDE.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
44

55
## Overview
66

7-
Internal Apify monorepo of shared TypeScript utilities and constants published as `@apify/*` packages on npm. Managed with Lerna (independent versioning) and npm workspaces.
7+
Internal Apify monorepo of shared TypeScript utilities and constants published as `@apify/*` packages on npm. Managed with Lerna (independent versioning) and pnpm workspaces.
88

99
## Commands
1010

1111
```bash
12-
npm install # Install all dependencies
13-
npm run build # Build all packages (lerna run build)
14-
npm test # Run all tests (vitest)
15-
npm run test-cov # Run tests with coverage
16-
npx vitest run test/consts.test.ts # Run a single test file
17-
npx vitest run test/consts.test.ts -t "pattern" # Run specific test by name
18-
npm run lint # Lint all source and test files
19-
npm run lint:fix # Lint with auto-fix
20-
npm run clean # Clean all dist/ folders
12+
pnpm install # Install all dependencies
13+
pnpm build # Build all packages (lerna run build)
14+
pnpm test # Run all tests (vitest)
15+
pnpm test-cov # Run tests with coverage
16+
pnpm exec vitest run test/consts.test.ts # Run a single test file
17+
pnpm exec vitest run test/consts.test.ts -t "pattern" # Run specific test by name
18+
pnpm lint # Lint all source and test files
19+
pnpm lint:fix # Lint with auto-fix
20+
pnpm clean # Clean all dist/ folders
2121
```
2222

2323
## Architecture

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ When contributing to this repository, please first discuss the change you wish t
44

55
## Submitting a pull request
66

7-
- Fork the project and install NPM dependencies. **NPM 7 is needed to have support for workspaces.**
7+
- Fork the project and install dependencies with [pnpm](https://pnpm.io/) (we use pnpm workspaces).
88

99
```sh
10-
npm install
10+
pnpm install
1111
```
1212

1313
- Run tests before you start working, to be sure they all pass, and your setup is working correctly:
1414

1515
```sh
16-
npm test
16+
pnpm test
1717
```
1818

1919
- Be sure to **include appropriate test cases**.
20-
- Follow defined coding standard, use `npm run lint` command to check it.
20+
- Follow defined coding standard, use `pnpm lint` command to check it.
2121
- Commit your changes using a descriptive commit message that follows defined
2222
[commit message conventions](#commit-message-guidelines). Adherence to these conventions is necessary because release notes are automatically generated from these messages.
2323
- Push the code to your forked repository and create a pull request on GitHub.
@@ -52,7 +52,7 @@ empty line to separate subject and body).
5252
5353
## Adding new package
5454
55-
This repository is managed via `lerna` and NPM workspaces. When adding new package, be sure to include all
55+
This repository is managed via `lerna` and pnpm workspaces. When adding new package, be sure to include all
5656
the appropriate config files (`package.json`, `tsconfig.json` and `tsconfig.build.json`). It should be mostly
5757
ok to just copy&paste one of the existing packages, wipe its contents and change the package name. Be sure
5858
to clean up the dependencies as well. Keep all the scripts defined in the `package.json`, especially the `build` one.

lerna.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
}
1616
},
1717
"useNx": false,
18+
"npmClient": "pnpm",
1819
"ignoreChanges": [
1920
"**/test/**",
2021
"**/*.md"

0 commit comments

Comments
 (0)