Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rumkin/allow-publish-tag
Publish package with allowed dist-tags only
https://github.com/rumkin/allow-publish-tag
cli development dist-tags hook npm tools util
Last synced: 10 days ago
JSON representation
Publish package with allowed dist-tags only
- Host: GitHub
- URL: https://github.com/rumkin/allow-publish-tag
- Owner: rumkin
- Created: 2018-12-16T23:54:06.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-11-18T15:01:46.000Z (about 4 years ago)
- Last Synced: 2025-01-28T17:40:52.405Z (11 days ago)
- Topics: cli, development, dist-tags, hook, npm, tools, util
- Language: JavaScript
- Homepage:
- Size: 17.6 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# 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`:
```js
{
"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:```js
{
"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
```text
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`
```text
AllowPublishTagFlag | AllowPublishTagList | AllowPublishTagDict
```Configuration value `AllowPublishTagRecord` describes the value of `allowPublishTag` field of `package.json`.
### `AllowPublishTagFlag`
```text
true
```Boolean value `true` turns default APT configuration on.
Example:
```js
{
"allowPublishTag": true
}
```### `AllowPublishTagList`
```text
Array|string
```Array should contain allowed prerelease names for the `next` dist-tag, which are strings or [picomatch](https://npmjs.com/package/picomatch)-compatible glob patterns.
Example:
```js
{
"allowPublishTag": ["alpha", "beta", "pre.*"]
}
```### `AllowPublishTagDict`
```text
{
[string]: Array|string,
'*': Array|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](https://npmjs.com/package/picomatch)-compatible glob pattern. If there is the asterisk key, then
this rules will match all dist-tags.Example:
```js
{
"allowPublishTag": {
"next": "{alpha,beta,rc}?(.+([0-9]))"
}
}
```## License
MIT.