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

@gylove1994/pnpm-workspace-runner

v0.1.0

Published

Interactive CLI to locate pnpm workspace root, list packages and scripts, and run selected scripts.

Readme

pnpm-workspace-runner

交互式 CLI:自动定位 pnpm 工作区根目录,列出包与脚本,并支持在选定目标中执行脚本、安装/移除依赖(含一键添加对应 @types/*)。

  • Node 要求:>= 18
  • 包管理器:pnpm
  • 可执行文件:pnpm-workspace-runner

安装与启动

工作区内已经配置好本工具,构建后可直接运行:

pnpm -C tools/pnpm-workspace-runner build
pnpm-workspace-runner

也可以通过 node 直接执行打包产物:

node tools/pnpm-workspace-runner/dist/index.mjs

交互流程

  1. 选择一个目标:
    • <workspace-root>(工作区根目录)
    • 某个具体包(自动从 pnpm-workspace.yamlpackages 模式解析)
  2. 在同一个列表中选择要执行的项(单步完成):
    • 目标包的 scripts(显示为:脚本名 — 命令预览)
    • 操作项:
      • 安装依赖 (pnpm add)
      • 安装依赖并添加类型包 (pnpm add + @types,types 为 dev)
      • 移除依赖 (pnpm remove)
      • 自定义命令...

选择不同项后会继续询问必要参数,例如附加参数、包名列表等。

功能说明

运行脚本

  • 选择任意脚本后,可输入额外参数(以空格分隔)。
  • 实际执行:pnpm -C <目标目录> run <scriptName> ...extraArgs

安装依赖(pnpm add)

  • 输入要安装的包(以空格分隔,支持 namename@version)。
  • 选项:是否作为 dev 依赖安装(-D)、是否精确版本(-E)、附加自定义参数。
  • 实际执行:pnpm -C <目标目录> add [包...] [-D] [-E] ...extraArgs

安装依赖并添加类型包(pnpm add + @types)

  • 对输入的每个包自动生成 @types/* 并以 dev 依赖安装。
  • 名称映射规则:
    • 普通包:react@types/react
    • 作用域包:@scope/name@types/scope__name
    • 多级名:@scope/a/b@types/scope__a__b
    • 已是 @types/* 的包不会重复添加
  • 实际执行两步:
    • pnpm -C <目标目录> add [包...] [-D?] [-E?] ...extraArgs
    • pnpm -C <目标目录> add -D [@types 包...]

移除依赖(pnpm remove)

  • 输入要移除的包(以空格分隔)。
  • 可附加自定义参数。
  • 实际执行:pnpm -C <目标目录> remove [包...] ...extraArgs

自定义命令

  • 在目标目录作为 cwd 执行任意命令行。

示例

  • 在包 packages/genid 中运行 build 脚本:

    1. 选择 packages/genid
    2. 选择 build — tsup -d dist src/index.ts(示例)
    3. 可选输入额外参数,例如 --watch
  • 在包 packages/genid 中安装依赖:

    • 选择 packages/genid安装依赖 (pnpm add) → 输入:zod → 选择是否 -D/-E
  • 在包 packages/genid 中安装依赖并自动添加类型包:

    • 选择 packages/genid安装依赖并添加类型包 → 输入:react @radix-ui/react-popover → 将附加安装 @types/react@types/radix-ui__react-popover(作为 dev)
  • 在包 packages/genid 中移除依赖:

    • 选择 packages/genid移除依赖 (pnpm remove) → 输入:zod

常见问题

  • 无法找到工作区:请确认在包含 pnpm-workspace.yaml 的目录或其任意子目录中运行本工具。
  • 列表没有脚本:该包的 package.json 中没有 scripts,仍可使用安装/移除依赖与自定义命令。

开发

pnpm -C tools/pnpm-workspace-runner dev
# 修改 src/index.ts 后自动重新构建到 dist/