mirror of
https://github.com/S2-/minifyfromhtml.git
synced 2025-08-04 20:40:07 +02:00
update packages to latest version
This commit is contained in:
16
node_modules/npm/lib/config/clear-credentials-by-uri.js
generated
vendored
Normal file
16
node_modules/npm/lib/config/clear-credentials-by-uri.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
var assert = require("assert")
|
||||
|
||||
var toNerfDart = require("./nerf-dart.js")
|
||||
|
||||
module.exports = clearCredentialsByURI
|
||||
|
||||
function clearCredentialsByURI (uri) {
|
||||
assert(uri && typeof uri === "string", "registry URL is required")
|
||||
|
||||
var nerfed = toNerfDart(uri)
|
||||
|
||||
this.del(nerfed + ":_authToken", "user")
|
||||
this.del(nerfed + ":_password", "user")
|
||||
this.del(nerfed + ":username", "user")
|
||||
this.del(nerfed + ":email", "user")
|
||||
}
|
441
node_modules/npm/lib/config/core.js
generated
vendored
Normal file
441
node_modules/npm/lib/config/core.js
generated
vendored
Normal file
@@ -0,0 +1,441 @@
|
||||
|
||||
var CC = require("config-chain").ConfigChain
|
||||
var inherits = require("inherits")
|
||||
var configDefs = require("./defaults.js")
|
||||
var types = configDefs.types
|
||||
var once = require("once")
|
||||
var fs = require("fs")
|
||||
var path = require("path")
|
||||
var nopt = require("nopt")
|
||||
var ini = require("ini")
|
||||
var Umask = configDefs.Umask
|
||||
var mkdirp = require("mkdirp")
|
||||
var umask = require("../utils/umask")
|
||||
|
||||
exports.load = load
|
||||
exports.Conf = Conf
|
||||
exports.loaded = false
|
||||
exports.rootConf = null
|
||||
exports.usingBuiltin = false
|
||||
exports.defs = configDefs
|
||||
|
||||
Object.defineProperty(exports, "defaults", { get: function () {
|
||||
return configDefs.defaults
|
||||
}, enumerable: true })
|
||||
|
||||
Object.defineProperty(exports, "types", { get: function () {
|
||||
return configDefs.types
|
||||
}, enumerable: true })
|
||||
|
||||
exports.validate = validate
|
||||
|
||||
var myUid = process.env.SUDO_UID !== undefined
|
||||
? process.env.SUDO_UID : (process.getuid && process.getuid())
|
||||
var myGid = process.env.SUDO_GID !== undefined
|
||||
? process.env.SUDO_GID : (process.getgid && process.getgid())
|
||||
|
||||
|
||||
var loading = false
|
||||
var loadCbs = []
|
||||
function load () {
|
||||
var cli, builtin, cb
|
||||
for (var i = 0; i < arguments.length; i++)
|
||||
switch (typeof arguments[i]) {
|
||||
case "string": builtin = arguments[i]; break
|
||||
case "object": cli = arguments[i]; break
|
||||
case "function": cb = arguments[i]; break
|
||||
}
|
||||
|
||||
if (!cb)
|
||||
cb = function () {}
|
||||
|
||||
if (exports.loaded) {
|
||||
var ret = exports.loaded
|
||||
if (cli) {
|
||||
ret = new Conf(ret)
|
||||
ret.unshift(cli)
|
||||
}
|
||||
return process.nextTick(cb.bind(null, null, ret))
|
||||
}
|
||||
|
||||
// either a fresh object, or a clone of the passed in obj
|
||||
if (!cli)
|
||||
cli = {}
|
||||
else
|
||||
cli = Object.keys(cli).reduce(function (c, k) {
|
||||
c[k] = cli[k]
|
||||
return c
|
||||
}, {})
|
||||
|
||||
loadCbs.push(cb)
|
||||
if (loading)
|
||||
return
|
||||
|
||||
loading = true
|
||||
|
||||
cb = once(function (er, conf) {
|
||||
if (!er) {
|
||||
exports.loaded = conf
|
||||
loading = false
|
||||
}
|
||||
loadCbs.forEach(function (fn) {
|
||||
fn(er, conf)
|
||||
})
|
||||
loadCbs.length = 0
|
||||
})
|
||||
|
||||
// check for a builtin if provided.
|
||||
exports.usingBuiltin = !!builtin
|
||||
var rc = exports.rootConf = new Conf()
|
||||
if (builtin)
|
||||
rc.addFile(builtin, "builtin")
|
||||
else
|
||||
rc.add({}, "builtin")
|
||||
|
||||
rc.on("load", function () {
|
||||
load_(builtin, rc, cli, cb)
|
||||
})
|
||||
rc.on("error", cb)
|
||||
}
|
||||
|
||||
function load_(builtin, rc, cli, cb) {
|
||||
var defaults = configDefs.defaults
|
||||
var conf = new Conf(rc)
|
||||
|
||||
conf.usingBuiltin = !!builtin
|
||||
conf.add(cli, "cli")
|
||||
conf.addEnv()
|
||||
|
||||
conf.loadPrefix(function(er) {
|
||||
if (er)
|
||||
return cb(er)
|
||||
|
||||
// If you're doing `npm --userconfig=~/foo.npmrc` then you'd expect
|
||||
// that ~/.npmrc won't override the stuff in ~/foo.npmrc (or, indeed
|
||||
// be used at all).
|
||||
//
|
||||
// However, if the cwd is ~, then ~/.npmrc is the home for the project
|
||||
// config, and will override the userconfig.
|
||||
//
|
||||
// If you're not setting the userconfig explicitly, then it will be loaded
|
||||
// twice, which is harmless but excessive. If you *are* setting the
|
||||
// userconfig explicitly then it will override your explicit intent, and
|
||||
// that IS harmful and unexpected.
|
||||
//
|
||||
// Solution: Do not load project config file that is the same as either
|
||||
// the default or resolved userconfig value. npm will log a "verbose"
|
||||
// message about this when it happens, but it is a rare enough edge case
|
||||
// that we don't have to be super concerned about it.
|
||||
var projectConf = path.resolve(conf.localPrefix, ".npmrc")
|
||||
var defaultUserConfig = rc.get("userconfig")
|
||||
var resolvedUserConfig = conf.get("userconfig")
|
||||
if (!conf.get("global") &&
|
||||
projectConf !== defaultUserConfig &&
|
||||
projectConf !== resolvedUserConfig) {
|
||||
conf.addFile(projectConf, "project")
|
||||
conf.once("load", afterPrefix)
|
||||
} else {
|
||||
conf.add({}, "project")
|
||||
afterPrefix()
|
||||
}
|
||||
})
|
||||
|
||||
function afterPrefix() {
|
||||
conf.addFile(conf.get("userconfig"), "user")
|
||||
conf.once("error", cb)
|
||||
conf.once("load", afterUser)
|
||||
}
|
||||
|
||||
function afterUser () {
|
||||
// globalconfig and globalignorefile defaults
|
||||
// need to respond to the 'prefix' setting up to this point.
|
||||
// Eg, `npm config get globalconfig --prefix ~/local` should
|
||||
// return `~/local/etc/npmrc`
|
||||
// annoying humans and their expectations!
|
||||
if (conf.get("prefix")) {
|
||||
var etc = path.resolve(conf.get("prefix"), "etc")
|
||||
mkdirp(etc, function (err) {
|
||||
defaults.globalconfig = path.resolve(etc, "npmrc")
|
||||
defaults.globalignorefile = path.resolve(etc, "npmignore")
|
||||
afterUserContinuation()
|
||||
})
|
||||
} else {
|
||||
afterUserContinuation()
|
||||
}
|
||||
}
|
||||
|
||||
function afterUserContinuation() {
|
||||
conf.addFile(conf.get("globalconfig"), "global")
|
||||
|
||||
// move the builtin into the conf stack now.
|
||||
conf.root = defaults
|
||||
conf.add(rc.shift(), "builtin")
|
||||
conf.once("load", function () {
|
||||
conf.loadExtras(afterExtras)
|
||||
})
|
||||
}
|
||||
|
||||
function afterExtras(er) {
|
||||
if (er)
|
||||
return cb(er)
|
||||
|
||||
// warn about invalid bits.
|
||||
validate(conf)
|
||||
|
||||
var cafile = conf.get("cafile")
|
||||
|
||||
if (cafile) {
|
||||
return conf.loadCAFile(cafile, finalize)
|
||||
}
|
||||
|
||||
finalize()
|
||||
}
|
||||
|
||||
function finalize(er) {
|
||||
if (er) {
|
||||
return cb(er)
|
||||
}
|
||||
|
||||
exports.loaded = conf
|
||||
cb(er, conf)
|
||||
}
|
||||
}
|
||||
|
||||
// Basically the same as CC, but:
|
||||
// 1. Always ini
|
||||
// 2. Parses environment variable names in field values
|
||||
// 3. Field values that start with ~/ are replaced with process.env.HOME
|
||||
// 4. Can inherit from another Conf object, using it as the base.
|
||||
inherits(Conf, CC)
|
||||
function Conf (base) {
|
||||
if (!(this instanceof Conf))
|
||||
return new Conf(base)
|
||||
|
||||
CC.apply(this)
|
||||
|
||||
if (base)
|
||||
if (base instanceof Conf)
|
||||
this.root = base.list[0] || base.root
|
||||
else
|
||||
this.root = base
|
||||
else
|
||||
this.root = configDefs.defaults
|
||||
}
|
||||
|
||||
Conf.prototype.loadPrefix = require("./load-prefix.js")
|
||||
Conf.prototype.loadCAFile = require("./load-cafile.js")
|
||||
Conf.prototype.loadUid = require("./load-uid.js")
|
||||
Conf.prototype.setUser = require("./set-user.js")
|
||||
Conf.prototype.findPrefix = require("./find-prefix.js")
|
||||
Conf.prototype.getCredentialsByURI = require("./get-credentials-by-uri.js")
|
||||
Conf.prototype.setCredentialsByURI = require("./set-credentials-by-uri.js")
|
||||
Conf.prototype.clearCredentialsByURI = require("./clear-credentials-by-uri.js")
|
||||
|
||||
Conf.prototype.loadExtras = function(cb) {
|
||||
this.setUser(function(er) {
|
||||
if (er)
|
||||
return cb(er)
|
||||
this.loadUid(function(er) {
|
||||
if (er)
|
||||
return cb(er)
|
||||
// Without prefix, nothing will ever work
|
||||
mkdirp(this.prefix, cb)
|
||||
}.bind(this))
|
||||
}.bind(this))
|
||||
}
|
||||
|
||||
Conf.prototype.save = function (where, cb) {
|
||||
var target = this.sources[where]
|
||||
if (!target || !(target.path || target.source) || !target.data) {
|
||||
if (where !== "builtin")
|
||||
var er = new Error("bad save target: " + where)
|
||||
if (cb) {
|
||||
process.nextTick(cb.bind(null, er))
|
||||
return this
|
||||
}
|
||||
return this.emit("error", er)
|
||||
}
|
||||
|
||||
if (target.source) {
|
||||
var pref = target.prefix || ""
|
||||
Object.keys(target.data).forEach(function (k) {
|
||||
target.source[pref + k] = target.data[k]
|
||||
})
|
||||
if (cb) process.nextTick(cb)
|
||||
return this
|
||||
}
|
||||
|
||||
var data = ini.stringify(target.data)
|
||||
|
||||
then = then.bind(this)
|
||||
done = done.bind(this)
|
||||
this._saving ++
|
||||
|
||||
var mode = where === "user" ? "0600" : "0666"
|
||||
if (!data.trim()) {
|
||||
fs.unlink(target.path, function () {
|
||||
// ignore the possible error (e.g. the file doesn't exist)
|
||||
done(null)
|
||||
})
|
||||
} else {
|
||||
mkdirp(path.dirname(target.path), function (er) {
|
||||
if (er)
|
||||
return then(er)
|
||||
fs.writeFile(target.path, data, "utf8", function (er) {
|
||||
if (er)
|
||||
return then(er)
|
||||
if (where === "user" && myUid && myGid)
|
||||
fs.chown(target.path, +myUid, +myGid, then)
|
||||
else
|
||||
then()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function then (er) {
|
||||
if (er)
|
||||
return done(er)
|
||||
fs.chmod(target.path, mode, done)
|
||||
}
|
||||
|
||||
function done (er) {
|
||||
if (er) {
|
||||
if (cb) return cb(er)
|
||||
else return this.emit("error", er)
|
||||
}
|
||||
this._saving --
|
||||
if (this._saving === 0) {
|
||||
if (cb) cb()
|
||||
this.emit("save")
|
||||
}
|
||||
}
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
Conf.prototype.addFile = function (file, name) {
|
||||
name = name || file
|
||||
var marker = {__source__:name}
|
||||
this.sources[name] = { path: file, type: "ini" }
|
||||
this.push(marker)
|
||||
this._await()
|
||||
fs.readFile(file, "utf8", function (er, data) {
|
||||
if (er) // just ignore missing files.
|
||||
return this.add({}, marker)
|
||||
this.addString(data, file, "ini", marker)
|
||||
}.bind(this))
|
||||
return this
|
||||
}
|
||||
|
||||
// always ini files.
|
||||
Conf.prototype.parse = function (content, file) {
|
||||
return CC.prototype.parse.call(this, content, file, "ini")
|
||||
}
|
||||
|
||||
Conf.prototype.add = function (data, marker) {
|
||||
try {
|
||||
Object.keys(data).forEach(function (k) {
|
||||
data[k] = parseField(data[k], k)
|
||||
})
|
||||
}
|
||||
catch (e) {
|
||||
this.emit("error", e)
|
||||
return this
|
||||
}
|
||||
return CC.prototype.add.call(this, data, marker)
|
||||
}
|
||||
|
||||
Conf.prototype.addEnv = function (env) {
|
||||
env = env || process.env
|
||||
var conf = {}
|
||||
Object.keys(env)
|
||||
.filter(function (k) { return k.match(/^npm_config_/i) })
|
||||
.forEach(function (k) {
|
||||
if (!env[k])
|
||||
return
|
||||
|
||||
// leave first char untouched, even if
|
||||
// it is a "_" - convert all other to "-"
|
||||
var p = k.toLowerCase()
|
||||
.replace(/^npm_config_/, "")
|
||||
.replace(/(?!^)_/g, "-")
|
||||
conf[p] = env[k]
|
||||
})
|
||||
return CC.prototype.addEnv.call(this, "", conf, "env")
|
||||
}
|
||||
|
||||
function parseField (f, k) {
|
||||
if (typeof f !== "string" && !(f instanceof String))
|
||||
return f
|
||||
|
||||
// type can be an array or single thing.
|
||||
var typeList = [].concat(types[k])
|
||||
var isPath = -1 !== typeList.indexOf(path)
|
||||
var isBool = -1 !== typeList.indexOf(Boolean)
|
||||
var isString = -1 !== typeList.indexOf(String)
|
||||
var isUmask = -1 !== typeList.indexOf(Umask)
|
||||
var isNumber = -1 !== typeList.indexOf(Number)
|
||||
|
||||
f = (""+f).trim()
|
||||
|
||||
if (f.match(/^".*"$/)) {
|
||||
try {
|
||||
f = JSON.parse(f)
|
||||
}
|
||||
catch (e) {
|
||||
throw new Error("Failed parsing JSON config key " + k + ": " + f)
|
||||
}
|
||||
}
|
||||
|
||||
if (isBool && !isString && f === "")
|
||||
return true
|
||||
|
||||
switch (f) {
|
||||
case "true": return true
|
||||
case "false": return false
|
||||
case "null": return null
|
||||
case "undefined": return undefined
|
||||
}
|
||||
|
||||
f = envReplace(f)
|
||||
|
||||
if (isPath) {
|
||||
var homePattern = process.platform === "win32" ? /^~(\/|\\)/ : /^~\//
|
||||
if (f.match(homePattern) && process.env.HOME) {
|
||||
f = path.resolve(process.env.HOME, f.substr(2))
|
||||
}
|
||||
f = path.resolve(f)
|
||||
}
|
||||
|
||||
if (isUmask)
|
||||
f = umask.fromString(f)
|
||||
|
||||
if (isNumber && !isNaN(f))
|
||||
f = +f
|
||||
|
||||
return f
|
||||
}
|
||||
|
||||
function envReplace (f) {
|
||||
if (typeof f !== "string" || !f) return f
|
||||
|
||||
// replace any ${ENV} values with the appropriate environ.
|
||||
var envExpr = /(\\*)\$\{([^}]+)\}/g
|
||||
return f.replace(envExpr, function (orig, esc, name) {
|
||||
esc = esc.length && esc.length % 2
|
||||
if (esc)
|
||||
return orig
|
||||
if (undefined === process.env[name])
|
||||
throw new Error("Failed to replace env in config: "+orig)
|
||||
return process.env[name]
|
||||
})
|
||||
}
|
||||
|
||||
function validate (cl) {
|
||||
// warn about invalid configs at every level.
|
||||
cl.list.forEach(function (conf) {
|
||||
nopt.clean(conf, configDefs.types)
|
||||
})
|
||||
|
||||
nopt.clean(cl.root, configDefs.types)
|
||||
}
|
380
node_modules/npm/lib/config/defaults.js
generated
vendored
Normal file
380
node_modules/npm/lib/config/defaults.js
generated
vendored
Normal file
@@ -0,0 +1,380 @@
|
||||
// defaults, types, and shorthands.
|
||||
|
||||
|
||||
var path = require("path")
|
||||
, url = require("url")
|
||||
, Stream = require("stream").Stream
|
||||
, semver = require("semver")
|
||||
, stableFamily = semver.parse(process.version)
|
||||
, nopt = require("nopt")
|
||||
, os = require("os")
|
||||
, osenv = require("osenv")
|
||||
, umask = require("../utils/umask")
|
||||
|
||||
var log
|
||||
try {
|
||||
log = require("npmlog")
|
||||
} catch (er) {
|
||||
var util = require("util")
|
||||
log = { warn: function (m) {
|
||||
console.warn(m + " " + util.format.apply(util, [].slice.call(arguments, 1)))
|
||||
} }
|
||||
}
|
||||
|
||||
exports.Umask = Umask
|
||||
function Umask () {}
|
||||
function validateUmask (data, k, val) {
|
||||
return umask.validate(data, k, val)
|
||||
}
|
||||
|
||||
function validateSemver (data, k, val) {
|
||||
if (!semver.valid(val)) return false
|
||||
data[k] = semver.valid(val)
|
||||
}
|
||||
|
||||
function validateStream (data, k, val) {
|
||||
if (!(val instanceof Stream)) return false
|
||||
data[k] = val
|
||||
}
|
||||
|
||||
nopt.typeDefs.semver = { type: semver, validate: validateSemver }
|
||||
nopt.typeDefs.Stream = { type: Stream, validate: validateStream }
|
||||
nopt.typeDefs.Umask = { type: Umask, validate: validateUmask }
|
||||
|
||||
nopt.invalidHandler = function (k, val, type) {
|
||||
log.warn("invalid config", k + "=" + JSON.stringify(val))
|
||||
|
||||
if (Array.isArray(type)) {
|
||||
if (type.indexOf(url) !== -1) type = url
|
||||
else if (type.indexOf(path) !== -1) type = path
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case Umask:
|
||||
log.warn("invalid config", "Must be umask, octal number in range 0000..0777")
|
||||
break
|
||||
case url:
|
||||
log.warn("invalid config", "Must be a full url with 'http://'")
|
||||
break
|
||||
case path:
|
||||
log.warn("invalid config", "Must be a valid filesystem path")
|
||||
break
|
||||
case Number:
|
||||
log.warn("invalid config", "Must be a numeric value")
|
||||
break
|
||||
case Stream:
|
||||
log.warn("invalid config", "Must be an instance of the Stream class")
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (!stableFamily || (+stableFamily.minor % 2)) stableFamily = null
|
||||
else stableFamily = stableFamily.major + "." + stableFamily.minor
|
||||
|
||||
var defaults
|
||||
|
||||
var temp = osenv.tmpdir()
|
||||
var home = osenv.home()
|
||||
|
||||
var uidOrPid = process.getuid ? process.getuid() : process.pid
|
||||
|
||||
if (home) process.env.HOME = home
|
||||
else home = path.resolve(temp, "npm-" + uidOrPid)
|
||||
|
||||
var cacheExtra = process.platform === "win32" ? "npm-cache" : ".npm"
|
||||
var cacheRoot = process.platform === "win32" && process.env.APPDATA || home
|
||||
var cache = path.resolve(cacheRoot, cacheExtra)
|
||||
|
||||
|
||||
var globalPrefix
|
||||
Object.defineProperty(exports, "defaults", {get: function () {
|
||||
if (defaults) return defaults
|
||||
|
||||
if (process.env.PREFIX) {
|
||||
globalPrefix = process.env.PREFIX
|
||||
} else if (process.platform === "win32") {
|
||||
// c:\node\node.exe --> prefix=c:\node\
|
||||
globalPrefix = path.dirname(process.execPath)
|
||||
} else {
|
||||
// /usr/local/bin/node --> prefix=/usr/local
|
||||
globalPrefix = path.dirname(path.dirname(process.execPath))
|
||||
|
||||
// destdir only is respected on Unix
|
||||
if (process.env.DESTDIR) {
|
||||
globalPrefix = path.join(process.env.DESTDIR, globalPrefix)
|
||||
}
|
||||
}
|
||||
|
||||
defaults = {
|
||||
access : null
|
||||
, "always-auth" : false
|
||||
|
||||
, "bin-links" : true
|
||||
, browser : null
|
||||
|
||||
, ca: null
|
||||
, cafile: null
|
||||
|
||||
, cache : cache
|
||||
|
||||
, "cache-lock-stale": 60000
|
||||
, "cache-lock-retries": 10
|
||||
, "cache-lock-wait": 10000
|
||||
|
||||
, "cache-max": Infinity
|
||||
, "cache-min": 10
|
||||
|
||||
, cert: null
|
||||
|
||||
, color : true
|
||||
, depth: Infinity
|
||||
, description : true
|
||||
, dev : false
|
||||
, editor : osenv.editor()
|
||||
, "engine-strict": false
|
||||
, force : false
|
||||
|
||||
, "fetch-retries": 2
|
||||
, "fetch-retry-factor": 10
|
||||
, "fetch-retry-mintimeout": 10000
|
||||
, "fetch-retry-maxtimeout": 60000
|
||||
|
||||
, git: "git"
|
||||
, "git-tag-version": true
|
||||
|
||||
, global : false
|
||||
, globalconfig : path.resolve(globalPrefix, "etc", "npmrc")
|
||||
, group : process.platform === "win32" ? 0
|
||||
: process.env.SUDO_GID || (process.getgid && process.getgid())
|
||||
, heading: "npm"
|
||||
, "if-present": false
|
||||
, "ignore-scripts": false
|
||||
, "init-module": path.resolve(home, ".npm-init.js")
|
||||
, "init-author-name" : ""
|
||||
, "init-author-email" : ""
|
||||
, "init-author-url" : ""
|
||||
, "init-version": "1.0.0"
|
||||
, "init-license": "ISC"
|
||||
, json: false
|
||||
, key: null
|
||||
, link: false
|
||||
, "local-address" : undefined
|
||||
, loglevel : "warn"
|
||||
, logstream : process.stderr
|
||||
, long : false
|
||||
, maxsockets : 50
|
||||
, message : "%s"
|
||||
, "node-version" : process.version
|
||||
, npat : false
|
||||
, "onload-script" : false
|
||||
, optional: true
|
||||
, parseable : false
|
||||
, prefix : globalPrefix
|
||||
, production: process.env.NODE_ENV === "production"
|
||||
, "proprietary-attribs": true
|
||||
, proxy : null
|
||||
, "https-proxy" : null
|
||||
, "user-agent" : "npm/{npm-version} "
|
||||
+ "node/{node-version} "
|
||||
+ "{platform} "
|
||||
+ "{arch}"
|
||||
, "rebuild-bundle" : true
|
||||
, registry : "https://registry.npmjs.org/"
|
||||
, rollback : true
|
||||
, save : false
|
||||
, "save-bundle": false
|
||||
, "save-dev" : false
|
||||
, "save-exact" : false
|
||||
, "save-optional" : false
|
||||
, "save-prefix": "^"
|
||||
, scope : ""
|
||||
, searchopts: ""
|
||||
, searchexclude: null
|
||||
, searchsort: "name"
|
||||
, shell : osenv.shell()
|
||||
, shrinkwrap: true
|
||||
, "sign-git-tag": false
|
||||
, spin: true
|
||||
, "strict-ssl": true
|
||||
, tag : "latest"
|
||||
, "tag-version-prefix" : "v"
|
||||
, tmp : temp
|
||||
, unicode : true
|
||||
, "unsafe-perm" : process.platform === "win32"
|
||||
|| process.platform === "cygwin"
|
||||
|| !( process.getuid && process.setuid
|
||||
&& process.getgid && process.setgid )
|
||||
|| process.getuid() !== 0
|
||||
, usage : false
|
||||
, user : process.platform === "win32" ? 0 : "nobody"
|
||||
, userconfig : path.resolve(home, ".npmrc")
|
||||
, umask: process.umask ? process.umask() : umask.fromString("022")
|
||||
, version : false
|
||||
, versions : false
|
||||
, viewer: process.platform === "win32" ? "browser" : "man"
|
||||
|
||||
, _exit : true
|
||||
}
|
||||
|
||||
return defaults
|
||||
}})
|
||||
|
||||
exports.types =
|
||||
{ access : [null, "restricted", "public"]
|
||||
, "always-auth" : Boolean
|
||||
, "bin-links": Boolean
|
||||
, browser : [null, String]
|
||||
, ca: [null, String, Array]
|
||||
, cafile : path
|
||||
, cache : path
|
||||
, "cache-lock-stale": Number
|
||||
, "cache-lock-retries": Number
|
||||
, "cache-lock-wait": Number
|
||||
, "cache-max": Number
|
||||
, "cache-min": Number
|
||||
, cert: [null, String]
|
||||
, color : ["always", Boolean]
|
||||
, depth : Number
|
||||
, description : Boolean
|
||||
, dev : Boolean
|
||||
, editor : String
|
||||
, "engine-strict": Boolean
|
||||
, force : Boolean
|
||||
, "fetch-retries": Number
|
||||
, "fetch-retry-factor": Number
|
||||
, "fetch-retry-mintimeout": Number
|
||||
, "fetch-retry-maxtimeout": Number
|
||||
, git: String
|
||||
, "git-tag-version": Boolean
|
||||
, global : Boolean
|
||||
, globalconfig : path
|
||||
, group : [Number, String]
|
||||
, "https-proxy" : [null, url]
|
||||
, "user-agent" : String
|
||||
, "heading": String
|
||||
, "if-present": Boolean
|
||||
, "ignore-scripts": Boolean
|
||||
, "init-module": path
|
||||
, "init-author-name" : String
|
||||
, "init-author-email" : String
|
||||
, "init-author-url" : ["", url]
|
||||
, "init-license": String
|
||||
, "init-version": semver
|
||||
, json: Boolean
|
||||
, key: [null, String]
|
||||
, link: Boolean
|
||||
// local-address must be listed as an IP for a local network interface
|
||||
// must be IPv4 due to node bug
|
||||
, "local-address" : getLocalAddresses()
|
||||
, loglevel : ["silent", "error", "warn", "http", "info", "verbose", "silly"]
|
||||
, logstream : Stream
|
||||
, long : Boolean
|
||||
, maxsockets : Number
|
||||
, message: String
|
||||
, "node-version" : [null, semver]
|
||||
, npat : Boolean
|
||||
, "onload-script" : [null, String]
|
||||
, optional: Boolean
|
||||
, parseable : Boolean
|
||||
, prefix: path
|
||||
, production: Boolean
|
||||
, "proprietary-attribs": Boolean
|
||||
, proxy : [null, false, url] // allow proxy to be disabled explicitly
|
||||
, "rebuild-bundle" : Boolean
|
||||
, registry : [null, url]
|
||||
, rollback : Boolean
|
||||
, save : Boolean
|
||||
, "save-bundle": Boolean
|
||||
, "save-dev" : Boolean
|
||||
, "save-exact" : Boolean
|
||||
, "save-optional" : Boolean
|
||||
, "save-prefix": String
|
||||
, scope : String
|
||||
, searchopts : String
|
||||
, searchexclude: [null, String]
|
||||
, searchsort: [ "name", "-name"
|
||||
, "description", "-description"
|
||||
, "author", "-author"
|
||||
, "date", "-date"
|
||||
, "keywords", "-keywords" ]
|
||||
, shell : String
|
||||
, shrinkwrap: Boolean
|
||||
, "sign-git-tag": Boolean
|
||||
, spin: ["always", Boolean]
|
||||
, "strict-ssl": Boolean
|
||||
, tag : String
|
||||
, tmp : path
|
||||
, unicode : Boolean
|
||||
, "unsafe-perm" : Boolean
|
||||
, usage : Boolean
|
||||
, user : [Number, String]
|
||||
, userconfig : path
|
||||
, umask: Umask
|
||||
, version : Boolean
|
||||
, "tag-version-prefix" : String
|
||||
, versions : Boolean
|
||||
, viewer: String
|
||||
, _exit : Boolean
|
||||
}
|
||||
|
||||
function getLocalAddresses () {
|
||||
var interfaces
|
||||
// #8094: some environments require elevated permissions to enumerate
|
||||
// interfaces, and synchronously throw EPERM when run without
|
||||
// elevated privileges
|
||||
try {
|
||||
interfaces = os.networkInterfaces()
|
||||
} catch (e) {
|
||||
interfaces = {}
|
||||
}
|
||||
|
||||
return Object.keys(interfaces).map(function (nic) {
|
||||
return interfaces[nic].filter(function (addr) {
|
||||
return addr.family === 'IPv4'
|
||||
})
|
||||
.map(function (addr) {
|
||||
return addr.address
|
||||
})
|
||||
}).reduce(function (curr, next) {
|
||||
return curr.concat(next)
|
||||
}, []).concat(undefined)
|
||||
}
|
||||
|
||||
exports.shorthands =
|
||||
{ s : ["--loglevel", "silent"]
|
||||
, d : ["--loglevel", "info"]
|
||||
, dd : ["--loglevel", "verbose"]
|
||||
, ddd : ["--loglevel", "silly"]
|
||||
, noreg : ["--no-registry"]
|
||||
, N : ["--no-registry"]
|
||||
, reg : ["--registry"]
|
||||
, "no-reg" : ["--no-registry"]
|
||||
, silent : ["--loglevel", "silent"]
|
||||
, verbose : ["--loglevel", "verbose"]
|
||||
, quiet: ["--loglevel", "warn"]
|
||||
, q: ["--loglevel", "warn"]
|
||||
, h : ["--usage"]
|
||||
, H : ["--usage"]
|
||||
, "?" : ["--usage"]
|
||||
, help : ["--usage"]
|
||||
, v : ["--version"]
|
||||
, f : ["--force"]
|
||||
, gangster : ["--force"]
|
||||
, gangsta : ["--force"]
|
||||
, desc : ["--description"]
|
||||
, "no-desc" : ["--no-description"]
|
||||
, "local" : ["--no-global"]
|
||||
, l : ["--long"]
|
||||
, m : ["--message"]
|
||||
, p : ["--parseable"]
|
||||
, porcelain : ["--parseable"]
|
||||
, g : ["--global"]
|
||||
, S : ["--save"]
|
||||
, D : ["--save-dev"]
|
||||
, E : ["--save-exact"]
|
||||
, O : ["--save-optional"]
|
||||
, y : ["--yes"]
|
||||
, n : ["--no-yes"]
|
||||
, B : ["--save-bundle"]
|
||||
, C : ["--prefix"]
|
||||
}
|
56
node_modules/npm/lib/config/find-prefix.js
generated
vendored
Normal file
56
node_modules/npm/lib/config/find-prefix.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
// try to find the most reasonable prefix to use
|
||||
|
||||
module.exports = findPrefix
|
||||
|
||||
var fs = require("fs")
|
||||
var path = require("path")
|
||||
|
||||
function findPrefix (p, cb_) {
|
||||
function cb (er, p) {
|
||||
process.nextTick(function () {
|
||||
cb_(er, p)
|
||||
})
|
||||
}
|
||||
|
||||
p = path.resolve(p)
|
||||
// if there's no node_modules folder, then
|
||||
// walk up until we hopefully find one.
|
||||
// if none anywhere, then use cwd.
|
||||
var walkedUp = false
|
||||
while (path.basename(p) === "node_modules") {
|
||||
p = path.dirname(p)
|
||||
walkedUp = true
|
||||
}
|
||||
if (walkedUp) return cb(null, p)
|
||||
|
||||
findPrefix_(p, p, cb)
|
||||
}
|
||||
|
||||
function findPrefix_ (p, original, cb) {
|
||||
if (p === "/"
|
||||
|| (process.platform === "win32" && p.match(/^[a-zA-Z]:(\\|\/)?$/))) {
|
||||
return cb(null, original)
|
||||
}
|
||||
fs.readdir(p, function (er, files) {
|
||||
// an error right away is a bad sign.
|
||||
// unless the prefix was simply a non
|
||||
// existent directory.
|
||||
if (er && p === original) {
|
||||
if (er.code === "ENOENT") return cb(null, original);
|
||||
return cb(er)
|
||||
}
|
||||
|
||||
// walked up too high or something.
|
||||
if (er) return cb(null, original)
|
||||
|
||||
if (files.indexOf("node_modules") !== -1
|
||||
|| files.indexOf("package.json") !== -1) {
|
||||
return cb(null, p)
|
||||
}
|
||||
|
||||
var d = path.dirname(p)
|
||||
if (d === p) return cb(null, original)
|
||||
|
||||
return findPrefix_(d, original, cb)
|
||||
})
|
||||
}
|
74
node_modules/npm/lib/config/get-credentials-by-uri.js
generated
vendored
Normal file
74
node_modules/npm/lib/config/get-credentials-by-uri.js
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
var assert = require("assert")
|
||||
|
||||
var toNerfDart = require("./nerf-dart.js")
|
||||
|
||||
module.exports = getCredentialsByURI
|
||||
|
||||
function getCredentialsByURI (uri) {
|
||||
assert(uri && typeof uri === "string", "registry URL is required")
|
||||
var nerfed = toNerfDart(uri)
|
||||
var defnerf = toNerfDart(this.get("registry"))
|
||||
|
||||
// hidden class micro-optimization
|
||||
var c = {
|
||||
scope : nerfed,
|
||||
token : undefined,
|
||||
password : undefined,
|
||||
username : undefined,
|
||||
email : undefined,
|
||||
auth : undefined,
|
||||
alwaysAuth : undefined
|
||||
}
|
||||
|
||||
// used to override scope matching for tokens as well as legacy auth
|
||||
if (this.get(nerfed + ':always-auth') !== undefined) {
|
||||
var val = this.get(nerfed + ':always-auth')
|
||||
c.alwaysAuth = val === 'false' ? false : !!val
|
||||
} else if (this.get('always-auth') !== undefined) {
|
||||
c.alwaysAuth = this.get('always-auth')
|
||||
}
|
||||
|
||||
if (this.get(nerfed + ':_authToken')) {
|
||||
c.token = this.get(nerfed + ':_authToken')
|
||||
// the bearer token is enough, don't confuse things
|
||||
return c
|
||||
}
|
||||
|
||||
// Handle the old-style _auth=<base64> style for the default
|
||||
// registry, if set.
|
||||
//
|
||||
// XXX(isaacs): Remove when npm 1.4 is no longer relevant
|
||||
var authDef = this.get("_auth")
|
||||
var userDef = this.get("username")
|
||||
var passDef = this.get("_password")
|
||||
if (authDef && !(userDef && passDef)) {
|
||||
authDef = new Buffer(authDef, "base64").toString()
|
||||
authDef = authDef.split(":")
|
||||
userDef = authDef.shift()
|
||||
passDef = authDef.join(":")
|
||||
}
|
||||
|
||||
if (this.get(nerfed + ":_password")) {
|
||||
c.password = new Buffer(this.get(nerfed + ":_password"), "base64").toString("utf8")
|
||||
} else if (nerfed === defnerf && passDef) {
|
||||
c.password = passDef
|
||||
}
|
||||
|
||||
if (this.get(nerfed + ":username")) {
|
||||
c.username = this.get(nerfed + ":username")
|
||||
} else if (nerfed === defnerf && userDef) {
|
||||
c.username = userDef
|
||||
}
|
||||
|
||||
if (this.get(nerfed + ":email")) {
|
||||
c.email = this.get(nerfed + ":email")
|
||||
} else if (this.get("email")) {
|
||||
c.email = this.get("email")
|
||||
}
|
||||
|
||||
if (c.username && c.password) {
|
||||
c.auth = new Buffer(c.username + ":" + c.password).toString("base64")
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
34
node_modules/npm/lib/config/load-cafile.js
generated
vendored
Normal file
34
node_modules/npm/lib/config/load-cafile.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
module.exports = loadCAFile
|
||||
|
||||
var fs = require("fs")
|
||||
|
||||
function loadCAFile(cafilePath, cb) {
|
||||
if (!cafilePath)
|
||||
return process.nextTick(cb)
|
||||
|
||||
fs.readFile(cafilePath, "utf8", afterCARead.bind(this))
|
||||
|
||||
function afterCARead(er, cadata) {
|
||||
|
||||
if (er) {
|
||||
// previous cafile no longer exists, so just continue on gracefully
|
||||
if (er.code === 'ENOENT') return cb()
|
||||
return cb(er)
|
||||
}
|
||||
|
||||
var delim = "-----END CERTIFICATE-----"
|
||||
var output
|
||||
|
||||
output = cadata
|
||||
.split(delim)
|
||||
.filter(function(xs) {
|
||||
return !!xs.trim()
|
||||
})
|
||||
.map(function(xs) {
|
||||
return xs.trimLeft() + delim
|
||||
})
|
||||
|
||||
this.set("ca", output)
|
||||
cb(null)
|
||||
}
|
||||
}
|
49
node_modules/npm/lib/config/load-prefix.js
generated
vendored
Normal file
49
node_modules/npm/lib/config/load-prefix.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
module.exports = loadPrefix
|
||||
|
||||
var findPrefix = require("./find-prefix.js")
|
||||
var path = require("path")
|
||||
|
||||
function loadPrefix (cb) {
|
||||
var cli = this.list[0]
|
||||
|
||||
Object.defineProperty(this, "prefix",
|
||||
{ set : function (prefix) {
|
||||
var g = this.get("global")
|
||||
this[g ? "globalPrefix" : "localPrefix"] = prefix
|
||||
}.bind(this)
|
||||
, get : function () {
|
||||
var g = this.get("global")
|
||||
return g ? this.globalPrefix : this.localPrefix
|
||||
}.bind(this)
|
||||
, enumerable : true
|
||||
})
|
||||
|
||||
Object.defineProperty(this, "globalPrefix",
|
||||
{ set : function (prefix) {
|
||||
this.set("prefix", prefix)
|
||||
}.bind(this)
|
||||
, get : function () {
|
||||
return path.resolve(this.get("prefix"))
|
||||
}.bind(this)
|
||||
, enumerable : true
|
||||
})
|
||||
|
||||
var p
|
||||
Object.defineProperty(this, "localPrefix",
|
||||
{ set : function (prefix) { p = prefix },
|
||||
get : function () { return p }
|
||||
, enumerable: true })
|
||||
|
||||
// try to guess at a good node_modules location.
|
||||
// If we are *explicitly* given a prefix on the cli, then
|
||||
// always use that. otherwise, infer local prefix from cwd.
|
||||
if (Object.prototype.hasOwnProperty.call(cli, "prefix")) {
|
||||
p = path.resolve(cli.prefix)
|
||||
process.nextTick(cb)
|
||||
} else {
|
||||
findPrefix(process.cwd(), function (er, found) {
|
||||
p = found
|
||||
cb(er)
|
||||
})
|
||||
}
|
||||
}
|
15
node_modules/npm/lib/config/load-uid.js
generated
vendored
Normal file
15
node_modules/npm/lib/config/load-uid.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
module.exports = loadUid
|
||||
|
||||
var getUid = require("uid-number")
|
||||
|
||||
// Call in the context of a npmconf object
|
||||
|
||||
function loadUid (cb) {
|
||||
// if we're not in unsafe-perm mode, then figure out who
|
||||
// to run stuff as. Do this first, to support `npm update npm -g`
|
||||
if (!this.get("unsafe-perm")) {
|
||||
getUid(this.get("user"), this.get("group"), cb)
|
||||
} else {
|
||||
process.nextTick(cb)
|
||||
}
|
||||
}
|
23
node_modules/npm/lib/config/nerf-dart.js
generated
vendored
Normal file
23
node_modules/npm/lib/config/nerf-dart.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
var url = require("url")
|
||||
|
||||
module.exports = toNerfDart
|
||||
|
||||
/**
|
||||
* Maps a URL to an identifier.
|
||||
*
|
||||
* Name courtesy schiffertronix media LLC, a New Jersey corporation
|
||||
*
|
||||
* @param {String} uri The URL to be nerfed.
|
||||
*
|
||||
* @returns {String} A nerfed URL.
|
||||
*/
|
||||
function toNerfDart(uri) {
|
||||
var parsed = url.parse(uri)
|
||||
delete parsed.protocol
|
||||
delete parsed.auth
|
||||
delete parsed.query
|
||||
delete parsed.search
|
||||
delete parsed.hash
|
||||
|
||||
return url.resolve(url.format(parsed), ".")
|
||||
}
|
42
node_modules/npm/lib/config/set-credentials-by-uri.js
generated
vendored
Normal file
42
node_modules/npm/lib/config/set-credentials-by-uri.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
var assert = require("assert")
|
||||
|
||||
var toNerfDart = require("./nerf-dart.js")
|
||||
|
||||
module.exports = setCredentialsByURI
|
||||
|
||||
function setCredentialsByURI (uri, c) {
|
||||
assert(uri && typeof uri === "string", "registry URL is required")
|
||||
assert(c && typeof c === "object", "credentials are required")
|
||||
|
||||
var nerfed = toNerfDart(uri)
|
||||
|
||||
if (c.token) {
|
||||
this.set(nerfed + ":_authToken", c.token, "user")
|
||||
this.del(nerfed + ":_password", "user")
|
||||
this.del(nerfed + ":username", "user")
|
||||
this.del(nerfed + ":email", "user")
|
||||
this.del(nerfed + ":always-auth", "user")
|
||||
}
|
||||
else if (c.username || c.password || c.email) {
|
||||
assert(c.username, "must include username")
|
||||
assert(c.password, "must include password")
|
||||
assert(c.email, "must include email address")
|
||||
|
||||
this.del(nerfed + ":_authToken", "user")
|
||||
|
||||
var encoded = new Buffer(c.password, "utf8").toString("base64")
|
||||
this.set(nerfed + ":_password", encoded, "user")
|
||||
this.set(nerfed + ":username", c.username, "user")
|
||||
this.set(nerfed + ":email", c.email, "user")
|
||||
|
||||
if (c.alwaysAuth !== undefined) {
|
||||
this.set(nerfed + ":always-auth", c.alwaysAuth, "user")
|
||||
}
|
||||
else {
|
||||
this.del(nerfed + ":always-auth", "user")
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new Error("No credentials to set.")
|
||||
}
|
||||
}
|
29
node_modules/npm/lib/config/set-user.js
generated
vendored
Normal file
29
node_modules/npm/lib/config/set-user.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
module.exports = setUser
|
||||
|
||||
var assert = require("assert")
|
||||
var path = require("path")
|
||||
var fs = require("fs")
|
||||
var mkdirp = require("mkdirp")
|
||||
|
||||
function setUser (cb) {
|
||||
var defaultConf = this.root
|
||||
assert(defaultConf !== Object.prototype)
|
||||
|
||||
// If global, leave it as-is.
|
||||
// If not global, then set the user to the owner of the prefix folder.
|
||||
// Just set the default, so it can be overridden.
|
||||
if (this.get("global")) return cb()
|
||||
if (process.env.SUDO_UID) {
|
||||
defaultConf.user = +(process.env.SUDO_UID)
|
||||
return cb()
|
||||
}
|
||||
|
||||
var prefix = path.resolve(this.get("prefix"))
|
||||
mkdirp(prefix, function (er) {
|
||||
if (er) return cb(er)
|
||||
fs.stat(prefix, function (er, st) {
|
||||
defaultConf.user = st && st.uid
|
||||
return cb(er)
|
||||
})
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user