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

@build-script/node-package-tools

v1.0.36

Published

[English](./README.en.md)

Downloads

2

Readme

English

Node.js 包发布辅助工具集

使用方式

二选一:

  • node-package-tools [--common opts] <command> [--params]
  • njspkg [--common opts] <command> [--params]

通用参数

通用参数也可以在command后面

  • --quiet: 默认显示较多输出,设置后只显示结果
  • --registry <xxx>: 默认使用.npmrc中的设置
  • --dist-tag <xxx>: 要比较的tag,默认为"latest"
  • --package <xxx>: 包的本地路径,默认为当前目录

可用工具

  • --bump: 不要输出,而是:如果发现有修改,则自动更新package.json(当前仅支持将version的PATCH位+1)
  • --json: 输出json(当检测到stdout不是终端时,默认为json输出)

此工具要求PATH中存在git

输出结果示例:

  • --json模式: { changedFiles: [......], changed: true }
  • 默认模式: changed no. / changed yes.

只要运行过程没有错误,程序就返回0,无论是否发现修改。

  1. 调用npm-registry-fetch包,从npm下载最新的package.json,它支持标准http缓存和代理设置
  2. 和本地的package.json比较version字段
    • 如果本地版本号大于远程,则直接判定为有修改
  3. 从npm下载dist.tarball指定的压缩包,解压到一个临时目录中
  4. 在包目录中运行npm pack(也支持pnpm、yarn)得到压缩包
  5. 检查两个压缩包是否相同
    1. 在临时目录中初始化git仓库
    2. 立即提交前面解压结果
    3. 将打包结果覆盖到同一个目录中
    4. 再次提交
    5. 检查git log输出的内容(强制LANG=C)
      • 如果没有任何修改,则判定为无修改
  6. 如果有--bump,调用semver修改package.json中的version字段
  7. 否则输出有修改

没有专用参数,但命令行中的“--”不可省略

示例:

Eg: njspkg run-if-version-mismatch -- pnpm publish --no-git-checks