From 6383d9f4ff984db03a75092ac73fbed938071dc3 Mon Sep 17 00:00:00 2001 From: XadillaX Date: Mon, 6 Jun 2022 14:50:51 +0800 Subject: [PATCH] fix: broken enquirer in listr2 Refs: https://github.com/cenk1cenk2/listr2/issues/631 Fixes: https://github.com/nodejs/node-core-utils/issues/603 --- lib/update-v8/applyNodeChanges.js | 7 ++++++- lib/update-v8/backport.js | 19 ++++++++++++++++--- lib/update-v8/index.js | 11 ++++++++++- lib/update-v8/majorUpdate.js | 7 ++++++- lib/update-v8/minorUpdate.js | 7 ++++++- lib/update-v8/updateV8Clone.js | 7 ++++++- lib/update-v8/updateVersionNumbers.js | 7 ++++++- package.json | 1 + 8 files changed, 57 insertions(+), 9 deletions(-) diff --git a/lib/update-v8/applyNodeChanges.js b/lib/update-v8/applyNodeChanges.js index 806e1d25..3dbfd246 100644 --- a/lib/update-v8/applyNodeChanges.js +++ b/lib/update-v8/applyNodeChanges.js @@ -1,5 +1,6 @@ import path from 'node:path'; +import Enquirer from 'enquirer'; import { Listr } from 'listr2'; import { @@ -22,7 +23,11 @@ export default function applyNodeChanges() { task: async(ctx) => { const v8Version = await getNodeV8Version(ctx.nodeDir); const list = filterForVersion(nodeChanges, v8Version); - return new Listr(list.map((change) => change.task())); + return new Listr(list.map((change) => change.task()), { + injectWrapper: { + enquirer: new Enquirer() + } + }); } }; } diff --git a/lib/update-v8/backport.js b/lib/update-v8/backport.js index 8bc86c5a..d3d2fca0 100644 --- a/lib/update-v8/backport.js +++ b/lib/update-v8/backport.js @@ -3,6 +3,7 @@ import { promises as fs } from 'node:fs'; +import Enquirer from 'enquirer'; import inquirer from 'inquirer'; import { Listr } from 'listr2'; @@ -50,7 +51,11 @@ export function doBackport(options) { return { title: 'V8 commit backport', task: () => { - return new Listr(todo); + return new Listr(todo, { + injectWrapper: { + enquirer: new Enquirer() + } + }); } }; }; @@ -168,7 +173,11 @@ function applyAndCommitPatches() { return { title: 'Apply and commit patches to deps/v8', task: (ctx) => { - return new Listr(ctx.patches.map(applyPatchTask)); + return new Listr(ctx.patches.map(applyPatchTask), { + injectWrapper: { + enquirer: new Enquirer() + } + }); } }; } @@ -191,7 +200,11 @@ function applyPatchTask(patch) { } } todo.push(commitPatch(patch)); - return new Listr(todo); + return new Listr(todo, { + injectWrapper: { + enquirer: new Enquirer() + } + }); } }; } diff --git a/lib/update-v8/index.js b/lib/update-v8/index.js index cbb528ae..0fa6c536 100644 --- a/lib/update-v8/index.js +++ b/lib/update-v8/index.js @@ -1,3 +1,4 @@ +import Enquirer from 'enquirer'; import { Listr } from 'listr2'; import { checkOptions, doBackport } from './backport.js'; @@ -33,8 +34,16 @@ export async function backport(options) { return tasks.run(options); }; +/** + * Get the listr2 options. + * @param {{ verbose?: boolean }} options The original options. + * @return {import('listr2').ListrOptions} The listr2 options. + */ function getOptions(opts) { return { - renderer: opts.verbose ? 'verbose' : 'default' + renderer: opts.verbose ? 'verbose' : 'default', + injectWrapper: { + enquirer: new Enquirer() + } }; } diff --git a/lib/update-v8/majorUpdate.js b/lib/update-v8/majorUpdate.js index cf376ffd..10d74826 100644 --- a/lib/update-v8/majorUpdate.js +++ b/lib/update-v8/majorUpdate.js @@ -1,6 +1,7 @@ import path from 'node:path'; import { promises as fs } from 'node:fs'; +import Enquirer from 'enquirer'; import { execa } from 'execa'; import { Listr } from 'listr2'; @@ -28,7 +29,11 @@ export default function majorUpdate() { addDepsV8(), updateV8Deps(), applyNodeChanges() - ]); + ], { + injectWrapper: { + enquirer: new Enquirer() + } + }); } }; }; diff --git a/lib/update-v8/minorUpdate.js b/lib/update-v8/minorUpdate.js index cb5bc8fc..0c50d0fb 100644 --- a/lib/update-v8/minorUpdate.js +++ b/lib/update-v8/minorUpdate.js @@ -1,6 +1,7 @@ import path from 'node:path'; import { promises as fs } from 'node:fs'; +import Enquirer from 'enquirer'; import { execa } from 'execa'; import { Listr } from 'listr2'; @@ -14,7 +15,11 @@ export default function minorUpdate() { getCurrentV8Version(), getLatestV8Version(), doMinorUpdate() - ]); + ], { + injectWrapper: { + enquirer: new Enquirer() + } + }); } }; }; diff --git a/lib/update-v8/updateV8Clone.js b/lib/update-v8/updateV8Clone.js index 37004af2..1f8fb5eb 100644 --- a/lib/update-v8/updateV8Clone.js +++ b/lib/update-v8/updateV8Clone.js @@ -1,5 +1,6 @@ import { promises as fs } from 'node:fs'; +import Enquirer from 'enquirer'; import { execa } from 'execa'; import { Listr } from 'listr2'; @@ -9,7 +10,11 @@ export default function updateV8Clone() { return { title: 'Update local V8 clone', task: () => { - return new Listr([fetchOrigin(), createClone()]); + return new Listr([fetchOrigin(), createClone()], { + injectWrapper: { + enquirer: new Enquirer() + } + }); } }; }; diff --git a/lib/update-v8/updateVersionNumbers.js b/lib/update-v8/updateVersionNumbers.js index 5c832e08..abbe6b45 100644 --- a/lib/update-v8/updateVersionNumbers.js +++ b/lib/update-v8/updateVersionNumbers.js @@ -1,6 +1,7 @@ import path from 'node:path'; import { promises as fs } from 'node:fs'; +import Enquirer from 'enquirer'; import { Listr } from 'listr2'; import { getNodeV8Version } from './util.js'; @@ -9,7 +10,11 @@ export default function updateVersionNumbers() { return { title: 'Update version numbers', task: () => { - return new Listr([resetEmbedderString(), bumpNodeModule()]); + return new Listr([resetEmbedderString(), bumpNodeModule()], { + injectWrapper: { + enquirer: new Enquirer() + } + }); } }; }; diff --git a/package.json b/package.json index 65d6f851..b7641bb0 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "cheerio": "^1.0.0-rc.10", "clipboardy": "^3.0.0", "core-validate-commit": "^3.16.0", + "enquirer": "^2.3.6", "execa": "^6.1.0", "figures": "^4.0.1", "form-data": "^4.0.0",