How to use the inquirer.registerPrompt 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 pingyhq / pingy-cli / packages / cli / init / scaffold.js View on Github external
'use strict';

const ora = require('ora');
const inquirer = require('inquirer');
const pathTree = require('tree-from-paths');
const initLib = require('@pingy/init');
const scaffoldLib = require('@pingy/scaffold-primitive');
const listWithHelpText = require('./promptListWithHelpText');
const { basename } = require('path');

inquirer.registerPrompt('listWithHelpText', listWithHelpText);

const toNodeTree = (baseDir, paths) =>
  `  ${basename(baseDir)}/\n${pathTree
    .render(paths, baseDir, (parent, file) => file)
    .substring(1)
    .split('\n')
    .join('\n  ')}`;

const cwdNodeTree = info => toNodeTree(process.cwd(), info.preparedFiles);

const scaffoldConfirm = filesToWriteTxt =>
  inquirer.prompt([
    {
      type: 'listWithHelpText',
      name: 'doScaffold',
      // TODO: If any existing files exist then put up a red warning.
github Alek-S / select-run / cli.js View on Github external
const packageJsonPath = path.join(process.cwd(), 'package.json');


let packageJson;
try{
	packageJson = require(packageJsonPath);
}
catch(error) {
	// no package.json found
	errorMsg('package.json could not be read, you in the right directory?')
}

console.log(chalk.gray(`path: ${packageJsonPath}\n`) );

/* add checkbox-plus to inquirer prompt type */
inquirer.registerPrompt('checkbox-plus', require('inquirer-checkbox-plus-prompt'));
userInterview();



/**
 * @function userInterview
 * start the user interview with checkbox multi-select
 */
function userInterview () {
	const interviewMessage =
		`Select scripts -- (Press ${chalk.cyan('')} to select,` +
		` ${chalk.cyan('')} to complete)` +
		`\n${chalk.yellow('filter')}: `;

	inquirer
		.prompt({
github shanesmith / gerrit-cli / lib / prompter.js View on Github external
"use strict";

var Q = require("bluebird");
var util = require("util");
var inquirer = require("inquirer");
var inquirerAutocomplete = require("inquirer-autocomplete-prompt");

// injects into String.prototype.....
require("string_score");

inquirer.registerPrompt("autocomplete", inquirerAutocomplete);

var prompter = {};

prompter.confirm = function(text, defaultValue) {
  if (Array.isArray(text)) {
    text = util.format.apply(null, text);
  }
  return prompter.prompt({
    type: "confirm",
    message: text,
    name: "answer",
    default: defaultValue
  }).then(function(answer) {
    return answer.answer;
  });
};
github gpmer / gpm.js / app / gpm.ts View on Github external
import pruneHandler from "./command/prune";
import findHandler from "./command/find";
import removeHandler from "./command/remove";
import {
  IRuntimeOption,
  IAddOption,
  IRemoveOption,
  ICleanOption,
  IRelinkOption,
  IFindOption,
  IPruneOption,
  IListOption
} from "./type";
import { Json$ } from "./registry";

inquirer.registerPrompt(
  "autocomplete",
  require("inquirer-autocomplete-prompt")
);

const pkg = require(path.join(__dirname, "../package.json"));

class Gpm {
  public paths = paths;
  public version: string = pkg.version;
  public description: string = pkg.description;
  private inited = false;
  async runtime(options: IRuntimeOption = {}): Promise {
    return runtimeHandler(options);
  }
  async init() {
    try {
github raulfdm / sub-tv / src / instances.ts View on Github external
import ora from 'ora';
import inquirerLocal from 'inquirer';

inquirerLocal.registerPrompt('autocomplete', require('inquirer-autocomplete-prompt'));

export const inquirer = inquirerLocal;

export const spinner = ora();
github ProofSuite / togen-cli / lib / interface / settings_menu.js View on Github external
require('../utils');

const command = require('inquirer');
const Table = require('cli-table2');
const clear = require('clear');

const questions = require('../questions');
command.registerPrompt('datetime', require('inquirer-datepicker-prompt'));

const Options = require('../options/index.js');
const Display = require('../display.js');
const Config = require('../config.js')

const display = new Display();
const config = new Config();

class SettingsMenu {

  constructor(settings) {
    this.settings = settings || new Options({})
  }

  async start() {
    await this.showConfigurationMenu()
github mokkabonna / inquirer-autocomplete-prompt / example.js View on Github external
/**
 * List prompt example
 */

'use strict';
var inquirer = require('inquirer');
var _ = require('lodash');
var fuzzy = require('fuzzy');

inquirer.registerPrompt('autocomplete', require('./index'));

var states = [
  'Alabama',
  'Alaska',
  'American Samoa',
  'Arizona',
  'Arkansas',
  'California',
  'Colorado',
  'Connecticut',
  'Delaware',
  'District Of Columbia',
  'Federated States Of Micronesia',
  'Florida',
  'Georgia',
  'Guam',
github jaebradley / getmethefuckthere / src / LocationSelector.js View on Github external
import inquirer from 'inquirer';
import inquirerAutocompletePrompt from 'inquirer-autocomplete-prompt';

inquirer.registerPrompt('autocomplete', inquirerAutocompletePrompt);

class LocationSelector {
  constructor(googleMapsService) {
    this.googleMapsService = googleMapsService;
    this.locations = {};
  }

  parseLocations(locations) {
    const choices = [];
    locations.results.forEach(({ geometry, formatted_address: formattedAddress }) => {
      const location = {
        latitude: geometry.location.lat,
        longitude: geometry.location.lng,
      };
      this.locations[formattedAddress] = location;
      choices.push({ name: formattedAddress, short: formattedAddress });
github contentful / contentful-cli / lib / cmds / guide.js View on Github external
const { log, wrappedLog } = require('../utils/log')
const { asciiText } = require('../utils/text')
const { handleAsyncError: handle } = require('../utils/async')

const loginStep = require('../guide/step-login')
const seedStep = require('../guide/step-seed')
const createSpaceStep = require('../guide/step-create-space')
const setupStep = require('../guide/step-setup')
const devServerStep = require('../guide/step-dev-server')
const finishStep = require('../guide/step-finish')

const { AbortedError, GUIDE_MAX_WIDTH } = require('../guide/helpers')
const { errorStyle, pathStyle } = require('../utils/styles')

inquirer.registerPrompt('directory', selectDirectory)

const guides = {
  'starter-nuxt-blog': {
    name: 'Nuxt Starter Blog',
    directoryName: 'contentful-nuxt-blog',
    repository: 'contentful/blog-in-5-minutes',
    seed: 'blog',
    setupConfig: async ({
      managementToken,
      deliveryToken,
      spaceId,
      installationDirectory
    }) => {
      const config = await bfj.read(
        join(installationDirectory, '.contentful.sample.json')
      )
github SS-React / react-prime / cli / cliQuestions.js View on Github external
const inquirer = require('inquirer');
const chalk = require('chalk');

const {
  cliFileMethods, folderDir, fileList, htmlList,
} = require('./cliFileMethods');

inquirer.registerPrompt('autocomplete', require('inquirer-autocomplete-prompt'));

const cliQuestions = [
  {
    type: 'autocomplete',
    name: 'static',
    suggestOnly: true,
    message: chalk.rgb(46, 255, 0)('Type the directory containing your bundle:'),
    source: cliFileMethods.searchFolders,
    validate(answer) {
      if (!folderDir.includes(answer)) {
        return chalk.rgb(255, 0, 0).bold('Invalid entry point');
      }
      return true;
    },
  },
  {