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 🙏

© 2024 – Pkg Stats / Ryan Hefner

zz-commander-tools

v1.1.2

Published

npm打包工具

Downloads

9

Readme

@zz-common/commander-tools

commander-tools 是转转 FE 团队的基础库开发工具,集成了基础库开发过程中常用的本地调试、编译、打包、生成文档、发版等功能。

配合 sdk 模板使用可以大幅提高开发效率,只需专注业务逻辑,无需关心项目工程化的实现。

使用

安装

$ npm i -D @zz-common/commander-tools

配置

package.jsonscripts 配置中添加如下指令,即可使用

{
  "scripts": {
    "lint": "commander-tools run lint",
    "fix": "commander-tools run lint --fix",
    "staged": "commander-tools run lint --staged",
    "staged-fix": "commander-tools run lint --staged --fix",
    "dev": "commander-tools run dev",
    "compile": "commander-tools run compile",
    "dist": "commander-tools run dist",
    "analyz": "commander-tools run dist --analyz",
    "build": "commander-tools run build",
    "pub": "commander-tools run pub",
    "pub-beta": "commander-tools run pub-beta",
    "unpub": "commander-tools run unpub",
    "doc": "commander-tools run doc",
    "build-doc": "commander-tools run build-doc",
    "doc-upload": "commander-tools run doc-upload"
  }
}

API

eslint 校验

# eslint 校验
$ commander-tools run lint
# eslint 校验并修复
$ commander-tools run lint --fix
# eslint 校验暂存区的文件
$ commander-tools run lint --staged
# eslint 校验并修复暂存区的文件
$ commander-tools run lint --staged --fix

本地调试

# 本地调试模式
$ commander-tools run dev

代码构建

# 编译成 esModule 和 commonjs 模块,到 es, lib 文件夹
$ commander-tools run compile

# 编译代码,外链形式(默认 src 顶层目录下的文件都会作为入口文件)
$ commander-tools run dist
# 编译代码,单入口形式
$ commander-tools run dist --single
# 编译代码,分析 bundle 大小
$ commander-tools run dist --analyz

# 打包编译,集成 compile, dist 和 build-doc
$ commander-tools run build

生成文档

# 打开开发文档在浏览器中运行
$ commander-tools run doc

# 生成文档
$ commander-tools run build-doc

# 上传文档
$ commander-tools run doc-upload

npm 发版

# 发布 npm 正式包,同时更新 tag
$ commander-tools run pub

# 发布 npm beta 包
$ commander-tools run pub-beta

# 删除 npm 包对应版本和 tag
$ commander-tools run unpub

附加能力

commitizen

commander-tools 也集成了友好的问答式 git commit 指令,帮助提高基础库开发的 commit 规范,只需在 package.json 中添加如下配置:

{
  "scripts": {
    "cz": "git cz -a"
  },
  "config": {
    "commitizen": {
      "path": "@zz-common/commander-tools/lib/config/commitizen.config"
    }
  },
}

即可通过 npm run cz 指令代替 git add . && git commit -m 'xxx',效果如下:

cz

commitlint

配合 husky 使用,则能更好的在每次提交代码前校验本次修改的代码和 commit 信息,确保代码稳定和 commit 规范。

commander-tools 也内置了相关功能。

  1. 安装 husky
$ npm i -D husky
  1. package.json 中添加如下配置:
{
  "husky": {
    "hooks": {
      "pre-commit": "commander-tools run lint --staged",
      "commit-msg": "commander-tools run commitlint"
    }
  }
}