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

mono-exec

v1.1.0

Published

Interactive script runner for monorepos - Choose workspace and script interactively

Readme

mono-exec

Monorepo 交互式脚本运行器 - 交互式选择工作区和脚本

npm version License: MIT

English | 简体中文

为什么选择 mono-exec?

在 Monorepo 中管理脚本可能很繁琐。使用 mono-exec,你将获得一个交互式 CLI

  • 交互式选择工作区和脚本(不再需要输入 --filter 标志!)

  • 🚀 支持包管理器工作区 - 自动检测并支持:

    • pnpm workspaces (pnpm-workspace.yaml)
    • npm/yarn workspaces (package.json workspaces)
  • 🎯 零配置 - 安装即用

演示

$ mexec

✔ 找到 3 个工作区
? 选择一个工作区:
❯ my-app (apps/my-app)
  my-lib (packages/my-lib)
  shared-ui (packages/shared-ui)

? 选择要运行的脚本:
❯ dev → npm run dev
  build → npm run build
  test → npm run test

运行命令:
pnpm --filter my-app run dev

安装

全局安装(推荐)

npm install -g mono-exec
# 或
pnpm add -g mono-exec
# 或
yarn global add mono-exec

本地安装(每个项目)

在 monorepo 根目录安装:

npm install -D mono-exec
# 或
pnpm add -D mono-exec
# 或
yarn add -D mono-exec

使用本地安装的 mono-exec:

方式一:通过 npx/pnpm dlx(推荐)

# npm
npx mono-exec

# pnpm
pnpm dlx mono-exec
pnpm exec mono-exec

# yarn
yarn mono-exec

方式二:在 package.json 中添加脚本

在根目录的 package.json 中添加:

{
  "scripts": {
    "dev": "mexec",
    "list": "mexec ls"
  }
}

然后使用:

npm run dev
# 或
pnpm dev
# 或
yarn dev

方式三:直接执行

./node_modules/.bin/mexec

使用

交互模式(默认)

交互式选择工作区和脚本:

mexec

智能上下文检测:

  • 在 Monorepo 根目录 → 选择工作区,然后选择脚本
  • 在子项目目录 → 直接选择脚本(跳过工作区选择!)
  • 在普通项目 → 直接选择脚本
# 示例 1: 在 Monorepo 根目录
$ cd ~/my-monorepo
$ mexec
? 选择一个工作区: my-app
? 选择要运行的脚本: dev

# 示例 2: 在子项目中(新功能!)
$ cd ~/my-monorepo/apps/my-app
$ mexec
运行在: my-app
? 选择要运行的脚本: dev  # 跳过工作区选择!

列出工作区

查看所有可用的工作区:

mexec list
# 或
mexec ls

运行当前目录脚本

运行当前目录 package.json 中的脚本:

mexec .

当你在 Monorepo 中想要运行根目录 package.json 定义的脚本而不是工作区脚本时,这个命令很有帮助。

# 示例: 在 Monorepo 根目录
$ mexec .
运行在: root (/path/to/monorepo)
? 选择要运行的脚本: build

功能特性

🎯 交互式选择

不再需要输入冗长的包名或 --filter 标志。直接从列表中选择!

🧠 智能上下文检测

自动检测你当前的位置:

  • 在 Monorepo 根目录? → 完整的交互式体验(选择工作区 → 选择脚本)
  • 在子项目中? → 跳过工作区选择,直接进入脚本选择
  • 在普通项目中? → 作为脚本运行器工作

无需配置 - 开箱即用!

🏷️ 分类分组

工作区会自动按类型(apps/packages)分组,以便更好地组织。

🎨 精美的用户界面

  • 彩色输出
  • 加载动画
  • 执行前清晰的命令预览

⚡ 零配置

开箱即用,支持:

  • pnpm workspaces (pnpm-workspace.yaml)
  • npm/yarn workspaces (package.json)

要求

  • Node.js >= 18.0.0
  • 一个 Monorepo,包含以下之一:
    • pnpm-workspace.yaml (pnpm workspaces)
    • package.json 中的 workspaces 字段 (npm/yarn workspaces)

工作原理

  1. 检测 你的 Monorepo 类型(pnpm/npm/yarn)
  2. 扫描 工作区配置以查找所有包
  3. 读取 每个工作区的 package.json 以列出可用的脚本
  4. 展示 一个交互式菜单供选择
  5. 执行 使用适当的命令运行所选脚本:
    • pnpm: pnpm --filter [workspace] run [script]
    • npm/yarn: npm run [script] -w [workspace]

对比

使用 mono-exec 之前

# 需要记住包名并手动输入 filter
pnpm --filter @mycompany/my-very-long-package-name run dev

# 或者在根 package.json 中创建许多 npm 脚本
pnpm dev:app1
pnpm dev:app2
pnpm dev:lib1
# ... 随着包的增多变得难以维护

使用 mono-exec 之后

# 交互式选择
$ mexec
? 选择工作区: my-app
? 选择脚本: dev

贡献

欢迎贡献!请随时提交 Pull Request。

许可证

MIT © [Josp3r]

相关项目


用 ❤️ 打造更好的 Monorepo 开发体验