Skip to content
v7.0.0

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 Typescript v5.0.0+ should be fixed.

  • Listr options disableColor and forceColor have been removed since they were not working as intended. Users are encouraged to use underlying environment variables for colorrette, which are FORCE_COLOR and NO_COLOR.

  • Environment variable LISTR_DISABLE_COLOR has been removed in favor of using the underlying library's NO_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 of rendererOptions and fallbackRendererOptions 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. Now inquirer is also supported addition to initially supported enquirer. Prompts adapters are in their respective packages of @listr2/prompt-adapter-enquirer, @listr2/prompt-adapter-inquirer.

    Old form:

    typescript
    import { 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:

    typescript
    import { 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.

    typescript
    import { 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 with Enquirer, e.g. PromptTypes became EnquirerPromptTypes.

  • Listr option injectWrapper has been removed. This was only being used by the prompt system. Now you can inject an enquirer instance through the adapter directly.

  • There is a new ListrTaskState which is PROMPT_FAILED, that will be emitted whenever a prompt has failed.