Kkingsword09

pnpm-catalogs-fix

Fix incorrect pnpm catalog configurations in package.json and pnpm-workspace.yaml files

pnpmcatalogworkspacefix
Public
22 downloads
0 stars
How to Use
Run this codemod on your codebase using one of the following commands

The easiest way to run this codemod without installing anything globally:

Documentation

pnpm Catalogs Fix

Automatically resolves broken pnpm catalog references across pnpm-workspace.yaml and package.json files. The workflow de-references nested catalog: values, reconciles catalog definitions, and rewrites package dependencies so every consumer points back to the catalog.

Example

Resolve chained catalog entries

Before:

yaml

After:

yaml

Enforce catalog usage in packages

Before:

json

After:

json

Usage

Via Codemod CLI (Recommended)

bash

Direct Execution

Run TypeScript directly with Node.js 20.6+ (no build required):

bash

Or specify workspace path:

bash

Alternatively, build and run the compiled JavaScript:

bash

How It Works

The codemod uses @codemod.com/workflow API (version 0.0.31) to:

  1. Locate workspace: Automatically finds pnpm-workspace.yaml with catalog definitions
  2. Resolve catalog chains: Recursively resolves catalog: references pointing to other catalogs
  3. Fix workspace catalogs: Updates pnpm-workspace.yaml with resolved versions
  4. Normalize package.json: Replaces explicit versions with catalog: references where appropriate
  5. Report changes: Provides detailed output of all fixes applied

The workflow locates pnpm-workspace.yaml, resolves catalog chains, normalises catalog definitions, and rewrites any workspace packages to reference the catalog version.

Technical Details

  • Runtime: Node.js 20.6+ with native TypeScript support (--experimental-strip-types)
  • Language: TypeScript (ESM)
  • Dependencies: @codemod.com/workflow 0.0.31
  • Workflow Version: codemod.com workflow schema v1

Requirements

  • Node.js 20.6+ (for native TypeScript support)
  • pnpm workspace with pnpm-workspace.yaml

Ready to contribute?

Build your own codemod and share it with the community.