Skip to content

Commit

Permalink
feat(repo): Introduce pnpm (#4528)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacekradko authored Nov 14, 2024
1 parent 60d3f76 commit 305a03b
Show file tree
Hide file tree
Showing 139 changed files with 33,792 additions and 58,409 deletions.
2 changes: 2 additions & 0 deletions .changeset/little-planes-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/BUG_REPORT.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ body:
attributes:
label: Environment
render: Shell
description: Run "npx envinfo --system --browsers --binaries --npmPackages" in your project directory and paste the output here.
description: Run "pnpm dlx envinfo --system --browsers --binaries --npmPackages" in your project directory and paste the output here.
placeholder: |
You'll get an output similar to this:
Expand Down
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

## Checklist

- [ ] `npm test` runs as expected.
- [ ] `npm run build` runs as expected.
- [ ] `pnpm test` runs as expected.
- [ ] `pnpm build` runs as expected.
- [ ] (If applicable) [JSDoc comments](https://jsdoc.app/about-getting-started.html) have been added or updated for any package exports
- [ ] (If applicable) [Documentation](https://github.com/clerk/clerk-docs) has been updated

Expand Down
12 changes: 7 additions & 5 deletions .github/actions/init/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,18 @@ runs:
shell: bash
run: echo $TURBO_ARGS

- name: Install PNPM
uses: pnpm/action-setup@v4

- name: Setup NodeJS ${{ inputs.node-version }}
uses: actions/setup-node@v4
with:
cache: npm
cache-dependency-path: '**/package-lock.json'
cache: pnpm
node-version: ${{ inputs.node-version }}
registry-url: ${{ inputs.registry-url }}

- name: Install NPM Dependencies
run: npm ci --audit=false --fund=false --engine-strict=false
- name: Install PNPM Dependencies
run: pnpm install
shell: bash

- name: Get Playwright Version
Expand All @@ -133,4 +135,4 @@ runs:
if: inputs.playwright-enabled == 'true' && steps.playwright-cache.outputs.cache-hit != 'true'
shell: bash
run: |
npx playwright install chromium
pnpm playwright install chromium
6 changes: 3 additions & 3 deletions .github/actions/verdaccio/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ runs:
steps:
- name: Update NPM Registry to Verdaccio
shell: bash
run: npm set registry ${{ inputs.registry }}
run: pnpm set registry ${{ inputs.registry }}

- name: Run Verdaccio (using publish config)
shell: bash
run: |
nohup ./node_modules/.bin/verdaccio --config ./verdaccio.publish.yaml & echo "VERDACCIO_PID=$!" >> $GITHUB_ENV
sleep 5
npm config set $(echo ${{ inputs.registry }} | sed -E 's/https?://')/:_authToken secretToken
pnpm config set $(echo ${{ inputs.registry }} | sed -E 's/https?://')/:_authToken secretToken
- name: Publish to Verdaccio
shell: bash
Expand All @@ -47,4 +47,4 @@ runs:
shell: bash
run: |
nohup ./node_modules/.bin/verdaccio --config ./verdaccio.install.yaml & sleep 5
npm config set $(echo ${{ inputs.registry }} | sed -E 's/https?://')/:_authToken secretToken
pnpm config set $(echo ${{ inputs.registry }} | sed -E 's/https?://')/:_authToken secretToken
2 changes: 1 addition & 1 deletion .github/actions/version-prepatch/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ runs:
- name: Bump prepatch version
id: bump-prepatch-version
shell: bash
run: npm version prepatch --no-git-tag-version --preid=$TAG --workspace=$PACKAGE
run: pnpm version prepatch --no-git-tag-version --preid=$TAG --workspace=$PACKAGE
env:
PACKAGE: ${{ inputs.package }}
TAG: ${{ inputs.tag }}
Expand Down
32 changes: 16 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ jobs:

- name: Require Changeset
if: ${{ !(github.event_name == 'merge_group') }}
run: if [[ "${{ github.event.pull_request.user.login }}" = "clerk-cookie" || "${{ github.event.pull_request.user.login }}" = "renovate[bot]" ]]; then echo 'Skipping' && exit 0; else npx changeset status --since=origin/main; fi
run: if [[ "${{ github.event.pull_request.user.login }}" = "clerk-cookie" || "${{ github.event.pull_request.user.login }}" = "renovate[bot]" ]]; then echo 'Skipping' && exit 0; else pnpm changeset status --since=origin/main; fi

- name: Lint GitHub Actions Workflows
run: npx eslint .github
run: pnpm eslint .github
shell: bash

- name: Check Formatting
run: npm run format:check
run: pnpm format:check

- name: Build Packages
run: npx turbo build $TURBO_ARGS --only
run: pnpm turbo build $TURBO_ARGS --only

- name: Check size using bundlewatch
run: npx turbo bundlewatch $TURBO_ARGS --only
run: pnpm turbo bundlewatch $TURBO_ARGS --only
env:
BUNDLEWATCH_GITHUB_TOKEN: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
CI_REPO_OWNER: ${{ vars.REPO_OWNER }}
Expand All @@ -67,13 +67,13 @@ jobs:
CI_BRANCH_BASE: refs/heads/main

- name: Lint packages using publint
run: npx turbo lint:publint $TURBO_ARGS --only
run: pnpm turbo lint:publint $TURBO_ARGS --only

- name: Lint types using attw
run: npx turbo lint:attw $TURBO_ARGS --only
run: pnpm turbo lint:attw $TURBO_ARGS --only

- name: Run lint
run: npx turbo lint $TURBO_ARGS --only -- --quiet
run: pnpm turbo lint $TURBO_ARGS --only -- --quiet

- name: Upload Turbo Summary
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -118,10 +118,10 @@ jobs:
run: |
if [ "${{ matrix.node-version }}" == "18" ]; then
echo "Running tests on Node 18 only for packages with LTS support."
npx turbo test $TURBO_ARGS --filter="@clerk/astro" --filter="@clerk/backend" --filter="@clerk/express" --filter="@clerk/nextjs" --filter="@clerk/clerk-react" --filter="@clerk/clerk-sdk-node" --filter="@clerk/shared" --filter="@clerk/remix" --filter="@clerk/tanstack-start" --filter="@clerk/elements" --filter="@clerk/vue"
pnpm turbo test $TURBO_ARGS --filter="@clerk/astro" --filter="@clerk/backend" --filter="@clerk/express" --filter="@clerk/nextjs" --filter="@clerk/clerk-react" --filter="@clerk/clerk-sdk-node" --filter="@clerk/shared" --filter="@clerk/remix" --filter="@clerk/tanstack-start" --filter="@clerk/elements" --filter="@clerk/vue"
else
echo "Running tests for all packages on Node 20."
npx turbo test $TURBO_ARGS
pnpm turbo test $TURBO_ARGS
fi
env:
NODE_VERSION: ${{ matrix.node-version }}
Expand Down Expand Up @@ -201,7 +201,7 @@ jobs:
INTEGRATION_INSTANCE_KEYS: ${{ secrets.INTEGRATION_INSTANCE_KEYS }}
run: |
AFFECTED=0
(npx turbo-ignore --task=test:integration:${{ matrix.test-name }} --fallback=${{ github.base_ref || 'refs/heads/main' }}) || AFFECTED=1
(pnpm turbo-ignore --task=test:integration:${{ matrix.test-name }} --fallback=${{ github.base_ref || 'refs/heads/main' }}) || AFFECTED=1
echo "affected=${AFFECTED}"
echo "affected=${AFFECTED}" >> $GITHUB_OUTPUT
Expand All @@ -210,21 +210,21 @@ jobs:
uses: ./.github/actions/verdaccio
with:
publish-cmd: |
if [ "$(npm config get registry)" = "https://registry.npmjs.org/" ]; then echo 'Error: Using default registry' && exit 1; else npx turbo build $TURBO_ARGS --only && npx changeset publish --no-git-tag; fi
if [ "$(pnpm config get registry)" = "https://registry.npmjs.org/" ]; then echo 'Error: Using default registry' && exit 1; else pnpm turbo build $TURBO_ARGS --only && pnpm changeset publish --no-git-tag; fi
- name: Install @clerk/backend in /integration
if: ${{ steps.task-status.outputs.affected == '1' }}
working-directory: ./integration
run: npm init -y && npm install @clerk/backend
run: pnpm init && pnpm add @clerk/backend

- name: Install @clerk/clerk-js in os temp
if: ${{ steps.task-status.outputs.affected == '1' }}
working-directory: ${{runner.temp}}
run: mkdir clerk-js && cd clerk-js && npm init -y && npm install @clerk/clerk-js
run: mkdir clerk-js && cd clerk-js && pnpm init && pnpm add @clerk/clerk-js

- name: Copy components @clerk/astro
if: ${{ matrix.test-name == 'astro' }}
run: cd packages/astro && npm run copy:components
run: cd packages/astro && pnpm copy:components

- name: Write all ENV certificates to files in integration/certs
if: ${{ steps.task-status.outputs.affected == '1' }}
Expand Down Expand Up @@ -252,7 +252,7 @@ jobs:
- name: Run Integration Tests
if: ${{ steps.task-status.outputs.affected == '1' }}
id: integration-tests
run: sudo --preserve-env npx turbo test:integration:${{ matrix.test-name }} $TURBO_ARGS
run: sudo npm install -g pnpm && sudo --preserve-env pnpm turbo test:integration:${{ matrix.test-name }} $TURBO_ARGS
env:
E2E_APP_CLERK_JS_DIR: ${{runner.temp}}
E2E_CLERK_VERSION: 'latest'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/e2e-cleanups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ jobs:
uses: ./.github/actions/verdaccio
with:
publish-cmd: |
if [ "$(npm config get registry)" = "https://registry.npmjs.org/" ]; then echo 'Error: Using default registry' && exit 1; else npx turbo build $TURBO_ARGS --only && npx changeset publish --no-git-tag; fi
if [ "$(pnpm config get registry)" = "https://registry.npmjs.org/" ]; then echo 'Error: Using default registry' && exit 1; else pnpm turbo build $TURBO_ARGS --only && pnpm changeset publish --no-git-tag; fi
- name: Install @clerk/backend in /integration
working-directory: ./integration
run: npm init -y && npm install @clerk/backend
run: pnpm init && pnpm add @clerk/backend

- name: Run cleanup
run: npm run test:integration:cleanup
run: pnpm test:integration:cleanup
env:
INTEGRATION_INSTANCE_KEYS: ${{ secrets.INTEGRATION_INSTANCE_KEYS }}
8 changes: 4 additions & 4 deletions .github/workflows/nightly-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ jobs:
uses: ./.github/actions/verdaccio
with:
publish-cmd: |
if [ "$(npm config get registry)" = "https://registry.npmjs.org/" ]; then echo 'Error: Using default registry' && exit 1; else npx turbo build $TURBO_ARGS --only && npx changeset publish --no-git-tag; fi
if [ "$(npm config get registry)" = "https://registry.npmjs.org/" ]; then echo 'Error: Using default registry' && exit 1; else pnpm turbo build $TURBO_ARGS --only && pnpm changeset publish --no-git-tag; fi
- name: Install @clerk/backend in /integration
working-directory: ./integration
run: npm init -y && npm install @clerk/backend
run: pnpm init && pnpm add @clerk/backend

- name: Install @clerk/clerk-js in os temp
working-directory: ${{runner.temp}}
run: mkdir clerk-js && cd clerk-js && npm init -y && npm install @clerk/clerk-js
run: mkdir clerk-js && cd clerk-js && pnpm init && pnpm add @clerk/clerk-js

- name: Run Integration Tests
run: npx turbo test:integration:${{ matrix.test-name }} $TURBO_ARGS --only --force --no-cache
run: pnpm turbo test:integration:${{ matrix.test-name }} $TURBO_ARGS --only --force --no-cache
env:
E2E_APP_CLERK_JS_DIR: ${{runner.temp}}
E2E_CLERK_VERSION: 'latest'
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/pr-title-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ jobs:
packages/*/package.json
sparse-checkout-cone-mode: false

- name: Install PNPM
uses: pnpm/action-setup@v4

- name: Lint Pull Request Title
run: |
npm init --scope=clerk --yes
npm i --save-dev @commitlint/config-conventional @commitlint/cli globby --audit=false --fund=false
echo '${{ github.event.pull_request.title }}' | npm exec @commitlint/cli -- --config commitlint.config.ts
pnpm init
pnpm add -D @commitlint/config-conventional @commitlint/cli globby
echo '${{ github.event.pull_request.title }}' | pnpm dlx @commitlint/cli -- --config commitlint.config.ts
4 changes: 2 additions & 2 deletions .github/workflows/preview.retheme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ jobs:
registry-url: 'https://registry.npmjs.org'

- name: Build packages
run: npx turbo build $TURBO_ARGS
run: pnpm turbo build $TURBO_ARGS

- name: Install site in isolation
run: node scripts/install-site-in-isolation.mjs playground/nextjs

- name: Install Vercel CLI
run: npm install --global vercel@latest
run: pnpm add -g vercel@latest

- name: Pull Vercel environment information
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
registry-url: 'https://registry.npmjs.org'

- name: Build packages
run: npx turbo build $TURBO_ARGS
run: pnpm turbo build $TURBO_ARGS

- name: Get date
run: |
Expand All @@ -90,7 +90,7 @@ jobs:
run: node scripts/install-site-in-isolation.mjs playground/nextjs

- name: Install Vercel CLI
run: npm install --global vercel@latest
run: pnpm add -g vercel@latest

- name: Pull Vercel environment information
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release-canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ jobs:

- name: Version packages for canary
id: version-packages
run: npm run version:canary | tail -1 >> "$GITHUB_OUTPUT"
run: pnpm version:canary | tail -1 >> "$GITHUB_OUTPUT"

- name: Build release
if: steps.version-packages.outputs.success == '1'
run: npx turbo build $TURBO_ARGS
run: pnpm turbo build $TURBO_ARGS

- name: Canary release
if: steps.version-packages.outputs.success == '1'
run: npm run release:canary
run: pnpm release:canary
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ jobs:
- name: Version packages for snapshot
id: version-packages
run: npm run version:snapshot ${{ steps.extract-snapshot-name.outputs.name }} | tail -1 >> "$GITHUB_OUTPUT"
run: pnpm version:snapshot ${{ steps.extract-snapshot-name.outputs.name }} | tail -1 >> "$GITHUB_OUTPUT"

- name: Build release
if: steps.version-packages.outputs.success == '1'
run: npx turbo build $TURBO_ARGS
run: pnpm turbo build $TURBO_ARGS

- name: Snapshot release
if: steps.version-packages.outputs.success == '1'
run: npm run release:snapshot
run: pnpm release:snapshot
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ jobs:
playwright-enabled: true # Must be present to enable caching on branched workflows

- name: Build release
run: npx turbo build $TURBO_ARGS --force
run: pnpm turbo build $TURBO_ARGS --force

- name: Create Release PR
id: changesets
uses: changesets/action@v1
with:
commit: 'ci(repo): Version packages'
title: 'ci(repo): Version packages'
publish: npm run release
publish: pnpm release
# Workaround for https://github.com/changesets/changesets/issues/421
version: npm run version
version: pnpm version
env:
GITHUB_TOKEN: ${{ secrets.CLERK_COOKIE_PAT }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate-renovate-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
- name: Validate Renovate Config
env:
RENOVATE_VERSION: 37.440.7 # Last version compatible with Node 18
run: npx --yes --package renovate@${{ env.RENOVATE_VERSION }} renovate-config-validator
run: pnpm dlx renovate@${{ env.RENOVATE_VERSION }} renovate-config-validator
4 changes: 2 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
###############################
#
#if [ -n "$unique_folders" ]; then
# npx turbo run build --output-logs=errors-only $unique_folders
# pnpm turbo run build --output-logs=errors-only $unique_folders
#else
# echo "SKIPPING: No packages to build"
#fi
Expand All @@ -39,4 +39,4 @@
# Run Lint Staged
##############################

npx lint-staged
pnpm lint-staged
4 changes: 2 additions & 2 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"*.{mjs,js,jsx,ts,tsx}": ["npx eslint --fix", "npx prettier --write"],
"*.{json,md,mdx}": ["npx prettier --write"]
"*.{mjs,js,jsx,ts,tsx}": ["pnpm eslint --fix", "pnpm prettier --write"],
"*.{json,md,mdx}": ["pnpm prettier --write"]
}
5 changes: 4 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
engine-strict=true
engine-strict=false
legacy-peer-deps=false

prefer-workspace-packages=true
link-workspace-packages=true
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dist
/packages/sdk-node/examples
node_modules
package-lock.json
pnpm-lock.yaml
playground
packages/backend/tests/**/*.js
/**/CHANGELOG.md
Expand Down
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"name": "playground/nextjs: debug server",
"type": "node-terminal",
"request": "launch",
"command": "npm run dev",
"command": "pnpm dev",
"cwd": "${workspaceFolder}/playground/nextjs"
},
{
"name": "playground/nextjs12: debug server",
"type": "node-terminal",
"request": "launch",
"command": "npm run dev",
"command": "pnpm dev",
"cwd": "${workspaceFolder}/playground/nextjs12"
},
{
Expand Down
Loading

0 comments on commit 305a03b

Please sign in to comment.