How to use the inquirer.createPromptModule 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 popomore / projj / lib / base_command.js View on Github external
* prompt(questions) {
    if (!this[PROMPT]) {
      // create a self contained inquirer module.
      this[PROMPT] = inquirer.createPromptModule();
      const promptMapping = this[PROMPT].prompts;
      for (const key of Object.keys(promptMapping)) {
        const Clz = promptMapping[key];
        // extend origin prompt instance to emit event
        promptMapping[key] = class CustomPrompt extends Clz {
          /* istanbul ignore next */
          static get name() { return Clz.name; }
          run() {
            process.send && process.send({ type: 'prompt', name: this.opt.name });
            process.emit('message', { type: 'prompt', name: this.opt.name });
            return super.run();
          }
        };
      }
    }
    return this[PROMPT](questions);
github devisle / advanced-react-cli / cliRoutes / ReactComponent / mainReactComponent.js View on Github external
const inquirer = require('inquirer')

// Cli Model
const cliModel = require('../../cliModel')
const reactComponents = cliModel.reactComponents
const installFolder = cliModel.installFolder
const addPackage = cliModel.addPackage
const componentName = cliModel.componentName

// Component Dependencies
const FunctionComponent = require('./functionComponent')
const ClassComponent = require('./classComponent')

const prompt = inquirer.createPromptModule()

/*

  Generates a React Component based on user inputs

*/
module.exports = class ReactComponent {
  // Prompts User for Component type
  componentPrompt () {
    prompt(reactComponents).then(({ component }) => {
      this.componentName(component)
    })
  }
  // Prompts User for Component Name
  componentName (component) {
    prompt(componentName).then(({ componentName }) => {
github devisle / advanced-react-cli / lib / cliRoutes / TypeScript / types / node.js View on Github external
var errorLogging = require('../../../customNodeCMD/customError') // CLI Model

var cliModel = require('../../../cliModel/index')

var installOption = cliModel.installOption // Cli Install Commands

var _require = require('../../../cliModel/install-commands'),
  TypeScriptReactObj = _require.TypeScriptReactObj

var typesNode = TypeScriptReactObj.typesNode

var _require2 = require('../../../cliModel/install-commands-yarn'),
  TypeScriptReactObjYarn = _require2.TypeScriptReactObjYarn

var typesNodeYarn = TypeScriptReactObjYarn.typesNodeYarn
var prompt = inquirer.createPromptModule()
/*

  Installs @types/nodes

*/

module.exports =
  /*#__PURE__*/
  (function () {
    function TypesNodes () {
      ;(0, _classCallCheck2['default'])(this, TypesNodes)
    }

    ;(0, _createClass2['default'])(TypesNodes, [
      {
        key: 'installOrUninstall',
github devisle / advanced-react-cli / cliRoutes / CRA / cra.js View on Github external
const inquirer = require('inquirer')

// Cli Model
const cliModel = require('../../cliModel')
const addPackage = cliModel.addPackage
const installFolder = cliModel.installFolder
const YarnOrNpm = cliModel.YarnOrNpm

//Import CRA Install Dependencies
const installAll = require('./installAll')
const installCRA = require('./installCRA')
const installCRAandReactRouter = require('./installCRAandReactRouter')
const installCRAandRedux = require('./installCRAandRedux')

const prompt = inquirer.createPromptModule()

/*

  Installs a Boilerplate react application using Create-react-app + optional packages

*/
module.exports = class CRA {
  CRAPrompt () {
    prompt(YarnOrNpm).then(({ packageManager }) => {
      const packageInstaller = packageManager
      prompt({
        ...installFolder[0],
        message: 'Please give project name, example (my-app)'
      }).then(({ folderName }) => {
        if (folderName.length > 1) {
          /*
github devisle / advanced-react-cli / lib / cliRoutes / CustomPackageInstall / index.js View on Github external
var customCMD = require('../../customNodeCMD')

var errorLogging = require('../../customNodeCMD/customError') // Cli Model

var cliModel = require('../../cliModel')

var multiplePackageInstall = cliModel.multiplePackageInstall
var YarnOrNpm = cliModel.YarnOrNpm

var _require = require('../../cliModel/install-commands'),
  createReactApp = _require.createReactApp

var _require2 = require('../../cliModel/install-commands-yarn'),
  createReactAppYarn = _require2.createReactAppYarn

var _prompt = inquirer.createPromptModule()
/*

  Installs A React Application with Custom Packages

*/

module.exports =
  /*#__PURE__*/
  (function () {
    function CustomPackageInstall () {
      ;(0, _classCallCheck2['default'])(this, CustomPackageInstall)
    }

    ;(0, _createClass2['default'])(CustomPackageInstall, [
      {
        key: 'prompt',
github devisle / advanced-react-cli / lib / cliRoutes / StateManagement / unstated.js View on Github external
var errorLogging = require('../../customNodeCMD/customError') // Cli Model

var cliModel = require('../../cliModel/index')

var installOption = cliModel.installOption // Cli Install Commands

var _require = require('../../cliModel/install-commands'),
  unstatedObj = _require.unstatedObj

var unstated = unstatedObj.unstated

var _require2 = require('../../cliModel/install-commands-yarn'),
  unstatedObjYarn = _require2.unstatedObjYarn

var unstatedYarn = unstatedObjYarn.unstatedYarn
var prompt = inquirer.createPromptModule()

module.exports =
  /*#__PURE__*/
  (function () {
    function Unstated () {
      ;(0, _classCallCheck2['default'])(this, Unstated)
    }

    ;(0, _createClass2['default'])(Unstated, [
      {
        key: 'installOrUninstall',
        value: function installOrUninstall (packageInstaller) {
          var _this = this

          prompt(installOption).then(function (_ref) {
            var decision = _ref.decision
github boijs / boi / bin / features / new.js View on Github external
'use strict'

let path = require('path');
let Promise = require("bluebird");
let chalk = require('chalk');
let _ = require('lodash');
let inquirer = require('inquirer');

require('shelljs/global');

// 默认app name
const DEFAULT_NAME = 'app';

let prompt = inquirer.createPromptModule();

let info = {
    appname: DEFAULT_NAME,
    projtype: '',
    modules: [],
    boiPlugins: [],
    thirdparty: []
};

let qs_appname = {
    type: 'input',
    name: 'appname',
    message: 'Give your app a nice name',
    default: 'app',
    validate: function(input) {
        // 命名规范,只能包含英文字母和.
github jchip / create-my-card / src / index.js View on Github external
function getInput() {
  let existCardInfo = {};
  const prompt = Inquirer.createPromptModule();

  const questions = [
    {
      type: "input",
      name: "name",
      message: "Please enter your name:",
      default: () => existCardInfo.name,
      validate: x => {
        if (x) return true;
        return "Must provide name for your card";
      }
    },
    {
      type: "input",
      name: "handle",
      message: "Please enter your handle:",
github davidedantonio / create-fastify-app / generators / mysql / index.js View on Github external
async function generate (args, cb) {
  const opts = parseArgs(args)
  if (opts.help) {
    return showHelp()
  }

  const dir = opts.directory || process.cwd()
  const pluginPath = path.join(dir, 'app', 'plugins')

  try {
    await isValidFastifyProject(dir, null)
  } catch (e) {
    return cb(e)
  }

  const prompt = inquirer.createPromptModule()
  const answers = await prompt([
    { type: 'input', name: 'mysql_host', message: 'Host: ', default: 'localhost' },
    { type: 'input', name: 'mysql_port', message: 'Port: ', default: '3306' },
    { type: 'input', name: 'mysql_database', message: 'Database: ', default: 'fastify' },
    { type: 'input', name: 'mysql_user', message: 'User: ', default: 'root' },
    { type: 'input', name: 'mysql_password', message: 'Password: ' }
  ])

  try {
    await generatePlugin(pluginPath, answers)
  } catch (e) {
    return cb(e)
  }

  log('success', 'MySQL plugin correctly configured with given information')
}
github rung-tools / rung-cli / src / boilerplate.js View on Github external
function askQuestions() {
    return request.get('https://app.rung.com.br/api/categories')
        .then(prop('body') & map(({ name, alias: value }) => ({ name, value })))
        .catch(~[{ name: 'Miscellaneous', value: 'miscellaneous' }])
        .then(categories => [
            { name: 'name', message: 'Project name', default: getDefaultName(process.cwd()) },
            { name: 'version', message: 'Version', default: '1.0.0', validate: semver.valid & Boolean },
            { name: 'title', message: 'Title', default: 'Untitled' },
            { name: 'description', message: 'Description' },
            { name: 'category', type: 'list', message: 'Category', default: 'miscellaneous', choices: categories },
            { name: 'license', message: 'license', default: 'MIT' }
        ])
        .then(inquirer.createPromptModule());
}