From d8d33f7bdc7e87ec0a014ccdffeefbd87517d86b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Mon, 7 Oct 2019 20:02:40 +0200 Subject: [PATCH] fix(bootstrap): Run lifecycle scripts in topological queue instead of batches (#2224) --- commands/bootstrap/index.js | 18 +++++++++--------- commands/bootstrap/package.json | 3 +-- package-lock.json | 17 +---------------- 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/commands/bootstrap/index.js b/commands/bootstrap/index.js index 360fb03dca..dc5034d2a4 100644 --- a/commands/bootstrap/index.js +++ b/commands/bootstrap/index.js @@ -14,8 +14,7 @@ const rimrafDir = require("@lerna/rimraf-dir"); const hasNpmVersion = require("@lerna/has-npm-version"); const npmInstall = require("@lerna/npm-install"); const { createRunner } = require("@lerna/run-lifecycle"); -const batchPackages = require("@lerna/batch-packages"); -const runParallelBatches = require("@lerna/run-parallel-batches"); +const runTopologically = require("@lerna/run-topologically"); const symlinkBinary = require("@lerna/symlink-binary"); const symlinkDependencies = require("@lerna/symlink-dependencies"); const ValidationError = require("@lerna/validation-error"); @@ -178,10 +177,6 @@ class BootstrapCommand extends Command { }); chain = chain.then(() => { - this.batchedPackages = this.toposort - ? batchPackages(this.filteredPackages, this.options.rejectCycles) - : [this.filteredPackages]; - if (npmClient === "yarn" && !mutex) { return getPort({ port: 42424, host: "0.0.0.0" }).then(port => { this.npmConfig.mutex = `network:${port}`; @@ -281,9 +276,14 @@ class BootstrapCommand extends Command { tracker.addWork(this.filteredPackages.length); - return pFinally(runParallelBatches(this.batchedPackages, this.concurrency, mapPackageWithScript), () => - tracker.finish() - ); + const runner = this.toposort + ? runTopologically(this.filteredPackages, mapPackageWithScript, { + concurrency: this.concurrency, + rejectCycles: this.options.rejectCycles, + }) + : pMap(this.filteredPackages, mapPackageWithScript, { concurrency: this.concurrency }); + + return pFinally(runner, () => tracker.finish()); } hoistedDirectory(dependency) { diff --git a/commands/bootstrap/package.json b/commands/bootstrap/package.json index 25fcb0374b..2344435f96 100644 --- a/commands/bootstrap/package.json +++ b/commands/bootstrap/package.json @@ -36,7 +36,6 @@ "populate--": true }, "dependencies": { - "@lerna/batch-packages": "file:../../utils/batch-packages", "@lerna/command": "file:../../core/command", "@lerna/filter-options": "file:../../core/filter-options", "@lerna/has-npm-version": "file:../../utils/has-npm-version", @@ -45,7 +44,7 @@ "@lerna/pulse-till-done": "file:../../utils/pulse-till-done", "@lerna/rimraf-dir": "file:../../utils/rimraf-dir", "@lerna/run-lifecycle": "file:../../utils/run-lifecycle", - "@lerna/run-parallel-batches": "file:../../utils/run-parallel-batches", + "@lerna/run-topologically": "file:../../utils/run-topologically", "@lerna/symlink-binary": "file:../../utils/symlink-binary", "@lerna/symlink-dependencies": "file:../../utils/symlink-dependencies", "@lerna/validation-error": "file:../../core/validation-error", diff --git a/package-lock.json b/package-lock.json index 938bbac640..284b70f939 100644 --- a/package-lock.json +++ b/package-lock.json @@ -777,17 +777,9 @@ "semver": "^6.2.0" } }, - "@lerna/batch-packages": { - "version": "file:utils/batch-packages", - "requires": { - "@lerna/package-graph": "file:core/package-graph", - "npmlog": "^4.1.2" - } - }, "@lerna/bootstrap": { "version": "file:commands/bootstrap", "requires": { - "@lerna/batch-packages": "file:utils/batch-packages", "@lerna/command": "file:core/command", "@lerna/filter-options": "file:core/filter-options", "@lerna/has-npm-version": "file:utils/has-npm-version", @@ -796,7 +788,7 @@ "@lerna/pulse-till-done": "file:utils/pulse-till-done", "@lerna/rimraf-dir": "file:utils/rimraf-dir", "@lerna/run-lifecycle": "file:utils/run-lifecycle", - "@lerna/run-parallel-batches": "file:utils/run-parallel-batches", + "@lerna/run-topologically": "file:utils/run-topologically", "@lerna/symlink-binary": "file:utils/symlink-binary", "@lerna/symlink-dependencies": "file:utils/symlink-dependencies", "@lerna/validation-error": "file:core/validation-error", @@ -1298,13 +1290,6 @@ "npmlog": "^4.1.2" } }, - "@lerna/run-parallel-batches": { - "version": "file:utils/run-parallel-batches", - "requires": { - "p-map": "^2.1.0", - "p-map-series": "^1.0.0" - } - }, "@lerna/run-topologically": { "version": "file:utils/run-topologically", "requires": {