push all website files

This commit is contained in:
Jacob Levine
2019-01-06 13:14:45 -06:00
parent d7301e26c3
commit d2d5d4c04e
15662 changed files with 2166516 additions and 0 deletions

13
website/node_modules/npm/lib/install/action/build.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
'use strict'
var chain = require('slide').chain
var build = require('../../build.js')
var npm = require('../../npm.js')
var packageId = require('../../utils/package-id.js')
module.exports = function (staging, pkg, log, next) {
log.silly('build', packageId(pkg))
chain([
[build.linkStuff, pkg.package, pkg.path, npm.config.get('global')],
[build.writeBuiltinConf, pkg.package, pkg.path]
], next)
}

View File

@@ -0,0 +1,18 @@
'use strict'
const BB = require('bluebird')
const extract = require('pacote/extract')
const npmlog = require('npmlog')
module.exports = (args, cb) => {
const parsed = typeof args === 'string' ? JSON.parse(args) : args
const spec = parsed[0]
const extractTo = parsed[1]
const opts = parsed[2]
if (!opts.log) {
opts.log = npmlog
}
opts.log.level = opts.loglevel || opts.log.level
BB.resolve(extract(spec, extractTo, opts)).nodeify(cb)
}

136
website/node_modules/npm/lib/install/action/extract.js generated vendored Normal file
View File

@@ -0,0 +1,136 @@
'use strict'
const BB = require('bluebird')
const stat = BB.promisify(require('graceful-fs').stat)
const gentlyRm = BB.promisify(require('../../utils/gently-rm.js'))
const mkdirp = BB.promisify(require('mkdirp'))
const moduleStagingPath = require('../module-staging-path.js')
const move = require('../../utils/move.js')
const npa = require('npm-package-arg')
const npm = require('../../npm.js')
const packageId = require('../../utils/package-id.js')
let pacoteOpts
const path = require('path')
const localWorker = require('./extract-worker.js')
const workerFarm = require('worker-farm')
const isRegistry = require('../../utils/is-registry.js')
const WORKER_PATH = require.resolve('./extract-worker.js')
let workers
// NOTE: temporarily disabled on non-OSX due to ongoing issues:
//
// * Seems to make Windows antivirus issues much more common
// * Messes with Docker (I think)
//
// There are other issues that should be fixed that affect OSX too:
//
// * Logging is messed up right now because pacote does its own thing
// * Global deduplication in pacote breaks due to multiple procs
//
// As these get fixed, we can start experimenting with re-enabling it
// at least on some platforms.
const ENABLE_WORKERS = process.platform === 'darwin'
extract.init = () => {
if (ENABLE_WORKERS) {
workers = workerFarm({
maxConcurrentCallsPerWorker: npm.limit.fetch,
maxRetries: 1
}, WORKER_PATH)
}
return BB.resolve()
}
extract.teardown = () => {
if (ENABLE_WORKERS) {
workerFarm.end(workers)
workers = null
}
return BB.resolve()
}
module.exports = extract
function extract (staging, pkg, log) {
log.silly('extract', packageId(pkg))
const extractTo = moduleStagingPath(staging, pkg)
if (!pacoteOpts) {
pacoteOpts = require('../../config/pacote')
}
const opts = pacoteOpts({
integrity: pkg.package._integrity,
resolved: pkg.package._resolved
})
const args = [
pkg.package._requested,
extractTo,
opts
]
return BB.fromNode((cb) => {
let launcher = localWorker
let msg = args
const spec = typeof args[0] === 'string' ? npa(args[0]) : args[0]
args[0] = spec.raw
if (ENABLE_WORKERS && (isRegistry(spec) || spec.type === 'remote')) {
// We can't serialize these options
opts.loglevel = opts.log.level
opts.log = null
opts.dirPacker = null
// workers will run things in parallel!
launcher = workers
try {
msg = JSON.stringify(msg)
} catch (e) {
return cb(e)
}
}
launcher(msg, cb)
}).then(() => {
if (pkg.package.bundleDependencies || anyBundled(pkg)) {
return readBundled(pkg, staging, extractTo)
}
}).then(() => {
return gentlyRm(path.join(extractTo, 'node_modules'))
})
}
function anyBundled (top, pkg) {
if (!pkg) pkg = top
return pkg.children.some((child) => child.fromBundle === top || anyBundled(top, child))
}
function readBundled (pkg, staging, extractTo) {
return BB.map(pkg.children, (child) => {
if (!child.fromBundle) return
if (child.error) {
throw child.error
} else {
return stageBundledModule(pkg, child, staging, extractTo)
}
}, {concurrency: 10})
}
function stageBundledModule (bundler, child, staging, parentPath) {
const stageFrom = path.join(parentPath, 'node_modules', child.package.name)
const stageTo = moduleStagingPath(staging, child)
return BB.map(child.children, (child) => {
if (child.error) {
throw child.error
} else {
return stageBundledModule(bundler, child, staging, stageFrom)
}
}).then(() => {
return finishModule(bundler, child, stageTo, stageFrom)
})
}
function finishModule (bundler, child, stageTo, stageFrom) {
// If we were the one's who bundled this module…
if (child.fromBundle === bundler) {
return mkdirp(path.dirname(stageTo)).then(() => {
return move(stageFrom, stageTo)
})
} else {
return stat(stageFrom).then(() => gentlyRm(stageFrom), () => {})
}
}

16
website/node_modules/npm/lib/install/action/fetch.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
'use strict'
const BB = require('bluebird')
const finished = BB.promisify(require('mississippi').finished)
const packageId = require('../../utils/package-id.js')
const pacote = require('pacote')
const pacoteOpts = require('../../config/pacote')
module.exports = fetch
function fetch (staging, pkg, log, next) {
log.silly('fetch', packageId(pkg))
const opts = pacoteOpts({integrity: pkg.package._integrity})
return finished(pacote.tarball.stream(pkg.package._requested, opts))
.then(() => next(), next)
}

106
website/node_modules/npm/lib/install/action/finalize.js generated vendored Normal file
View File

@@ -0,0 +1,106 @@
'use strict'
const path = require('path')
const fs = require('graceful-fs')
const Bluebird = require('bluebird')
const rimraf = Bluebird.promisify(require('rimraf'))
const mkdirp = Bluebird.promisify(require('mkdirp'))
const lstat = Bluebird.promisify(fs.lstat)
const readdir = Bluebird.promisify(fs.readdir)
const symlink = Bluebird.promisify(fs.symlink)
const gentlyRm = Bluebird.promisify(require('../../utils/gently-rm'))
const moduleStagingPath = require('../module-staging-path.js')
const move = require('move-concurrently')
const moveOpts = {fs: fs, Promise: Bluebird, maxConcurrency: 4}
const getRequested = require('../get-requested.js')
const log = require('npmlog')
const packageId = require('../../utils/package-id.js')
module.exports = function (staging, pkg, log) {
log.silly('finalize', pkg.realpath)
const extractedTo = moduleStagingPath(staging, pkg)
const delpath = path.join(path.dirname(pkg.realpath), '.' + path.basename(pkg.realpath) + '.DELETE')
let movedDestAway = false
const requested = pkg.package._requested || getRequested(pkg)
if (requested.type === 'directory') {
const relative = path.relative(path.dirname(pkg.path), pkg.realpath)
return makeParentPath(pkg.path)
.then(() => symlink(relative, pkg.path, 'junction'))
.catch((ex) => {
return rimraf(pkg.path).then(() => symlink(relative, pkg.path, 'junction'))
})
} else {
return makeParentPath(pkg.realpath)
.then(moveStagingToDestination)
.then(restoreOldNodeModules)
.catch((err) => {
if (movedDestAway) {
return rimraf(pkg.realpath).then(moveOldDestinationBack).then(() => {
throw err
})
} else {
throw err
}
})
.then(() => rimraf(delpath))
}
function makeParentPath (dir) {
return mkdirp(path.dirname(dir))
}
function moveStagingToDestination () {
return destinationIsClear()
.then(actuallyMoveStaging)
.catch(() => moveOldDestinationAway().then(actuallyMoveStaging))
}
function destinationIsClear () {
return lstat(pkg.realpath).then(() => {
throw new Error('destination exists')
}, () => {})
}
function actuallyMoveStaging () {
return move(extractedTo, pkg.realpath, moveOpts)
}
function moveOldDestinationAway () {
return rimraf(delpath).then(() => {
return move(pkg.realpath, delpath, moveOpts)
}).then(() => { movedDestAway = true })
}
function moveOldDestinationBack () {
return move(delpath, pkg.realpath, moveOpts).then(() => { movedDestAway = false })
}
function restoreOldNodeModules () {
if (!movedDestAway) return
return readdir(path.join(delpath, 'node_modules')).catch(() => []).then((modules) => {
if (!modules.length) return
return mkdirp(path.join(pkg.realpath, 'node_modules')).then(() => Bluebird.map(modules, (file) => {
const from = path.join(delpath, 'node_modules', file)
const to = path.join(pkg.realpath, 'node_modules', file)
return move(from, to, moveOpts)
}))
})
}
}
module.exports.rollback = function (top, staging, pkg) {
return Bluebird.try(() => {
const requested = pkg.package._requested || getRequested(pkg)
if (requested && requested.type === 'directory') return Promise.resolve()
// strictly speaking rolling back a finalize should ONLY remove module that
// was being finalized, not any of the things under it. But currently
// those modules are guaranteed to be useless so we may as well remove them too.
// When/if we separate `commit` step and can rollback to previous versions
// of upgraded modules then we'll need to revisit this…
return gentlyRm(pkg.path, false, top).catch((err) => {
log.warn('rollback', `Rolling back ${packageId(pkg)} failed (this is probably harmless): ${err.message ? err.message : err}`)
})
})
}

View File

@@ -0,0 +1,17 @@
'use strict'
var path = require('path')
var npm = require('../../npm.js')
var Installer = require('../../install.js').Installer
var packageId = require('../../utils/package-id.js')
module.exports = function (staging, pkg, log, next) {
log.silly('global-install', packageId(pkg))
var globalRoot = path.resolve(npm.globalDir, '..')
npm.config.set('global', true)
var install = new Installer(globalRoot, false, [pkg.package.name + '@' + pkg.package._requested.fetchSpec])
install.link = false
install.run(function () {
npm.config.set('global', false)
next.apply(null, arguments)
})
}

View File

@@ -0,0 +1,8 @@
'use strict'
var npm = require('../../npm.js')
var packageId = require('../../utils/package-id.js')
module.exports = function (staging, pkg, log, next) {
log.silly('global-link', packageId(pkg))
npm.link(pkg.package.name, next)
}

View File

@@ -0,0 +1,8 @@
'use strict'
var lifecycle = require('../../utils/lifecycle.js')
var packageId = require('../../utils/package-id.js')
module.exports = function (staging, pkg, log, next) {
log.silly('install', packageId(pkg))
lifecycle(pkg.package, 'install', pkg.path, next)
}

96
website/node_modules/npm/lib/install/action/move.js generated vendored Normal file
View File

@@ -0,0 +1,96 @@
'use strict'
var fs = require('graceful-fs')
var path = require('path')
var chain = require('slide').chain
var iferr = require('iferr')
var rimraf = require('rimraf')
var mkdirp = require('mkdirp')
var rmStuff = require('../../unbuild.js').rmStuff
var lifecycle = require('../../utils/lifecycle.js')
var move = require('../../utils/move.js')
/*
Move a module from one point in the node_modules tree to another.
Do not disturb either the source or target location's node_modules
folders.
*/
module.exports = function (staging, pkg, log, next) {
log.silly('move', pkg.fromPath, pkg.path)
chain([
[lifecycle, pkg.package, 'preuninstall', pkg.fromPath, { failOk: true }],
[lifecycle, pkg.package, 'uninstall', pkg.fromPath, { failOk: true }],
[rmStuff, pkg.package, pkg.fromPath],
[lifecycle, pkg.package, 'postuninstall', pkg.fromPath, { failOk: true }],
[moveModuleOnly, pkg.fromPath, pkg.path, log],
[lifecycle, pkg.package, 'preinstall', pkg.path, { failOk: true }],
[removeEmptyParents, path.resolve(pkg.fromPath, '..')]
], next)
}
function removeEmptyParents (pkgdir, next) {
fs.rmdir(pkgdir, function (er) {
// FIXME: Make sure windows does what we want here
if (er && er.code !== 'ENOENT') return next()
removeEmptyParents(path.resolve(pkgdir, '..'), next)
})
}
function moveModuleOnly (from, to, log, done) {
var fromModules = path.join(from, 'node_modules')
var tempFromModules = from + '.node_modules'
var toModules = path.join(to, 'node_modules')
var tempToModules = to + '.node_modules'
log.silly('move', 'move existing destination node_modules away', toModules)
move(toModules, tempToModules).then(removeDestination(done), removeDestination(done))
function removeDestination (next) {
return function (er) {
log.silly('move', 'remove existing destination', to)
if (er) {
rimraf(to, iferr(next, makeDestination(next)))
} else {
rimraf(to, iferr(next, makeDestination(iferr(next, moveToModulesBack(next)))))
}
}
}
function moveToModulesBack (next) {
return function () {
log.silly('move', 'move existing destination node_modules back', toModules)
move(tempToModules, toModules).then(next, done)
}
}
function makeDestination (next) {
return function () {
log.silly('move', 'make sure destination parent exists', path.resolve(to, '..'))
mkdirp(path.resolve(to, '..'), iferr(done, moveNodeModules(next)))
}
}
function moveNodeModules (next) {
return function () {
log.silly('move', 'move source node_modules away', fromModules)
move(fromModules, tempFromModules).then(doMove(moveNodeModulesBack(next)), doMove(next))
}
}
function doMove (next) {
return function () {
log.silly('move', 'move module dir to final dest', from, to)
move(from, to).then(next, done)
}
}
function moveNodeModulesBack (next) {
return function () {
mkdirp(from, iferr(done, function () {
log.silly('move', 'put source node_modules back', fromModules)
move(tempFromModules, fromModules).then(next, done)
}))
}
}
}

View File

@@ -0,0 +1,8 @@
'use strict'
var lifecycle = require('../../utils/lifecycle.js')
var packageId = require('../../utils/package-id.js')
module.exports = function (staging, pkg, log, next) {
log.silly('postinstall', packageId(pkg))
lifecycle(pkg.package, 'postinstall', pkg.path, next)
}

View File

@@ -0,0 +1,8 @@
'use strict'
var lifecycle = require('../../utils/lifecycle.js')
var packageId = require('../../utils/package-id.js')
module.exports = function (staging, pkg, log, next) {
log.silly('preinstall', packageId(pkg))
lifecycle(pkg.package, 'preinstall', pkg.path, next)
}

27
website/node_modules/npm/lib/install/action/prepare.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
'use strict'
var chain = require('slide').chain
var lifecycle = require('../../utils/lifecycle.js')
var packageId = require('../../utils/package-id.js')
var prepublishWarning = require('../../utils/warn-deprecated.js')('prepublish-on-install')
var moduleStagingPath = require('../module-staging-path.js')
module.exports = function (staging, pkg, log, next) {
log.silly('prepublish', packageId(pkg))
// TODO: for `npm@5`, change the behavior and remove this warning.
// see https://github.com/npm/npm/issues/10074 for details
if (pkg.package && pkg.package.scripts && pkg.package.scripts.prepublish) {
prepublishWarning([
'As of npm@5, `prepublish` scripts are deprecated.',
'Use `prepare` for build steps and `prepublishOnly` for upload-only.',
'See the deprecation note in `npm help scripts` for more information.'
])
}
var buildpath = moduleStagingPath(staging, pkg)
chain(
[
[lifecycle, pkg.package, 'prepublish', buildpath],
[lifecycle, pkg.package, 'prepare', buildpath]
],
next
)
}

View File

@@ -0,0 +1,45 @@
'use strict'
const Bluebird = require('bluebird')
const checkPlatform = Bluebird.promisify(require('npm-install-checks').checkPlatform)
const getRequested = require('../get-requested.js')
const npm = require('../../npm.js')
const path = require('path')
const readJson = Bluebird.promisify(require('read-package-json'))
const updatePackageJson = Bluebird.promisify(require('../update-package-json'))
module.exports = function (staging, pkg, log) {
log.silly('refresh-package-json', pkg.realpath)
return readJson(path.join(pkg.path, 'package.json'), false).then((metadata) => {
Object.keys(pkg.package).forEach(function (key) {
if (key !== 'version' && key !== 'dependencies' && !isEmpty(pkg.package[key])) {
metadata[key] = pkg.package[key]
}
})
if (metadata._resolved == null && pkg.fakeChild) {
metadata._resolved = pkg.fakeChild.resolved
}
// These two sneak in and it's awful
delete metadata.readme
delete metadata.readmeFilename
pkg.package = metadata
pkg.fakeChild = false
}).catch(() => 'ignore').then(() => {
return checkPlatform(pkg.package, npm.config.get('force'))
}).then(() => {
const requested = pkg.package._requested || getRequested(pkg)
if (requested.type !== 'directory') {
return updatePackageJson(pkg, pkg.path)
}
})
}
function isEmpty (value) {
if (value == null) return true
if (Array.isArray(value)) return !value.length
if (typeof value === 'object') return !Object.keys(value).length
return false
}

85
website/node_modules/npm/lib/install/action/remove.js generated vendored Normal file
View File

@@ -0,0 +1,85 @@
'use strict'
var path = require('path')
var fs = require('graceful-fs')
var rimraf = require('rimraf')
var asyncMap = require('slide').asyncMap
var mkdirp = require('mkdirp')
var npm = require('../../npm.js')
var andIgnoreErrors = require('../and-ignore-errors.js')
var move = require('../../utils/move.js')
var isInside = require('path-is-inside')
var vacuum = require('fs-vacuum')
// This is weird because we want to remove the module but not it's node_modules folder
// allowing for this allows us to not worry about the order of operations
module.exports = function (staging, pkg, log, next) {
log.silly('remove', pkg.path)
if (pkg.target) {
removeLink(pkg, next)
} else {
removeDir(pkg, log, next)
}
}
function removeLink (pkg, next) {
var base = isInside(pkg.path, npm.prefix) ? npm.prefix : pkg.path
rimraf(pkg.path, (err) => {
if (err) return next(err)
vacuum(pkg.path, {base: base}, next)
})
}
function removeDir (pkg, log, next) {
var modpath = path.join(path.dirname(pkg.path), '.' + path.basename(pkg.path) + '.MODULES')
move(path.join(pkg.path, 'node_modules'), modpath).then(unbuildPackage, unbuildPackage)
function unbuildPackage (moveEr) {
rimraf(pkg.path, moveEr ? andRemoveEmptyParents(pkg.path) : moveModulesBack)
}
function andRemoveEmptyParents (path) {
return function (er) {
if (er) return next(er)
removeEmptyParents(pkg.path)
}
}
function moveModulesBack () {
fs.readdir(modpath, makeTarget)
}
function makeTarget (readdirEr, files) {
if (readdirEr) return cleanup()
if (!files.length) return cleanup()
mkdirp(path.join(pkg.path, 'node_modules'), function (mkdirEr) { moveModules(mkdirEr, files) })
}
function moveModules (mkdirEr, files) {
if (mkdirEr) return next(mkdirEr)
asyncMap(files, function (file, done) {
var from = path.join(modpath, file)
var to = path.join(pkg.path, 'node_modules', file)
// we ignore errors here, because they can legitimately happen, for instance,
// bundled modules will be in both node_modules folders
move(from, to).then(andIgnoreErrors(done), andIgnoreErrors(done))
}, cleanup)
}
function cleanup () {
rimraf(modpath, afterCleanup)
}
function afterCleanup (rimrafEr) {
if (rimrafEr) log.warn('remove', rimrafEr)
removeEmptyParents(path.resolve(pkg.path, '..'))
}
function removeEmptyParents (pkgdir) {
fs.rmdir(pkgdir, function (er) {
// FIXME: Make sure windows does what we want here
if (er && er.code !== 'ENOENT') return next()
removeEmptyParents(path.resolve(pkgdir, '..'))
})
}
}

16
website/node_modules/npm/lib/install/action/unbuild.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
'use strict'
var Bluebird = require('bluebird')
var lifecycle = Bluebird.promisify(require('../../utils/lifecycle.js'))
var packageId = require('../../utils/package-id.js')
var rmStuff = Bluebird.promisify(require('../../unbuild.js').rmStuff)
module.exports = function (staging, pkg, log) {
log.silly('unbuild', packageId(pkg))
return lifecycle(pkg.package, 'preuninstall', pkg.path, { failOk: true }).then(() => {
return lifecycle(pkg.package, 'uninstall', pkg.path, { failOk: true })
}).then(() => {
return rmStuff(pkg.package, pkg.path)
}).then(() => {
return lifecycle(pkg.package, 'postuninstall', pkg.path, { failOk: true })
})
}