Skip to content

Commit 5d0e707

Browse files
bmuenzenmeyeravivkeller
authored andcommitted
feat(infra): adopt pnpm
1 parent 4ef944c commit 5d0e707

File tree

74 files changed

+14117
-21733
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+14117
-21733
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ You can check the items by adding an `x` between the brackets, like this: `[x]`
2626
-->
2727

2828
- [ ] I have read the [Contributing Guidelines](https://github.com/nodejs/nodejs.org/blob/main/CONTRIBUTING.md) and made commit messages that follow the guideline.
29-
- [ ] I have run `npm run format` to ensure the code follows the style guide.
30-
- [ ] I have run `npm run test` to check if all tests are passing.
31-
- [ ] I have run `npx turbo build` to check if the website builds without errors.
29+
- [ ] I have run `pnpm format` to ensure the code follows the style guide.
30+
- [ ] I have run `pnpm test` to check if all tests are passing.
31+
- [ ] I have run `pnpm build` to check if the website builds without errors.
3232
- [ ] I've covered new added functionality with unit tests if necessary.

.github/dependabot.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ updates:
6060
- 'react'
6161
- 'react-dom'
6262
- '@types/react'
63-
- '@types/react-dom'
6463
tailwind:
6564
patterns:
6665
- '@savvywombat/tailwindcss-grid-areas'

.github/workflows/build.yml

Lines changed: 29 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ on:
1616
types:
1717
- labeled
1818
merge_group:
19+
workflow_dispatch:
1920

2021
defaults:
2122
run:
@@ -26,15 +27,18 @@ permissions:
2627
contents: read
2728
actions: read
2829

30+
env:
31+
# See https://turbo.build/repo/docs/reference/command-line-reference/run#--cache-dir
32+
TURBO_ARGS: --cache-dir=.turbo/cache
33+
# See https://turbo.build/repo/docs/reference/command-line-reference/run#--force
34+
TURBO_FORCE: true
35+
2936
jobs:
3037
build:
31-
# This Job should run either on `merge_groups` or `push` events
38+
# This Job should run either on non-`pull_request_target` events,
3239
# or `pull_request_target` event with a `labeled` action with a label named `github_actions:pull-request`
33-
# since we want to run Website Builds on all these 3 occasions. As this allows us to be certain the that builds are passing
34-
if: |
35-
(github.event_name == 'push' || github.event_name == 'merge_group') ||
36-
(github.event_name == 'pull_request_target' &&
37-
github.event.label.name == 'github_actions:pull-request')
40+
# since we want to run Website Builds on all these occasions. As this allows us to be certain the that builds are passing
41+
if: github.event_name != 'pull_request_target' || github.event.label.name == 'github_actions:pull-request'
3842

3943
name: Build on ${{ matrix.os }}
4044
runs-on: ${{ matrix.os }}
@@ -50,14 +54,6 @@ jobs:
5054
with:
5155
egress-policy: audit
5256

53-
- name: Provide Turborepo Arguments
54-
# This step is responsible for providing a reusable string that can be used within other steps and jobs
55-
# that use the `turbo` cli command as a way of easily providing shared arguments to the `turbo` command
56-
id: turborepo_arguments
57-
# See https://turbo.build/repo/docs/reference/command-line-reference/run#--cache-dir
58-
# See https://turbo.build/repo/docs/reference/command-line-reference/run#--force
59-
run: echo "turbo_args=--force=true --cache-dir=.turbo/cache" >> "$GITHUB_OUTPUT"
60-
6157
- name: Use GNU tar instead BSD tar
6258
# This ensures that we use GNU `tar` which is more efficient for extracting caches's
6359
if: matrix.os == 'windows-latest'
@@ -78,34 +74,29 @@ jobs:
7874

7975
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
8076
with:
81-
# See here for caching with `yarn` https://github.com/actions/cache/blob/main/examples.md#node---yarn or you can leverage caching with actions/setup-node https://github.com/actions/setup-node
82-
path: |
83-
~/.npm
84-
${{ github.workspace }}/apps/site/.next/cache
85-
# Generate a new cache whenever packages or source files change.
86-
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
87-
# If source files changed but packages didn't, rebuild from a prior cache.
88-
restore-keys: |
89-
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
77+
path: ${{ github.workspace }}/apps/site/.next/cache
78+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
79+
restore-keys: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
80+
81+
- name: Set up pnpm
82+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
83+
with:
84+
cache: true
9085

9186
- name: Set up Node.js
9287
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
9388
with:
9489
# We want to ensure that the Node.js version running here respects our supported versions
9590
node-version-file: '.nvmrc'
96-
cache: 'npm'
91+
cache: 'pnpm'
9792

98-
- name: Install npm packages
99-
# We want to avoid npm from running the Audit Step and Funding messages on a CI environment
100-
# We also use `npm i` instead of `npm ci` so that the node_modules/.cache folder doesn't get deleted
101-
# We also use `--omit=dev` to avoid installing devDependencies as we don't need them during the build step
102-
run: npm i --no-audit --no-fund --userconfig=/dev/null --omit=dev
93+
- name: Install packages
94+
# We only want to install required production packages
95+
run: pnpm install --prod
10396

10497
- name: Build Next.js (ISR)
10598
# We want a ISR build on CI to ensure that regular Next.js builds work as expected.
106-
# We want to enforce that the actual `turbo@latest` package is used instead of a possible hijack from the user
107-
# the `${{ steps.turborepo_arguments.outputs.turbo_args }}` is a string substitution coming from a previous step
108-
run: npx --package=turbo@latest -- turbo build ${{ steps.turborepo_arguments.outputs.turbo_args }}
99+
run: pnpm exec turbo build ${{ env.TURBO_ARGS }}
109100
env:
110101
# We want to ensure we have enough RAM allocated to the Node.js process
111102
# this should be a last resort in case by any chances the build memory gets too high
@@ -118,9 +109,7 @@ jobs:
118109
# We only run full static builds within Pull Requests. This step is also used to export
119110
# static output in all languages, and it only works on `push` events.
120111
if: github.event_name == 'push'
121-
# We want to enforce that the actual `turbo@latest` package is used instead of a possible hijack from the user
122-
# the `${{ steps.turborepo_arguments.outputs.turbo_args }}` is a string substitution coming from a previous step
123-
run: npx --package=turbo@latest -- turbo deploy ${{ steps.turborepo_arguments.outputs.turbo_args }}
112+
run: pnpm exec turbo deploy ${{ env.TURBO_ARGS }}
124113
env:
125114
# We want to ensure we have enough RAM allocated to the Node.js process
126115
# this should be a last resort in case by any chances the build memory gets too high
@@ -139,9 +128,7 @@ jobs:
139128
if: |
140129
(github.event_name == 'pull_request_target' &&
141130
github.event.pull_request.head.ref != 'chore/crowdin')
142-
# We want to enforce that the actual `turbo@latest` package is used instead of a possible hijack from the user
143-
# the `${{ steps.turborepo_arguments.outputs.turbo_args }}` is a string substitution coming from a previous step
144-
run: npx --package=turbo@latest -- turbo deploy ${{ steps.turborepo_arguments.outputs.turbo_args }}
131+
run: pnpm exec turbo deploy ${{ env.TURBO_ARGS }}
145132
env:
146133
# We want to ensure we have enough RAM allocated to the Node.js process
147134
# this should be a last resort in case by any chances the build memory gets too high
@@ -154,14 +141,12 @@ jobs:
154141

155142
- name: Sync Orama Cloud
156143
# We only want to sync the Orama Cloud production indexes on `push` events.
157-
# We also want to sync the Orama Cloud preview (deployment) indexes on `pull_request_target` events.
144+
# We also want to sync the Orama Cloud preview (deployment) indexes on `pull_request_target` events (or manual triggers).
158145
# We also want to ensure that the sync only happens on the `ubuntu-latest` runner to avoid duplicate syncs
159146
# or Windows-based path issues.
160147
env:
161148
ORAMA_INDEX_ID: ${{ github.event_name == 'push' && secrets.ORAMA_PRODUCTION_INDEX_ID || secrets.ORAMA_INDEX_ID }}
162149
ORAMA_SECRET_KEY: ${{ github.event_name == 'push' && secrets.ORAMA_PRODUCTION_SECRET_KEY || secrets.ORAMA_SECRET_KEY }}
163-
if: |
164-
(matrix.os == 'ubuntu-latest') &&
165-
((github.event_name == 'push') || (github.event_name == 'pull_request_target'))
166-
run: |
167-
cd apps/site && npm run sync-orama
150+
if: matrix.os == 'ubuntu-latest' && github.event_name != 'merge_group'
151+
working-directory: apps/site
152+
run: pnpm sync-orama

.github/workflows/chromatic.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ on:
1616
- main
1717
types:
1818
- labeled
19+
workflow_dispatch:
1920

2021
defaults:
2122
run:
@@ -26,19 +27,14 @@ permissions:
2627
contents: read
2728
actions: read
2829

29-
env:
30-
# See https://turbo.build/repo/docs/reference/command-line-reference/run#--force
31-
TURBO_FORCE: true
32-
3330
jobs:
3431
chromatic:
3532
# We only need to run Storybook Builds and Storybook Visual Regression Tests within Pull Requests that actually
3633
# introduce changes to the Storybook. Hence, we skip running these on Crowdin PRs and Dependabot PRs
3734
# sha reference has no stable git tag reference or URL. see https://github.com/chromaui/chromatic-cli/issues/797
3835
if: |
39-
github.event_name == 'push' || github.event_name == 'merge_group' ||
36+
github.event_name != 'pull_request_target' ||
4037
(
41-
github.event_name == 'pull_request_target' &&
4238
github.event.label.name == 'github_actions:pull-request' &&
4339
startsWith(github.event.pull_request.head.ref, 'dependabot/') == false &&
4440
github.event.pull_request.head.ref != 'chore/crowdin'
@@ -66,22 +62,27 @@ jobs:
6662
# previous changes and previous commits and determine which Storybooks should be tested against and what should be built
6763
fetch-depth: 0
6864

65+
- name: Set up pnpm
66+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
67+
with:
68+
cache: true
69+
6970
- name: Set up Node.js
7071
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
7172
with:
7273
# We want to ensure that the Node.js version running here respects our supported versions
7374
node-version-file: '.nvmrc'
74-
cache: 'npm'
75+
cache: 'pnpm'
7576

76-
- name: Install npm packages
77-
# We want to avoid npm from running the Audit Step and Funding messages on a CI environment
78-
# We also use `npm i` instead of `npm ci` so that the node_modules/.cache folder doesn't get deleted
79-
run: npm i --no-audit --no-fund --userconfig=/dev/null
77+
- name: Install packages
78+
run: pnpm install
8079

8180
- name: Start Visual Regression Tests (Chromatic)
8281
# This assigns the Environment Deployment for Storybook
82+
# This action must be manually updated to the latest commit from
83+
# https://github.com/chromaui/action
8384
id: chromatic-deploy
84-
uses: chromaui/action@c93e0bc3a63aa176e14a75b61a31847cbfdd341c
85+
uses: chromaui/action@e8cc4c31775280b175a3c440076c00d19a9014d7 # v11.28.2
8586
with:
8687
workingDir: packages/ui-components
8788
buildScriptName: storybook:build

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

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ jobs:
5555
with:
5656
path: |
5757
.turbo/cache
58-
node_modules/.cache
5958
.eslintmdcache
6059
.stylelintcache
6160
.prettiercache
@@ -64,22 +63,25 @@ jobs:
6463
# as they will only run on files that have changed since the last cached run
6564
# this might of course lead to certain files not being checked against the linter, but the chances
6665
# of such situation from happening are very slim as the checksums of both files would need to match
67-
key: cache-lint-${{ hashFiles('package-lock.json') }}-
66+
key: cache-lint-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('.turbo/cache/**') }}
6867
restore-keys: |
69-
cache-lint-${{ hashFiles('package-lock.json') }}-
68+
cache-lint-${{ hashFiles('pnpm-lock.yaml') }}-
7069
cache-lint-
7170
71+
- name: Set up pnpm
72+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
73+
with:
74+
cache: true
75+
7276
- name: Set up Node.js
7377
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
7478
with:
7579
# We want to ensure that the Node.js version running here respects our supported versions
7680
node-version-file: '.nvmrc'
77-
cache: 'npm'
81+
cache: 'pnpm'
7882

79-
- name: Install npm packages
80-
# We want to avoid npm from running the Audit Step and Funding messages on a CI environment
81-
# We also use `npm i` instead of `npm ci` so that the node_modules/.cache folder doesn't get deleted
82-
run: npm i --no-audit --no-fund --ignore-scripts --userconfig=/dev/null
83+
- name: Install packages
84+
run: pnpm install
8385

8486
- name: Run quality checks with `turbo`
8587
# We run the ESLint and Prettier commands on all Workflow triggers of the `Lint` job, besides if
@@ -88,7 +90,7 @@ jobs:
8890
if: |
8991
(github.event_name == 'push' || github.event_name == 'merge_group') ||
9092
(github.event_name == 'pull_request' && github.event.pull_request.head.ref != 'chore/crowdin')
91-
run: npx turbo lint check-types prettier
93+
run: pnpm exec turbo lint check-types prettier
9294

9395
- name: Save Lint Cache
9496
# We only want to save caches on `push` events or `pull_request_target` events
@@ -105,11 +107,10 @@ jobs:
105107
with:
106108
path: |
107109
.turbo/cache
108-
node_modules/.cache
109110
.eslintmdcache
110111
.stylelintcache
111112
.prettiercache
112-
key: cache-lint-${{ hashFiles('package-lock.json') }}-${{ hashFiles('.turbo/cache/**') }}
113+
key: cache-lint-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('.turbo/cache/**') }}
113114

114115
tests:
115116
name: Tests
@@ -124,22 +125,25 @@ jobs:
124125
- name: Git Checkout
125126
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
126127

128+
- name: Set up pnpm
129+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
130+
with:
131+
cache: true
132+
127133
- name: Set up Node.js
128134
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
129135
with:
130136
# We want to ensure that the Node.js version running here respects our supported versions
131137
node-version-file: '.nvmrc'
132-
cache: 'npm'
138+
cache: 'pnpm'
133139

134-
- name: Install npm packages
135-
# We want to avoid npm from running the Audit Step and Funding messages on a CI environment
136-
# We also use `npm i` instead of `npm ci` so that the node_modules/.cache folder doesn't get deleted
137-
run: npm i --no-audit --no-fund --userconfig=/dev/null
140+
- name: Install packages
141+
run: pnpm install
138142

139143
- name: Run Unit Tests
140144
# We want to run Unit Tests in every circumstance, including Crowdin PRs and Dependabot PRs to ensure
141145
# that changes to dependencies or translations don't break the Unit Tests
142-
run: npm run test:ci
146+
run: pnpm test:ci
143147

144148
- name: Upload test coverage to Codecov
145149
if: ${{ !cancelled() && github.event_name != 'merge_group' }}

.github/workflows/translations-sync.yml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,32 +89,35 @@ jobs:
8989
# as they will only run on files that have changed since the last cached run
9090
# this might of course lead to certain files not being checked against the linter, but the chances
9191
# of such situation from happening are very slim as the checksums of both files would need to match
92-
key: cache-lint-${{ hashFiles('package-lock.json') }}-
92+
key: cache-lint-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('apps/site/.eslintmdcache') }}
9393
restore-keys: |
94-
cache-lint-${{ hashFiles('package-lock.json') }}-
94+
cache-lint-${{ hashFiles('pnpm-lock.yaml') }}-
9595
cache-lint-
9696
97+
- name: Set up pnpm
98+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
99+
with:
100+
cache: true
101+
97102
- name: Set up Node.js
98103
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
99104
with:
100105
# We want to ensure that the Node.js version running here respects our supported versions
101106
node-version-file: '.nvmrc'
102-
cache: 'npm'
107+
cache: 'pnpm'
103108

104-
- name: Install npm packages
105-
# We want to avoid npm from running the Audit Step and Funding messages on a CI environment
106-
# We also use `npm i` instead of `npm ci` so that the node_modules/.cache folder doesn't get deleted
107-
run: npm i --no-audit --no-fund --ignore-scripts --userconfig=/dev/null
109+
- name: Install packages
110+
run: pnpm install
108111

109-
- name: Run `npx lint:md --fix`
112+
- name: Run `lint:md --fix`
110113
# This runs a specific version of ESLint with only the Translation Pages Globbing
111114
# This avoid that unrelated changes get linted/modified within this PR
112-
run: npx eslint "apps/site/pages/**/*.md?(x)" --fix --cache --cache-strategy=metadata --cache-file=apps/site/.eslintmdcache --config=apps/site/eslint.config.js
115+
run: pnpm exec eslint "apps/site/pages/**/*.md?(x)" --fix --cache --cache-strategy=metadata --cache-file=apps/site/.eslintmdcache --config=apps/site/eslint.config.js
113116

114-
- name: Run `npx prettier --write`
117+
- name: Run `prettier --write`
115118
# This runs a specific version of Prettier with only the Translation Pages Globbing
116119
# This avoid that unrelated changes get prettied/modified within this PR
117-
run: npx prettier "apps/site/{pages,i18n}/**/*.{json,md,mdx}" --check --write --cache --cache-strategy=metadata --cache-location=apps/site/.prettiercache
120+
run: pnpm exec prettier "apps/site/{pages,i18n}/**/*.{json,md,mdx}" --check --write --cache --cache-strategy=metadata --cache-location=apps/site/.prettiercache
118121

119122
- name: Push Changes back to Pull Request
120123
uses: stefanzweifel/git-auto-commit-action@e348103e9026cc0eee72ae06630dbe30c8bf7a79 # v5.1.0
@@ -129,4 +132,4 @@ jobs:
129132
path: |
130133
apps/site/.eslintmdcache
131134
apps/site/.prettiercache
132-
key: cache-lint-${{ hashFiles('package-lock.json') }}-${{ hashFiles('apps/site/.eslintmdcache') }}
135+
key: cache-lint-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('apps/site/.eslintmdcache') }}

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Commonly ignored Node.js files
22
node_modules
3+
.env.*
4+
5+
# npm Compatibility
6+
# https://github.com/nodejs/nodejs.org/discussions/5334#discussioncomment-12827850
37
npm-debug.log
48
.npm
5-
.env.*
9+
package-lock.json
610

711
# Next.js Build Output
812
.next

.husky/pre-commit

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# lint and format staged files
2-
npx lint-staged
2+
3+
pnpm exec lint-staged
34

45
# verify typescript staged files
5-
npx tsc --build apps/site
6+
7+
pnpm exec tsc --build apps/site

.npmrc

Lines changed: 0 additions & 2 deletions
This file was deleted.

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v22
1+
v22.13.0

0 commit comments

Comments
 (0)