How to use the prompts.prompt function in prompts

To help you get started, we’ve selected a few prompts 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 prisma / lift / src / Lift.ts View on Github external
const warnings = migrationsWithDbSteps.flatMap(m => m.warnings)

    if (warnings.length > 0 && !autoApprove) {
      if (onWarnings && typeof onWarnings === 'function' && !autoApprove) {
        const ok = await onWarnings(warnings)
        if (!ok) {
          await exit()
        }
      }
      console.log(chalk.bold(`\n\n⚠️  There will be data loss:\n`))
      for (const warning of warnings) {
        console.log(`  • ${warning.description}`)
      }
      console.log() // empty line before prompt
      if (!autoApprove && !onWarnings) {
        const response = await prompt({
          type: 'confirm',
          name: 'value',
          message: `Are you sure you want to apply this change?`,
        })

        if (!response.value) {
          await exit()
        }
      } else {
        console.log(`As ${chalk.bold('--auto-approve')} is provided, the destructive changes are accepted.\n`)
      }
    }

    const progressRenderer = new ProgressRenderer(migrationsWithDbSteps, short || false)

    progressRenderer.render()
github preactjs / preact-cli / packages / cli / lib / commands / create.js View on Github external
module.exports = async function(repo, dest, argv) {
	// Prompt if incomplete data
	if (!repo || !dest) {
		const questions = requestParams(argv);
		const onCancel = () => {
			info('Aborting execution');
			process.exit();
		};
		const response = await prompt(questions, { onCancel });

		Object.assign(argv, response);
		repo = repo || response.template;
		dest = dest || response.dest;
	}

	if (!repo || !dest) {
		warn('Insufficient arguments!');
		info('Alternatively, run `preact create --help` for usage info.');
		return;
	}

	let cwd = resolve(argv.cwd);
	let target = resolve(cwd, dest);
	let isYarn = argv.yarn && hasCommand('yarn');
	let exists = isDir(target);