https://github.com/flex-development/dist-tag
Distribution tag lookup utility
https://github.com/flex-development/dist-tag
dist-tag npm-dist-tag npm-publish typescript
Last synced: 4 months ago
JSON representation
Distribution tag lookup utility
- Host: GitHub
- URL: https://github.com/flex-development/dist-tag
- Owner: flex-development
- License: bsd-3-clause
- Created: 2021-08-25T21:58:35.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-01-27T06:07:46.000Z (over 2 years ago)
- Last Synced: 2024-10-17T02:44:27.328Z (9 months ago)
- Topics: dist-tag, npm-dist-tag, npm-publish, typescript
- Language: JavaScript
- Homepage:
- Size: 2.47 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# dist-tag
[](https://conventionalcommits.org)
[](https://github.com/prettier/prettier)
[](https://github.com/voxpelli/badges-cjs-esm)
[](https://npmjs.com/package/@flex-development/dist-tag)
[](LICENSE.md)
[](https://typescriptlang.org)> [Distribution tag][1] lookup utility for Node.js and CLI environments.
## Install
```sh
yarn add @flex-development/dist-tag
```### GitHub Package Registry
To install from the GitHub Package Registry, setup a `.npmrc` or `.yarnrc.yml`
file to authenticate with the registry. A [Personal Access Token with at least
the `read:packages` scope][2] is required.#### `.npmrc`
```utf-8
//npm.pkg.github.com/:_authToken=${GH_PAT}
@flex-development:registry=https://npm.pkg.github.com/
```#### `.yarnrc.yml`
```yaml
npmRegistries:
//npm.pkg.github.com:
npmAlwaysAuth: true
npmAuthToken: ${GH_PAT}npmScopes:
flex-development:
npmRegistryServer: https://npm.pkg.github.com
```### Git
For details on requesting a specific branch, commit, or tag, see
[npm-install][3] or [Git - Protocols | Yarn][4].#### NPM
```sh
npm i flex-development/dist-tag
```#### Yarn
```sh
yarn add @flex-development/dist-tag@flex-development/dist-tag
```## Usage
### CLI
```sh
Usage
$ dist-tag [target] [options]Options
-d, --delimiter Lookup target separator
-v, --version Displays current version
-h, --help Displays this messageExamples
$ dist-tag # ''
$ dist-tag 2.0.0 # ''
$ dist-tag 2.0.0-alpha.1 # 'alpha'
$ dist-tag [email protected] --delimiter @ # 'beta'
$ dist-tag $(git describe --tags --abbrev=0) -d @ # depends on the tag 😉
```If you installed `dist-tag` locally, you may need to update your `PATH`:
```sh
[ -d $PWD/node_modules/.bin ] && export PATH=$PWD/node_modules/.bin:$PATH
```### Node.js
```typescript
import dtag from '@flex-development/dist-tag'console.log(dtag()) // ''
console.log(dtag({ target: '2.0.0' })) // ''
console.log(dtag({ target: '2.0.0-alpha.1' })) // 'alpha'
console.log(dtag({ delimiter: '@', target: '[email protected]' })) // 'beta'
```Options can be viewed [here](src/options.ts).
[1]: https://docs.npmjs.com/cli/v8/commands/npm-dist-tag
[2]:
https://docs.github.com/en/packages/learn-github-packages/about-permissions-for-github-packages#about-scopes-and-permissions-for-package-registries
[3]: https://docs.npmjs.com/cli/v8/commands/npm-install#description
[4]: https://yarnpkg.com/features/protocols#git