Skip to content

Commit 2d544d8

Browse files
B4nanclaude
andcommitted
chore: migrate to pnpm and enable minimum release age
Migrates from npm workspaces to pnpm workspaces and adds a 1-day minimum release age supply-chain guard at the package-manager layer (pnpm-workspace.yaml) and at the Renovate layer. Internal `@apify/*` and `@crawlee/*` packages are whitelisted at both layers for immediate updates. Notable 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) - lerna.json: npmClient: "pnpm" - .npmrc: node-linker=hoisted (flat node_modules layout) - packages/*/package.json scripts: "npm run X" -> "pnpm X" - CI workflows: add pnpm/action-setup, use pnpm install --frozen-lockfile and pnpm/pnpm exec in place of npm/npx; drop Node 16 from matrix (pnpm 10 requires Node 18+) - renovate.json: minimumReleaseAge "1 day", internalChecksFilter "strict", @apify/* and @crawlee/* whitelist; drop npm constraint - Docs: CONTRIBUTING.md and CLAUDE.md updated for pnpm commands Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f3f3e8c commit 2d544d8

27 files changed

Lines changed: 10530 additions & 18393 deletions

File tree

.github/workflows/publish_to_npm.yaml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,23 @@ jobs:
2222
ref: ${{ inputs.ref }}
2323
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
2424
fetch-depth: 0 # we need to pull everything to allow lerna to detect what packages changed
25+
- uses: pnpm/action-setup@v4
2526
- name: Use Node.js 24
2627
uses: actions/setup-node@v6
2728
with:
2829
node-version: 24
2930
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
31+
cache: 'pnpm'
3432
- name: Install dependencies
35-
run: npm ci --no-audit
33+
run: pnpm install --frozen-lockfile
3634
- name: Build module
37-
run: npm run build
35+
run: pnpm build
3836
- name: Publish to NPM
3937
run: |
4038
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
39+
pnpm exec lerna publish --contents dist --yes
40+
pnpm install --no-frozen-lockfile # reinstall to have updated lock file
41+
pnpm exec lerna ls --json | node scripts/sync-root-changelog.ts
4442
env:
4543
GH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
4644
GIT_AUTHOR_NAME: Apify Release Bot

.github/workflows/test_and_release.yaml

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

2020
steps:
2121
- uses: actions/checkout@v6
22+
- uses: pnpm/action-setup@v4
2223
- name: Use Node.js ${{ matrix.node-version }}
2324
uses: actions/setup-node@v6
2425
with:
2526
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
27+
cache: 'pnpm'
3428
- name: Install Dependencies
35-
run: npm ci --no-audit
29+
run: pnpm install --frozen-lockfile
3630
- name: Run Tests
37-
run: npm test
31+
run: pnpm test
3832

3933
build:
4034
name: Build
4135
runs-on: ubuntu-latest
4236

4337
steps:
4438
- uses: actions/checkout@v6
45-
- name: Use Node.js 20
39+
- uses: pnpm/action-setup@v4
40+
- name: Use Node.js 24
4641
uses: actions/setup-node@v6
4742
with:
4843
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') }}
44+
cache: 'pnpm'
5445
- name: Install Dependencies
55-
run: npm ci --no-audit
56-
- run: npm run build
46+
run: pnpm install --frozen-lockfile
47+
- run: pnpm build
5748

5849
- name: Check build consistency
5950
run: |
6051
git diff --exit-code || {
61-
echo -e "Some files changed after running npm run build! Please build the project locally and commit the changes.";
52+
echo -e "Some files changed after running pnpm build! Please build the project locally and commit the changes.";
6253
exit 1;
6354
}
6455
@@ -68,18 +59,15 @@ jobs:
6859

6960
steps:
7061
- uses: actions/checkout@v6
71-
- name: Use Node.js 20
62+
- uses: pnpm/action-setup@v4
63+
- name: Use Node.js 24
7264
uses: actions/setup-node@v6
7365
with:
7466
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') }}
67+
cache: 'pnpm'
8068
- name: Install Dependencies
81-
run: npm ci --no-audit
82-
- run: npm run lint
69+
run: pnpm install --frozen-lockfile
70+
- run: pnpm lint
8371

8472
publish:
8573
name: Publish to NPM
@@ -90,24 +78,23 @@ jobs:
9078
- uses: actions/checkout@v6
9179
with:
9280
fetch-depth: 0 # we need to pull everything to allow lerna to detect what packages changed
81+
- uses: pnpm/action-setup@v4
9382
- uses: actions/setup-node@v6
9483
with:
9584
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') }}
85+
cache: 'pnpm'
86+
- name: Install Dependencies
87+
run: pnpm install --frozen-lockfile
10188
- name: Check for changes
10289
id: changed_packages
10390
run: |
104-
echo "changed_packages=$(npx lerna changed -p | wc -l | xargs)" | tee -a $GITHUB_OUTPUT
91+
echo "changed_packages=$(pnpm exec lerna changed -p | wc -l | xargs)" | tee -a $GITHUB_OUTPUT
10592
- name: Execute publish workflow
10693
if: steps.changed_packages.outputs.changed_packages != '0'
10794
uses: apify/workflows/execute-workflow@main
10895
with:
10996
workflow: publish_to_npm.yaml
11097
inputs: >
111-
{
112-
"ref": "master"
98+
{
99+
"ref": "master"
113100
}

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@ pids
1212
.idea
1313
yarn.lock
1414
packages/*/package-lock.json
15-
.npmrc
1615

1716
.vscode

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node-linker=hoisted

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 (jest --silent)
15-
npm run test-cov # Run tests with coverage
16-
npx jest test/consts.test.ts # Run a single test file
17-
npx jest 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 (jest --silent)
15+
pnpm test-cov # Run tests with coverage
16+
pnpm exec jest test/consts.test.ts # Run a single test file
17+
pnpm exec jest 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)