Comparing version 2.0.0-beta.24 to 2.0.0-beta.25
@@ -44,3 +44,3 @@ "use strict"; | ||
callback(err || stderr); | ||
callback(err || stderr, stdout); | ||
} else { | ||
@@ -47,0 +47,0 @@ callback(null, stdout); |
@@ -44,2 +44,4 @@ "use strict"; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -96,4 +98,11 @@ | ||
// As packages are completed their names will go into this object. | ||
var donePackages = {}; | ||
// This maps package names to the number of packages that depend on them. | ||
// As packages are completed their names will be removed from this object. | ||
var pendingDeps = {}; | ||
todoPackages.forEach(function (pkg) { | ||
return filteredGraph.get(pkg.name).dependencies.forEach(function (dep) { | ||
if (!pendingDeps[dep]) pendingDeps[dep] = 0; | ||
pendingDeps[dep]++; | ||
}); | ||
}); | ||
@@ -113,6 +122,16 @@ // Bootstrap runs the "prepublish" script in each package. This script | ||
return !node.dependencies.filter(function (dep) { | ||
return !donePackages[dep]; | ||
return pendingDeps[dep]; | ||
}).length; | ||
}); | ||
// If we weren't able to find a package with no remaining dependencies, | ||
// then we've encountered a cycle in the dependency graph. Run a | ||
// single-package batch with the package that has the most dependents. | ||
if (todoPackages.length && !batch.length) { | ||
_this3.logger.warning("Encountered a cycle in the dependency graph. " + "This may cause instability if dependencies are used during `prepublish`."); | ||
batch.push(todoPackages.reduce(function (a, b) { | ||
return (pendingDeps[a.name] || 0) > (pendingDeps[b.name] || 0) ? a : b; | ||
})); | ||
} | ||
_async2.default.parallelLimit(batch.map(function (pkg) { | ||
@@ -127,6 +146,8 @@ return function (done) { | ||
}, function (cb) { | ||
return _this3.linkBinariesForPackage(pkg, cb); | ||
}, function (cb) { | ||
return _this3.runPrepublishForPackage(pkg, cb); | ||
}], function (err) { | ||
_this3.progressBar.tick(pkg.name); | ||
donePackages[pkg.name] = true; | ||
delete pendingDeps[pkg.name]; | ||
todoPackages.splice(todoPackages.indexOf(pkg), 1); | ||
@@ -215,5 +236,37 @@ done(err); | ||
}, { | ||
key: "linkBinariesForPackage", | ||
value: function linkBinariesForPackage(pkg, callback) { | ||
var _this6 = this; | ||
var actions = this.packages.filter(function (dep) { | ||
return _this6.hasMatchingDependency(pkg, dep) && dep.bin; | ||
}).map(function (dep) { | ||
return function (cb) { | ||
return _this6.createBinaryLink(pkg, dep, cb); | ||
}; | ||
}); | ||
_async2.default.parallelLimit(actions, this.concurrency, callback); | ||
} | ||
}, { | ||
key: "createBinaryLink", | ||
value: function createBinaryLink(pkg, dep, callback) { | ||
var dest = _path2.default.join(pkg.nodeModulesLocation, ".bin"); | ||
// The `bin` in a package.json may be either a string or an object. | ||
// Normalize to an object. | ||
var bins = typeof dep.bin === "string" ? _defineProperty({}, dep.name, dep.bin) : dep.bin; | ||
_async2.default.series([function (cb) { | ||
return _FileSystemUtilities2.default.mkdirp(dest, cb); | ||
}].concat(Object.keys(bins).map(function (name) { | ||
return function (cb) { | ||
return _FileSystemUtilities2.default.symlink(_path2.default.join(dep.location, bins[name]), _path2.default.join(dest, name), cb); | ||
}; | ||
})), callback); | ||
} | ||
}, { | ||
key: "installExternalPackages", | ||
value: function installExternalPackages(pkg, callback) { | ||
var _this6 = this; | ||
var _this7 = this; | ||
@@ -223,9 +276,9 @@ var allDependencies = pkg.allDependencies; | ||
var externalPackages = Object.keys(allDependencies).filter(function (dependency) { | ||
var match = (0, _lodash2.default)(_this6.packages, function (pkg) { | ||
var match = (0, _lodash2.default)(_this7.packages, function (pkg) { | ||
return pkg.name === dependency; | ||
}); | ||
return !(match && _this6.hasMatchingDependency(pkg, match)); | ||
return !(match && _this7.hasMatchingDependency(pkg, match)); | ||
}).filter(function (dependency) { | ||
return !_this6.hasDependencyInstalled(pkg, dependency); | ||
return !_this7.hasDependencyInstalled(pkg, dependency); | ||
}).map(function (dependency) { | ||
@@ -232,0 +285,0 @@ return dependency + "@" + allDependencies[dependency]; |
@@ -210,39 +210,39 @@ "use strict"; | ||
} else if (!this.repository.isIndependent()) { | ||
this.promptVersion(null, this.globalVersion, function (err, version) { | ||
if (err) { | ||
callback(err); | ||
} else { | ||
callback(null, { version: version }); | ||
} | ||
}); | ||
this.promptVersion(null, this.globalVersion, function (err, version) { | ||
if (err) { | ||
callback(err); | ||
} else { | ||
callback(null, { version: version }); | ||
} | ||
}); | ||
// Independent Canary Mode | ||
} else if (this.flags.canary) { | ||
(function () { | ||
var versions = {}; | ||
var canaryVersionSuffix = _this4.getCanaryVersionSuffix(); | ||
// Independent Canary Mode | ||
} else if (this.flags.canary) { | ||
(function () { | ||
var versions = {}; | ||
var canaryVersionSuffix = _this4.getCanaryVersionSuffix(); | ||
_this4.updates.forEach(function (update) { | ||
versions[update.package.name] = update.package.version + canaryVersionSuffix; | ||
}); | ||
_this4.updates.forEach(function (update) { | ||
versions[update.package.name] = update.package.version + canaryVersionSuffix; | ||
}); | ||
callback(null, { versions: versions }); | ||
callback(null, { versions: versions }); | ||
// Independent Non-Canary Mode | ||
})(); | ||
} else { | ||
_async2.default.mapLimit(this.updates, 1, function (update, cb) { | ||
_this4.promptVersion(update.package.name, update.package.version, cb); | ||
}, function (err, versions) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
// Independent Non-Canary Mode | ||
})(); | ||
} else { | ||
_async2.default.mapLimit(this.updates, 1, function (update, cb) { | ||
_this4.promptVersion(update.package.name, update.package.version, cb); | ||
}, function (err, versions) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
_this4.updates.forEach(function (update, index) { | ||
versions[update.package.name] = versions[index]; | ||
}); | ||
_this4.updates.forEach(function (update, index) { | ||
versions[update.package.name] = versions[index]; | ||
}); | ||
callback(null, { versions: versions }); | ||
}); | ||
} | ||
callback(null, { versions: versions }); | ||
}); | ||
} | ||
} | ||
@@ -249,0 +249,0 @@ }, { |
@@ -111,6 +111,5 @@ "use strict"; | ||
_NpmUtilities2.default.runScriptInDir(this.script, this.args, pkg.location, function (err, stdout) { | ||
_this5.logger.info(stdout); | ||
if (err) { | ||
_this5.logger.error("Errored while running npm script '" + _this5.script + "' in '" + pkg.name + "'", err); | ||
} else { | ||
_this5.logger.info(stdout); | ||
} | ||
@@ -117,0 +116,0 @@ callback(err); |
@@ -10,3 +10,3 @@ "use strict"; | ||
var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _desc, _value, _class; | ||
var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _desc, _value, _class; | ||
@@ -72,3 +72,3 @@ var _pathExists = require("path-exists"); | ||
var FileSystemUtilities = (_dec = _logger2.default.logifySync, _dec2 = _logger2.default.logifyAsync, _dec3 = _logger2.default.logifyAsync, _dec4 = _logger2.default.logifySync, _dec5 = _logger2.default.logifyAsync, _dec6 = _logger2.default.logifySync, _dec7 = _logger2.default.logifySync, _dec8 = _logger2.default.logifyAsync, _dec9 = _logger2.default.logifySync, (_class = function () { | ||
var FileSystemUtilities = (_dec = _logger2.default.logifySync, _dec2 = _logger2.default.logifyAsync, _dec3 = _logger2.default.logifySync, _dec4 = _logger2.default.logifySync, _dec5 = _logger2.default.logifyAsync, _dec6 = _logger2.default.logifySync, _dec7 = _logger2.default.logifySync, _dec8 = _logger2.default.logifyAsync, _dec9 = _logger2.default.logifyAsync, _dec10 = _logger2.default.logifySync, (_class = function () { | ||
function FileSystemUtilities() { | ||
@@ -119,2 +119,16 @@ _classCallCheck(this, FileSystemUtilities); | ||
}, { | ||
key: "symlink", | ||
value: function symlink(src, dest, callback) { | ||
_fs2.default.lstat(dest, function (err) { | ||
if (!err) { | ||
// Something exists at `dest`. Need to remove it first. | ||
_fs2.default.unlink(dest, function () { | ||
return _fs2.default.symlink(src, dest, callback); | ||
}); | ||
} else { | ||
_fs2.default.symlink(src, dest, callback); | ||
} | ||
}); | ||
} | ||
}, { | ||
key: "unlinkSync", | ||
@@ -127,4 +141,4 @@ value: function unlinkSync(filePath) { | ||
return FileSystemUtilities; | ||
}(), (_applyDecoratedDescriptor(_class, "mkdirSync", [_dec], Object.getOwnPropertyDescriptor(_class, "mkdirSync"), _class), _applyDecoratedDescriptor(_class, "mkdirp", [_dec2], Object.getOwnPropertyDescriptor(_class, "mkdirp"), _class), _applyDecoratedDescriptor(_class, "readdirSync", [_dec3], Object.getOwnPropertyDescriptor(_class, "readdirSync"), _class), _applyDecoratedDescriptor(_class, "existsSync", [_dec4], Object.getOwnPropertyDescriptor(_class, "existsSync"), _class), _applyDecoratedDescriptor(_class, "writeFile", [_dec5], Object.getOwnPropertyDescriptor(_class, "writeFile"), _class), _applyDecoratedDescriptor(_class, "writeFileSync", [_dec6], Object.getOwnPropertyDescriptor(_class, "writeFileSync"), _class), _applyDecoratedDescriptor(_class, "readFileSync", [_dec7], Object.getOwnPropertyDescriptor(_class, "readFileSync"), _class), _applyDecoratedDescriptor(_class, "rimraf", [_dec8], Object.getOwnPropertyDescriptor(_class, "rimraf"), _class), _applyDecoratedDescriptor(_class, "unlinkSync", [_dec9], Object.getOwnPropertyDescriptor(_class, "unlinkSync"), _class)), _class)); | ||
}(), (_applyDecoratedDescriptor(_class, "mkdirSync", [_dec], Object.getOwnPropertyDescriptor(_class, "mkdirSync"), _class), _applyDecoratedDescriptor(_class, "mkdirp", [_dec2], Object.getOwnPropertyDescriptor(_class, "mkdirp"), _class), _applyDecoratedDescriptor(_class, "readdirSync", [_dec3], Object.getOwnPropertyDescriptor(_class, "readdirSync"), _class), _applyDecoratedDescriptor(_class, "existsSync", [_dec4], Object.getOwnPropertyDescriptor(_class, "existsSync"), _class), _applyDecoratedDescriptor(_class, "writeFile", [_dec5], Object.getOwnPropertyDescriptor(_class, "writeFile"), _class), _applyDecoratedDescriptor(_class, "writeFileSync", [_dec6], Object.getOwnPropertyDescriptor(_class, "writeFileSync"), _class), _applyDecoratedDescriptor(_class, "readFileSync", [_dec7], Object.getOwnPropertyDescriptor(_class, "readFileSync"), _class), _applyDecoratedDescriptor(_class, "rimraf", [_dec8], Object.getOwnPropertyDescriptor(_class, "rimraf"), _class), _applyDecoratedDescriptor(_class, "symlink", [_dec9], Object.getOwnPropertyDescriptor(_class, "symlink"), _class), _applyDecoratedDescriptor(_class, "unlinkSync", [_dec10], Object.getOwnPropertyDescriptor(_class, "unlinkSync"), _class)), _class)); | ||
exports.default = FileSystemUtilities; | ||
module.exports = exports["default"]; |
@@ -64,2 +64,7 @@ "use strict"; | ||
}, { | ||
key: "bin", | ||
get: function get() { | ||
return this._package.bin; | ||
} | ||
}, { | ||
key: "dependencies", | ||
@@ -66,0 +71,0 @@ get: function get() { |
{ | ||
"name": "lerna", | ||
"version": "2.0.0-beta.24", | ||
"version": "2.0.0-beta.25", | ||
"description": "Tool for managing JavaScript projects with multiple packages", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -433,2 +433,32 @@ <p align="center"> | ||
### Common `devDependencies` | ||
Most `devDependencies` can be pulled up to the root of a Lerna repo. | ||
This has a few benefits: | ||
- All packages use the same version of a given dependency | ||
- Can keep dependencies at the root up-to-date with an automated tool such as [GreenKeeper](https://greenkeeper.io/) | ||
- Dependency installation time is reduced | ||
- Less storage is needed | ||
Note that `devDependencies` providing "binary" executables that are used by | ||
npm scripts still need to be installed directly in each package where they're | ||
used. | ||
For example the `nsp` dependency is necessary in this case for `lerna run nsp` | ||
(and `npm run nsp` within the package's directory) to work correctly: | ||
```json | ||
{ | ||
"scripts": { | ||
"nsp": "nsp" | ||
}, | ||
"devDependencies": { | ||
"nsp": "^2.3.3" | ||
} | ||
} | ||
``` | ||
### Flags | ||
@@ -453,3 +483,3 @@ | ||
```sh | ||
$ lerna run --scope toolbar-* -- ls -la | ||
$ lerna run --scope toolbar-* test | ||
``` | ||
@@ -456,0 +486,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
156564
2870
522