npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

codeshift

v0.1.0

Published

CodeShift — AST-driven refactor engine to port projects between frameworks/APIs. CLI + library. Use with caution; review changes before applying.

Readme

CodeShift

CodeShift (package: codeshift) is an AST-driven refactor engine that automates repeatable, safe-ish transformations across a codebase. It is not a magical converter — transformations are intentionally conservative and must be reviewed before applying to production code.

⚠️ WARNING: Always run in dry-run mode first (--apply is required to write files). Backups are created by default (.codeshift.bak).

Install

# Install globally
npm install -g codeshift

# Or use with npx (no installation needed)
npx codeshift --help

# Or install as a project dependency
npm install --save-dev codeshift

Usage

CLI

# List available transforms
npx codeshift --list

# Dry-run (default) - see what would change
npx codeshift "src/**/*.js" --transform express-to-fastify

# Apply changes (creates backups by default)
npx codeshift "src/**/*.js" --transform express-to-fastify --apply

# Run all transforms
npx codeshift "src/**/*.js" --apply

# Output markdown report
npx codeshift "src/**/*.js" --format md --out report.md

# No backups (not recommended)
npx codeshift "src/**/*.js" --apply --no-backup

Library

const { runTransforms, listTransforms } = require('codeshift');

// List available transforms
const transforms = listTransforms();
console.log(transforms);

// Run transforms (dry-run by default)
const report = await runTransforms(['src/**/*.js'], {
  transforms: ['express-to-fastify'],
  apply: false,
  backup: true,
  verbose: true
});

console.log(JSON.stringify(report, null, 2));

Available Transforms

express-to-fastify

Converts simple Express router patterns to Fastify route registration.

Handles:

  • router.get('/path', handler)fastify.route({ method: 'GET', url: '/path', handler })
  • router.post(...), router.put(...), etc.

Limitations:

  • Only handles simple route handlers (no complex middleware chains)
  • Does not auto-convert Express-specific middleware (body-parser, etc.)
  • Manual verification required

cjs-to-esm

Converts CommonJS require() and module.exports to ESM import/export.

Handles:

  • const x = require('mod')import x from 'mod'
  • const {a, b} = require('mod')import {a, b} from 'mod'
  • module.exports = xexport default x

Limitations:

  • Only converts files with pure CommonJS (skips files with existing import/export)
  • Does not handle dynamic require() calls
  • Does not convert module.exports.foo = bar patterns

mongoose-to-prisma

Converts simple Mongoose query patterns to Prisma-like calls.

Handles:

  • Model.find(query)prisma.model.findMany({ where: query })
  • Model.findOne(query)prisma.model.findFirst({ where: query })

Limitations:

  • Very limited scope — only handles simple .find() and .findOne() calls
  • Does not auto-convert .save(), .create(), or complex queries
  • Assumes Prisma client is available (does not auto-inject imports)
  • Model name conversion is lowercase (e.g., Userprisma.user)

Safety Features

  1. Dry-run by default — Use --apply to actually write files
  2. Automatic backups — Creates .codeshift.bak files before writing (disable with --no-backup)
  3. Syntax validation — Verifies transformed code parses correctly before writing
  4. Conservative transforms — Only handles well-defined, simple patterns

Report Format

Reports include:

  • summary: Files scanned, transforms run, total changes
  • changes: Array of change objects with transform ID, file, line, and message

Development

# Install dependencies
npm install

# Run tests
npm test

# Link for local testing
npm link

Contributing

Transforms are plugin-style modules in lib/transforms/. Each transform exports:

  • id: Unique identifier
  • description: Human-readable description
  • matchFiles: Array of glob patterns for file matching
  • transform(ast, context): Function that mutates AST and returns { changed: boolean, messages: [] }

License

MIT

Disclaimer

This tool is provided as-is. Always review changes before committing to production. Complex migrations require manual intervention and testing.