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

@ouyangtianfeng/cmd-utils

v1.0.1

Published

一个轻量级的命令别名管理脚手架工具,让你能够快速设置和执行自定义命令

Readme

@ou/cmd-utils

一个轻量级的命令别名管理脚手架工具,让你能够快速设置和执行自定义命令。

功能特性

  • ✨ 简单易用的命令别名管理
  • 📋 列出所有已设置的命令别名
  • 🎯 执行自定义命令别名
  • 🔄 重置命令别名到初始状态
  • 🎨 交互式修改命令别名
  • ✅ 命令存在性校验

安装

npm install @ouyangtianfeng/cmd-utils -g

快速开始

列出所有命令别名

ocu ls

设置命令别名

# 方式1:直接设置别名
ocu set pi pnpm install

# 方式2:进入交互式修改模式
ocu set

执行自定义命令

# 执行已设置的别名
ocu pi

重置命令别名

# 重置所有命令别名
ocu reset

# 重置单个命令别名
ocu reset once

详细使用说明

ocu ls

列出所有已设置的命令别名。

ocu ls

输出示例:

=== 可用命令别名列表 ===
[1] pi     -> pnpm install
[2] pa     -> pnpm add 
[3] pb     -> pnpm build
[4] nst    -> npm config set registry https://registry.npmmirror.com
[5] ns     -> npm config set registry https://registry.npmjs.org
[6] ncr    -> npm config get registry
=========================

ocu set

用于设置和管理命令别名。

# 语法
ocu set [alias] [...command]

# 示例
ocu set pa pnpm add
ocu set pb pnpm build

参数说明:

  • alias: 命令别名(可选)
  • command: 实际执行的命令(可选)

交互式模式: 当不传递任何参数时,会进入交互式修改模式:

📋 当前JSON文件中的内容:
[1] pi     -> pnpm install
[2] pa     -> pnpm add 
[3] pb     -> pnpm build
[4] nst    -> npm config set registry https://registry.npmmirror.com
[5] ns     -> npm config set registry https://registry.npmjs.org
[6] ncr    -> npm config get registry

? 请选择操作:
❯ 修改已有命令
  新增命令
  删除命令
  退出

ocu reset

用于重置命令别名。

# 重置所有命令别名到初始状态
ocu reset

# 重置单个命令别名
ocu reset once

执行自定义命令

直接使用 ocu 后跟命令别名即可执行对应命令。

ocu <alias>

示例:

# 执行 pnpm install
ocu pi

# 执行 pnpm add react
ocu pa react

命令存在性校验

工具会自动校验命令是否存在:

ocu set nn non_existent_command
ocu nn
# 输出:命令 non_existent_command 不存在,是否输入错误或者未安装

项目结构

@ou/cmd-utils/
├── src/
│   ├── cli/             # 命令配置文件
│   │   ├── command.json     # 当前命令别名配置
│   │   └── historyCommand.json # 初始命令别名配置
│   ├── utils/           # 工具函数
│   │   ├── isCommand.ts     # 命令存在性校验
│   │   ├── readFile.ts      # 文件读取
│   │   ├── restCommand.ts   # 重置命令
│   │   └── setCommamd.ts    # 设置命令
│   └── index.ts         # 主入口文件
├── dist/                # 构建输出目录
├── package.json         # 项目配置
├── tsconfig.json        # TypeScript配置
└── tsdown.config.ts     # 构建配置

开发

# 克隆项目
git clone <repository-url>
cd cmd-utils

# 安装依赖
pnpm install

# 构建项目
pnpm build

# 开发模式
pnpm dev

发布

npm publish --access public

贡献

欢迎提交 Issue 和 Pull Request!

许可证

ISC