![]() |
2 years ago | |
---|---|---|
.. | ||
test | 2 years ago | |
.travis.yml | 2 years ago | |
CHANGELOG.md | 2 years ago | |
LICENSE | 2 years ago | |
PULL_REQUEST_TEMPLATE | 2 years ago | |
README.md | 2 years ago | |
appveyor.yml | 2 years ago | |
index.js | 2 years ago | |
package.json | 2 years ago |
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.
const access = require('libnpmteam')
// List all teams for the @npm org.
console.log(await team.lsTeams('npm'))
$ npm install libnpmteam
The npm team enthusiastically welcomes contributions and project participation! There's a bunch of things you can do if you want to contribute! The Contributor Guide has all the information you need for everything from reporting bugs to contributing entire new features. Please don't hesitate to jump in if you'd like to, or even ask us questions if something isn't clear.
All participants and maintainers in this project are expected to follow Code of Conduct, and just generally be excellent to each other.
Please refer to the Changelog for project history details, too.
Happy hacking!
opts
for libnpmteam
commandslibnpmteam
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>}
opts.Promise
- If you pass this in, the Promises returned by libnpmteam
commands will use this Promise class instead. For example: {Promise: require('bluebird')}
> 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.
await team.create('@npm:cli', {token: 'myregistrytoken'})
// The @npm:cli team now exists.
> team.destroy(team, [opts]) -> Promise
Destroys a team named team
. Team names use the format @<scope>:<name>
, with
the @
being optional.
await team.destroy('@npm:cli', {token: 'myregistrytoken'})
// The @npm:cli team has been destroyed.
> team.add(user, team, [opts]) -> Promise
Adds user
to team
.
await team.add('zkat', '@npm:cli', {token: 'myregistrytoken'})
// @zkat now belongs to the @npm:cli team.
> team.rm(user, team, [opts]) -> Promise
Removes user
from team
.
await team.rm('zkat', '@npm:cli', {token: 'myregistrytoken'})
// @zkat is no longer part of the @npm:cli team.
> team.lsTeams(scope, [opts]) -> Promise
Resolves to an array of team names belonging to scope
.
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()
.
for await (let team of team.lsTeams.stream('@npm', {token: 'myregistrytoken'})) {
console.log(team)
}
// outputs
// npm:cli
// npm:web
// npm:registry
// npm:developers
> 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()
.
await team.lsUsers('@npm:cli', {token: 'myregistrytoken'})
=>
[
'iarna',
'zkat'
]
> team.lsUsers.stream(team, [opts]) -> Stream
Returns a stream of usernames belonging to team
.
For a Promise-based version of these results, see team.lsUsers()
.
for await (let user of team.lsUsers.stream('@npm:cli', {token: 'myregistrytoken'})) {
console.log(user)
}
// outputs
// iarna
// zkat