This commit is contained in:
2025-08-18 23:06:34 +08:00
parent 0bc04fb659
commit ed18af0cad
1926 changed files with 275098 additions and 0 deletions

13
package/node_modules/libnpmteam/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,13 @@
Copyright npm, Inc
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

188
package/node_modules/libnpmteam/README.md generated vendored Normal file
View File

@@ -0,0 +1,188 @@
# libnpmteam
[![npm version](https://img.shields.io/npm/v/libnpmteam.svg)](https://npm.im/libnpmteam)
[![license](https://img.shields.io/npm/l/libnpmteam.svg)](https://npm.im/libnpmteam)
[![CI - libnpmteam](https://github.com/npm/cli/actions/workflows/ci-libnpmteam.yml/badge.svg)](https://github.com/npm/cli/actions/workflows/ci-libnpmteam.yml)
[`libnpmteam`](https://github.com/npm/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
```javascript
const team = require('libnpmteam')
// List all teams for the @npm org.
console.log(await team.lsTeams('npm'))
```
## Publishing
1. Manually create CHANGELOG.md file
1. Commit changes to CHANGELOG.md
```bash
$ git commit -m "chore: updated CHANGELOG.md"
```
1. Run `npm version {newVersion}`
```bash
# Example
$ npm version patch
# 1. Runs `coverage` and `lint` scripts
# 2. Bumps package version; and **create commit/tag**
# 3. Runs `npm publish`; publishing directory with **unpushed commit**
# 4. Runs `git push origin --follow-tags`
```
## Table of Contents
* [Installing](#install)
* [Example](#example)
* [API](#api)
* [team opts](#opts)
* [`create()`](#create)
* [`destroy()`](#destroy)
* [`add()`](#add)
* [`rm()`](#rm)
* [`lsTeams()`](#ls-teams)
* [`lsTeams.stream()`](#ls-teams-stream)
* [`lsUsers()`](#ls-users)
* [`lsUsers.stream()`](#ls-users-stream)
### Install
`$ npm install libnpmteam`
### API
#### <a name="opts"></a> `opts` for `libnpmteam` commands
`libnpmteam` uses [`npm-registry-fetch`](https://npm.im/npm-registry-fetch).
All options are passed through directly to that library, so please refer to [its
own `opts`
documentation](https://www.npmjs.com/package/npm-registry-fetch#fetch-options)
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>}`
#### <a name="create"></a> `> 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
```javascript
await team.create('@npm:cli', {token: 'myregistrytoken'})
// The @npm:cli team now exists.
```
#### <a name="destroy"></a> `> team.destroy(team, [opts]) -> Promise`
Destroys a team named `team`. Team names use the format `@<scope>:<name>`, with
the `@` being optional.
##### Example
```javascript
await team.destroy('@npm:cli', {token: 'myregistrytoken'})
// The @npm:cli team has been destroyed.
```
#### <a name="add"></a> `> team.add(user, team, [opts]) -> Promise`
Adds `user` to `team`.
##### Example
```javascript
await team.add('zkat', '@npm:cli', {token: 'myregistrytoken'})
// @zkat now belongs to the @npm:cli team.
```
#### <a name="rm"></a> `> team.rm(user, team, [opts]) -> Promise`
Removes `user` from `team`.
##### Example
```javascript
await team.rm('zkat', '@npm:cli', {token: 'myregistrytoken'})
// @zkat is no longer part of the @npm:cli team.
```
#### <a name="ls-teams"></a> `> team.lsTeams(scope, [opts]) -> Promise`
Resolves to an array of team names belonging to `scope`.
##### Example
```javascript
await team.lsTeams('@npm', {token: 'myregistrytoken'})
=>
[
'npm:cli',
'npm:web',
'npm:registry',
'npm:developers'
]
```
#### <a name="ls-teams-stream"></a> `> 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()`](#ls-teams).
##### Example
```javascript
for await (let team of team.lsTeams.stream('@npm', {token: 'myregistrytoken'})) {
console.log(team)
}
// outputs
// npm:cli
// npm:web
// npm:registry
// npm:developers
```
#### <a name="ls-users"></a> `> 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()`](#ls-users-stream).
##### Example
```javascript
await team.lsUsers('@npm:cli', {token: 'myregistrytoken'})
=>
[
'iarna',
'zkat'
]
```
#### <a name="ls-users-stream"></a> `> 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()`](#ls-users).
##### Example
```javascript
for await (let user of team.lsUsers.stream('@npm:cli', {token: 'myregistrytoken'})) {
console.log(user)
}
// outputs
// iarna
// zkat
```

92
package/node_modules/libnpmteam/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,92 @@
'use strict'
const eu = encodeURIComponent
const npmFetch = require('npm-registry-fetch')
const validate = require('aproba')
const cmd = module.exports
cmd.create = (entity, opts = {}) => {
return Promise.resolve().then(() => {
const { scope, team } = splitEntity(entity)
validate('SSO', [scope, team, opts])
const uri = `/-/org/${eu(scope)}/team`
return npmFetch.json(uri, {
...opts,
method: 'PUT',
scope,
body: { name: team, description: opts.description },
})
})
}
cmd.destroy = async (entity, opts = {}) => {
const { scope, team } = splitEntity(entity)
validate('SSO', [scope, team, opts])
const uri = `/-/team/${eu(scope)}/${eu(team)}`
await npmFetch(uri, {
...opts,
method: 'DELETE',
scope,
ignoreBody: true,
})
return true
}
cmd.add = (user, entity, opts = {}) => {
const { scope, team } = splitEntity(entity)
validate('SSO', [scope, team, opts])
const uri = `/-/team/${eu(scope)}/${eu(team)}/user`
return npmFetch.json(uri, {
...opts,
method: 'PUT',
scope,
body: { user },
})
}
cmd.rm = async (user, entity, opts = {}) => {
const { scope, team } = splitEntity(entity)
validate('SSO', [scope, team, opts])
const uri = `/-/team/${eu(scope)}/${eu(team)}/user`
await npmFetch(uri, {
...opts,
method: 'DELETE',
scope,
body: { user },
ignoreBody: true,
})
return true
}
cmd.lsTeams = (...args) => cmd.lsTeams.stream(...args).collect()
cmd.lsTeams.stream = (scope, opts = {}) => {
validate('SO', [scope, opts])
const uri = `/-/org/${eu(scope)}/team`
return npmFetch.json.stream(uri, '.*', {
...opts,
query: { format: 'cli' },
})
}
cmd.lsUsers = (...args) => cmd.lsUsers.stream(...args).collect()
cmd.lsUsers.stream = (entity, opts = {}) => {
const { scope, team } = splitEntity(entity)
validate('SSO', [scope, team, opts])
const uri = `/-/team/${eu(scope)}/${eu(team)}/user`
return npmFetch.json.stream(uri, '.*', {
...opts,
query: { format: 'cli' },
})
}
cmd.edit = () => {
throw new Error('edit is not implemented yet')
}
function splitEntity (entity = '') {
const [, scope, team] = entity.match(/^@?([^:]+):(.*)$/) || []
return { scope, team }
}

51
package/node_modules/libnpmteam/package.json generated vendored Normal file
View File

@@ -0,0 +1,51 @@
{
"name": "libnpmteam",
"description": "npm Team management APIs",
"version": "6.0.5",
"author": "GitHub Inc.",
"license": "ISC",
"main": "lib/index.js",
"scripts": {
"lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
"test": "tap",
"posttest": "npm run lint",
"postlint": "template-oss-check",
"lintfix": "npm run lint -- --fix",
"snap": "tap",
"template-oss-apply": "template-oss-apply --force"
},
"devDependencies": {
"@npmcli/eslint-config": "^4.0.0",
"@npmcli/template-oss": "4.22.0",
"nock": "^13.3.3",
"tap": "^16.3.8"
},
"repository": {
"type": "git",
"url": "git+https://github.com/npm/cli.git",
"directory": "workspaces/libnpmteam"
},
"files": [
"bin/",
"lib/"
],
"homepage": "https://npmjs.com/package/libnpmteam",
"dependencies": {
"aproba": "^2.0.0",
"npm-registry-fetch": "^17.0.1"
},
"engines": {
"node": "^16.14.0 || >=18.0.0"
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "4.22.0",
"content": "../../scripts/template-oss/index.js"
},
"tap": {
"nyc-arg": [
"--exclude",
"tap-snapshots/**"
]
}
}