How to use listr - 10 common examples

To help you get started, we’ve selected a few listr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github leecade / fe / src / commands / build.js View on Github external
// Make default config
  let config = webpackProdConfig(env)

  // Merge custom config
  try {
    config = require(path.join(env.CONFIG_DIR, 'webpack.config.prod.js'))(config, env)
  } catch (err) {
  }

  const compiler = webpack(config)

  let sizeMap = null
  let buildStats = null

  const tasks = new Listr([{
    title: 'Build',
    task: () => new Listr([{
      title: 'Prepare resources',
      task: async () => {
        sizeMap = await calcSizeMap(env.BUILD_DIR)
      }
    }, {
      title: 'Clean build folder',
      task: async () => rimraf.sync(env.BUILD_DIR + '/*')
    }, {
      title: 'Compile static resources',
      task: () => new Promise((resolve, reject) =>
        compiler.run(async (err, stats) => {
          if (err) reject(err)
          if (stats.compilation.errors.length) reject(stats.compilation.errors)
          buildStats = stats
github flux-capacitor / flux-capacitor / packages / flux-capacitor-cli / src / commands / init.js View on Github external
async function initInDirectory (print, destPath, database) {
  const templatePath = path.resolve(__dirname, '..', '..', 'template')
  const dbDriverPackage = getDbDriverPackage(database)

  const generatedFiles = [ '.env' ]
  const optionalGeneratedFiles = [ '.gitignore' ]
  const templateFiles = await recursiveFileList(templatePath)
  const packageJsonPath = await locateOrCreatePackageJson(destPath, print)

  print('')   // just for the newline

  await new Listr([
    step('Copy boilerplate files', async () => {
      await assertFilesCanBeCopied(destPath, templateFiles.concat(generatedFiles))
      await copyTemplate(templatePath, templateFiles, destPath)
    }),
    step('Create .gitignore & .env file', async () => {
      await createDotFiles(destPath, { database })
    }),
    step('Update package.json', async () => {
      await patchPackageJson(packageJsonPath, path.join(destPath, 'store.js'), path.join(destPath, 'server.js'))
    }),
    step('Install dependencies', async () => {
      const packages = templateDependencies.concat([ dbDriverPackage ])
      await installPackages(packages, destPath)
    })
  ]).run()
}
github aragon / aragon-cli / packages / cli / src / commands / dao_cmds / token_cmds / new.js View on Github external
// Decode sender
  const accounts = await web3.eth.getAccounts()
  const from = accounts[0]

  // Get chain id
  const chainId = await web3.eth.net.getId()

  if (chainId === 1)
    tokenFactoryAddress = tokenFactoryAddress || MAINNET_MINIME_TOKEN_FACTORY

  if (chainId === 4)
    tokenFactoryAddress = tokenFactoryAddress || RINKEBY_MINIME_TOKEN_FACTORY

  transferEnabled = parseArgumentStringIfPossible(transferEnabled)

  return new TaskList(
    [
      {
        title: 'Deploy the MiniMeTokenFactory contract',
        enabled: () => !web3Utils.isAddress(tokenFactoryAddress),
        task: async (ctx, task) => {
          const handleProgress = (step, data) => {
            switch (step) {
              case 1:
                task.output = 'Estimating gas...'
                break
              case 2:
                task.output = `Estimated gas: ${data}`
                break
              case 3:
                task.output = 'Waiting for the transaction to be mined...'
                break
github okonet / lint-staged / test / index2.spec.js View on Github external
it('should pass debug flag to Listr', async () => {
    expect.assertions(1)
    await lintStaged(
      {
        configPath: path.join(__dirname, '__mocks__', 'my-config.json'),
        debug: true
      },
      console
    )
    expect(Listr.mock.calls[0][1]).toEqual({ dateFormat: false, renderer: 'verbose' })
  })
})
github okonet / lint-staged / test / index2.spec.js View on Github external
it('should pass quiet flag to Listr', async () => {
    expect.assertions(1)
    await lintStaged(
      { configPath: path.join(__dirname, '__mocks__', 'my-config.json'), quiet: true },
      console
    )
    expect(Listr.mock.calls[0][1]).toEqual({ dateFormat: false, renderer: 'silent' })
  })
github vitwit / JS-SDKGen / src / main.js View on Github external
try {
    await access(jsonFileDir, fs.constants.R_OK);

    if (jsFile) {
      await access(jsFile, fs.constants.R_OK);
    }
  } catch (err) {
    console.error(
      "%s does not exist or invalid or no permission to read",
      chalk.red.bold("ERROR")
    );

    process.exit(1);
  }

  const tasks = new Listr(
    [
      {
        title: "Generating Sdk...",
        task: () => generateSDK(options)
      }
    ],
    {
      exitOnError: false
    }
  );

  await tasks.run();

  console.log(
    `
    %s sdk folder generated successfully with required files
github contentful / contentful-migration / src / bin / cli.ts View on Github external
if (options.skipConfirmation) {
      return { applyMigration: true }
    }

    return inquirer.prompt([{
      type: 'confirm',
      message: 'Do you want to apply the migration',
      name: 'applyMigration'
    }])
  }

  const answers = await confirm({ skipConfirmation: argv.yes })

  if (answers.applyMigration) {
    try {
      const successfulMigration = await (new Listr(tasks)).run()
      console.log(chalk`🎉  {bold.green Migration successful}`)
      return successfulMigration
    } catch (err) {
      console.error(chalk`🚨  {bold.red Migration unsuccessful}`)
      console.error(chalk`{red ${err.message}}\n`)
      err.errors.forEach((err) => console.error(chalk`{red ${err}}\n\n`))
      await Promise.all(serverErrorsWritten)
      console.error(`Please check the errors log for more details: ${errorsFile}`)
      terminate(err)
    }
  } else {
    console.warn(chalk`⚠️  {bold.yellow Migration aborted}`)
  }
}
github aragon / aragon-cli / packages / cli / src / commands / dao_cmds / token_cmds / change-controller.js View on Github external
export const handler = async function({
  reporter,
  gasPrice,
  network,
  tokenAddress,
  newController,
  silent,
  debug,
}) {
  const web3 = await ensureWeb3(network)
  let txReceipt

  const tasks = new TaskList(
    [
      {
        title: 'Changing the MiniMe token controller',
        task: async () => {
          txReceipt = await changeController(
            web3,
            tokenAddress,
            newController,
            gasPrice
          )
        },
      },
    ],
    listrOpts(silent, debug)
  )
github aragon / aragon-cli / packages / cli / src / commands / devchain_cmds / status.js View on Github external
export const task = async ({ port, reset, silent, debug }) => {
  return new TaskList(
    [
      {
        title: 'Check port',
        task: async ctx => {
          ctx.portTaken = await isPortTaken(port)
          if (ctx.portTaken) {
            const processData = await find('port', port)
            ctx.processID = processData[0].pid
          }
        },
      },
      {
        title: 'Kill running process',
        enabled: ctx => ctx.portTaken && reset,
        task: async ctx => {
          await execa('kill', [ctx.processID])

listr

Terminal task list

MIT
Latest version published 6 years ago

Package Health Score

67 / 100
Full package analysis

Popular listr functions