libnpmteam
libnpmteam
is a Node.js
library that provides programmatic access to the guts of the npm CLI's npm team
command and its various subcommands.
Example
const access = require('libnpmteam')
console.log(await team.lsTeams('npm'))
Publishing
- Manually create CHANGELOG.md file
- Commit changes to CHANGELOG.md
$ git commit -m "chore: updated CHANGELOG.md"
- Run
npm version {newVersion}
$ npm version patch
Table of Contents
Install
$ npm install libnpmteam
API
opts
for libnpmteam
commands
libnpmteam
uses npm-registry-fetch
.
All options are passed through directly to that library, so please refer to its
own opts
documentation
for options that can be passed in.
A couple of options of note for those in a hurry:
opts.token
- can be passed in and will be used as the authentication token for the registry. For other ways to pass in auth details, see the n-r-f docs.opts.otp
- certain operations will require an OTP token to be passed in. If a libnpmteam
command fails with err.code === EOTP
, please retry the request with {otp: <2fa token>}
> team.create(team, [opts]) -> Promise
Creates a team named team
. Team names use the format @<scope>:<name>
, with
the @
being optional.
Additionally, opts.description
may be passed in to include a description.
Example
await team.create('@npm:cli', {token: 'myregistrytoken'})
> team.destroy(team, [opts]) -> Promise
Destroys a team named team
. Team names use the format @<scope>:<name>
, with
the @
being optional.
Example
await team.destroy('@npm:cli', {token: 'myregistrytoken'})
> team.add(user, team, [opts]) -> Promise
Adds user
to team
.
Example
await team.add('zkat', '@npm:cli', {token: 'myregistrytoken'})
> team.rm(user, team, [opts]) -> Promise
Removes user
from team
.
Example
await team.rm('zkat', '@npm:cli', {token: 'myregistrytoken'})
> team.lsTeams(scope, [opts]) -> Promise
Resolves to an array of team names belonging to scope
.
Example
await team.lsTeams('@npm', {token: 'myregistrytoken'})
=>
[
'npm:cli',
'npm:web',
'npm:registry',
'npm:developers'
]
> team.lsTeams.stream(scope, [opts]) -> Stream
Returns a stream of teams belonging to scope
.
For a Promise-based version of these results, see team.lsTeams()
.
Example
for await (let team of team.lsTeams.stream('@npm', {token: 'myregistrytoken'})) {
console.log(team)
}
> team.lsUsers(team, [opts]) -> Promise
Resolves to an array of usernames belonging to team
.
For a streamed version of these results, see team.lsUsers.stream()
.
Example
await team.lsUsers('@npm:cli', {token: 'myregistrytoken'})
=>
[
'iarna',
'zkat'
]
Returns a stream of usernames belonging to team
.
For a Promise-based version of these results, see team.lsUsers()
.
Example
for await (let user of team.lsUsers.stream('@npm:cli', {token: 'myregistrytoken'})) {
console.log(user)
}