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

publish-version

v0.1.3

Published

A CLI to automate versioning and package publishing tasks

Downloads

15

Readme

publish-version

  • 用于自动执行版本控制和包发布任务的 CLI。

  • 严格遵循 Semantic Versioning 语义化版本规范。

安装

项目内安装

npm install publish-version -D
{
  ...
  "scripts": {
    "release": "publish-version"
  },
  "devDependencies": {
    "publish-version": "*"
  }
  ...
}

全局安装

npm install publish-version -g
npx publish-version // 使用
npx publish-version --help // 显示帮助

使用

release(发版)

根据提示选择

publish-version
publish-version --preRelease  // beta版本选择
publish-version --preRelease=rc // rc版本选择

指定版本(如果此时版本为 0.0.1)

publish-version patch // 0.0.2
publish-version minor // 0.1.0
publish-version major // 1.0.0
publish-version 1.1.0 // 1.1.0

指定版本(如果此时版本为 0.0.1)

publish-version major --preRelease=beta // 1.0.0-beta.0
publish-version premajor --preReleaseId=beta --npm.tag=beta // 1.0.0-beta.0

发布私有的包

  1. 如果你在 package.json 中设置了 "private": true,那么 npm 将拒绝发布它
  2. @npm/package-name 这种形式的包名,是有作用域的包名形式,执行 npm publish 的时候默认是发布私有的包。

这是一种防止意外发布私有存储库的方法。如果您想发布私有的包(优先级:scripts>自定义配置>package.json)

scripts

{
  ...
  "scripts": {
    "release": "publish-version --npm.access=public"
  }
  ...
}

自定义配置

{
"npm": {
    "access": "public"
  }
}

package.json

 "publishConfig": {
    "access": "public"
  }

no publish(不发布)

publish-version --no-npm.skipCheck // no check(eg:用户是否是包合作者,用户是否登录,registry是否可用等)
publish-version --no-npm.publish  // no publish
publish-version --no-npm // no check,publish

no git project(非 git 项目) 或 no check,commit,push(git 不检查,提交,推送)

publish-version --no-git.skipCheck // no check(eg:是否是git仓库,是否是指定分支,是否工作区干净等)
publish-version --no-git.commit  // no commit
publish-version --no-git.push // no push
publish-version --no-git // no check,commit,push

no update version(不更新版本)

publish-version --no-increment

changelog

自定义配置

{
"git": {
    "changelog": "npx auto-changelog --commit-limit false" //or npx conventional-changelog-cli -p angular -i CHANGELOG.md -s -r 0
  },
  "hooks": {
      "afterVersion": "npx auto-changelog -p" //or npx conventional-changelog-cli -p angular -i CHANGELOG.md -s
    }
}

only changelog(仅更新 changelog)

publish-version --only-changelog

自定义配置

{
"git": {
    "changelog": "npx auto-changelog --commit-limit false" //or npx conventional-changelog-cli -p angular -i CHANGELOG.md -s -r 0
  }
}

默认值配置

项目有默认配置

我们可以通过设置,覆盖默认配置

  • 项目根目录下(优先级:package.json>.publish-version.json>.publish-version.js)
  • 也可指定配置文件--config path/publish-version.json
{
"git": {
    "skipCheck": true
  },
  "npm": {
    "publishPath": "dist"
  }
}

变量(运行中提供的变量)

version;
latestVersion;
name;
repo.remote, repo.protocol, repo.host, repo.owner, repo.repository, repo.project;

hooks(运行过程中提供的钩子)

| 名称 | 含义 | | :------------ | --------------: | | beforeStart | npm,git 检查前 | | afterStart | npm,git 检查后 | | beforeVersion | 更新 version 前 | | afterVersion | 更新 version 后 | | beforePublish | publish 前 | | afterPublish | publish 后 |

{
  "hooks": {
    "beforeStart": "npm run codecheck",
    "afterStart": "echo afterStart",
    "beforeVersion": "echo ${name} current version ${latestVersion}",
    "afterVersion": "npx auto-changelog -p",
 "beforePublish": "echo before publish ${name} v${version}.",
    "afterPublish": "echo after publish ${name} v${version} to ${repo.repository}."
  }
}