Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
README.md173 linesDownload Raw Back to libnpmteam
1# libnpmteam
2
3[![npm version](https://img.shields.io/npm/v/libnpmteam.svg)](https://npm.im/libnpmteam)
4[![license](https://img.shields.io/npm/l/libnpmteam.svg)](https://npm.im/libnpmteam)
5[![CI - libnpmteam](https://github.com/npm/cli/actions/workflows/ci-libnpmteam.yml/badge.svg)](https://github.com/npm/cli/actions/workflows/ci-libnpmteam.yml)
6
7[`libnpmteam`](https://github.com/npm/libnpmteam) is a Node.js
8library that provides programmatic access to the guts of the npm CLI's `npm
9team` command and its various subcommands.
10
11## Table of Contents
12
13* [Installing](#install)
14* [Example](#example)
15* [API](#api)
16  * [team opts](#opts)
17  * [`create()`](#create)
18  * [`destroy()`](#destroy)
19  * [`add()`](#add)
20  * [`rm()`](#rm)
21  * [`lsTeams()`](#ls-teams)
22  * [`lsTeams.stream()`](#ls-teams-stream)
23  * [`lsUsers()`](#ls-users)
24  * [`lsUsers.stream()`](#ls-users-stream)
25
26### Install
27
28`$ npm install libnpmteam`
29
30### Example
31
32```javascript
33const team = require('libnpmteam')
34
35// List all teams for the @npm org.
36console.log(await team.lsTeams('npm'))
37```
38
39### API
40
41#### <a name="opts"></a> `opts` for `libnpmteam` commands
42
43`libnpmteam` uses [`npm-registry-fetch`](https://npm.im/npm-registry-fetch).
44All options are passed through directly to that library, so please refer to [its
45own `opts`
46documentation](https://www.npmjs.com/package/npm-registry-fetch#fetch-options)
47for options that can be passed in.
48
49A couple of options of note for those in a hurry:
50
51* `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.
52* `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>}`
53
54#### <a name="create"></a> `> team.create(team, [opts]) -> Promise`
55
56Creates a team named `team`. Team names use the format `@<scope>:<name>`, with
57the `@` being optional.
58
59Additionally, `opts.description` may be passed in to include a description.
60
61##### Example
62
63```javascript
64await team.create('@npm:cli', {token: 'myregistrytoken'})
65// The @npm:cli team now exists.
66```
67
68#### <a name="destroy"></a> `> team.destroy(team, [opts]) -> Promise`
69
70Destroys a team named `team`. Team names use the format `@<scope>:<name>`, with
71the `@` being optional.
72
73##### Example
74
75```javascript
76await team.destroy('@npm:cli', {token: 'myregistrytoken'})
77// The @npm:cli team has been destroyed.
78```
79
80#### <a name="add"></a> `> team.add(user, team, [opts]) -> Promise`
81
82Adds `user` to `team`.
83
84##### Example
85
86```javascript
87await team.add('zkat', '@npm:cli', {token: 'myregistrytoken'})
88// @zkat now belongs to the @npm:cli team.
89```
90
91#### <a name="rm"></a> `> team.rm(user, team, [opts]) -> Promise`
92
93Removes `user` from `team`.
94
95##### Example
96
97```javascript
98await team.rm('zkat', '@npm:cli', {token: 'myregistrytoken'})
99// @zkat is no longer part of the @npm:cli team.
100```
101
102#### <a name="ls-teams"></a> `> team.lsTeams(scope, [opts]) -> Promise`
103
104Resolves to an array of team names belonging to `scope`.
105
106##### Example
107
108```javascript
109await team.lsTeams('@npm', {token: 'myregistrytoken'})
110=>
111[
112  'npm:cli',
113  'npm:web',
114  'npm:registry',
115  'npm:developers'
116]
117```
118
119#### <a name="ls-teams-stream"></a> `> team.lsTeams.stream(scope, [opts]) -> Stream`
120
121Returns a stream of teams belonging to `scope`.
122
123For a Promise-based version of these results, see [`team.lsTeams()`](#ls-teams).
124
125##### Example
126
127```javascript
128for await (let team of team.lsTeams.stream('@npm', {token: 'myregistrytoken'})) {
129  console.log(team)
130}
131
132// outputs
133// npm:cli
134// npm:web
135// npm:registry
136// npm:developers
137```
138
139#### <a name="ls-users"></a> `> team.lsUsers(team, [opts]) -> Promise`
140
141Resolves to an array of usernames belonging to `team`.
142
143For a streamed version of these results, see [`team.lsUsers.stream()`](#ls-users-stream).
144
145##### Example
146
147```javascript
148await team.lsUsers('@npm:cli', {token: 'myregistrytoken'})
149=>
150[
151  'iarna',
152  'zkat'
153]
154```
155
156#### <a name="ls-users-stream"></a> `> team.lsUsers.stream(team, [opts]) -> Stream`
157
158Returns a stream of usernames belonging to `team`.
159
160For a Promise-based version of these results, see [`team.lsUsers()`](#ls-users).
161
162##### Example
163
164```javascript
165for await (let user of team.lsUsers.stream('@npm:cli', {token: 'myregistrytoken'})) {
166  console.log(user)
167}
168
169// outputs
170// iarna
171// zkat
172```
173 
codekingpro/portable-devtools · Team Ai