Skip to content

Conversation

@romaricpascal
Copy link
Member

@romaricpascal romaricpascal commented Aug 22, 2025

Note

This is a follow up to changes introduced in #2461

Prompts have been removed from inquirer since 10.0.0, so we need to migrate our use of inquirer.prompt to the standalone confirm prompt offered by @inquirer/prompt.

It does simplify the code a little as the prompt call now returns the users answers, without having to give each prompt a name and picking the value in an answers object.

The replacement has happened like for like, leaving the check for whether being run in a "text terminal" when asking for the usage data, but not if changing port. It doesn't add any new test either.


// npm dependencies
const inquirer = require('inquirer')
const {default: confirm} = require('@inquirer/confirm')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note @inquirer/confirm assigns the actual confirm function to module.exports.default rather than module.exports itself so we need a little renaming here.

when: () => process.stdout.isTTY,
default: false
}]).then(answers => answers.usageData)
async function askForUsageDataPermission () {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note Using async ensures the function returns a Promise if the if block doesn't run. This is not critical as the code calling askForUsageForDataPermission is called with an await rather than using .then, but better safe than sorry.

.then would throw if askForUsageDataPermission returned undefined while await will happily use undefined as a return value on the next tick of the event loop.

Prompts have been removed from `inquirer` since 10.0.0,
so we need to migrate our use of `inquirer.prompt` to the standalone
`confirm` prompt offered by `@inquirer/prompt`.

It does simplify the code a little as the prompt call now returns
the users answers, without having to give each prompt a name and picking the value
in an `answers` object.

The replacement has happened like for like, leaving the check for whether
being [run in a "text terminal"](https://nodejs.org/api/tty.html#tty) when asking
for the usage data, but not if changing port. It doesn't add any new test either.
@romaricpascal romaricpascal marked this pull request as ready for review August 22, 2025 13:57
Copy link
Contributor

@owenatgov owenatgov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tidying this up! Sorry for not catching it in my original PR.

This whole saga probably a changelog entry since we're changing a user-facing dependency, but I can handle that next week.

@36degrees
Copy link
Contributor

This whole saga probably a changelog entry since we're changing a user-facing dependency, but I can handle that next week.

As I understand it, since we fixed it so that npm-shrinkwrap.json is now correctly included in the package, the kit's dependencies exist in a separate space to the user's prototype, so they can no longer use the kit's dependencies without installing them separately anyway – see #2457.

There probably should be something in the changelog (especially if this fix goes out by itself. Maybe just something like 'Update from inquirer 8.2.6 to @inquirer/confirm 5.1.15 to address a vulnerability in tmp'?

We can't use jest.replaceProperty here because in a non-TTY environment the isTTY property _does not exist_ on process.stdout, and Jest will only replace existing properties.

The tests ran fine locally but were failing on CI with:

“Property `isTTY` does not exist in the provided object”
@36degrees
Copy link
Contributor

I've pushed a couple of additional commits to add a changelog entry and and also to tests for the 'usage data' side of things – ideally it'd be good to cover findAPortNotInUse but testing a function with callbacks is hurting my poor little Friday brain.

@36degrees 36degrees merged commit 4456a5a into main Sep 11, 2025
33 checks passed
@36degrees 36degrees deleted the use-inquirer-prompts branch September 11, 2025 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants