From 305a03b07efc88313b36df355d52b6f306ec0eb1 Mon Sep 17 00:00:00 2001 From: Jacek Radko Date: Thu, 14 Nov 2024 12:45:17 -0600 Subject: [PATCH] feat(repo): Introduce pnpm (#4528) --- .changeset/little-planes-report.md | 2 + .github/ISSUE_TEMPLATE/BUG_REPORT.yml | 2 +- .github/PULL_REQUEST_TEMPLATE.md | 4 +- .github/actions/init/action.yml | 12 +- .github/actions/verdaccio/action.yml | 6 +- .github/actions/version-prepatch/action.yml | 2 +- .github/workflows/ci.yml | 32 +- .github/workflows/e2e-cleanups.yml | 6 +- .github/workflows/nightly-checks.yml | 8 +- .github/workflows/pr-title-linter.yml | 9 +- .github/workflows/preview.retheme.yml | 4 +- .github/workflows/preview.yml | 4 +- .github/workflows/release-canary.yml | 6 +- .github/workflows/release-snapshot.yml | 6 +- .github/workflows/release.yml | 6 +- .../workflows/validate-renovate-config.yml | 2 +- .husky/pre-commit | 4 +- .lintstagedrc.json | 4 +- .npmrc | 5 +- .prettierignore | 1 + .vscode/launch.json | 4 +- docs/CONTRIBUTING.md | 38 +- integration/README.md | 18 +- integration/models/applicationConfig.ts | 2 +- integration/models/deployment.ts | 6 +- integration/presets/astro.ts | 11 +- integration/presets/elements.ts | 8 +- integration/presets/expo.ts | 8 +- integration/presets/express.ts | 8 +- integration/presets/next.ts | 17 +- integration/presets/react.ts | 12 +- integration/presets/remix.ts | 8 +- integration/presets/tanstack.ts | 20 +- integration/presets/vue.ts | 2 +- .../templates/astro-hybrid/package.json | 8 +- integration/templates/astro-node/README.md | 16 +- integration/templates/astro-node/package.json | 8 +- integration/templates/elements-next/README.md | 2 +- .../templates/elements-next/package.json | 8 +- integration/templates/expo-web/README.md | 6 +- integration/templates/expo-web/package.json | 9 +- .../next-app-router-quickstart/package.json | 10 +- .../templates/next-app-router/package.json | 4 +- integration/templates/react-cra/README.md | 4 +- integration/templates/react-cra/package.json | 8 +- .../templates/react-cra/public/index.html | 4 +- integration/templates/react-vite/package.json | 8 +- integration/templates/remix-node/README.md | 2 +- integration/templates/remix-node/package.json | 4 +- .../templates/tanstack-router/package.json | 8 +- .../templates/tanstack-start/README.md | 2 +- .../templates/tanstack-start/package.json | 8 +- package-lock.json | 51504 ---------------- package.json | 69 +- packages/astro/package.json | 12 +- packages/backend/package.json | 10 +- .../backend/src/__tests__/exports.test.ts | 2 + packages/backend/tsup.config.ts | 2 +- packages/chrome-extension/package.json | 10 +- packages/chrome-extension/tsup.config.ts | 2 +- packages/clerk-js/package.json | 16 +- .../clerk-js/src/core/auth/cookieSuffix.ts | 2 + .../src/ui/elements/withAvatarShimmer.tsx | 2 +- packages/clerk-js/tsconfig.json | 2 +- packages/clerk-js/turbo.json | 2 - packages/dev-cli/package.json | 2 +- .../elements/examples/nextjs/package.json | 8 +- packages/elements/package.json | 30 +- packages/elements/turbo.json | 1 - packages/eslint-config-custom/_base.js | 3 +- packages/expo-passkeys/package.json | 28 +- packages/expo-passkeys/src/index.ts | 5 +- packages/expo-passkeys/src/utils.ts | 5 +- .../expo-passkeys/tsconfig.declarations.json | 12 + packages/expo-passkeys/tsconfig.json | 27 +- packages/expo-passkeys/tsup.config.ts | 30 + packages/expo-passkeys/turbo.json | 19 - packages/expo/package.json | 12 +- packages/expo/tsup.config.ts | 2 +- packages/express/package.json | 7 +- packages/express/src/authenticateRequest.ts | 2 +- packages/fastify/package.json | 4 +- packages/localizations/package.json | 2 +- packages/nextjs/package.json | 12 +- packages/nextjs/src/server/clerkMiddleware.ts | 1 + packages/nextjs/tsup.config.ts | 4 +- packages/react/package.json | 13 +- .../src/utils/useCustomElementPortal.tsx | 2 +- packages/react/tsup.config.ts | 2 +- packages/react/turbo.json | 3 +- packages/remix/package.json | 13 +- packages/remix/src/utils/utils.ts | 4 +- packages/remix/tsup.config.ts | 2 +- packages/sdk-node/package.json | 8 +- packages/shared/package.json | 6 +- packages/shared/tsup.config.ts | 4 +- packages/tailwindcss-transformer/package.json | 3 +- packages/tailwindcss-transformer/turbo.json | 1 - packages/tanstack-start/package.json | 12 +- packages/tanstack-start/src/utils/env.ts | 2 +- packages/tanstack-start/tsup.config.ts | 4 +- packages/testing/package.json | 2 +- packages/themes/package.json | 2 +- packages/types/package.json | 2 +- packages/ui/package.json | 13 +- packages/ui/src/hooks/use-display-config.ts | 4 +- .../ui/src/hooks/use-enabled-connections.ts | 5 +- packages/ui/theme-builder/README.md | 2 +- packages/ui/theme-builder/package-lock.json | 6286 -- packages/ui/theme-builder/package.json | 10 +- packages/ui/theme-builder/scripts/deploy.mjs | 2 +- packages/upgrade/package.json | 8 +- packages/vue/.eslintrc.cjs | 3 + packages/vue/package.json | 5 +- playground/app-router/package.json | 4 +- playground/chrome-extension/README.md | 2 +- playground/chrome-extension/package.json | 2 +- playground/cra-js/README.md | 6 +- playground/cra-js/public/index.html | 4 +- playground/expo/README.md | 10 +- playground/expo/package.json | 2 +- playground/express/README.md | 6 +- playground/express/package.json | 2 +- playground/fastify/README.md | 2 +- playground/fastify/package.json | 8 +- playground/nextjs/README.md | 12 +- playground/nextjs/package.json | 2 +- playground/remix-cf-pages/README.md | 4 +- playground/remix-cf-pages/package.json | 2 +- playground/remix-cf-worker/README.md | 6 +- playground/remix-cf-worker/wrangler.toml | 2 +- playground/remix-node/README.md | 20 +- playground/vite-react-ts/package.json | 2 +- pnpm-lock.yaml | 33259 ++++++++++ pnpm-workspace.yaml | 2 + scripts/canary.mjs | 8 +- scripts/nuke.sh | 2 +- scripts/patch-incorrect-lockfile.mjs | 144 - scripts/snapshot.mjs | 8 +- 139 files changed, 33792 insertions(+), 58409 deletions(-) create mode 100644 .changeset/little-planes-report.md delete mode 100644 package-lock.json create mode 100644 packages/expo-passkeys/tsconfig.declarations.json create mode 100644 packages/expo-passkeys/tsup.config.ts delete mode 100644 packages/expo-passkeys/turbo.json delete mode 100644 packages/ui/theme-builder/package-lock.json create mode 100644 pnpm-lock.yaml create mode 100644 pnpm-workspace.yaml delete mode 100644 scripts/patch-incorrect-lockfile.mjs diff --git a/.changeset/little-planes-report.md b/.changeset/little-planes-report.md new file mode 100644 index 0000000000..a845151cc8 --- /dev/null +++ b/.changeset/little-planes-report.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml index 63b79fc34e..47e01e8a8c 100644 --- a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml +++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml @@ -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: diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index fd89ded5ed..57d9afd7f8 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -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 diff --git a/.github/actions/init/action.yml b/.github/actions/init/action.yml index ce9add0638..0bf23f8d05 100644 --- a/.github/actions/init/action.yml +++ b/.github/actions/init/action.yml @@ -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 @@ -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 diff --git a/.github/actions/verdaccio/action.yml b/.github/actions/verdaccio/action.yml index bb00a07950..13fd69e18b 100644 --- a/.github/actions/verdaccio/action.yml +++ b/.github/actions/verdaccio/action.yml @@ -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 @@ -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 diff --git a/.github/actions/version-prepatch/action.yml b/.github/actions/version-prepatch/action.yml index 51d42654fa..852ab285a2 100644 --- a/.github/actions/version-prepatch/action.yml +++ b/.github/actions/version-prepatch/action.yml @@ -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 }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aee4e028a9..c2a358f3bc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 }} @@ -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 @@ -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 }} @@ -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 @@ -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' }} @@ -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' diff --git a/.github/workflows/e2e-cleanups.yml b/.github/workflows/e2e-cleanups.yml index 26f89f36f7..e6770240ba 100644 --- a/.github/workflows/e2e-cleanups.yml +++ b/.github/workflows/e2e-cleanups.yml @@ -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 }} diff --git a/.github/workflows/nightly-checks.yml b/.github/workflows/nightly-checks.yml index 486316b523..c18401a2b2 100644 --- a/.github/workflows/nightly-checks.yml +++ b/.github/workflows/nightly-checks.yml @@ -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' diff --git a/.github/workflows/pr-title-linter.yml b/.github/workflows/pr-title-linter.yml index bf4d4af222..b70a34647f 100644 --- a/.github/workflows/pr-title-linter.yml +++ b/.github/workflows/pr-title-linter.yml @@ -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 diff --git a/.github/workflows/preview.retheme.yml b/.github/workflows/preview.retheme.yml index 0b1bd01599..bd54bb9307 100644 --- a/.github/workflows/preview.retheme.yml +++ b/.github/workflows/preview.retheme.yml @@ -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: | diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 2241c9227e..e1bfb68d1c 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -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: | @@ -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: | diff --git a/.github/workflows/release-canary.yml b/.github/workflows/release-canary.yml index 34b15a5bf9..91c5982f91 100644 --- a/.github/workflows/release-canary.yml +++ b/.github/workflows/release-canary.yml @@ -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 diff --git a/.github/workflows/release-snapshot.yml b/.github/workflows/release-snapshot.yml index 1fd124e294..ca7c40dd0a 100644 --- a/.github/workflows/release-snapshot.yml +++ b/.github/workflows/release-snapshot.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bd9bdaa94b..81ffb9293b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -49,7 +49,7 @@ 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 @@ -57,9 +57,9 @@ jobs: 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 }} diff --git a/.github/workflows/validate-renovate-config.yml b/.github/workflows/validate-renovate-config.yml index 7994d61f94..517aa3d926 100644 --- a/.github/workflows/validate-renovate-config.yml +++ b/.github/workflows/validate-renovate-config.yml @@ -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 diff --git a/.husky/pre-commit b/.husky/pre-commit index 5d2103ba28..667c2be4ec 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -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 @@ -39,4 +39,4 @@ # Run Lint Staged ############################## -npx lint-staged +pnpm lint-staged diff --git a/.lintstagedrc.json b/.lintstagedrc.json index 1ea2c6f849..430985043d 100644 --- a/.lintstagedrc.json +++ b/.lintstagedrc.json @@ -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"] } diff --git a/.npmrc b/.npmrc index 710f872fac..2661c87420 100644 --- a/.npmrc +++ b/.npmrc @@ -1,2 +1,5 @@ -engine-strict=true +engine-strict=false legacy-peer-deps=false + +prefer-workspace-packages=true +link-workspace-packages=true diff --git a/.prettierignore b/.prettierignore index 192205c492..51fec5bdd2 100644 --- a/.prettierignore +++ b/.prettierignore @@ -17,6 +17,7 @@ dist /packages/sdk-node/examples node_modules package-lock.json +pnpm-lock.yaml playground packages/backend/tests/**/*.js /**/CHANGELOG.md diff --git a/.vscode/launch.json b/.vscode/launch.json index c6caa847f7..6851e3696c 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -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" }, { diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index d6e779a305..150de10e52 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -31,12 +31,12 @@ Please note we have a [code of conduct](https://github.com/clerk/javascript/blob The current monorepo setup is based on: -- [npm workspaces](https://docs.npmjs.com/cli/v8/using-npm/workspaces), used for managing all Clerk packages from within a single repository. +- [pnpm workspaces](https://pnpm.io/workspaces), used for managing all Clerk packages from within a single repository. - [Turborepo](https://turbo.build/repo/docs), used for task running and task output caching. - [Changesets](https://github.com/changesets/changesets), used for package versioning, publishing and changelog generation. - [GitHub Actions](https://docs.github.com/en/actions), used for quality checks and automated release orchestration. - [Yalc](https://github.com/wclr/yalc), used for to publish packages locally and test them in other local projects. -- [Jest](https://jestjs.io/), used for running unit tests. +- [Jest](https://jestjs.io/) or [Vitest](https://vitest.dev/), used for running unit tests. - [Playwright](https://playwright.dev/), used for running the [integration](../integration/) test suite. All packages of the monorepo are inside [packages](../packages). For package specific details on installation, architecture and usage, you can refer to the package's README file. @@ -59,26 +59,32 @@ To set up your development environment, please follow these steps: 1. Clone the repo - ```sh - git clone https://github.com/clerk/javascript - ``` +```sh +git clone https://github.com/clerk/javascript +``` + +1. Enable `pnpm` package manager. + +```sh +corepack enable +``` -1. Install the dependencies. We're using npm workspaces, so you **should always run `npm install` from the root of the monorepo**, as it will install dependencies for all the packages: +1. Install the dependencies. We're using pnpm workspaces, so you **should always run `pnpm install` from the root of the monorepo**, as it will install dependencies for all the packages: - ```sh - cd javascript - npm install - ``` +```sh +cd javascript +pnpm install +``` 1. Build all the packages in the monorepo by running: - ```sh - npm run build - ``` +```sh +pnpm build +``` - This ensures that all internal TypeScript types are generated and any dependencies between packages are resolving. +This ensures that all internal TypeScript types are generated and any dependencies between packages are resolving. -Once you're ready to make changes, run `npm run dev` from the monorepo root. +Once you're ready to make changes, run `pnpm dev` from the monorepo root. If you want to run the `dev` script of an individual package, navigate to the folder and run the script from there. This way you can also individually run the `build` script. @@ -107,7 +113,7 @@ If your change can't only be tested by unit tests, you should add/edit an integr 1. Fork the project 1. Create your feature branch (`git checkout -b feat/amazing_feature`) 1. It's highly recommended to [write tests](#writing-tests) to ensure your change works and will continue to work in the future -1. If required, create a `changeset` that describes your changes (`npm run changeset`). In cases where a changeset is not required, an empty changeset can be created instead (`npm run changeset:empty`) - an empty changeset will not generate a changelog entry for the change, so please use it as an escape hatch or for internal refactors only. +1. If required, create a `changeset` that describes your changes (`pnpm changeset`). In cases where a changeset is not required, an empty changeset can be created instead (`pnpm changeset:empty`) - an empty changeset will not generate a changelog entry for the change, so please use it as an escape hatch or for internal refactors only. 1. Commit your changes (`git commit -m 'feat: Add amazing_feature'`) 1. Push to the branch (`git push origin feat/amazing_feature`) 1. [Open a Pull Request](https://github.com/clerk/javascript/compare?expand=1). Make sure the description includes enough information for the reviewer to understand what the PR is about. diff --git a/integration/README.md b/integration/README.md index d044886f7f..04f5cb5e67 100644 --- a/integration/README.md +++ b/integration/README.md @@ -17,8 +17,8 @@ Before you begin writing tests, you should already have: - Followed the setup instructions in the [contributing guide](../docs/CONTRIBUTING.md) - Access to Clerk's 1Password - Access to the **Integration testing** organization on Clerk (it owns the Clerk instances used in the tests) -- Chromium installed. Run `npx playwright install chromium`. -- WebKit installed. Run `npx playwright install webkit`. +- Chromium installed. Run `pnpm playwright install chromium`. +- WebKit installed. Run `pnpm playwright install webkit`. ## Initial setup @@ -46,18 +46,18 @@ The **most important** scripts: - All integration tests in parallel: ```shell - npm run test:integration:base + pnpm test:integration:base ``` - All tests for a specific preset (e.g. Next.js): ```shell - npm run test:integration:nextjs + pnpm test:integration:nextjs ``` Check the `package.json` for more preset scripts. You can filter tests by filename, e.g. if you only want to run the tests for `email-link.test.ts` you should use: ```shell -npm run test:integration:base -- email.link.test.ts +pnpm test:integration:base -- email.link.test.ts ``` Additionally, you can use two flags to configure how Playwright runs: @@ -68,7 +68,7 @@ Additionally, you can use two flags to configure how Playwright runs: For example: ```shell -npm run test:integration:base -- --ui email.link.test.ts +pnpm test:integration:base -- --ui email.link.test.ts ``` > [!TIP] @@ -83,7 +83,7 @@ Below you can find code snippets for running tests in a specific manner, easily During E2E runs a temporary site is created in which the template is copied into. If you want to keep the site around, pass the `CLEANUP` environment variable: ```shell -CLEANUP=0 npm run test:integration:base +CLEANUP=0 pnpm test:integration:base ``` For all available environment variables, check the [`constants.ts`](../integration/constants.ts) file. @@ -99,7 +99,7 @@ You might have a similar setup to this: Then you can use a combination of environment variables to fast track your tests: ```shell -E2E_APP_SK=sk_test_xxx E2E_APP_PK=pk_test_xxx E2E_APP_URL=http://localhost:3000 E2E_APP_CLERK_JS=https://xxx.clerk.accounts.dev/npm/@clerk/clerk-js@5/dist/clerk.browser.js npm run test:integration:base -- --ui +E2E_APP_SK=sk_test_xxx E2E_APP_PK=pk_test_xxx E2E_APP_URL=http://localhost:3000 E2E_APP_CLERK_JS=https://xxx.clerk.accounts.dev/npm/@clerk/clerk-js@5/dist/clerk.browser.js pnpm test:integration:base -- --ui ``` You need to replace all environment variables with your specific values/needs, above are just placeholders. @@ -382,7 +382,7 @@ Assuming you have a `react-parcel` template defined in `integration/templates`, Inside other presets you'll see additional `.addScript()` methods which you can use to override the default npm scripts for `setup`, `dev`, `build`, and `serve`. Ideally your template already defines these npm scripts. ```ts -.addScript('dev', 'npm run dev') +.addScript('dev', 'pnpm dev') ``` You can use `.addFile()` to append another file to the template: diff --git a/integration/models/applicationConfig.ts b/integration/models/applicationConfig.ts index 511f81c40e..54e20b6c12 100644 --- a/integration/models/applicationConfig.ts +++ b/integration/models/applicationConfig.ts @@ -15,7 +15,7 @@ export const applicationConfig = () => { let serverUrl = ''; const templates: string[] = []; const files = new Map(); - const scripts: Scripts = { dev: 'npm run dev', serve: 'npm run serve', build: 'npm run build', setup: 'npm i' }; + const scripts: Scripts = { dev: 'pnpm dev', serve: 'pnpm serve', build: 'pnpm build', setup: 'pnpm install' }; const envFormatters = { public: (key: string) => key, private: (key: string) => key }; const logger = createLogger({ prefix: 'appConfig', color: 'yellow' }); const dependencies = new Map(); diff --git a/integration/models/deployment.ts b/integration/models/deployment.ts index d30dc2b801..524dbb0162 100644 --- a/integration/models/deployment.ts +++ b/integration/models/deployment.ts @@ -40,14 +40,14 @@ export const vercelDeployment = async (config: ApplicationConfig) => { // resolve issues with vercel cli not finding a git repo await run(`git init`, { cwd: app.appDir, log: logger.info }); // pull project config from vercel using the env variables - await run(`npx vercel pull --yes --token ${process.env.VERCEL_TOKEN}`, procConfig); + await run(`pnpm vercel pull --yes --token ${process.env.VERCEL_TOKEN}`, procConfig); // build for prod locally - await run(`npx vercel build --prod`, procConfig); + await run(`pnpm vercel build --prod`, procConfig); const pk = app.env.publicVariables.get('CLERK_PUBLISHABLE_KEY'); const sk = app.env.privateVariables.get('CLERK_SECRET_KEY'); // deploy to vercel and set the Clerk env variables await run( - `npx vercel --prod --prebuilt --token ${process.env.VERCEL_TOKEN} --env NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=${pk} --env CLERK_SECRET_KEY=${sk}`, + `pnpm vercel --prod --prebuilt --token ${process.env.VERCEL_TOKEN} --env NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=${pk} --env CLERK_SECRET_KEY=${sk}`, procConfig, ); diff --git a/integration/presets/astro.ts b/integration/presets/astro.ts index 5b1bb70ec8..0a6ee24551 100644 --- a/integration/presets/astro.ts +++ b/integration/presets/astro.ts @@ -9,13 +9,10 @@ const astroNode = applicationConfig() .setName('astro-node') .useTemplate(templates['astro-node']) .setEnvFormatter('public', key => `PUBLIC_${key}`) - // When creating symlinks, the Astro vite plugin is unable to process `