How to use the inquirer.prompt function in inquirer

To help you get started, we’ve selected a few inquirer 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 expo / expo / tools / expotools / src / commands / PromoteVersionsToProduction.ts View on Github external
// amount of time so that the cache is invalidated before fetching from prod
  await new Promise(resolve => setTimeout(resolve, 10));

  Config.api.host = PRODUCTION_HOST;
  const versionsProd = await Versions.versionsAsync();
  const delta = jsondiffpatch.diff(versionsProd, versionsStaging);

  if (!delta) {
    console.log(chalk.yellow('There are no changes to apply in the configuration.'));
    return;
  }

  console.log(`Here is the diff from ${chalk.green('staging')} -> ${chalk.green('production')}:`);
  console.log(jsondiffpatch.formatters.console.format(delta, versionsProd));

  const { isCorrect } = await inquirer.prompt<{ isCorrect: boolean }>([
    {
      type: 'confirm',
      name: 'isCorrect',
      message: `Does this look correct? Type \`y\` to update ${chalk.green('production')} config.`,
      default: false,
    },
  ]);

  if (isCorrect) {
    // Promote staging configuration to production.
    await Versions.setVersionsAsync(versionsStaging);

    console.log(
      chalk.green('\nSuccessfully updated production config. You can check it out on'),
      chalk.blue(`https://${PRODUCTION_HOST}/--/api/v2/versions`)
    );
github Fitbit / fitbit-sdk-toolchain / src / newProject.ts View on Github external
const packageJSON = fsExtra.readJSONSync(packageJSONPath);
  const config = normalizeProjectConfig(packageJSON);

  // Extract the member to a variable so that type guards work properly.
  const packageName = packageJSON.name;

  const defaultDisplayName =
    typeof packageName === 'string' ? lodash.startCase(packageName) : undefined;

  const {
    appType,
    appDisplayName,
    withCompanion,
    withSettings,
    enabledBuildTargets,
  }: ProjectCreationArgs = await inquirer.prompt([
    {
      name: 'appType',
      type: 'list',
      choices: Object.values(AppType),
      message: 'What type of application should be created?',
    },
    {
      name: 'appDisplayName',
      message: 'What should the name of this application be?',
      // Inquirer will not allow a default that fails validation
      // to be submited.
      default: defaultDisplayName,
      validate: validateDisplayName,
    },
    {
      name: 'withCompanion',
github aws-amplify / amplify-cli / packages / amplify-category-predictions / provider-utils / awscloudformation / prediction-category-walkthroughs / infer-walkthrough.js View on Github external
async function followUpQuestions(context, questionObj, inferType, defaultValues, parameters) {
  const answers = await inquirer.prompt(questionObj.endpointPrompt(parameters));
  if (answers.endpointConfig === 'import') {
    // attempt to get existing endpoints
    Object.assign(answers, await getEndpoints(context, questionObj, parameters));
  }
  if (answers.endpointConfig === 'create') {
    // create endpoint in console
    await createEndpoint(context, defaultValues);
    // import existing endpoint
    Object.assign(answers, await getEndpoints(context, questionObj, parameters));
  }

  Object.assign(answers, await inquirer.prompt(questionObj.authAccess.prompt(parameters)));
  return answers;
}
github aws-amplify / amplify-cli / packages / amplify-category-analytics / provider-utils / awscloudformation / service-walkthroughs / pinpoint-walkthrough.js View on Github external
choices: inputs[i].options,
        },
        question
      );
    } else {
      question = Object.assign(
        {
          type: 'input',
        },
        question
      );
    }
    questions.push(question);
  }

  return inquirer.prompt(questions).then(async answers => {
    answers[inputs[0].key] = answers[inputs[1].key];
    Object.assign(defaultValues, answers);
    const resource = defaultValues.resourceName;

    // Check for authorization rules and settings

    const { checkRequirements, externalAuthEnable } = require('amplify-category-auth');

    const apiRequirements = {
      authSelections: 'identityPoolOnly',
      allowUnauthenticatedIdentities: true,
    };
    // getting requirement satisfaction map
    const satisfiedRequirements = await checkRequirements(apiRequirements, context, 'api', answers.resourceName);
    // checking to see if any requirements are unsatisfied
    const foundUnmetRequirements = Object.values(satisfiedRequirements).includes(false);
github xtremespb / zoia2 / bin / pack.js View on Github external
const start = async () => {
    const data = await inquirer.prompt(questions);
    console.log('Creating ZIP archive(s) containing required files...');
    switch (data.mode) {
    case 'API':
        packAPI();
        break;
    case 'Web':
        packWeb();
        break;
    case 'Admin':
        packAdmin();
        break;
    case 'Everything (multiple archives)':
        packAPI();
        packWeb();
        packAdmin();
        break;
github storybookjs / storybook / scripts / run-registry.js View on Github external
const askForPublish = (packages, url, version) =>
  inquirer
    .prompt([
      {
        type: 'confirm',
        message: `${chalk.green('READY TO PUBLISH')} shall we kick off a publish?`,
        name: 'sure',
      },
    ])
    .then(({ sure }) => {
      if (sure) {
        logger.log(`🚀 publishing version ${version}`);
        return publish(packages, url).then(() => askForPublish(packages, url, version));
      }
      return false;
    });
github apollographql / apollo-tooling / packages / apollo / src / commands / config / init.ts View on Github external
async getGlobs(globs: string[], message: string): Promise {
    const {
      glob,
      more
    }: { glob: string; more: boolean } = await inquirer.prompt([
      {
        type: "input",
        name: "glob",
        message
      },
      {
        type: "confirm",
        name: "more",
        message: "Add another pattern?"
      }
    ]);

    const allGlobs = [...globs, glob];
    if (more) {
      return this.getGlobs(allGlobs, message);
    } else {
github wisamjs / theia / lib / theia-helper.js View on Github external
function confirmInstall(type, pckgs) {
  var defer = Q.defer();
  var questions = {
    type: 'confirm',
    name: 'toInstall',
    message: 'npm install --' + type + ' :\n ' + chalk.blue('* ' +
      pckgs.join(
        '\n * ')) + '\n Continue?',
    default: false
  };

  inquirer.prompt(questions,
    function (answer) {
      if (!answer.toInstall) {
        defer.reject();
      }
      defer.resolve(pckgs);


    });
  return defer.promise;
}
github ProofSuite / togen-cli / lib / interface / deployer_menu.js View on Github external
async showDeploySettingsMenu() {
    display.message.deployerSettingsMenu()
    let menu = questions.deployerSettingsMenu({additionalFields: ['Back']})
    const options = await command.prompt(menu);

    if (options.choice === 'Show deployment settings') {
      await this.showDeploymentSettings()
      await this.showDeploySettingsMenu()
    }
    if (options.choice === 'Default Network/Wallet') {
      await this.showDefaultNetworkAndWalletForm()
      await this.showDeploySettingsMenu()
    }
    else if (options.choice === 'Configure Infura Token') {
      await this.showInfuraTokenForm()
      await this.showDeploySettingsMenu()
    }
    else if (options.choice === 'Configure Gas Options') {
      await this.showGasOptionsForm()
      await this.showDeploySettingsMenu()
github wordup-dev / wordup-cli / src / prompts / installation.js View on Github external
let transformed = val
        if (val.length > 1) {
          const lastDigit = val.substr(-1)
          transformed = lastDigit.padStart(val.length, '*')
        }
        return transformed
      },
      validate: function (val) {
        if (!val) {
          return 'Please provide a key'
        }
        return true
      },
    }]

    const answers = await inquirer.prompt(questions)

    this.privateKey = answers.privateKey

    if(answers.url){
      const wpInstall = 'wordup-connect:'+answers.url
      if(this.project){
        this.project.setWordupPkg('wpInstall',wpInstall)
      }else{
        return wpInstall
      }
    }

  }