Skip to content

chore: switch from yarn to pnpm #8822

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .github/actions/setup-node/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,22 @@ inputs:
runs:
using: "composite"
steps:
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Node
uses: buildjet/setup-node@v3
with:
node-version: 18.17.0
# See https://github.com/actions/setup-node#caching-global-packages-data
cache: "yarn"
cache-dependency-path: ${{ inputs.directory }}/yarn.lock
cache: "pnpm"
cache-dependency-path: ${{ inputs.directory }}/pnpm-lock.yaml
- name: Install root node_modules
shell: bash
run: ./scripts/pnpm_install.sh

- name: Install node_modules
shell: bash
run: ../scripts/yarn_install.sh
run: ../scripts/pnpm_install.sh
working-directory: ${{ inputs.directory }}
34 changes: 6 additions & 28 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -218,18 +218,6 @@ jobs:
cache: false
go-version: 1.20.6

- name: Install prettier
# We only need prettier for fmt, so do not install all dependencies.
# There is no way to install a single package with yarn, so we have to
# make a new package.json with only prettier listed as a dependency.
# Then running `yarn` will only install prettier.
run: |
cd site
mv package.json package.json.bak
jq '{dependencies: {prettier: .devDependencies.prettier}}' < package.json.bak > package.json
yarn --frozen-lockfile
mv package.json.bak package.json

- name: Install shfmt
run: go install mvdan.cc/sh/v3/cmd/shfmt@v3.5.0

Expand Down Expand Up @@ -492,7 +480,7 @@ jobs:
- name: Setup Node
uses: ./.github/actions/setup-node

- run: yarn test:ci --max-workers $(nproc)
- run: pnpm test:ci --max-workers $(nproc)
working-directory: site

- name: Check code coverage
Expand Down Expand Up @@ -528,13 +516,12 @@ jobs:

- name: Build
run: |
sudo npm install -g prettier
make -B site/out/index.html

- run: yarn playwright:install
- run: pnpm playwright:install
working-directory: site

- run: yarn playwright:test
- run: pnpm playwright:test
env:
DEBUG: pw:api
working-directory: site
Expand Down Expand Up @@ -638,28 +625,19 @@ jobs:
with:
sqlc-version: "1.19.1"

- name: Install dependencies
run: |
cd offlinedocs
yarn
# Install prettier globally
prettier_version=$(jq -r '.devDependencies.prettier' < package.json)
yarn global add "prettier@${prettier_version}"

- name: Format
run: |
cd offlinedocs
yarn format:check
pnpm format:check

- name: Lint
run: |
cd offlinedocs
yarn lint
pnpm lint

- name: Build
run: |
version="$(./scripts/version.sh)"
make -j build/coder_docs_"$version".tgz
make -j build/coder_docs_"$(./scripts/version.sh)".tgz

required:
runs-on: ubuntu-latest
Expand Down
23 changes: 12 additions & 11 deletions .github/workflows/typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ encrypter = "encrypter"

[files]
extend-exclude = [
"**.svg",
"**.png",
"**.lock",
"go.sum",
"go.mod",
# These files contain base64 strings that confuse the detector
"**XService**.ts",
"**identity.go",
"scripts/ci-report/testdata/**",
"**/*_test.go",
"**/*.test.tsx"
"**.svg",
"**.png",
"**.lock",
"go.sum",
"go.mod",
# These files contain base64 strings that confuse the detector
"**XService**.ts",
"**identity.go",
"scripts/ci-report/testdata/**",
"**/*_test.go",
"**/*.test.tsx",
"**/pnpm-lock.yaml",
]
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,5 @@ scripts/apitypings/testdata/**/*.ts

# Generated files shouldn't be formatted.
site/e2e/provisionerGenerated.ts

**/pnpm-lock.yaml
2 changes: 2 additions & 0 deletions .prettierignore.include
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ scripts/apitypings/testdata/**/*.ts

# Generated files shouldn't be formatted.
site/e2e/provisionerGenerated.ts

**/pnpm-lock.yaml
29 changes: 13 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ endif
# Note, all find statements should be written with `.` or `./path` as
# the search path so that these exclusions match.
FIND_EXCLUSIONS= \
-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 \)
-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 \)
# Source files used for make targets, evaluated on use.
GO_SRC_FILES := $(shell find . $(FIND_EXCLUSIONS) -type f -name '*.go' -not -name '*_test.go')
# All the shell files in the repo, excluding ignored files.
Expand Down Expand Up @@ -357,13 +357,13 @@ build/coder_helm_$(VERSION).tgz:

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

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

build/coder_docs_$(VERSION).tgz: offlinedocs/out/index.html
tar -czf "$@" -C offlinedocs/out .
Expand All @@ -390,9 +390,9 @@ fmt/prettier:
cd site
# Avoid writing files in CI to reduce file write activity
ifdef CI
yarn run format:check
pnpm run format:check
else
yarn run format:write
pnpm run format:write
endif
.PHONY: fmt/prettier

Expand Down Expand Up @@ -420,7 +420,7 @@ lint/site-icons:

lint/ts:
cd site
yarn && yarn lint
pnpm i && pnpm lint
.PHONY: lint/ts

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

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

docs/admin/prometheus.md: scripts/metricsdocgen/main.go scripts/metricsdocgen/metrics
go run scripts/metricsdocgen/main.go
cd site
yarn run format:write:only ../docs/admin/prometheus.md
pnpm run format:write:only ./docs/admin/prometheus.md

docs/cli.md: scripts/clidocgen/main.go $(GO_SRC_FILES)
BASE_PATH="." go run ./scripts/clidocgen
cd site
yarn run format:write:only ../docs/cli.md ../docs/cli/*.md ../docs/manifest.json
pnpm run format:write:only ./docs/cli.md ./docs/cli/*.md ./docs/manifest.json

docs/admin/audit-logs.md: scripts/auditdocgen/main.go enterprise/audit/table.go coderd/rbac/object_gen.go
go run scripts/auditdocgen/main.go
cd site
yarn run format:write:only ../docs/admin/audit-logs.md
pnpm run format:write:only ./docs/admin/audit-logs.md

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
./scripts/apidocgen/generate.sh
yarn run --cwd=site format:write:only ../docs/api ../docs/manifest.json ../coderd/apidoc/swagger.json
pnpm run format:write:only ./docs/api ./docs/manifest.json ./coderd/apidoc/swagger.json

update-golden-files: cli/testdata/.gen-golden helm/tests/testdata/.gen-golden scripts/ci-report/testdata/.gen-golden enterprise/cli/testdata/.gen-golden
.PHONY: update-golden-files
Expand Down
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@
kubernetes-helm
mockgen
nfpm
nodePackages.pnpm
nodePackages.typescript
nodePackages.typescript-language-server
nodejs
openssh
openssl
pango
pixman
postgresql
pkg-config
postgresql
protoc-gen-go
ripgrep
shellcheck
shfmt
sqlc
terraform
typos
yarn
yq
zip
zstd
Expand Down
4 changes: 1 addition & 3 deletions offlinedocs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
pnpm-debug.log*

# local env files
.env*.local
Expand Down
1 change: 1 addition & 0 deletions offlinedocs/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/pnpm-lock.yaml
19 changes: 10 additions & 9 deletions offlinedocs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "yarn copy-images && next dev",
"build": "next build",
"start": "next start",
"export": "yarn copy-images && next build && next export",
"dev": "pnpm copy-images && next dev",
"build": "pnpm exec next build",
"start": "pnpm exec next start",
"export": "pnpm copy-images && next build && next export",
"copy-images": "sh ./scripts/copyImages.sh",
"lint": "yarn run lint:types",
"lint:fix": "FIX=true yarn lint",
"lint:types": "tsc --noEmit",
"format:check": "prettier --cache --check './**/*.{css,html,js,json,jsx,md,ts,tsx,yaml,yml}'",
"format:write": "prettier --cache --write './**/*.{css,html,js,json,jsx,md,ts,tsx,yaml,yml}'"
"lint": "pnpm run lint:types",
"lint:fix": "FIX=true pnpm lint",
"lint:types": "pnpm exec tsc --noEmit",
"format:check": "pnpm exec prettier --cache --check './**/*.{css,html,js,json,jsx,md,ts,tsx,yaml,yml}'",
"format:write": "pnpm exec prettier --cache --write './**/*.{css,html,js,json,jsx,md,ts,tsx,yaml,yml}'"
},
"dependencies": {
"@chakra-ui/react": "2.8.0",
"@emotion/react": "11",
"@emotion/styled": "11",
"@types/lodash": "4.14.196",
"archiver": "5.3.1",
"framer-motion": "10",
"front-matter": "4.0.2",
Expand Down
Loading