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 🙏

© 2026 – Pkg Stats / Ryan Hefner

publish-manager

v0.0.1

Published

Process the fields in the package.json at npm publish.

Readme

publish-manager

publish-manager目前仅用于在发包之前修改package.json文件,比如删除、添加甚至合并一些字段。

Install

npm install publish-manager -D

或者全局安装

npm install publish-manager -g

Usage

publish-manager主要有两个命令,cleanserestore

cleanse

publish-manager cleanse

用于整理package.json的内容。按配置删除、添加和合并一些字段。

restore

publish-manager restore

用于还原package.json的内容。

更方便的使用方式

通过添加npm script的方式会更方便,不过可能有个小细节需要注意下:

当不需要删除package.json中的scripts字段时,可以配置为:

{
  "scripts": {
    "prepublish": "publish-manager cleanse",
    "postpublish": "publish-manager restore"
  }
}

当需要删除package.json中的scripts字段时,如果还配置为prepublishpostpublish的话, 由于在prepublish阶段删除掉了scripts字段,即删除了所有的 scripts,会导致postpublish阶段定义的命令无法再被执行, 从而会使package.json不能自动还原(不能自动还原时可以手动执行npx publish-manager restore来还原)。 所以更建议配置为:

{
  "scripts": {
    "custom:publish": "publish-manager cleanse && npm publish && publish-manager restore"
  }
}

Config

publish-manager在项目根目录下查找配置文件的顺序为.publish-manager.js.publish-manager.json.publish-manager。 如果均未找到, 最后会从package.json文件中查找publish-manager字段作为配置。

Javascript格式的配置方式

.publish-manager.js中的配置参考如下:

module.exports = {
  indent: 2,
  // removeFields 既支持数组也支持对象格式,但是细节上有一些区别
  // removeFields: [ "scripts", "lint-staged", "config", "devDependencies" ],
  removeFields: {
    scripts: true,
    "lint-staged": true,
    config: true,
    devDependencies: true,
    dependencies: ["vue"]
  },
  addFields: {
    author: "author's info",
    peerDependencies: {
      vue: "^3.2.0"
    }
  }
}

Json格式的配置方式

.publish-manager.json或者.publish-manager文件中使用json格式的配置:

{
  "indent": 2,
  "removeFields": {
    "scripts": true,
    "lint-staged": true,
    "config": true,
    "devDependencies": true,
    "dependencies": [
      "vue"
    ]
  },
  "addFields": {
    "author": "author's info",
    "peerDependencies": {
      "vue": "^3.2.0"
    }
  }
}

Options

  • indent

    Type: String | Number
    Default: 2
    定义用于格式化整理后的package.json的缩进。 有关更多信息 , 请参见JSON.stringifyspace参数。

  • addFields

    Type: Object
    Default: {} 指定需要新增或合并的字段。

  • removeFields

    Type: Array | Object
    Default: {} 指定需要删除的字段。虽然ArrayObject格式都可以配置删除的字段,但是两者之间有些细微的区别。

    对于如下的package.json时:

    {
      "scripts": {
        "serve": "...serve",
        "build": "...build",
        "test": "...test",
        "prepare": "...prepare"
      }
    }

    当要删除的字段为package.json的一级字段时,该项配置在Array或者Object中没有区别; 例如要删除"scripts"字段,可以配置成removeFields: ["scripts"]removeFields: {"scripts": true}。 当要删除的字段为二级及以上字段时,此时配置在Array中的字段会被删除; 如removeFields: {"scripts": ["serve", "build"]}会删除"serve""build"保留"test""prepare"; 配置在Object中的字段,当为false时会被保留,其余的全会被删除,包括未指定的字段; 如:

      {
        "removeFields": {
          "scripts": {
            "prepare": false,
            "test": true
          }
        }
      }

    上面的配置仅会保留"prepare"字段。
    采用这种表现是为了方便的只保留某些字段或者只删除某些字段。