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

modern-cmdk-codemod

v1.0.2

Published

Codemods that migrate cmdk code to modern-cmdk: four jscodeshift transforms that report every site they cannot migrate instead of guessing.

Readme

Codemods that migrate cmdk code to modern-cmdk: four jscodeshift transforms that report every site they cannot migrate instead of guessing.

npx modern-cmdk-codemod --dry-run should-filter ./src

Four transforms · --dry-run writes nothing and prints a diff · by default writes only files that git has committed · Node ≥ 26.4.0

Quick start

Nothing to install: npx (or pnpm dlx) runs it. Start from a committed tree and commit after each transform, so every step is a diff you can review:

npx modern-cmdk-codemod should-filter ./src && git commit -am should-filter
npx modern-cmdk-codemod forward-ref ./src && git commit -am forward-ref
npx modern-cmdk-codemod data-attrs ./src && git commit -am data-attrs
npx modern-cmdk-codemod import-rewrite ./src && git commit -am import-rewrite

import-rewrite goes last: should-filter recognises a cmdk filter function only while the import still reads 'cmdk'. Unless you pass --force or --lenient, a run that writes refuses to start when a file it matched has uncommitted changes or lies outside the git work tree you run it from, or when git is missing.

What each transform changes

1. should-filter: shouldFilter={false} becomes filter={false}, shouldFilter={expr} becomes filter={expr ? undefined : false}, and a cmdk filter function is wrapped to take (item, query).

-export const C = () => <Command label="c" shouldFilter={false} />;
+export const C = () => <Command label="c" filter={false} />;

2. forward-ref: forwardRef is unwrapped into a component that takes ref as a prop (React 19), keeping the props and ref types.

-import { forwardRef, useImperativeHandle } from 'react';
+import { useImperativeHandle, type Ref } from 'react';
 type Props = { label: string };
-export const Tag = forwardRef((props: Props, ref) => {
+export const Tag = (
+  {
+    ref,
+    ...props
+  }: Props & {
+    ref?: Ref<unknown>;
+  }
+) => {
   useImperativeHandle(ref, () => ({}));
   return <span>{props.label}</span>;
-});
+};

3. data-attrs: cmdk-* attributes and --cmdk-list-height become their data-command-* and --command-* names in JSX, in selector strings and in .css and .scss files, with the state attributes beside them.

-[cmdk-item][data-selected="true"],
-[cmdk-item]:hover {
+[data-command-item][data-active],
+[data-command-item]:hover {
   background: #eee;
 }

4. import-rewrite: 'cmdk' becomes 'modern-cmdk/react' in imports, re-exports, import(), require() and vi.mock or jest.mock.

-import { Command } from 'cmdk';
-import 'cmdk';
-export { CommandItem } from 'cmdk';
+import { Command } from 'modern-cmdk/react';
+import 'modern-cmdk/react';
+export { CommandItem } from 'modern-cmdk/react';

A site a transform cannot migrate is printed as <path>: <message> on stderr, counted in the summary and left as it was.

A report is printed as <path>: <message> on stderr, counted in the summary, and never changes the exit code; the site is left as it was for you to migrate by hand. These are the messages as the code writes them (<...> is filled in per site):

  • should-filter: <Command> at line N has both shouldFilter and filter; left unchanged for manual migration (...); ... has a filter value the transform cannot adapt; left unchanged for manual migration; ... has a filter expression that may not be a function; left unchanged for manual migration; ... has a filter expression that is computed where it stands (a call or other computed value), ...; left unchanged for manual migration: hoist it to a const and pass the name; <Command> at line N has a non-expression shouldFilter value; left unchanged for manual migration; ... has an empty shouldFilter value; left unchanged for manual migration.
  • forward-ref: forwardRef() without a render function: unwrap by hand; forwardRef(<name>): unwrap by hand and forwardRef(<expression>): unwrap by hand; forwardRef render function with more than two parameters: unwrap by hand; forwardRef props parameter is not an identifier or object pattern: unwrap by hand; forwardRef props pattern already has a 'ref' key: unwrap by hand; forwardRef ref parameter is not a plain identifier: unwrap by hand; forwardRef<T>() render function without parameters: unwrap by hand; forwardRef props pattern has a computed key that may be 'ref': unwrap by hand; forwardRef render function has a JSX spread and no ref type argument: unwrap by hand; forwardRef ref is annotated but the props type is unknown: unwrap by hand.
  • data-attrs (each message starts with line N: where the line is known): <attr> has no modern-cmdk equivalent: <reason>; left unchanged (cmdk-label, which cmdk renders as a visually hidden <label> while modern-cmdk puts the label on the root as aria-label, and cmdk-item-select, a DOM event that has no counterpart: use the item onSelect prop); <selector> beside a cmdk attribute cannot be migrated automatically: ...; left unchanged for a state attribute with a value other than "true" or "false"; <selector> under a rule whose selectors only partly hold a cmdk attribute cannot be migrated automatically; left unchanged (SCSS); <variant>: on a cmdk element cannot be migrated automatically: ...; left unchanged (Tailwind data-[selected]: and data-[disabled]: presence forms); <attr> is a cmdk attribute name outside a selector; modern-cmdk renders <data-command-attr>; left unchanged (a bare attribute name in a string); <variant>: has no modern-cmdk equivalent, <presence> is a presence attribute with no false value (use not-<presence>:); left unchanged (Tailwind data-[selected=false]: and data-[disabled=false]:). <variant>: styles this element by the state of another element (an ancestor or a sibling) that need not be a cmdk element, so it cannot be migrated automatically; left unchanged: check it by hand (a group-, peer- or in- data variant, such as group-data-[selected=true]:, peer-has-data-[...]: or not-in-data-[...]:; migrate it by hand once you know which element carries the state).
  • import-rewrite: <name> has no modern-cmdk/react export; left on the cmdk import (defaultFilter, CommandProps); useCommandState was rewritten, but its state is modern-cmdk's CommandState, not cmdk's; review the selector; 'cmdk/<subpath>' is a cmdk subpath with no modern-cmdk/react counterpart; left unchanged; declare module 'cmdk' was left unchanged; move the declaration to 'modern-cmdk/react' by hand; the mock factory for 'cmdk' names ..., which modern-cmdk/react does not export under that name; the factory body is not rewritten, check it by hand; <name> has no modern-cmdk/react export; left on the cmdk export; <name> has no modern-cmdk/react export; used through <namespace or binding>; <name> has no modern-cmdk/react export; used through import('cmdk'); <name> has no modern-cmdk/react export under that name; destructured from the cmdk module; export * from 'cmdk' re-exported names that modern-cmdk/react lacks (CommandRoot, defaultFilter); re-export the modern-cmdk/react names by hand (and the same for export * as K from 'cmdk').

Options

| Option | Effect | |---|---| | --dry-run | Write nothing; print a unified diff of every file that would change | | --force | Write into a tree with uncommitted changes, or outside git | | --strict | The default: exit 2 on a usage error, 1 when a file errors or nothing matches | | --lenient | Lenient exit codes and no git check; not with --strict | | --concurrency=N | Files processed at once (default: the smaller of 8 and the cores) | | -h, --help | Print the usage | | -v, --version | Print the package name and version |

The last line of a run is the summary: N changed, N unchanged, N errors count files. , N skipped counts files the transform does not read (a .css file under should-filter, for example) and , N reported counts the reports printed; each appears only above zero. A dry run ends the line with (dry run, nothing written).

| Code | Default (strict) | --lenient | |---|---|---| | 0 | Success, reports included; --help | --help, missing arguments, usage errors and per-file errors | | 1 | A file errored, no file matched, or the run failed | An unknown transform, no matching files, an uncaught error | | 2 | A usage error, or a refused dirty tree | --strict given with --lenient |

A directory argument covers its .ts, .tsx, .mts, .cts, .js, .jsx, .mjs, .cjs, .css and .scss files. A quoted glob works too: "./src/**/*.{tsx,css}". Skipped: node_modules, dist, build, .next, .git, coverage, .turbo, out, storybook-static, .vercel, every path your .gitignore covers (when git is found), files reached through a symlinked directory, and names that start with a dot unless a pattern segment or a directory argument names them.

The deprecated modern-cmdk bin

modern-cmdk also ships a modern-cmdk bin that runs the same four transforms. It is deprecated: it warns on every run, keeps lenient exit codes unless --strict is given, skips fewer directories, reads no .gitignore and makes no git check. Use modern-cmdk-codemod.

Requirements

Node 26.4.0 or later; git for a run that writes, unless you pass --force or --lenient. One dependency: jscodeshift.

The modern-cmdk packages

| Package | Use it to | |---|---| | modern-cmdk | build the palette: core engine, React adapter, stylesheet | | create-modern-cmdk | start a Vite, React 19 and TypeScript project with a palette in it | | modern-cmdk-codemod | move code written for cmdk to modern-cmdk |

Links

Documentation · Changelog · Releases · Issues · Security policy · Repository

License

MIT © 2026 Albert Badalov