const listProcesses = async (processes, flags) => { inquirer.registerPrompt('autocomplete', require('inquirer-autocomplete-prompt')); const answer = await inquirer.prompt([{ name: 'processes', message: 'Running processes:', type: 'autocomplete', pageSize: 10, source: async (answers, input) => filterProcesses(input, processes, flags) }]); try { await fkill(answer.processes); } catch (_) { handleFkillError(answer.processes); } }
const handleFkillError = async processes => { const suffix = processes.length > 1 ? 'es' : ''; if (process.stdout.isTTY === false) { console.error(`Error killing process${suffix}. Try \`fkill --force ${processes.join(' ')}\``); process.exit(1); // eslint-disable-line unicorn/no-process-exit } else { const answer = await inquirer.prompt([{ type: 'confirm', name: 'forceKill', message: 'Error killing process. Would you like to use the force?' }]); if (answer.forceKill === true) { await fkill(processes, { force: true, ignoreCase: true }); } } }
console.log(); inquirer.prompt([{ name: 'continue', message: 'Do you want to continue?',
lando.Promise.try(() => { if (_.isEmpty(inquiry)) return {}; else { const inquirer = require('inquirer'); inquirer.registerPrompt('autocomplete', require('inquirer-autocomplete-prompt')); // Try to rebuild the inquiry if this is app level bootstrap and we have an app if (!_.isEmpty(argv._app) && lando._bootstrap === 'app') { // NOTE: We need to clone deep here otherwise any apps with interactive options get 2x all their events // NOTE: Not exactly clear on why app here gets conflated with the app returned from lando.getApp const app = _.cloneDeep(lando.getApp(argv._app.root)); return app.init().then(() => { inquiry = exports.getInteractive(_.find(app.tasks.concat(lando.tasks), {command: command}).options, argv); return inquirer.prompt(_.sortBy(inquiry, 'weight')); }); // Otherwise just run } else { inquiry = exports.getInteractive(_.find(lando.tasks, {command: command}).options, argv); return inquirer.prompt(_.sortBy(inquiry, 'weight')); } } })
async deployAuth(url) { if (process.env.CUBE_CLOUD_DEPLOY_AUTH) { const payload = jwt.decode(process.env.CUBE_CLOUD_DEPLOY_AUTH); if (!payload.url) { throw new Error('Malformed token in CUBE_CLOUD_DEPLOY_AUTH'); } if (url && payload.url !== url) { throw new Error('CUBE_CLOUD_DEPLOY_AUTH token doesn\'t match url in .cubecloud'); } return { [payload.url]: { auth: process.env.CUBE_CLOUD_DEPLOY_AUTH } }; } const config = await this.loadConfig(); if (config.auth) { return config.auth; } else { const auth = await inquirer.prompt([{ name: 'auth', message: `Cube Cloud Auth Token${url ? ` for ${url}` : ''}` }]); const authToken = auth.auth; return (await this.addAuthToken(authToken, config)).auth; } }
const prompt = await inquirer.prompt({ type: 'confirm', name: 'continue',
message: 'Send crash reports?', }; return inquirer.prompt([test]).then(answers => { lando.cache.set('report_errors', answers.reportErrors, {persist: true}); });
console.log(); inquirer.prompt(
function askQuestions() { const questions = [ { name: 'filename', type: 'input', message: 'Enter container name: (without whitespace)', validate(value) { if (value.length) { if ( helper.isUsedOnDir( helper.config.containersDir, value.indexOf('.js') > 0 ? value : `${value}.js` ) ) { return "It's already added. Please enter new container name."; } return true; } return 'It cannot be empty. Please enter it correctly...'; } } ]; inquirer.prompt(questions).then(({ filename }) => { helper.createContainerFromTemplate(filename, () => { afterContainerCreation(filename); }); }); }
inquirer.prompt(questions, (promptResult) => {
inquirer.prompt(questions).then(({ filename, prettyurl = null }) => { if (prettyurl) { afterPageCreation(filename, prettyurl);
}); inquirer.prompt(questions, (promptResult) => {
inquirer.prompt(questions).then(answers => {
inquirer.prompt(questions).then(({ filename, prettyurl = null }) => { helper.createPageFromTemplate(filename, () => { afterPageCreation(filename, prettyurl);