Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 = {};
this.__defineGetter__('prompt', function () {
if (!this._prompt) {
//
// Pass-thru any prompt specific options that are supplied.
//
var prompt = require('prompt'),
self = this;
prompt.allowEmpty = options.allowEmpty || prompt.allowEmpty;
prompt.message = options.message || prompt.message;
prompt.delimiter = options.delimiter || prompt.delimiter;
prompt.properties = options.properties || prompt.properties;
//
// Setup `destroy` property for destructive commands
//
prompt.properties.destroy = {
name: 'destroy',
message: 'This operation cannot be undone, Would you like to proceed?',
default: 'yes'
};
//
// Hoist up any prompt specific events and re-emit them as
// `prompt::*` events.
//
['start', 'pause', 'resume', 'prompt', 'invalid'].forEach(function (ev) {
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')) {
console.log('Error: link not found');
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]);
});
}
promptOptions() {
const that = this;
const done = this.async();
prompt.message = chalk.gray(' question');
prompt.delimiter = ':';
prompt.start();
prompt.get(
{
properties: {
name: {
description: chalk.white.bold('name'),
type: 'string',
pattern: /^[a-z0-9-_]+$/,
message: 'name must be lower-cased letters',
hidden: false,
replace: '*',
default: '',
required: true
},
description: {
function startPrompt() {
prompt.start();
prompt.message = 'SassySass'.magenta;
prompt.delimiter = ' ';
prompt.get({
properties: {
section: {
description: 'Choose Section for New Mixin:\n'.red + mixinSection.map(function (section, index) {
return index + '. ' + section;
}).join('\n').white + '\n'
},
mixinName: {
description: 'Enter a Name for New Mixin:'.red
}
}
}, function (err, result) {
if(err) {
return err;
}
},
password: {
required: true,
pattern: /^(?=.*?[a-zA-Z])(?=.*?[0-9]).{6,}/,
message: 'Password must be at least 6 characters long and should contain a lower case letter and a number',
hidden: true,
description: 'Password: '
},
confirmPassword: {
hidden: true,
description: 'Confirm Password: '
}
}
};
prompt.delimiter = '';
prompt.message = 'User -- ';
prompt.start();
prompt.get(schema, function(err, result) {
/*if (err && err.toString().indexOf('canceled') > 0) {
err = new Error('User registration cancelled');
} */
result.profile = profile;
cb(err, result);
});
});
}
prompt: function (options, done) {
var promptSchema = {
properties: {
"property": options
}
};
promptLib.start();
promptLib.colors = false;
promptLib.message = "";
promptLib.delimiter = "";
promptLib.get(promptSchema, function (err, results) {
done(err, !err && results.property);
});
},
.usage('-flag Supply only 1 flag. Args will vary based on flag. To use the wizard, type the flag and "wizard" (ie. s3motion -n wizard)')
.option('-n, --newClient <--name --accessKeyId --secretAccessKey --endpoint>', 'Add a New Client (will be stored in clients.json)')
.option('-L, --listClients', 'List clients')
.option('-b, --listBuckets <--client>', 'List buckets for a specific client')
.option('-N, --newBucket <--client --name>', 'Create a new bucket')
.option('-l, --listObjects <--client --bucket>', 'List objects in a bucket')
.option('-d, --downloadObject <--client --bucket --object --folder>', 'Download object(s) from bucket. Multiple object download supported by using commas and no spaces.')
.option('-u, --uploadObject <--client --bucket --object --folder>', 'Upload object(s) to bucket. Multiple object upload supported by using commas and no spaces.')
.option('-D, --deleteObject <--client --bucket --object>', 'Delete object(s) from bucket. Multiple deletion supported by using commas and no spaces.')
.option('-c, --copyObject <--sourceClient --sourceBucket --object --destClient --destBucket --delete>', 'Copy object(s) between buckets. If --delete is Y, then source object is deleted after copy.')
.option('-C, --copyBucket <--sourceClient --sourceBucket --destClient --destBucket>', 'Copy objects between buckets')
.option('-R, --REST', 'Starts the REST based Web Service on port 8080')
.parse(process.argv);
prompt.message = "";
prompt.delimiter = "";
prompt.colors = false;
prompt.override = optimist.argv;
if (program.newClient) {
var questions = {
properties: {
name: {
description: 'Name: ',
required: true
},
accessKeyId: {
description: 'Access Key: ',
required: true
},
secretAccessKey: {
description: 'Secret Access Key: ',
return new Promise((resolve, reject) => {
prompt.message = '📖';
prompt.delimiter = ' ';
prompt.start();
const params = {
properties: {
title: {
message: 'Title of the new post',
required: true
},
tags: {
message: 'Comma separated tags'
}
}
};
prompt.get(params, (err, result) => {
if (err) {