Software: Apache. PHP/5.3.29 uname -a: Linux tardis23.nocplanet.net 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024
Safe-mode: OFF (not secure) /opt/alt/alt-nodejs6/root/usr/lib/node_modules/npm/node_modules.bundled/npm-registry-client/lib/ drwxr-xr-x | |
| Viewing file: Select action/file-type: module.exports = team
var assert = require('assert')
var url = require('url')
var subcommands = {}
function team (sub, uri, params, cb) {
teamAssertions(sub, uri, params, cb)
return subcommands[sub].call(this, uri, params, cb)
}
subcommands.create = function (uri, params, cb) {
return this.request(apiUri(uri, 'org', params.scope, 'team'), {
method: 'PUT',
auth: params.auth,
body: JSON.stringify({
name: params.team
})
}, cb)
}
subcommands.destroy = function (uri, params, cb) {
return this.request(apiUri(uri, 'team', params.scope, params.team), {
method: 'DELETE',
auth: params.auth
}, cb)
}
subcommands.add = function (uri, params, cb) {
return this.request(apiUri(uri, 'team', params.scope, params.team, 'user'), {
method: 'PUT',
auth: params.auth,
body: JSON.stringify({
user: params.user
})
}, cb)
}
subcommands.rm = function (uri, params, cb) {
return this.request(apiUri(uri, 'team', params.scope, params.team, 'user'), {
method: 'DELETE',
auth: params.auth,
body: JSON.stringify({
user: params.user
})
}, cb)
}
subcommands.ls = function (uri, params, cb) {
var uriParams = '?format=cli'
if (params.team) {
var reqUri = apiUri(
uri, 'team', params.scope, params.team, 'user') + uriParams
return this.request(reqUri, {
method: 'GET',
auth: params.auth
}, cb)
} else {
return this.request(apiUri(uri, 'org', params.scope, 'team') + uriParams, {
method: 'GET',
auth: params.auth
}, cb)
}
}
// TODO - we punted this to v2
// subcommands.edit = function (uri, params, cb) {
// return this.request(apiUri(uri, 'team', params.scope, params.team, 'user'), {
// method: 'POST',
// auth: params.auth,
// body: JSON.stringify({
// users: params.users
// })
// }, cb)
// }
function apiUri (registryUri) {
var path = Array.prototype.slice.call(arguments, 1)
.map(encodeURIComponent)
.join('/')
return url.resolve(registryUri, '-/' + path)
}
function teamAssertions (subcommand, uri, params, cb) {
assert(subcommand, 'subcommand is required')
assert(subcommands.hasOwnProperty(subcommand),
'team subcommand must be one of ' + Object.keys(subcommands))
assert(typeof uri === 'string', 'registry URI is required')
assert(typeof params === 'object', 'params are required')
assert(typeof params.auth === 'object', 'auth is required')
assert(typeof params.scope === 'string', 'scope is required')
assert(!cb || typeof cb === 'function', 'callback must be a function')
if (subcommand !== 'ls') {
assert(typeof params.team === 'string', 'team name is required')
}
if (subcommand === 'rm' || subcommand === 'add') {
assert(typeof params.user === 'string', 'user is required')
}
if (subcommand === 'edit') {
assert(typeof params.users === 'object' &&
params.users.length != null,
'users is required')
}
}
|
:: Command execute :: | |
--[ c99shell v.2.1 [PHP 7 Update] [1.12.2019] maintained by KaizenLouie and updated by cermmik | C99Shell Github (MySQL update) | Generation time: 0.0202 ]-- |