@@ -9,11 +9,10 @@ import { NodeFS, NoopLogger } from '@netlify/build-info/node'
99import { resolveConfig } from '@netlify/config'
1010import { getGlobalConfigStore , LocalState } from '@netlify/dev-utils'
1111import { isCI } from 'ci-info'
12+ import search from '@inquirer/search'
1213import { Command , CommanderError , Help , Option , type OptionValues } from 'commander'
1314import debug from 'debug'
1415import { findUp } from 'find-up'
15- import inquirer from 'inquirer'
16- import inquirerAutocompletePrompt from 'inquirer-autocomplete-prompt'
1716import { deepMerge , pick } from '../utils/object-utilities.js'
1817
1918import { getAgent } from '../lib/http-agent.js'
@@ -36,6 +35,7 @@ import {
3635 logError ,
3736} from '../utils/command-helpers.js'
3837import { handleOptionError , isOptionError } from '../utils/command-error-handler.js'
38+ import { EXIT_CODES } from '../utils/exit-codes.js'
3939import type { FeatureFlags } from '../utils/feature-flags.js'
4040import { getFrameworksAPIPaths } from '../utils/frameworks-api.js'
4141import { getSiteByName } from '../utils/get-site.js'
@@ -52,8 +52,6 @@ type Analytics = {
5252 payload ?: Record < string , unknown >
5353}
5454
55- // load the autocomplete plugin
56- inquirer . registerPrompt ( 'autocomplete' , inquirerAutocompletePrompt )
5755/** Netlify CLI client id. Lives in bot@netlify.com */
5856// TODO: setup client for multiple environments
5957export const CLIENT_ID = 'd6f37de6614df7ae58664cfca524744d73807a377f5ee71f1a254f78412e3750'
@@ -149,13 +147,9 @@ async function selectWorkspace(project: Project, filter?: string): Promise<strin
149147 )
150148 }
151149
152- const { result } = await inquirer . prompt ( {
153- name : 'result' ,
154- // @ts -expect-error(serhalp) -- I think this is because `inquirer-autocomplete-prompt` extends known
155- // `type`s but TS doesn't know about it
156- type : 'autocomplete' ,
150+ return await search ( {
157151 message : 'Select the project you want to work with' ,
158- source : ( _unused : unknown , input = '' ) =>
152+ source : ( input = '' ) =>
159153 ( project . workspace ?. packages || [ ] )
160154 . filter ( ( pkg ) => pkg . path . includes ( input ) )
161155 . map ( ( pkg ) => ( {
@@ -165,8 +159,6 @@ async function selectWorkspace(project: Project, filter?: string): Promise<strin
165159 value : pkg . path ,
166160 } ) ) ,
167161 } )
168-
169- return result
170162 }
171163 return selected . path
172164}
@@ -474,6 +466,11 @@ export default class BaseCommand extends Command {
474466 )
475467 }
476468
469+ // Inquirer prompts reject with this on Ctrl+C, but the error class isn't exported.
470+ if ( error_ instanceof Error && error_ . name === 'ExitPromptError' ) {
471+ return exit ( EXIT_CODES . INTERRUPTED )
472+ }
473+
477474 if ( error_ !== undefined ) {
478475 logError ( error_ instanceof Error ? error_ : format ( error_ ) )
479476 exit ( 1 )
0 commit comments