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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@inth/hexbus-codemods

v0.6.3

Published

Reusable codemod harness for Hexbus CLIs.

Readme

@inth/hexbus-codemods

Reusable codemod harness for Inth app CLIs built on Hexbus. This package owns the shared mechanics for collecting files, creating ts-morph projects, filtering applicable codemods, running selected migrations, reporting results, and testing transforms with temporary fixtures.

Table of Contents

Key Features

  • Collect source files recursively with configurable extensions, ignored directories, and include predicates.
  • Create dry-run-aware ts-morph projects for transform authors.
  • Define typed codemod metadata with stable IDs, labels, hints, version constraints, and run functions.
  • Filter codemods by installed product version before prompting users.
  • Run selected codemods independently so one failure does not abort the full migration session.
  • Use fixture helpers to write temporary projects, run transforms, assert results, and clean up automatically.

Prerequisites

  • Node.js 18.17.0 or later
  • A Hexbus-powered Inth app CLI
  • Product-specific codemod definitions supplied by the consuming CLI

Quick Start

Create codemod definitions in your Inth app CLI, then pass them to the shared runner:

import {
  defineCodemod,
  runCodemods,
  createCodemodProject,
} from "@inth/hexbus-codemods";

const renameConfig = defineCodemod({
  id: "rename-config",
  label: "Rename config option",
  hint: "Updates old config keys to the new names",
  versioning: { fromRange: "<2.0.0" },
  async run(_context, options) {
    const project = await createCodemodProject(options.projectRoot, {
      dryRun: options.dryRun,
    });

    const changedFiles: string[] = [];
    for (const sourceFile of project.sourceFiles) {
      const before = sourceFile.getFullText();
      sourceFile.replaceWithText(before.replaceAll("oldConfig", "newConfig"));
      if (sourceFile.getFullText() !== before) {
        changedFiles.push(sourceFile.getFilePath());
      }
    }

    await project.save();
    return { changedFiles, errors: [] };
  },
});

await runCodemods(context, [renameConfig], {
  brandName: "my app",
  dryRun: Boolean(context.flags["dry-run"]),
  detectInstalledVersion: async (projectRoot) =>
    readInstalledVersion(projectRoot),
});

Installation

bun add @inth/hexbus-codemods hexbus
npm install @inth/hexbus-codemods hexbus
pnpm add @inth/hexbus-codemods hexbus

Usage

  1. Keep app-specific transforms in the app CLI. This package should only provide the runner and shared mechanics.
  2. Use defineCodemod to preserve generic context types across codemod arrays.
  3. Use createCodemodProject inside codemods when you need ts-morph source files and a dry-run-aware save method.
  4. Return changedFiles and errors from each codemod so runCodemods can produce consistent user-facing output.
  5. Use withTempProject, writeFixtureTree, readFixtureFile, and runAndAssert for fixture-backed tests.

Support

  • Open an issue in the Hexbus repository for runner bugs or missing shared codemod mechanics.
  • Keep transform-specific questions with the Inth app CLI that owns the codemod definitions.

License

Apache-2.0

Core Exports

  • Collection: collectSourceFiles, createCodemodProject, DEFAULT_IGNORED_DIRS, DEFAULT_SUPPORTED_EXTENSIONS
  • Runner: defineCodemod, runCodemods, logCodemodResult
  • Versioning: satisfiesSimpleRange, isCodemodApplicableForVersion
  • Testing: withTempProject, writeFixtureTree, readFixtureFile, runAndAssert
  • Types: CodemodDefinition, CodemodRunOptions, CodemodRunResult, RunCodemodsOptions, CollectOptions, CodemodProject

Version Gating

Codemods can declare simple version constraints with fromRange and toRange. Supported comparators are >, >=, <, <=, =, ^, and ~. When the installed version is unknown, codemods are treated as applicable so users can still opt in.

Testing

Fixture helpers create temporary project directories, write project-relative files, run your callback, and clean up by default.

import { readFixtureFile, withTempProject } from "@inth/hexbus-codemods";

await withTempProject({ "src/app.ts": "oldConfig();" }, async (projectRoot) => {
  await runMyCodemod(projectRoot);
  const output = await readFixtureFile(projectRoot, "src/app.ts");
  expect(output).toContain("newConfig");
});