11cb0ef41Sopenharmony_ci# libnpmteam 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ci[](https://npm.im/libnpmteam) 41cb0ef41Sopenharmony_ci[](https://npm.im/libnpmteam) 51cb0ef41Sopenharmony_ci[](https://github.com/npm/cli/actions/workflows/ci-libnpmteam.yml) 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci[`libnpmteam`](https://github.com/npm/libnpmteam) is a Node.js 81cb0ef41Sopenharmony_cilibrary that provides programmatic access to the guts of the npm CLI's `npm 91cb0ef41Sopenharmony_citeam` command and its various subcommands. 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ci## Example 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ci```javascript 141cb0ef41Sopenharmony_ciconst team = require('libnpmteam') 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci// List all teams for the @npm org. 171cb0ef41Sopenharmony_ciconsole.log(await team.lsTeams('npm')) 181cb0ef41Sopenharmony_ci``` 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ci## Publishing 211cb0ef41Sopenharmony_ci1. Manually create CHANGELOG.md file 221cb0ef41Sopenharmony_ci1. Commit changes to CHANGELOG.md 231cb0ef41Sopenharmony_ci ```bash 241cb0ef41Sopenharmony_ci $ git commit -m "chore: updated CHANGELOG.md" 251cb0ef41Sopenharmony_ci ``` 261cb0ef41Sopenharmony_ci1. Run `npm version {newVersion}` 271cb0ef41Sopenharmony_ci ```bash 281cb0ef41Sopenharmony_ci # Example 291cb0ef41Sopenharmony_ci $ npm version patch 301cb0ef41Sopenharmony_ci # 1. Runs `coverage` and `lint` scripts 311cb0ef41Sopenharmony_ci # 2. Bumps package version; and **create commit/tag** 321cb0ef41Sopenharmony_ci # 3. Runs `npm publish`; publishing directory with **unpushed commit** 331cb0ef41Sopenharmony_ci # 4. Runs `git push origin --follow-tags` 341cb0ef41Sopenharmony_ci ``` 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_ci## Table of Contents 371cb0ef41Sopenharmony_ci 381cb0ef41Sopenharmony_ci* [Installing](#install) 391cb0ef41Sopenharmony_ci* [Example](#example) 401cb0ef41Sopenharmony_ci* [API](#api) 411cb0ef41Sopenharmony_ci * [team opts](#opts) 421cb0ef41Sopenharmony_ci * [`create()`](#create) 431cb0ef41Sopenharmony_ci * [`destroy()`](#destroy) 441cb0ef41Sopenharmony_ci * [`add()`](#add) 451cb0ef41Sopenharmony_ci * [`rm()`](#rm) 461cb0ef41Sopenharmony_ci * [`lsTeams()`](#ls-teams) 471cb0ef41Sopenharmony_ci * [`lsTeams.stream()`](#ls-teams-stream) 481cb0ef41Sopenharmony_ci * [`lsUsers()`](#ls-users) 491cb0ef41Sopenharmony_ci * [`lsUsers.stream()`](#ls-users-stream) 501cb0ef41Sopenharmony_ci 511cb0ef41Sopenharmony_ci### Install 521cb0ef41Sopenharmony_ci 531cb0ef41Sopenharmony_ci`$ npm install libnpmteam` 541cb0ef41Sopenharmony_ci 551cb0ef41Sopenharmony_ci### API 561cb0ef41Sopenharmony_ci 571cb0ef41Sopenharmony_ci#### <a name="opts"></a> `opts` for `libnpmteam` commands 581cb0ef41Sopenharmony_ci 591cb0ef41Sopenharmony_ci`libnpmteam` uses [`npm-registry-fetch`](https://npm.im/npm-registry-fetch). 601cb0ef41Sopenharmony_ciAll options are passed through directly to that library, so please refer to [its 611cb0ef41Sopenharmony_ciown `opts` 621cb0ef41Sopenharmony_cidocumentation](https://www.npmjs.com/package/npm-registry-fetch#fetch-options) 631cb0ef41Sopenharmony_cifor options that can be passed in. 641cb0ef41Sopenharmony_ci 651cb0ef41Sopenharmony_ciA couple of options of note for those in a hurry: 661cb0ef41Sopenharmony_ci 671cb0ef41Sopenharmony_ci* `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. 681cb0ef41Sopenharmony_ci* `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>}` 691cb0ef41Sopenharmony_ci 701cb0ef41Sopenharmony_ci#### <a name="create"></a> `> team.create(team, [opts]) -> Promise` 711cb0ef41Sopenharmony_ci 721cb0ef41Sopenharmony_ciCreates a team named `team`. Team names use the format `@<scope>:<name>`, with 731cb0ef41Sopenharmony_cithe `@` being optional. 741cb0ef41Sopenharmony_ci 751cb0ef41Sopenharmony_ciAdditionally, `opts.description` may be passed in to include a description. 761cb0ef41Sopenharmony_ci 771cb0ef41Sopenharmony_ci##### Example 781cb0ef41Sopenharmony_ci 791cb0ef41Sopenharmony_ci```javascript 801cb0ef41Sopenharmony_ciawait team.create('@npm:cli', {token: 'myregistrytoken'}) 811cb0ef41Sopenharmony_ci// The @npm:cli team now exists. 821cb0ef41Sopenharmony_ci``` 831cb0ef41Sopenharmony_ci 841cb0ef41Sopenharmony_ci#### <a name="destroy"></a> `> team.destroy(team, [opts]) -> Promise` 851cb0ef41Sopenharmony_ci 861cb0ef41Sopenharmony_ciDestroys a team named `team`. Team names use the format `@<scope>:<name>`, with 871cb0ef41Sopenharmony_cithe `@` being optional. 881cb0ef41Sopenharmony_ci 891cb0ef41Sopenharmony_ci##### Example 901cb0ef41Sopenharmony_ci 911cb0ef41Sopenharmony_ci```javascript 921cb0ef41Sopenharmony_ciawait team.destroy('@npm:cli', {token: 'myregistrytoken'}) 931cb0ef41Sopenharmony_ci// The @npm:cli team has been destroyed. 941cb0ef41Sopenharmony_ci``` 951cb0ef41Sopenharmony_ci 961cb0ef41Sopenharmony_ci#### <a name="add"></a> `> team.add(user, team, [opts]) -> Promise` 971cb0ef41Sopenharmony_ci 981cb0ef41Sopenharmony_ciAdds `user` to `team`. 991cb0ef41Sopenharmony_ci 1001cb0ef41Sopenharmony_ci##### Example 1011cb0ef41Sopenharmony_ci 1021cb0ef41Sopenharmony_ci```javascript 1031cb0ef41Sopenharmony_ciawait team.add('zkat', '@npm:cli', {token: 'myregistrytoken'}) 1041cb0ef41Sopenharmony_ci// @zkat now belongs to the @npm:cli team. 1051cb0ef41Sopenharmony_ci``` 1061cb0ef41Sopenharmony_ci 1071cb0ef41Sopenharmony_ci#### <a name="rm"></a> `> team.rm(user, team, [opts]) -> Promise` 1081cb0ef41Sopenharmony_ci 1091cb0ef41Sopenharmony_ciRemoves `user` from `team`. 1101cb0ef41Sopenharmony_ci 1111cb0ef41Sopenharmony_ci##### Example 1121cb0ef41Sopenharmony_ci 1131cb0ef41Sopenharmony_ci```javascript 1141cb0ef41Sopenharmony_ciawait team.rm('zkat', '@npm:cli', {token: 'myregistrytoken'}) 1151cb0ef41Sopenharmony_ci// @zkat is no longer part of the @npm:cli team. 1161cb0ef41Sopenharmony_ci``` 1171cb0ef41Sopenharmony_ci 1181cb0ef41Sopenharmony_ci#### <a name="ls-teams"></a> `> team.lsTeams(scope, [opts]) -> Promise` 1191cb0ef41Sopenharmony_ci 1201cb0ef41Sopenharmony_ciResolves to an array of team names belonging to `scope`. 1211cb0ef41Sopenharmony_ci 1221cb0ef41Sopenharmony_ci##### Example 1231cb0ef41Sopenharmony_ci 1241cb0ef41Sopenharmony_ci```javascript 1251cb0ef41Sopenharmony_ciawait team.lsTeams('@npm', {token: 'myregistrytoken'}) 1261cb0ef41Sopenharmony_ci=> 1271cb0ef41Sopenharmony_ci[ 1281cb0ef41Sopenharmony_ci 'npm:cli', 1291cb0ef41Sopenharmony_ci 'npm:web', 1301cb0ef41Sopenharmony_ci 'npm:registry', 1311cb0ef41Sopenharmony_ci 'npm:developers' 1321cb0ef41Sopenharmony_ci] 1331cb0ef41Sopenharmony_ci``` 1341cb0ef41Sopenharmony_ci 1351cb0ef41Sopenharmony_ci#### <a name="ls-teams-stream"></a> `> team.lsTeams.stream(scope, [opts]) -> Stream` 1361cb0ef41Sopenharmony_ci 1371cb0ef41Sopenharmony_ciReturns a stream of teams belonging to `scope`. 1381cb0ef41Sopenharmony_ci 1391cb0ef41Sopenharmony_ciFor a Promise-based version of these results, see [`team.lsTeams()`](#ls-teams). 1401cb0ef41Sopenharmony_ci 1411cb0ef41Sopenharmony_ci##### Example 1421cb0ef41Sopenharmony_ci 1431cb0ef41Sopenharmony_ci```javascript 1441cb0ef41Sopenharmony_cifor await (let team of team.lsTeams.stream('@npm', {token: 'myregistrytoken'})) { 1451cb0ef41Sopenharmony_ci console.log(team) 1461cb0ef41Sopenharmony_ci} 1471cb0ef41Sopenharmony_ci 1481cb0ef41Sopenharmony_ci// outputs 1491cb0ef41Sopenharmony_ci// npm:cli 1501cb0ef41Sopenharmony_ci// npm:web 1511cb0ef41Sopenharmony_ci// npm:registry 1521cb0ef41Sopenharmony_ci// npm:developers 1531cb0ef41Sopenharmony_ci``` 1541cb0ef41Sopenharmony_ci 1551cb0ef41Sopenharmony_ci#### <a name="ls-users"></a> `> team.lsUsers(team, [opts]) -> Promise` 1561cb0ef41Sopenharmony_ci 1571cb0ef41Sopenharmony_ciResolves to an array of usernames belonging to `team`. 1581cb0ef41Sopenharmony_ci 1591cb0ef41Sopenharmony_ciFor a streamed version of these results, see [`team.lsUsers.stream()`](#ls-users-stream). 1601cb0ef41Sopenharmony_ci 1611cb0ef41Sopenharmony_ci##### Example 1621cb0ef41Sopenharmony_ci 1631cb0ef41Sopenharmony_ci```javascript 1641cb0ef41Sopenharmony_ciawait team.lsUsers('@npm:cli', {token: 'myregistrytoken'}) 1651cb0ef41Sopenharmony_ci=> 1661cb0ef41Sopenharmony_ci[ 1671cb0ef41Sopenharmony_ci 'iarna', 1681cb0ef41Sopenharmony_ci 'zkat' 1691cb0ef41Sopenharmony_ci] 1701cb0ef41Sopenharmony_ci``` 1711cb0ef41Sopenharmony_ci 1721cb0ef41Sopenharmony_ci#### <a name="ls-users-stream"></a> `> team.lsUsers.stream(team, [opts]) -> Stream` 1731cb0ef41Sopenharmony_ci 1741cb0ef41Sopenharmony_ciReturns a stream of usernames belonging to `team`. 1751cb0ef41Sopenharmony_ci 1761cb0ef41Sopenharmony_ciFor a Promise-based version of these results, see [`team.lsUsers()`](#ls-users). 1771cb0ef41Sopenharmony_ci 1781cb0ef41Sopenharmony_ci##### Example 1791cb0ef41Sopenharmony_ci 1801cb0ef41Sopenharmony_ci```javascript 1811cb0ef41Sopenharmony_cifor await (let user of team.lsUsers.stream('@npm:cli', {token: 'myregistrytoken'})) { 1821cb0ef41Sopenharmony_ci console.log(user) 1831cb0ef41Sopenharmony_ci} 1841cb0ef41Sopenharmony_ci 1851cb0ef41Sopenharmony_ci// outputs 1861cb0ef41Sopenharmony_ci// iarna 1871cb0ef41Sopenharmony_ci// zkat 1881cb0ef41Sopenharmony_ci``` 189