Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async.series( promptSeries, function(err, results){
// After all prompt questions have been answered...
if (results && /n/i.test(templateData['PROMPTS_COMFIRM'])) {
// User accepted all answers. Suspend prompt.
prompt.pause();
delete templateData['PROMPTS_COMFIRM'];
console.log('');
generator.copyTemplate = exports.copyTemplate.bind(generator, templateDir, dest, templateData);
generator.templateData = exports.templateData;
if(generator.run.length<2){
generator.run(templateData);
done();
}else
generator.run(templateData, done);
}
else if(results) prompts();
});
})();
pattern: /^\w+$/,
message: 'Host name must be only letters',
required: true
},
db_user_password: {
description: 'Enter your password',
type: 'string',
message: 'Password must be letters',
hidden: true,
replace: '*',
required: true
}
}
};
prompt.get(configScheme, function (err, result) {
let config = {};
try {
config = require(path.join('..', configFile));
} catch (e) {
console.log(' = Make new config.json file in root folder...');
fs.writeFileSync(configFile, JSON.stringify(config, null, 4));
}
if(!result){
return console.log('\n 취소되었습니다.')
}
// validate dbTablePrefix (ex. test => b_test_, b_test = b_test_)
const dbTablePrefix = validateDatabaseTablePrefix(result['db_table_prefix']);
fs.access(file, fs.F_OK, (err) => {
const prompts = []
if (!err) throw new Error('file exists: ' + file)
prompt.start()
if (program.provider === 'bitgo') {
if (program.user) schema.password.description = program.user + ' password'
else prompts.push(schema.username)
prompts.push(schema.password)
prompts.push(schema.enterpriseId)
}
// if (!program.otp) prompts.push(schema.otp)
prompts.push(schema.accessToken)
prompt.get(prompts, (err, result) => {
if (err) throw err
config.authenticate.username = program.user || result.username
config.authenticate = update(config.authenticate, underscore.omit(result, [ 'enterpriseId' ]))
if (result.enterpriseId) config.enterpriseId = result.enterpriseId
provider.online.authenticate(config, (err, options) => {
if (err) throw err
provider.online.createWallet(options, (err, wallet) => {
if (err) throw err
config.authenticate = underscore.pick(config.authenticate, [ 'username' ])
config.wallet = underscore.pick(wallet, [ 'id', 'label', 'currency' ])
config = underscore.pick(config, [ 'config', 'label', 'authenticate', 'wallet' ])
writeFile(file, config)
})
generators.push(function(done){
// events extend
_.extend(generator, new EventEmitter);
var options = generator.options;
if (Object.keys(options).length > 0) {
var prompt = require('prompt');
prompt.message = '[' + '?'.green + ']';
prompt.delimiter = ' ';
console.log(['\nGenerator', ('"'+template+'"').green, 'needs answer the following question:'].join(' '));
// Add one final "are you sure?" prompt.
options['PROMPTS_COMFIRM'] = {
message: 'Do you need to make any changes to the above before continuing?'.green,
default: 'y/N'
};
// Start the prompt
prompt.start();
(function prompts(){
var promptSeries = {};
Object.keys(options).map(function(key){
promptSeries[key] = function(callback){
var properties = {};
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
#!/usr/bin/env node
'use strict';
// Load .env files (if needed)
require('../env')();
var fs = require('fs'),
_ = require('lodash'),
doc = require("../api/doc/doc.model"),
prompt = require('prompt'),
argv = require('yargs').argv;
// Override prompt values with argv
prompt.override = argv
// Start the prompt
prompt.message = '';
prompt.delimiter = '';
prompt.start();
prompt.get([{
name: 'output',
type: 'string',
default: 'stats.json',
description: "Name of the ouput file:".magenta
}], function (err, params) {
console.log("Extracting data...");
// Extracting decades...
doc.decades().then(function(decades) {
var stats = { decades: decades };
console.log("Calculating slope...");
}, function() {
// After all prompt questions have been answered...
if (/n/i.test(result.ANSWERS_VALID)) {
// User accepted all answers. Suspend prompt.
prompt.pause();
// Clean up.
delete result.ANSWERS_VALID;
// Iterate over all results.
grunt.util.async.forEachSeries(Object.keys(result), function(name, next) {
// If this value needs to be sanitized, process it now.
if (sanitize[name]) {
sanitize[name](result[name], result, function(err, value) {
if (err) {
result[name] = err;
} else if (arguments.length === 2) {
result[name] = value === 'none' ? '' : value;
}
next();
});
} else {
if (result[name] === 'none') { result[name] = ''; }