How to use the inquirer.ui 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 leebenson / reactql / cli / index.js View on Github external
);
            }

            // Add/edit `.reactql` file containing the current version, to enable
            // later upgrades
            fse.writeFileSync(
              path.resolve(installationPath, '.reactql'),
              kit.version
            );

            // Install package dependencies using NPM
            const installer = ['npm', ['i']];

            // Create a bottom bar to display the installation spinner at the bottom
            // of the console.
            const ui = new inquirer.ui.BottomBar({ bottomBar: spinner[0] });

            // Temporary var to track the position of the 'spinner'
            let i = 0;

            // Update the spinner every 300ms, to reflect the installation activity
            const update = setInterval(function () {
              ui.updateBottomBar(`\n${spinner[++i % 4]} Installing modules -- Please wait...`);
            }, 300);

            // Execute yarn/npm as a child process, pipe output to stdout
            spawn(...installer, {cwd: installationPath, stdio: 'pipe'})
              .stdout.pipe(ui.log)
              .on('error', () => fatalError("Couldn't install packages"))
              // When finished, stop the spinner, update with usage instructons and exit
              .on('close', function () {
                clearInterval(update);
github teambit / bit / src / interactive / commands / init-interactive.js View on Github external
export default (async function initInteractive() {
  const ui = new inquirer.ui.BottomBar();

  ui.log.write(TOP_MESSAGE);
  const questions = await _buildQuestions();
  const answers = await inquirer.prompt(questions);
  if (answers.componentsDefaultDirectory === DEFAULT_LOCATION_ANS) {
    // Remove the default location note
    answers.componentsDefaultDirectory = DEFAULT_LOCATION_DIR;
  }
  answers.componentsDefaultDirectory = `${answers.componentsDefaultDirectory}/{name}`;
  let actualCompiler = answers.compiler;
  if (actualCompiler === CUSTOM_COMPILER_ANS) {
    actualCompiler = answers[CUSTOM_COMPILER_PROP_NAME];
    if (actualCompiler.startsWith('bit import')) {
      // remove bit import copied from the bit.dev
      actualCompiler = actualCompiler.replace('bit import ', '');
    }
github teambit / bit / src / interactive / commands / init-interactive.ts View on Github external
export default (async function initInteractive() {
  const ui = new inquirer.ui.BottomBar();

  ui.log.write(TOP_MESSAGE);
  const questions = await _buildQuestions();
  const answers = await inquirer.prompt(questions);
  if (answers.componentsDefaultDirectory === DEFAULT_LOCATION_ANS) {
    // Remove the default location note
    answers.componentsDefaultDirectory = DEFAULT_LOCATION_DIR;
  }
  answers.componentsDefaultDirectory = `${answers.componentsDefaultDirectory}/{name}`;
  let actualCompiler = answers.compiler;
  if (actualCompiler === CUSTOM_COMPILER_ANS) {
    actualCompiler = answers[CUSTOM_COMPILER_PROP_NAME];
    if (actualCompiler.startsWith('bit import')) {
      // remove bit import copied from the bit.dev
      actualCompiler = actualCompiler.replace('bit import ', '');
    }
github webiny / webiny-js / packages / webiny-cli / src / deploy / index.js View on Github external
import path from "path";
import { blue, grey } from "chalk";
import fs from "fs-extra";
import get from "lodash.get";
import inquirer from "inquirer";
import execa from "execa";
import archiver from "archiver";
import tempdir from "temp-dir";
import WebinyCloudSDK from "../sdk/client";
import createLogger from "../logger";
import listPackages from "../utils/listPackages";

const home = homedir();
const webinyConfigPath = path.join(home, ".webiny", "config");
const projectConfigPath = path.resolve(".webiny");
const ui = new inquirer.ui.BottomBar();

export default class Deploy {
    siteId = null;
    accessToken = null;
    sdk = null;
    logger = createLogger();
    packages = {};

    validateCiRequirements() {
        const { WEBINY_ACCESS_TOKEN, WEBINY_SITE_ID } = process.env;
        if (!WEBINY_ACCESS_TOKEN) {
            this.logger.error("WEBINY_ACCESS_TOKEN is not set!");
            process.exit(1);
        }
        if (!WEBINY_SITE_ID) {
            this.logger.error("WEBINY_SITE_ID is not set!");
github anaptfox / serverfy / lib / serverfy.js View on Github external
Serverfy.prototype.runNode = function(paths, options, callback) {
  var self = this;

  self.emit('progress', 'Installing npm modules...');

  var loader = [
    "/ Installing",
    "| Installing",
    "\\ Installing",
    "- Installing"
  ];
  var i = 4;
  var ui = new inquirer.ui.BottomBar({ bottomBar: loader[i % 4] });

  var interval = setInterval(function() {
    ui.updateBottomBar( loader[i++ % 4] );
  }, 300 );

  var spawn = require("child_process").spawn;

  var cmd = spawn(cmdify("npm"), [ "install"], { stdio: "pipe" });
  //cmd.stdout.pipe( ui.log );
  cmd.on( "close", function() {
    ui.updateBottomBar("Installation done!\n");
    clearInterval(interval);
    callback(null);
  });
  
};
github netlify / cli / lib / commands / deploy.js View on Github external
return withPath(config, cmd).then(sanityCheck(config)).then(function(path) {
      var options = {};
      var ui = null;
      var uploaded = 0;

      ui = new inquirer.ui.BottomBar();

      options.draft = cmd.draft;
      options[path.match(/\.zip$/) ? 'zip' : 'dir'] = path;

      options.progress = function(event, data) {
        if (ui == null) {
          return;
        }
        if (event == 'start' && data.total) {
          ui && ui.updateBottomBar("[                                        ] Uploading");
        }
        if (event == 'upload') {
            uploaded++;
            var progress = "[";
            for (var i=0; i<40; i++) {
              if (i<=40*uploaded/data.total) {
github c0bra / deviceframe / cli.js View on Github external
return new Promise(resolve => {
    const ui = new inquirer.ui.BottomBar();

    let frames = [];
    let prompt = null;

    function prompter() {
      prompt = inquirer.prompt({
        type: 'autocomplete',
        name: 'frames',
        message: 'Add the frames you want to use (ESC to complete)',
        source: (answers, input) => {
          input = input || '';
          input = input.toLowerCase();
          return Promise.resolve(
            deviceframe.frames.map(f => f.name.toLowerCase()).filter(name => name.indexOf(input) !== -1)
          );
        },
github curioswitch / curiostack / tools / cloudbuild-github / src / cli / cloudbuild-cli-setup.ts View on Github external
async function setup() {
  const ui = new inquirer.ui.BottomBar();

  const answers = await inquirer.prompt([
    {
      name: 'kms.location',
      message: 'Enter the location for the keyring used to encrypt secrets.',
      default: DEFAULT_KMS_LOCATION,
      validate: (val) => KMS_LOCATIONS.includes(val) || 'Invalid KMS location.',
      when: !program.defaults,
    },
    {
      name: 'kms.keyring',
      message:
        'Enter the name of the keyring used to encrypt secrets. ' +
        'Will be created if it does not exist.',
      default: DEFAULT_KMS_KEYRING,
      when: !program.defaults,
github lifenautjoe / webpack-starter-basic / kickstarter.js View on Github external
const inquirer = require('inquirer');
const ui = new inquirer.ui.BottomBar();
const fs = require('fs');
const rimraf = require('rimraf');

const packageJson = require('./package.json');

async function kickstart() {

    const questions = await inquirer.prompt([
        {
            type: 'input',
            name: 'projectName',
            message: `What's the name of your project? (kebab-cased)`,
            default: 'awesome-project'
        },
        {
            type: 'input',
github mathdroid / path-cli / login.js View on Github external
'use strict'
const request = require('request')
const inquirer = require('inquirer')
const chalk = require('chalk')
const fs = require('fs')

const BottomBar = inquirer.ui.BottomBar

let loader = [
  '/ ',
  '| ',
  '\\ ',
  '- '
]
let i = 4
let loadingInterval
let ui

let userJson = {}
let cb

function showLoadingBar (message) {
  ui = new BottomBar({bottomBar: loader[i % 4] + message})