Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
dns.lookup('studio.strapi.io', function (err) {
if (err) {
logger.error('No internet access...');
process.exit(1);
}
// Then, start the prompt with custom options.
prompt.start();
prompt.colors = false;
prompt.message = 'your Strapi ';
prompt.delimiter = '';
// Get email address and password.
prompt.get({
properties: {
email: {
description: 'email address',
pattern: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
type: 'string',
required: true
},
password: {
description: 'password',
type: 'string',
hidden: true,
const prompt = require('prompt')
const replace = require('replace-in-file')
const fs = require('fs-extra');
var Promise = require('promise');
var path = require('path');
// Making the text input a bit legible.
prompt.colors = false
prompt.message = ""
// The text input takes a "result" object and passes it to one of two functions to do the logistics.
prompt.get([{
name: 'appName',
required: true,
description: "What's the name of your application? Lowercase and no spaces, please.",
message: "Lowercase and no spaces, please.",
conform: function(value) {
return /^[a-z0-9]+((\-[a-z0-9]+){1,})?$/g.test(value)
}
},
{
name: 'type',
required: true,
portScanner.findAPortNotInUse(port, port + 50, '127.0.0.1', function (error, availablePort) {
if (error) { throw error }
if (port === availablePort) {
// Port is free, return it via the callback
callback(port)
} else {
// Port in use - offer to change to available port
console.error('ERROR: Port ' + port + ' in use - you may have another prototype running.\n')
// Set up prompt settings
prompt.colors = false
prompt.start()
prompt.message = ''
prompt.delimiter = ''
// Ask user if they want to change port
prompt.get([{
name: 'answer',
description: 'Change to an available port? (y/n)',
required: true,
type: 'string',
pattern: /y(es)?|no?/i,
message: 'Please enter y or n'
}], function (err, result) {
if (err) { throw err }
if (result.answer.match(/y(es)?/i)) {
// User answers yes
portScanner.findAPortNotInUse(port, port + 50, '127.0.0.1', function (error, availablePort) {
if (error) { throw error }
if (port === availablePort) {
callback(port)
} else {
// Default port in use - offer to change to available port
console.error('ERROR: Port ' + port + ' in use - you may have another prototype running.\n')
// Set up prompt settings
prompt.colors = false
prompt.start()
prompt.message = ''
prompt.delimiter = ''
// Ask user if they want to change port
prompt.get([{
name: 'answer',
description: 'Change to an available port? (y/n)',
required: true,
type: 'string',
pattern: /y(es)?|no?/i,
message: 'Please enter y or n'
}], function (err, result) {
if (err) { throw err }
if (result.answer.match(/y(es)?/i)) {
// User answers yes
return new Promise(function (resolve, reject) {
// Set up prompt settings
prompt.colors = false
prompt.start()
prompt.message = ''
prompt.delimiter = ''
const description = fs.readFileSync(path.join(__dirname, 'usage-data-prompt.txt'), 'utf8')
prompt.get([{
name: 'answer',
description: description,
required: true,
type: 'string',
pattern: /y(es)?|no?/i,
message: 'Please enter y or n',
ask: function () {
return process.stdout.isTTY
}
function setupConfig(next) {
var configureDatabases = require('../install/databases');
// prompt prepends "prompt: " to questions, let's clear that.
prompt.start();
prompt.message = '';
prompt.delimiter = '';
prompt.colors = false;
async.waterfall([
function (next) {
if (install.values) {
// Use provided values, fall back to defaults
var config = {};
var redisQuestions = require('./database/redis').questions;
var mongoQuestions = require('./database/mongo').questions;
var postgresQuestions = require('./database/postgres').questions;
var allQuestions = questions.main.concat(questions.optional).concat(redisQuestions).concat(mongoQuestions).concat(postgresQuestions);
allQuestions.forEach(function (question) {
if (install.values.hasOwnProperty(question.name)) {
config[question.name] = install.values[question.name];
} else if (question.hasOwnProperty('default')) {
config[question.name] = question.default;
function confirm (name) {
console.log(`Unpublishing '${chalk.bold(name)}' from ${chalk.green(whoami.server)}.`)
prompt.message = ''
prompt.colors = false
prompt.start()
prompt.get([{
name: 'sure',
description: 'Are you sure? This cannot be undone. [y/n]',
pattern: /^[a-zA-Z\s-]+$/,
message: '',
required: true
}], function (err, results) {
if (err) return console.log(err.message)
if (results.sure === 'yes' || results.sure === 'y') makeRequest(name)
else exitErr('Cancelled.')
})
}
return;
};
exec("mkdir -p " + options.path, function(err, stdout, stderr) {
if (err) throw err;
});
if (options.username.length !== 0 && options.password.length !== 0) {
debrid(args[0]);
return;
}
prompt.start();
prompt.message = null;
prompt.delimiter = "";
prompt.colors = false;
prompt.get(options.schema, function (err, result) {
options.password = result.password;
options.username = result.username;
if (options.username.length == 0 || options.password.length == 0) {
console.log('Error: Enter a username/password');
return;
}
debrid(args[0]);
});
}
promptQueue.push(function() {
prompt.colors = false;
prompt.delimiter = '';
prompt.message = chalk.gray(prefix) + ' * ';
prompt.start();
prompt.get({
name: 'input',
description: chalk.blue(message),
hidden: options.hidden || false,
required: options.required || false
}, function(err, result) {
if(err) {
throw new errors.ProcessInterruptedError('User canceled prompt');
}
promptQueue.done(function() {
done(result ? result.input : null);
required: true,
default: path.basename(utils.root)
},
description: {
message: 'description'
},
port: {
message: 'webpack-dev-server port',
default: '8080'
}
}
};
prompt.message = '';
prompt.delimiter = ':';
prompt.colors = false;
prompt.run = cb => {
banner();
utils.nl();
prompt.start();
prompt.get(SCHEMA, (err, result) => {
utils.nl();
cb(err, result);
utils.nl();
});
};
module.exports = prompt;