'use strict' var path = require('path') var validate = require('aproba') var asyncMap = require('slide').asyncMap var chain = require('slide').chain var npmInstallChecks = require('npm-install-checks') var checkGit = npmInstallChecks.checkGit var clone = require('lodash.clonedeep') var normalizePackageData = require('normalize-package-data') var npm = require('../npm.js') var andFinishTracker = require('./and-finish-tracker.js') var flattenTree = require('./flatten-tree.js') var validateAllPeerDeps = require('./deps.js').validateAllPeerDeps var packageId = require('../utils/package-id.js') module.exports = function (idealTree, log, next) { validate('OOF', arguments) var moduleMap = flattenTree(idealTree) var modules = Object.keys(moduleMap).map(function (name) { return moduleMap[name] }) chain([ [asyncMap, modules, function (mod, done) { chain([ mod.parent && !mod.isLink && [checkGit, mod.realpath], [checkErrors, mod, idealTree] ], done) }], [thenValidateAllPeerDeps, idealTree], [thenCheckTop, idealTree], [thenCheckDuplicateDeps, idealTree] ], andFinishTracker(log, next)) } function checkErrors (mod, idealTree, next) { if (mod.error && (mod.parent || path.resolve(npm.globalDir, '..') !== mod.path)) idealTree.warnings.push(mod.error) next() } function thenValidateAllPeerDeps (idealTree, next) { validate('OF', arguments) validateAllPeerDeps(idealTree, function (tree, pkgname, version) { var warn = new Error(packageId(tree) + ' requires a peer of ' + pkgname + '@' + version + ' but none is installed. You must install peer dependencies yourself.') warn.code = 'EPEERINVALID' idealTree.warnings.push(warn) }) next() } function thenCheckTop (idealTree, next) { validate('OF', arguments) if (idealTree.package.error) return next() // FIXME: when we replace read-package-json with something less magic, // this should done elsewhere. // As it is, the package has already been normalized and thus some // errors are suppressed. var pkg = clone(idealTree.package) try { normalizePackageData(pkg, function (warn) { var warnObj = new Error(packageId(idealTree) + ' ' + warn) warnObj.code = 'EPACKAGEJSON' idealTree.warnings.push(warnObj) }, false) } catch (er) { er.code = 'EPACKAGEJSON' idealTree.warnings.push(er) } var nodeVersion = npm.config.get('node-version') if (/-/.test(nodeVersion)) { // if this is a prerelease node… var warnObj = new Error('You are using a pre-release version of node and things may not work as expected') warnObj.code = 'ENODEPRE' idealTree.warnings.push(warnObj) } next() } // check for deps duplciated between devdeps and regular deps function thenCheckDuplicateDeps (idealTree, next) { var deps = idealTree.package.dependencies || {} var devDeps = idealTree.package.devDependencies || {} for (var pkg in devDeps) { if (pkg in deps) { var warnObj = new Error('The package ' + pkg + ' is included as both a dev and production dependency.') warnObj.code = 'EDUPLICATEDEP' idealTree.warnings.push(warnObj) } } next() }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
action | Folder | 0755 |
|
|
access-error.js | File | 202 B | 0644 |
|
actions.js | File | 5.52 KB | 0644 |
|
and-add-parent-to-errors.js | File | 375 B | 0644 |
|
and-finish-tracker.js | File | 360 B | 0644 |
|
and-ignore-errors.js | File | 204 B | 0644 |
|
audit.js | File | 8.24 KB | 0644 |
|
check-permissions.js | File | 1.85 KB | 0644 |
|
copy-tree.js | File | 770 B | 0644 |
|
decompose-actions.js | File | 2.18 KB | 0644 |
|
deps.js | File | 30.32 KB | 0644 |
|
diff-trees.js | File | 9.12 KB | 0644 |
|
exists.js | File | 775 B | 0644 |
|
flatten-tree.js | File | 1021 B | 0644 |
|
fund.js | File | 1.28 KB | 0644 |
|
get-requested.js | File | 635 B | 0644 |
|
has-modern-meta.js | File | 702 B | 0644 |
|
inflate-bundled.js | File | 628 B | 0644 |
|
inflate-shrinkwrap.js | File | 8.87 KB | 0644 |
|
is-dev-dep.js | File | 175 B | 0644 |
|
is-extraneous.js | File | 618 B | 0644 |
|
is-fs-access-available.js | File | 763 B | 0644 |
|
is-only-dev.js | File | 1.24 KB | 0644 |
|
is-only-optional.js | File | 674 B | 0644 |
|
is-opt-dep.js | File | 185 B | 0644 |
|
is-prod-dep.js | File | 172 B | 0644 |
|
module-staging-path.js | File | 259 B | 0644 |
|
mutate-into-logical-tree.js | File | 4.52 KB | 0644 |
|
node.js | File | 1.85 KB | 0644 |
|
read-shrinkwrap.js | File | 3.67 KB | 0644 |
|
realize-shrinkwrap-specifier.js | File | 621 B | 0644 |
|
report-optional-failure.js | File | 1.02 KB | 0644 |
|
save.js | File | 5.91 KB | 0644 |
|
update-package-json.js | File | 1.87 KB | 0644 |
|
validate-args.js | File | 2.73 KB | 0644 |
|
validate-tree.js | File | 3.1 KB | 0644 |
|
writable.js | File | 1 KB | 0644 |
|