Migration
WARNING
If you encounter any more of the breaking changes, please feel free to contribute by editing this page.
The repository has been converted to a monorepo and some parts of it has been broken down in to smaller packages.
Since this is still a hybrid module transpiled for
cjs
/esm
imports, with the new changes for Typescriptv5.0.0
+ should be fixed.Listr options
disableColor
andforceColor
have been removed since they were not working as intended. Users are encouraged to use underlying environment variables for colorrette, which areFORCE_COLOR
andNO_COLOR
.Environment variable
LISTR_DISABLE_COLOR
has been removed in favor of using the underlying library'sNO_COLOR
option instead to have consistency with other libraries.Task
options
property, which is used for per-renderer task options has been deprecated in favor ofrendererOptions
andfallbackRendererOptions
to define the per-renderer task options. This change has been done to properly inject circular types, as well as, pass task options to fallback renderer.Manager is now its own seperate package that can be installed on demand through
@listr2/manager
.task.prompt
has been refactored to support multiple adapters, this will break the existing behavior but will bring the ability to use different prompt libraries. Nowinquirer
is also supported addition to initially supportedenquirer
. Prompts adapters are in their respective packages of@listr2/prompt-adapter-enquirer
,@listr2/prompt-adapter-inquirer
.Old form:
typescriptimport { Listr } from 'listr2' await new Listr([ { task: async (ctx, task): Promise<void> => { ctx.input = await task.prompt<boolean>({ type: 'Toggle', message: 'Do you love me?' }) } } ]).run()
Can be migrated with ease:
typescriptimport { Listr } from 'listr2' import { ListrEnquirerPromptAdapter } from '@listr2/prompt-adapter-enquirer' await new Listr([ { task: async (ctx, task): Promise<boolean> => { ctx.input = await task.prompt(ListrEnquirerPromptAdapter).run<boolean>({ type: 'Toggle', message: 'Do you love me?' }) } } ]).run()
If you are using it in multiple places like canceling a prompt or asking multiple questions in a prompt, you can assign the adapter to a variable instead.
typescriptimport { Listr } from 'listr2' import { ListrEnquirerPromptAdapter } from '@listr2/prompt-adapter-enquirer' await new Listr([ { task: async (ctx, task): Promise<boolean> => { // create the adapter first const prompt = task.prompt(ListrEnquirerPromptAdapter) ctx.input = await prompt.run<boolean>({ type: 'Toggle', message: 'Do you love me?' }) ctx.input = await prompt.run<boolean>({ type: 'Toggle', message: 'And another one?' }) } } ]).run()
Any
enquirer
related exported types have been prefixed withEnquirer
, e.g.PromptTypes
becameEnquirerPromptTypes
.Listr option
injectWrapper
has been removed. This was only being used by the prompt system. Now you can inject anenquirer
instance through the adapter directly.There is a new
ListrTaskState
which isPROMPT_FAILED
, that will be emitted whenever a prompt has failed.