Switching default package manager to pnpm
Prerequisite
- A GitHub repository with the Speakeasy SDK Generation GitHub Action integrated and enabled.
Adding pnpm Support
- Open the GitHub Actions workflow file (e.g.,
.github/workflows/sdk-generation.yaml). - Modify the
generatejob to include thepnpm_versioninput. This ensures pnpm is installed during the action.
Example Workflow File
name: Generate
permissions:
checks: write
contents: write
pull-requests: write
statuses: write
"on":
workflow_dispatch:
inputs:
force:
description: Force generation of SDKs
type: boolean
default: false
set_version:
description: Optionally set a specific SDK version
type: string
jobs:
generate:
uses: speakeasy-api/sdk-generation-action/.github/workflows/workflow-executor.yaml@v15
with:
force: ${{ github.event.inputs.force }}
mode: pr
set_version: ${{ github.event.inputs.set_version }}
speakeasy_version: latest
working_directory: packages/sdk
pnpm_version: "9.19.4" # Specify the required pnpm version
secrets:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
npm_token: ${{ secrets.NPM_TOKEN_ELEVATED }}
speakeasy_api_key: ${{ secrets.SPEAKEASY_API_KEY }}(Optional) Verifying pnpm Installation
Ensure pnpm is used in the workflow by adding a step to verify its presence:
steps:
- name: Verify pnpm installation
run: pnpm --versionThis outputs the installed pnpm version for confirmation during workflow execution.
Additional Notes
- Use the same
pnpm_versionas used in local development for consistency. - Ensure any
package.jsonfiles are compatible with pnpm. Runpnpm installlocally to verify.
Using PNPM in Monorepos
When working with monorepos, pnpm offers several advantages including strict module resolution and efficient workspace management. To configure Speakeasy to use pnpm in your monorepo:
Local Development Configuration
Add the compileCommand configuration to your gen.yaml file:
typescript:
compileCommand:
- pnpm
- installWorkspace Configuration
Ensure your pnpm-workspace.yaml includes the SDK directory:
packages:
- "packages/*"
- "sdk/*" # Include your SDK locationBenefits for Monorepos
- Strict module resolution: Prevents dependency confusion between packages
- Efficient storage: Shared dependencies across workspace packages
- Better workspace support: Built-in monorepo tooling
Related Guide
For comprehensive monorepo setup and troubleshooting tips, see our TypeScript Monorepo Tips guide.
Last updated on