Skip to content

Commit 4b81cfa

Browse files
authored
chore: switch from yarn to pnpm (#8822)
1 parent cf35c0d commit 4b81cfa

32 files changed

+20469
-18664
lines changed

.github/actions/setup-node/action.yaml

+11-3
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,22 @@ inputs:
1010
runs:
1111
using: "composite"
1212
steps:
13+
- name: Install pnpm
14+
uses: pnpm/action-setup@v2
15+
with:
16+
version: 8
1317
- name: Setup Node
1418
uses: buildjet/setup-node@v3
1519
with:
1620
node-version: 18.17.0
1721
# See https://github.com/actions/setup-node#caching-global-packages-data
18-
cache: "yarn"
19-
cache-dependency-path: ${{ inputs.directory }}/yarn.lock
22+
cache: "pnpm"
23+
cache-dependency-path: ${{ inputs.directory }}/pnpm-lock.yaml
24+
- name: Install root node_modules
25+
shell: bash
26+
run: ./scripts/pnpm_install.sh
27+
2028
- name: Install node_modules
2129
shell: bash
22-
run: ../scripts/yarn_install.sh
30+
run: ../scripts/pnpm_install.sh
2331
working-directory: ${{ inputs.directory }}

.github/workflows/ci.yaml

+6-28
Original file line numberDiff line numberDiff line change
@@ -226,18 +226,6 @@ jobs:
226226
cache: false
227227
go-version: 1.20.6
228228

229-
- name: Install prettier
230-
# We only need prettier for fmt, so do not install all dependencies.
231-
# There is no way to install a single package with yarn, so we have to
232-
# make a new package.json with only prettier listed as a dependency.
233-
# Then running `yarn` will only install prettier.
234-
run: |
235-
cd site
236-
mv package.json package.json.bak
237-
jq '{dependencies: {prettier: .devDependencies.prettier}}' < package.json.bak > package.json
238-
yarn --frozen-lockfile
239-
mv package.json.bak package.json
240-
241229
- name: Install shfmt
242230
run: go install mvdan.cc/sh/v3/cmd/shfmt@v3.5.0
243231

@@ -508,7 +496,7 @@ jobs:
508496
- name: Setup Node
509497
uses: ./.github/actions/setup-node
510498

511-
- run: yarn test:ci --max-workers $(nproc)
499+
- run: pnpm test:ci --max-workers $(nproc)
512500
working-directory: site
513501

514502
- name: Check code coverage
@@ -546,13 +534,12 @@ jobs:
546534

547535
- name: Build
548536
run: |
549-
sudo npm install -g prettier
550537
make -B site/out/index.html
551538
552-
- run: yarn playwright:install
539+
- run: pnpm playwright:install
553540
working-directory: site
554541

555-
- run: yarn playwright:test
542+
- run: pnpm playwright:test
556543
env:
557544
DEBUG: pw:api
558545
working-directory: site
@@ -657,28 +644,19 @@ jobs:
657644
with:
658645
sqlc-version: "1.19.1"
659646

660-
- name: Install dependencies
661-
run: |
662-
cd offlinedocs
663-
yarn
664-
# Install prettier globally
665-
prettier_version=$(jq -r '.devDependencies.prettier' < package.json)
666-
yarn global add "prettier@${prettier_version}"
667-
668647
- name: Format
669648
run: |
670649
cd offlinedocs
671-
yarn format:check
650+
pnpm format:check
672651
673652
- name: Lint
674653
run: |
675654
cd offlinedocs
676-
yarn lint
655+
pnpm lint
677656
678657
- name: Build
679658
run: |
680-
version="$(./scripts/version.sh)"
681-
make -j build/coder_docs_"$version".tgz
659+
make -j build/coder_docs_"$(./scripts/version.sh)".tgz
682660
683661
required:
684662
runs-on: ubuntu-latest

.github/workflows/typos.toml

+12-11
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@ encrypter = "encrypter"
1717

1818
[files]
1919
extend-exclude = [
20-
"**.svg",
21-
"**.png",
22-
"**.lock",
23-
"go.sum",
24-
"go.mod",
25-
# These files contain base64 strings that confuse the detector
26-
"**XService**.ts",
27-
"**identity.go",
28-
"scripts/ci-report/testdata/**",
29-
"**/*_test.go",
30-
"**/*.test.tsx"
20+
"**.svg",
21+
"**.png",
22+
"**.lock",
23+
"go.sum",
24+
"go.mod",
25+
# These files contain base64 strings that confuse the detector
26+
"**XService**.ts",
27+
"**identity.go",
28+
"scripts/ci-report/testdata/**",
29+
"**/*_test.go",
30+
"**/*.test.tsx",
31+
"**/pnpm-lock.yaml",
3132
]

.prettierignore

+2
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,5 @@ scripts/apitypings/testdata/**/*.ts
7878

7979
# Generated files shouldn't be formatted.
8080
site/e2e/provisionerGenerated.ts
81+
82+
**/pnpm-lock.yaml

.prettierignore.include

+2
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ scripts/apitypings/testdata/**/*.ts
1111

1212
# Generated files shouldn't be formatted.
1313
site/e2e/provisionerGenerated.ts
14+
15+
**/pnpm-lock.yaml

Makefile

+13-16
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ endif
5050
# Note, all find statements should be written with `.` or `./path` as
5151
# the search path so that these exclusions match.
5252
FIND_EXCLUSIONS= \
53-
-not \( \( -path '*/.git/*' -o -path './build/*' -o -path './vendor/*' -o -path './.coderv2/*' -o -path '*/node_modules/*' -o -path './site/out/*' -o -path './coderd/apidoc/*' \) -prune \)
53+
-not \( \( -path '*/.git/*' -o -path './build/*' -o -path './vendor/*' -o -path './.coderv2/*' -o -path '*/node_modules/*' -o -path '*/out/*' -o -path './coderd/apidoc/*' -o -path '*/.next/*' \) -prune \)
5454
# Source files used for make targets, evaluated on use.
5555
GO_SRC_FILES := $(shell find . $(FIND_EXCLUSIONS) -type f -name '*.go' -not -name '*_test.go')
5656
# All the shell files in the repo, excluding ignored files.
@@ -357,13 +357,13 @@ build/coder_helm_$(VERSION).tgz:
357357

358358
site/out/index.html: site/package.json $(shell find ./site $(FIND_EXCLUSIONS) -type f \( -name '*.ts' -o -name '*.tsx' \))
359359
cd site
360-
../scripts/yarn_install.sh
361-
yarn build
360+
../scripts/pnpm_install.sh
361+
pnpm build
362362

363363
offlinedocs/out/index.html: $(shell find ./offlinedocs $(FIND_EXCLUSIONS) -type f) $(shell find ./docs $(FIND_EXCLUSIONS) -type f | sed 's: :\\ :g')
364364
cd offlinedocs
365-
../scripts/yarn_install.sh
366-
yarn export
365+
../scripts/pnpm_install.sh
366+
pnpm export
367367

368368
build/coder_docs_$(VERSION).tgz: offlinedocs/out/index.html
369369
tar -czf "$@" -C offlinedocs/out .
@@ -390,9 +390,9 @@ fmt/prettier:
390390
cd site
391391
# Avoid writing files in CI to reduce file write activity
392392
ifdef CI
393-
yarn run format:check
393+
pnpm run format:check
394394
else
395-
yarn run format:write
395+
pnpm run format:write
396396
endif
397397
.PHONY: fmt/prettier
398398

@@ -420,7 +420,7 @@ lint/site-icons:
420420

421421
lint/ts:
422422
cd site
423-
yarn && yarn lint
423+
pnpm i && pnpm lint
424424
.PHONY: lint/ts
425425

426426
lint/go:
@@ -532,29 +532,26 @@ provisionerd/proto/provisionerd.pb.go: provisionerd/proto/provisionerd.proto
532532
site/src/api/typesGenerated.ts: scripts/apitypings/main.go $(shell find ./codersdk $(FIND_EXCLUSIONS) -type f -name '*.go')
533533
go run scripts/apitypings/main.go > site/src/api/typesGenerated.ts
534534
cd site
535-
yarn run format:types
535+
pnpm run format:types
536536

537537
coderd/rbac/object_gen.go: scripts/rbacgen/main.go coderd/rbac/object.go
538538
go run scripts/rbacgen/main.go ./coderd/rbac > coderd/rbac/object_gen.go
539539

540540
docs/admin/prometheus.md: scripts/metricsdocgen/main.go scripts/metricsdocgen/metrics
541541
go run scripts/metricsdocgen/main.go
542-
cd site
543-
yarn run format:write:only ../docs/admin/prometheus.md
542+
pnpm run format:write:only ./docs/admin/prometheus.md
544543

545544
docs/cli.md: scripts/clidocgen/main.go $(GO_SRC_FILES)
546545
BASE_PATH="." go run ./scripts/clidocgen
547-
cd site
548-
yarn run format:write:only ../docs/cli.md ../docs/cli/*.md ../docs/manifest.json
546+
pnpm run format:write:only ./docs/cli.md ./docs/cli/*.md ./docs/manifest.json
549547

550548
docs/admin/audit-logs.md: scripts/auditdocgen/main.go enterprise/audit/table.go coderd/rbac/object_gen.go
551549
go run scripts/auditdocgen/main.go
552-
cd site
553-
yarn run format:write:only ../docs/admin/audit-logs.md
550+
pnpm run format:write:only ./docs/admin/audit-logs.md
554551

555552
coderd/apidoc/swagger.json: $(shell find ./scripts/apidocgen $(FIND_EXCLUSIONS) -type f) $(wildcard coderd/*.go) $(wildcard enterprise/coderd/*.go) $(wildcard codersdk/*.go) $(wildcard enterprise/wsproxy/wsproxysdk/*.go) $(DB_GEN_FILES) .swaggo docs/manifest.json coderd/rbac/object_gen.go
556553
./scripts/apidocgen/generate.sh
557-
yarn run --cwd=site format:write:only ../docs/api ../docs/manifest.json ../coderd/apidoc/swagger.json
554+
pnpm run format:write:only ./docs/api ./docs/manifest.json ./coderd/apidoc/swagger.json
558555

559556
update-golden-files: cli/testdata/.gen-golden helm/tests/testdata/.gen-golden scripts/ci-report/testdata/.gen-golden enterprise/cli/testdata/.gen-golden
560557
.PHONY: update-golden-files

flake.nix

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,23 @@
3232
kubernetes-helm
3333
mockgen
3434
nfpm
35+
nodePackages.pnpm
3536
nodePackages.typescript
3637
nodePackages.typescript-language-server
3738
nodejs
3839
openssh
3940
openssl
4041
pango
4142
pixman
42-
postgresql
4343
pkg-config
44+
postgresql
4445
protoc-gen-go
4546
ripgrep
4647
shellcheck
4748
shfmt
4849
sqlc
4950
terraform
5051
typos
51-
yarn
5252
yq
5353
zip
5454
zstd

offlinedocs/.gitignore

+1-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121

2222
# debug
2323
npm-debug.log*
24-
yarn-debug.log*
25-
yarn-error.log*
26-
.pnpm-debug.log*
24+
pnpm-debug.log*
2725

2826
# local env files
2927
.env*.local

offlinedocs/.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/pnpm-lock.yaml

offlinedocs/package.json

+10-9
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,22 @@
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
6-
"dev": "yarn copy-images && next dev",
7-
"build": "next build",
8-
"start": "next start",
9-
"export": "yarn copy-images && next build && next export",
6+
"dev": "pnpm copy-images && next dev",
7+
"build": "pnpm exec next build",
8+
"start": "pnpm exec next start",
9+
"export": "pnpm copy-images && next build && next export",
1010
"copy-images": "sh ./scripts/copyImages.sh",
11-
"lint": "yarn run lint:types",
12-
"lint:fix": "FIX=true yarn lint",
13-
"lint:types": "tsc --noEmit",
14-
"format:check": "prettier --cache --check './**/*.{css,html,js,json,jsx,md,ts,tsx,yaml,yml}'",
15-
"format:write": "prettier --cache --write './**/*.{css,html,js,json,jsx,md,ts,tsx,yaml,yml}'"
11+
"lint": "pnpm run lint:types",
12+
"lint:fix": "FIX=true pnpm lint",
13+
"lint:types": "pnpm exec tsc --noEmit",
14+
"format:check": "pnpm exec prettier --cache --check './**/*.{css,html,js,json,jsx,md,ts,tsx,yaml,yml}'",
15+
"format:write": "pnpm exec prettier --cache --write './**/*.{css,html,js,json,jsx,md,ts,tsx,yaml,yml}'"
1616
},
1717
"dependencies": {
1818
"@chakra-ui/react": "2.8.0",
1919
"@emotion/react": "11",
2020
"@emotion/styled": "11",
21+
"@types/lodash": "4.14.196",
2122
"archiver": "5.3.1",
2223
"framer-motion": "10",
2324
"front-matter": "4.0.2",

0 commit comments

Comments
 (0)