From 290539b657fe357d46bc185fcce7bb453e7f53d2 Mon Sep 17 00:00:00 2001 From: Daniel Stockman Date: Mon, 13 May 2019 15:42:29 -0700 Subject: [PATCH] feat(version): Add just-in-time queue management --- commands/version/index.js | 16 +++++++--------- commands/version/package.json | 1 + package-lock.json | 1 + 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/commands/version/index.js b/commands/version/index.js index ec23bedca2..fe50aab582 100644 --- a/commands/version/index.js +++ b/commands/version/index.js @@ -17,7 +17,7 @@ const PromptUtilities = require("@lerna/prompt"); const output = require("@lerna/output"); const collectUpdates = require("@lerna/collect-updates"); const { createRunner } = require("@lerna/run-lifecycle"); -const batchPackages = require("@lerna/batch-packages"); +const runTopologically = require("@lerna/run-topologically"); const ValidationError = require("@lerna/validation-error"); const { createGitHubClient, parseGitRepo } = require("@lerna/github-client"); const prereleaseIdFromVersion = require("@lerna/prerelease-id-from-version"); @@ -238,7 +238,6 @@ class VersionCommand extends Command { const tasks = [ () => this.getVersionsForUpdates(), versions => this.setUpdatesForVersions(versions), - () => this.setBatchUpdates(), () => this.confirmVersions(), ]; @@ -441,11 +440,8 @@ class VersionCommand extends Command { this.updatesVersions = versions; } } - } - setBatchUpdates() { this.packagesToVersion = this.updates.map(({ pkg }) => pkg); - this.batchedPackages = batchPackages(this.packagesToVersion, this.options.rejectCycles); } confirmVersions() { @@ -552,10 +548,12 @@ class VersionCommand extends Command { const mapUpdate = pPipe(actions); chain = chain.then(() => - pReduce(this.batchedPackages, (_, batch) => - // TODO: tune the concurrency? - pMap(batch, mapUpdate, { concurrency: 100 }) - ) + runTopologically({ + packages: this.packagesToVersion, + concurrency: this.concurrency, + rejectCycles: this.options.rejectCycles, + runner: mapUpdate, + }) ); if (!independentVersions) { diff --git a/commands/version/package.json b/commands/version/package.json index 6c381ccc64..1062e2d18c 100644 --- a/commands/version/package.json +++ b/commands/version/package.json @@ -45,6 +45,7 @@ "@lerna/prerelease-id-from-version": "file:../../utils/prerelease-id-from-version", "@lerna/prompt": "file:../../core/prompt", "@lerna/run-lifecycle": "file:../../utils/run-lifecycle", + "@lerna/run-topologically": "file:../../utils/run-topologically", "@lerna/validation-error": "file:../../core/validation-error", "chalk": "^2.3.1", "dedent": "^0.7.0", diff --git a/package-lock.json b/package-lock.json index f02bf08f87..761b7a99bb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1256,6 +1256,7 @@ "@lerna/prerelease-id-from-version": "file:utils/prerelease-id-from-version", "@lerna/prompt": "file:core/prompt", "@lerna/run-lifecycle": "file:utils/run-lifecycle", + "@lerna/run-topologically": "file:utils/run-topologically", "@lerna/validation-error": "file:core/validation-error", "chalk": "^2.3.1", "dedent": "^0.7.0",