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

jcommon-cli

v1.1.1

Published

JavaScript CLI tools for development automation

Readme

jcommon-cli

npm version npm downloads license

🛠️ JavaScript CLI 工具库 - 提供文件操作、包管理和开发自动化工具

📖 简介

jcommon-cli 是一个现代化的 JavaScript CLI 工具库,专注于提供开发自动化功能。采用模块化架构,提供清晰的 API 和强大的功能。

✨ 特性

  • 🔧 TypeScript 支持 - 完整的类型定义和智能提示
  • 📦 多格式输出 - 支持 CommonJS、ES6 模块和 UMD
  • 🎯 CLI 工具 - 内置命令行工具,提升开发效率
  • 🚀 高性能 - 优化的构建和执行性能

🚀 安装

npm install jcommon-cli

或全局安装 CLI 工具:

npm install -g jcommon-cli

📚 使用指南

作为库使用

// 导入文件操作功能
const { copyDir } = require('jcommon-cli');

// 复制目录
const result = copyDir('./src', './dist', { 
  emptyDst: true,
  filter: (src) => !src.includes('node_modules')
});

console.log(`复制了 ${result.fileCount} 个文件,${result.dirCount} 个目录`);

CLI 工具使用

# 批量拉取所有 git 仓库
jcommon-cli --git-pull-all

# 添加时间戳到 package.json
jcommon-cli --time

# 自动增加版本号
jcommon-cli --versionAdd

# 清理 package.json
jcommon-cli --cleanse-scripts "test,dev" --cleanse-dev-deps "webpack,rollup"

# 恢复 package.json
jcommon-cli --restore-pkg

# 查看帮助
jcommon-cli --help

📚 API 文档

文件操作

copyDir(src, dst, options)

复制目录及其内容,支持多种选项和错误处理。

参数:

  • src (string): 源目录路径
  • dst (string): 目标目录路径
  • options (CopyDirOptions, 可选): 复制选项

选项:

  • emptyDst (boolean): 是否清空目标目录,默认 false
  • preserveStructure (boolean): 是否保留源目录结构,默认 true
  • filter (function): 文件过滤器,返回 true 表示包含该文件
  • errorMode (string): 错误处理模式,可选值:'throw''skip''log'

返回值:

interface FileOperationResult {
  success: boolean;
  error?: string;
  fileCount: number;
  dirCount: number;
}

示例:

// 基本用法
const result = copyDir('./src', './dist', { emptyDst: true });

// 带过滤器的用法
const result = copyDir('./src', './dist', {
  filter: (src, dst) => !src.includes('node_modules'),
  errorMode: 'skip'
});

// 异步版本
const result = await copyDirAsync('./src', './dist');

CLI 工具详细说明

时间戳管理

# 添加默认格式时间戳
jcommon-cli --time

# 添加自定义格式时间戳
jcommon-cli --time "YYYY-MM-DD HH:mm:ss"

版本管理

# 自动增加版本号
jcommon-cli --versionAdd

# 指定版本类型
jcommon-cli --versionAdd patch

# 设置版本最大值
jcommon-cli --versionAdd --versionMax 50

包管理

# 清理脚本
jcommon-cli --cleanse-scripts "test,dev,build"

# 清理开发依赖
jcommon-cli --cleanse-dev-deps "webpack,rollup,typescript"

# 恢复 package.json
jcommon-cli --restore-pkg

Git 操作

# 批量拉取所有 git 仓库
jcommon-cli --git-pull-all

⚙️ 环境要求

  • Node.js >= 14.0.0
  • npm >= 6.0.0

📄 许可证

本项目基于 MIT 许可证开源。

📞 联系我们


⭐ 如果这个项目对你有帮助,请给我们一个 Star!