8000 add npm sources · avdim/github-script@6543232 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6543232

Browse files
committed
add npm sources
1 parent 6b985e6 commit 6543232

File tree

186 files changed

+21906
-3653
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

186 files changed

+21906
-3653
lines changed

package-lock.json

Lines changed: 4278 additions & 3625 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 81 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,90 @@
4343
"@octokit/plugin-rest-endpoint-methods": "^4.1.2",
4444
"async": "^3.2.0",
4545
"compressing": "^1.5.1",
46-
"graceful-fs": "^4.2.4",
46+
"graceful-fs": "~4.1.11",
4747
"lodash.curry": "^4.1.1",
4848
"mute": "^2.0.6",
4949
"mv": "^2.1.1",
50-
"npm": "^4.0.0",
51-
"rimraf": "^3.0.2"
50+
"rimraf": "~2.6.1",
51+
"JSONStream": "~1.3.1",
52+
"abbrev": "~1.1.0",
53+
"ansi-regex": "~2.1.1",
54+
"ansicolors": "~0.3.2",
55 10000 +
"ansistyles": "~0.1.3",
56+
"aproba": "~1.1.1",
57+
"archy": "~1.0.0",
58+
"asap": "~2.0.5",
59+
"bluebird": "~3.5.0",
60+
"call-limit": "~1.1.0",
61+
"chownr": "~1.0.1",
62+
"cmd-shim": "~2.0.2",
63+
"columnify": "~1.5.4",
64+
"config-chain": "~1.1.11",
65+
"dezalgo": "~1.0.3",
66+
"editor": "~1.0.0",
67+
"fs-vacuum": "~1.2.10",
68+
"fs-write-stream-atomic": "~1.0.10",
69+
"fstream": "~1.0.11",
70+
"fstream-npm": "~1.2.0",
71+
"glob": "~7.1.1",
72+
"has-unicode": "~2.0.1",
73+
"hosted-git-info": "~2.4.2",
74+
"iferr": "~0.1.5",
75+
"inflight": "~1.0.6",
76+
"inherits": "~2.0.3",
77+
"ini": "~1.3.4",
78+
"init-package-json": "~1.10.1",
79+
"lazy-property": "~1.0.0",
80+
"lockfile": "~1.0.3",
81+
"lodash._baseuniq": "~4.6.0",
82+
"lodash.clonedeep": "~4.5.0",
83+
"lodash.union": "~4.6.0",
84+
"lodash.uniq": "~4.5.0",
85+
"lodash.without": "~4.4.0",
86+
"mississippi": "~1.3.0",
87+
"mkdirp": "~0.5.1",
88+
"move-concurrently": "~1.0.1",
89+
"node-gyp": "~3.6.0",
90+
"nopt": "~4.0.1",
91+
"normalize-git-url": "~3.0.2",
92+
"normalize-package-data": "~2.3.8",
93+
"npm-cache-filename": "~1.0.2",
94+
"npm-install-checks": "~3.0.0",
95+
"npm-package-arg": "~4.2.1",
96+
"npm-registry-client": "~8.1.1",
97+
"npm-user-validate": "~0.1.5",
98+
"npmlog": "~4.0.2",
99+
"once": "~1.4.0",
100+
"opener": "~1.4.3",
101+
"osenv": "~0.1.4",
102+
"path-is-inside": "~1.0.2",
103+
"read": "~1.0.7",
104+
"read-cmd-shim": "~1.0.1",
105+
"read-installed": "~4.0.3",
106+
"read-package-json": "~2.0.5",
107+
"read-package-tree": "~5.1.5",
108+
"readable-stream": "~2.2.9",
109+
"realize-package-specifier": "~3.0.3",
110+
"request": "~2.81.0",
111+
"retry": "~0.10.1",
112+
"semver": "~5.3.0",
113+
"sha": "~2.0.1",
114+
"slide": "~1.1.6",
115+
"sorted-object": "~2.0.1",
116+
"sorted-union-stream": "~2.1.3",
117+
"strip-ansi": "~3.0.1",
118+
"tar": "~2.2.1",
119+
"text-table": "~0.2.0",
120+
"uid-number": "0.0.6",
121+
"umask": "~1.1.0",
122+
"unique-filename": "~1.1.0",
123+
"unpipe": "~1.0.0",
124+
"update-notifier": "~2.1.0",
125+
"uuid": "~3.0.1",
126+
"validate-npm-package-name": "~3.0.0",
127+
"which": "~1.2.14",
128+
"wrappy": "~1.0.2",
129+
"write-file-atomic": "~1.3.3"
52130
},
53131
"devDependencies": {
54132
"@types/jest": "^26.0.10",

src/access.js

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
'use strict'
2+
3+
var resolve = require('path').resolve
4+
5+
var readPackageJson = require('read-package-json')
6+
var mapToRegistry = require('./utils/map-to-registry.js')
7+
var npm = require('./npm.js')
8+
var output = require('./utils/output.js')
9+
10+
var whoami = require('./whoami')
11+
12+
module.exports = access
13+
14+
access.usage =
15+
'npm access public [<package>]\n' +
16+
'npm access restricted [<package>]\n' +
17+
'npm access grant <read-only|read-write> <scope:team> [<package>]\n' +
18+
'npm access revoke <scope:team> [<package>]\n' +
19+
'npm access ls-packages [<user>|<scope>|<scope:team>]\n' +
20+
'npm access ls-collaborators [<package> [<user>]]\n' +
21+
'npm access edit [<package>]'
22+
23+
access.subcommands = ['public', 'restricted', 'grant', 'revoke',
24+
'ls-packages', 'ls-collaborators', 'edit']
25+
26+
access.completion = function (opts, cb) {
27+
var argv = opts.conf.argv.remain
28+
if (argv.length === 2) {
29+
return cb(null, access.subcommands)
30+
}
31+
32+
switch (argv[2]) {
33+
case 'grant':
34+
if (argv.length === 3) {
35+
return cb(null, ['read-only', 'read-write'])
36+
} else {
37+
return cb(null, [])
38+
}
39+
case 'public':
40+
case 'restricted':
41+
case 'ls-packages':
42+
case 'ls-collaborators':
43+
case 'edit':
44+
return cb(null, [])
45+
case 'revoke':
46+
return cb(null, [])
47+
default:
48+
return cb(new Error(argv[2] + ' not recognized'))
49+
}
50+
}
51+
52+
function access (args, cb) {
53+
var cmd = args.shift()
54+
var params
55+
return parseParams(cmd, args, function (err, p) {
56+
if (err) { return cb(err) }
57+
params = p
58+
return mapToRegistry(params.package, npm.config, invokeCmd)
59+
})
60+
61+
function invokeCmd (err, uri, auth, base) {
62+
if (err) { return cb(err) }
63+
params.auth = auth
64+
try {
65+
return npm.registry.access(cmd, uri, params, function (err, data) {
66+
if (!err && data) {
67+
output(JSON.stringify(data, undefined, 2))
68+
}
69+
cb(err, data)
70+
})
71+
} catch (e) {
72+
cb(e.message + '\n\nUsage:\n' + access.usage)
73+
}
74+
}
75+
}
76+
77+
function parseParams (cmd, args, cb) {
78+
// mapToRegistry will complain if package is undefined,
79+
// but it's not needed for ls-packages
80+
var params = { 'package': '' }
81+
if (cmd === 'grant') {
82+
params.permissions = args.shift()
83+
}
84+
if (['grant', 'revoke', 'ls-packages'].indexOf(cmd) !== -1) {
85+
var entity = (args.shift() || '').split(':')
86+
params.scope = entity[0]
87+
params.team = entity[1]
88+
}
89+
90+
if (cmd === 'ls-packages') {
91+
if (!params.scope) {
92+
whoami([], true, function (err, scope) {
93+
params.scope = scope
94+
cb(err, params)
95+
})
96+
} else {
97+
cb(null, params)
98+
}
99+
} else {
100+
getPackage(args.shift(), function (err, pkg) {
101+
if (err) return cb(err)
102+
params.package = pkg
103+
104+
if (cmd === 'ls-collaborators') params.user = args.shift()
105+
cb(null, params)
106+
})
107+
}
108+
}
109+
110+
function getPackage (name, cb) {
111+
if (name && name.trim()) {
112+
cb(null, name.trim())
113+
} else {
114+
readPackageJson(
115+
resolve(npm.prefix, 'package.json'),
116+
function (err, data) {
117+
if (err) {
118+
if (err.code === 'ENOENT') {
119+
cb(new Error('no package name passed to command and no package.json found'))
120+
} else {
121+
cb(err)
122+
}
123+
} else {
124+
cb(null, data.name)
125+
}
126+
}
127+
)
128+
}
129+
}

src/adduser.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
module.exports = adduser
2+
3+
var log = require('npmlog')
4+
var npm = require('./npm.js')
5+
var usage = require('./utils/usage')
6+
var crypto
7+
8+
try {
9+
crypto = require('crypto')
10+
} catch (ex) {}
11+
12+
adduser.usage = usage(
13+
'adduser',
14+
'npm adduser [--registry=url] [--scope=@orgname] [--auth-type=legacy] [--always-auth]'
15+
)
16+
17+
function adduser (args, cb) {
18+
if (!crypto) {
19+
return cb(new Error(
20+
'You must compile node with ssl support to use the adduser feature'
21+
))
22+
}
23+
24+
var registry = npm.config.get('registry')
25+
var scope = npm.config.get('scope')
26+
var creds = npm.config.getCredentialsByURI(npm.config.get('registry'))
27+
28+
if (scope) {
29+
var scopedRegistry = npm.config.get(scope + ':registry')
30+
var cliRegistry = npm.config.get('registry', 'cli')
31+
if (scopedRegistry && !cliRegistry) registry = scopedRegistry
32+
}
33+
34+
log.disableProgress()
35+
36+
try {
37+
var auth = require('./auth/' + npm.config.get('auth-type'))
38+
} catch (e) {
39+
return cb(new Error('no such auth module'))
40+
}
41+
auth.login(creds, registry, scope, function (err, newCreds) {
42+
if (err) return cb(err)
43+
44+
npm.config.del('_token', 'user') // prevent legacy pollution
45+
if (scope) npm.config.set(scope + ':registry', registry, 'user')
46+
npm.config.setCredentialsByURI(registry, newCreds)
47+
npm.config.save('user', cb)
48+
})
49+
}

0 commit comments

Comments
 (0)
0