Skip to content

rumkin/allow-publish-tag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Allow Publish Tag

Allow publish tag prevents your NPM package from being accidentally published with latest dist-tag for prereleases, e.g. alpha, beta, etc. Instead it enforces you to use proper dist-tag (next by default). It works with prepublishOnly hook from package.json.

Installation

npm i allow-publish-tag

Usage

  1. Add prepublishOnly script in package.json.
  2. Run npm publish when you're ready to publish your package, or npm publish --dry-run.

Example package.json:

{
  "version" : "1.0.0-alpha.1",
  "scripts": {
    "prepublishOnly": "allow-publish-tag"
  }
}

Configuration

You can configure allow publish tag to use ccustom release scheme. For example use nightly and beta prereleases, like Electron does:

{
  "version" : "1.0.0-nightly.1",
  "scripts": {
    "prepublishOnly": "allow-publish-tag"
  },
  "allowPublishTags": {
    // Match all nightly or beta releases e.g "nightly", "beta.3", etc.
    "next": "{nightly,beta}?(.+([0-9]))"
  }
}

API

CLI

allow-publish-tags [...TAGS]
  • [...TAGS] – is a list of allowed dist-tags to be used with the current package version from package.json.

Using CLI with TAGS specified will allow to publish current version with any of provided dist-tags. If this list is empty, then allowPublishTag field from package.json will be used as configuration. If there is no allowPublishTag field, then the default configuration will be used.

AllowPublishTagRecord

AllowPublishTagFlag | AllowPublishTagList | AllowPublishTagDict

Configuration value AllowPublishTagRecord describes the value of allowPublishTag field of package.json.

AllowPublishTagFlag

true

Boolean value true turns default APT configuration on.

Example:

{
  "allowPublishTag": true
}

AllowPublishTagList

Array<string>|string

Array should contain allowed prerelease names for the next dist-tag, which are strings or picomatch-compatible glob patterns.

Example:

{
  "allowPublishTag": ["alpha", "beta", "pre.*"]
}

AllowPublishTagDict

{
  [string]: Array<string>|string,
  '*': Array<string>|string,
}

Dictionary contains records where key is a dist-tag and value is a list of allowed prereleases. Prerelease name could be a string or a picomatch-compatible glob pattern. If there is the asterisk key, then this rules will match all dist-tags.

Example:

{
  "allowPublishTag": {
    "next": "{alpha,beta,rc}?(.+([0-9]))"
  }
}

License

MIT.

Releases

No releases published

Packages

No packages published