Skip to content

Commit 445157d

Browse files
committed
feat: Enforce pnpm usage
Adds a GitHub Actions workflow and package.json configuration to ensure all contributors use pnpm. This prevents the accidental inclusion of npm lockfiles and enforces consistent package management.
1 parent a70d1aa commit 445157d

3 files changed

Lines changed: 31 additions & 0 deletions

File tree

.github/workflows/enforce-pnpm.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Enforce pnpm
2+
3+
on:
4+
pull_request:
5+
push:
6+
7+
jobs:
8+
reject-npm-lockfile:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
12+
- name: Reject npm lockfiles
13+
run: |
14+
if git ls-files | grep -E '(^|/)package-lock\.json$'; then
15+
echo "Remove package-lock.json and use pnpm."
16+
exit 1
17+
fi

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
min-release-age=3 # days
2+
engine-strict=true

package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
{
22
"scripts": {
3+
"preinstall": "node -e \"const userAgent = process.env.npm_config_user_agent || ''; if (process.env.INIT_CWD === process.cwd() && !userAgent.includes('pnpm/')) { console.error('Use pnpm in this repo.'); process.exit(1); }\"",
34
"build": "turbo run build",
45
"watch": "turbo run watch",
56
"dev": "turbo run dev",
67
"start": "turbo run start"
78
},
9+
"engines": {
10+
"pnpm": ">=10.27.0",
11+
"npm": "please-use-pnpm",
12+
"yarn": "please-use-pnpm"
13+
},
14+
"devEngines": {
15+
"packageManager": {
16+
"name": "pnpm",
17+
"version": ">=10.27.0",
18+
"onFail": "error"
19+
}
20+
},
821
"devDependencies": {
922
"tslab": "^1.0.21"
1023
},

0 commit comments

Comments
 (0)