@colbyfayock/semantic-release-pnpm

中文文档
1.2.2发布于 2023/12/15MITCommonJS近 30 天下载 7817

pnpm semantic-release plugin to publish a npm package

原始使用文档
文档目录8 节
  1. Install
  2. Usage
  3. Configuration
  4. Npm registry authentication
  5. Environment variables
  6. Options
  7. Npm configuration
  8. Examples

semantic-release-pnpm

semantic-release plugin to publish a npm package with pnpm.

StepDescription
verifyConditionsVerify the presence of the NPM_TOKEN environment variable, or an .npmrc file, and verify the authentication method is valid.
prepareUpdate the package.json version and create the npm package tarball.
addChannelAdd a release to a dist-tag.
publishPublish the npm package to the registry.

Install

$ npm install @colbyfayock/semantic-release-pnpm -D

Usage

The plugin can be configured in the semantic-release configuration file:

{
  "plugins": [
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator",
    "@colbyfayock/semantic-release-pnpm",
  ]
}

Configuration

Npm registry authentication

The npm authentication configuration is required and can be set via environment variables.

Both the token and the legacy (username, password and email) authentication are supported. It is recommended to use the token authentication. The legacy authentication is supported as the alternative npm registries Artifactory and npm-registry-couchapp only supports that form of authentication.

Notes:

  • Only the auth-only level of npm two-factor authentication is supported, semantic-release will not work with the default auth-and-writes level.
  • The presence of an .npmrc file will override any specified environment variables.

Environment variables

VariableDescription
NPM_TOKENNpm token created via npm token create
NPM_USERNAMENpm username created via npm adduser or on npmjs.com
NPM_PASSWORDPassword of the npm user.
NPM_EMAILEmail address associated with the npm user
NPM_CONFIG_USERCONFIGPath to non-default .npmrc file

Use either NPM_TOKEN for token authentication or NPM_USERNAME, NPM_PASSWORD and NPM_EMAIL for legacy authentication

Options

OptionsDescriptionDefault
npmPublishWhether to publish the npm package to the registry. If false the package.json version will still be updated.false if the package.json private property is true, true otherwise.
pkgRootDirectory path to publish..
tarballDirDirectory path in which to write the package tarball. If false the tarball is not be kept on the file system.false
publishBranchThe primary branch of the repository which is used for publishing the latest changes.master and main

Note: The pkgRoot directory must contain a package.json. The version will be updated only in the package.json and npm-shrinkwrap.json within the pkgRoot directory.

Note: If you use a shareable configuration that defines one of these options you can set it to false in your semantic-release configuration in order to use the default value.

Npm configuration

The plugin uses the pnpm CLI which will read the configuration from .npmrc. See npm config for the option list.

The registry can be configured via the npm environment variable NPM_CONFIG_REGISTRY and will take precedence over the configuration in .npmrc.

The registry and dist-tag can be configured in the package.json and will take precedence over the configuration in .npmrc and NPM_CONFIG_REGISTRY:

{
  "publishConfig": {
    "registry": "https://registry.npmjs.org/",
    "tag": "latest"
  }
}

Examples

The npmPublish and tarballDir option can be used to skip the publishing to the npm registry and instead, release the package tarball with another plugin. For example with the @semantic-release/github plugin:

{
  "plugins": [
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator",
    ["@colbyfayock/semantic-release-pnpm", {
      "npmPublish": false,
      "tarballDir": "dist",
    }],
    ["@semantic-release/github", {
      "assets": "dist/*.tgz"
    }]
  ]
}

When publishing from a sub-directory with the pkgRoot option, the package.json and npm-shrinkwrap.json updated with the new version can be moved to another directory with a postversion. For example with the @semantic-release/git plugin:

{
  "plugins": [
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator",
    ["@colbyfayock/semantic-release-pnpm", {
      "pkgRoot": "dist",
    }],
    ["@semantic-release/git", {
      "assets": ["package.json", "npm-shrinkwrap.json"]
    }]
  ]
}
{
  "scripts": {
    "postversion": "cp -r package.json .. && cp -r npm-shrinkwrap.json .."
  }
}

版本与发布记录

@colbyfayock/semantic-release-pnpm 共发布 11 个版本,首次发布于 2023/02/02;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.2.2latest2023/12/152 年前
1.2.12023/12/152 年前
1.2.02023/12/152 年前
1.1.12023/12/152 年前
1.1.02023/12/152 年前
1.0.82023/12/152 年前

关于 @colbyfayock/semantic-release-pnpm 的常见问题

@colbyfayock/semantic-release-pnpm 是什么?

pnpm semantic-release plugin to publish a npm package

如何安装 @colbyfayock/semantic-release-pnpm?

在项目目录运行 npm install @colbyfayock/semantic-release-pnpm,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:semantic-release(>=19.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@colbyfayock/semantic-release-pnpm 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/colbyfayock__semantic-release-pnpm 是否存在。

@colbyfayock/semantic-release-pnpm 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@colbyfayock/semantic-release-pnpm 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=16 || ^14.17。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@colbyfayock/semantic-release-pnpm 可以商用吗?

@colbyfayock/semantic-release-pnpm 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@colbyfayock/semantic-release-pnpm 的下载量有多少?

根据 npm 官方下载统计,@colbyfayock/semantic-release-pnpm 在 2026/10/11 – 2026/11/09 这 30 天内被下载 7,817 次,日均约 261 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@colbyfayock/semantic-release-pnpm 还在维护吗?

最新版本 1.2.2 发布于 2023/12/15(2 年前);至今共发布 11 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/02/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。