chore: migrate to pnpm for improved monorepo management (#287)

# Migrate to pnpm for improved monorepo management

## Summary
This PR migrates the Codex repository from npm to pnpm, providing faster
dependency installation, better disk space usage, and improved monorepo
management.

## Changes
- Added `pnpm-workspace.yaml` to define workspace packages
- Added `.npmrc` with optimal pnpm configuration
- Updated root package.json with workspace scripts
- Moved resolutions and overrides to the root package.json
- Updated scripts to use pnpm instead of npm
- Added documentation for the migration
- Updated GitHub Actions workflow for pnpm

## Benefits
- **Faster installations**: pnpm is significantly faster than npm
- **Disk space savings**: pnpm's content-addressable store avoids
duplication
- **Strict dependency management**: prevents phantom dependencies
- **Simplified monorepo management**: better workspace coordination
- **Preparation for Turborepo**: as discussed, this is the first step
before adding Turborepo

## Testing
- Verified that `pnpm install` works correctly
- Verified that `pnpm run build` completes successfully
- Ensured all existing functionality is preserved

## Documentation
Added a detailed migration guide in `PNPM_MIGRATION.md` explaining:
- Why we're migrating to pnpm
- How to use pnpm with this repository
- Common commands and workspace-specific commands
- Monorepo structure and configuration

## Next Steps
As discussed, once this change is stable, we can consider adding
Turborepo as a follow-up enhancement.
This commit is contained in:
Alpha Diop
2025-04-18 23:25:15 +00:00
committed by GitHub
parent 9a046dfcaa
commit e2fe2572ba
12 changed files with 152 additions and 7774 deletions

View File

@@ -19,40 +19,47 @@ jobs:
with:
node-version: 22
# Run codex-cli/ tasks first because they are higher signal.
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.8.1
run_install: false
- name: Install dependencies (codex-cli)
working-directory: codex-cli
run: npm ci
- name: Check formatting (codex-cli)
working-directory: codex-cli
run: npm run format
- name: Run tests (codex-cli)
working-directory: codex-cli
run: npm run test
- name: Lint (codex-cli)
working-directory: codex-cli
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
npm run lint -- \
echo "store_path=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.store_path }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
# Run all tasks using workspace filters
- name: Check formatting
run: pnpm run format
- name: Run tests
run: pnpm run test
- name: Lint
run: |
pnpm --filter @openai/codex exec -- eslint src tests --ext ts --ext tsx \
--report-unused-disable-directives \
--rule "no-console:error" \
--rule "no-debugger:error" \
--max-warnings=-1
- name: Typecheck (codex-cli)
working-directory: codex-cli
run: npm run typecheck
- name: Type-check
run: pnpm run typecheck
- name: Build (codex-cli)
working-directory: codex-cli
run: npm run build
# Run formatting checks in the root directory last.
- name: Install dependencies (root)
run: npm ci
- name: Check formatting (root)
run: npm run format
- name: Build
run: pnpm run build