Exemplo n.º 1
0
  function whichIssue(cb) {
    var what = args._[0];
    if (what) {
      return validIssue(what, cb);
    }

    read({
      prompt: 'which issue? (type the number): '
    }, function(err, what) {
      validIssue(what, cb);
    });

    function validIssue(number, cb) {
      Issue.first({number: number}, gotIssue);

      function gotIssue(err, _issue) {
        if (err) {
          error(err.detail);
        }
        if (_issue) {
          issue = _issue;
          cb(number);
        } else {
          error('Issue does not exist');
        }
      }
    }
  }
Exemplo n.º 2
0
 openWithFallback(res.authorize_url, fallbackMessage + '\n' + res.authorize_url, function (code) {
   read({silent: true, prompt: ''}, cli.log.bind(cli));
   
   process.stdout.write('\nWaiting for authorization ...');
   
   setTimeout(function () { checkAuthStatus(res.ticket); }, INITIAL_POLL_TIMEOUT);
 });
Exemplo n.º 3
0
function readUsername (c, u, cb) {
  var v = userValidate.username
  read({prompt: "Username: ", default: c.u}, function (er, un) {
    if (er) {
      return cb(er.message === "cancelled" ? er.message : er)
    }

    // make sure it's valid.  we have to do this here, because
    // couchdb will only ever say "bad password" with a 401 when
    // you try to PUT a _users record that the validate_doc_update
    // rejects for *any* reason.

    if (!un) {
      return readUsername(c, u, cb)
    }

    var error = v(un)
    if (error) {
      log.warn(error.message)
      return readUsername(c, u, cb)
    }

    c.changed = c.u !== un
    u.u = un
    cb(er)
  })
}
Exemplo n.º 4
0
 function getPhone (err, result) {
     person.phone = result;
     console.log("Your phone number is: " + result);
     myBook.push(person);
     console.log("\nEntry Added.\n")
     read({ prompt: '> '}, mainLoop);
 }
Exemplo n.º 5
0
function startPromptAndInjectEventsScript(driver, done) {
  var screenshotCount = 0;
  var recordingStartTime;
  var screenshotEvents = [];

  // I'm sick of callbacks and promises, sync read this
  var scriptToInject = fs.readFileSync(__dirname + '/bigBrother.js', 'utf8');

  driver.executeScript(scriptToInject);

  console.log('Begin record');
  console.log(
    'Type q to quit, l for taking a screenshot and marking a live playback ' +
    'point til next screenshot, and anything else to take a normal screenshot.'
  );

  read({prompt: '> '}, function handleKeyPress(err, key) {
    if (key === 'q') return done(screenshotEvents);

    var event = {
      action: 'screenshot',
      timeStamp: Date.now(),
    };

    if (key === 'l') {
      event.livePlayback = true;
    }

    screenshotEvents.push(event);
    screenshotCount++;
    console.log(screenshotCount + ' screenshot recorded.');
    read({prompt: '> '}, handleKeyPress);
  });
}
Exemplo n.º 6
0
function removeSession(modelName, sha) {
  let sha_ = sha.slice(0, 8);

  console.log(`This will remove the training session "${modelName}" at ${sha_} from Fomoro.`);
  console.log();
  console.log('All artifacts from the training session will be removed as well.');
  console.log('Your local files will not be touched.');
  console.log();
  read({ prompt: 'Is this okay? (y/n)' }, (err, yn) => {
    if (err) {
      console.error(exceptions.getUserMessage(err));
      process.exit(1);
      return;
    }

    if (yn.toLowerCase() === 'y') {
      console.log(`Removing "${modelName}" at ${sha_}...`);
      utils.postJSON(config.host + config.session_remove_endpoint, { model: modelName, sha: sha }, function(err, res, body) {
        if (err) {
          console.error(exceptions.getUserMessage(err));
          process.exit(1);
        } else if (res.statusCode !== 200) {
          err = exceptions.fromResponse(res, body);
          console.error(exceptions.getUserMessage(err));
          process.exit(1);
        } else {
          console.log(`Successfully removed "${modelName}" at ${sha_}.`);
        }
      });
    } else {
      console.log(`Okay, did NOT remove "${modelName}" at ${sha_}.`);
    }
  });
}
Exemplo n.º 7
0
Arquivo: init.js Projeto: guyzmuch/jpm
    promzard(initInput, {}, function (err, data) {
      if (err) {
        return reject(err);
      }
      
      // Set the "jetpack" keyword by default
      data.keywords = [ "jetpack" ];

      // convert to json string which a human can read
      data = JSON.stringify(data, null, 2) + "\n";

      packageDataTemp = JSON.parse(data);
      console.log("About to write to %s:\n\n%s\n", packagePath, data);
      read({
        prompt: "Is this ok? ",
        default: "yes"
      }, function (err, ok) {
        if (!ok || ok.toLowerCase().charAt(0) !== "y") {
          return reject("Aborted.");
        }
        else {
          fs.writeFile(packagePath, data, "utf-8").then(resolve, reject);
        }
      });
    });
Exemplo n.º 8
0
Mirror.prototype.authorize = function(callback) {
	var oauth = new googleapis.auth.OAuth2(this.p_appCredentials.clientId,
			this.p_appCredentials.clientSecret, 'urn:ietf:wg:oauth:2.0:oob');
	var url = oauth.generateAuthUrl({ access_type: 'offline',
			scope: 'https://www.googleapis.com/auth/drive' });

	console.log("Please go to the following url to retreive an authorization code:");
	console.log();
	console.log(url);
	console.log();

	var self = this;
	read({ prompt: 'Code:' }, function(error, code) {
		if(error) {
			callback(error);
			return;
		}

		oauth.getToken(code, function(error, tokens) {
			if(error) {
				callback(error);
				return;
			}

			self.p_refreshToken = tokens.refresh_token;
			self.emit('configchange');
			callback(null);
		});
	});
};
Exemplo n.º 9
0
	askQuestion(question) {
		var options = {
    			prompt: question.question
		}
  		read(options, this.answeredRight.bind(this))

 	}
Exemplo n.º 10
0
function readUsername (c, u, cb) {
  read({prompt: "Username: ", default: c.u}, function (er, un) {
    if (er) {
      return cb(er.message === "cancelled" ? er.message : er)
    }

    // make sure it's valid.  we have to do this here, because
    // couchdb will only ever say "bad password" with a 401 when
    // you try to PUT a _users record that the validate_doc_update
    // rejects for *any* reason.

    if (!un) {
      return readUsername(c, u, cb)
    }

    if (un !== un.toLowerCase()) {
      log.warn('Username must be lowercase')
      return readUsername(c, u, cb)
    }

    if (un !== encodeURIComponent(un)) {
      log.warn('Username may not contain non-url-safe chars')
      return readUsername(c, u, cb)
    }

    if (un.charAt(0) === '.') {
      log.warn('Username may not start with "."')
      return readUsername(c, u, cb)
    }

    c.changed = c.u !== un
    u.u = un
    cb(er)
  })
}
Exemplo n.º 11
0
 }, function(er, email) {
     if (er) {
         console.log('');
         process.exit();
     }
     read({
         prompt: "password: ",
         silent: true
     }, function(er, password) {
         if (er) {
             console.log('');
             process.exit();
         }
         console.log('Now enter the password you will give out for private access to your published resume.');
         read({
             prompt: "resume password: "
         }, function(er, passphrase) {
             if (er) {
                 console.log('');
                 process.exit();
             }
             publishSend(resumeJson, program.theme, email, password, false, passphrase, config.session);
         });
     });
 });
Exemplo n.º 12
0
 }, function(er, email) {
     if (!validEmail(email)) {
         console.log('Email format is invalid.'.red);
         process.exit();
     }
     if (er) {
         console.log('');
         process.exit();
     }
     read({
         prompt: "password: ",
         silent: true
     }, function(er, pass) {
         if (er) {
             console.log('');
             process.exit();
         }
         read({
             prompt: "re-enter password: ",
             silent: true
         }, function(er, pass2) {
             verify({
                 username: user,
                 email: email,
                 password: pass,
                 verify: pass2,
                 passMatch: (pass === pass2)
             });
         });
     });
 });
Exemplo n.º 13
0
module.exports = function(key) {
  if (!key) {
    var dataset = utils.readConfig();
    key = `${dataset.name}@${dataset.version}`;
  }

  console.log(`This will remove the dataset "${key}" from Fomoro.`);
  console.log('Your local files will not be touched.');
  read({ prompt: 'Is this okay? (y/n)' }, (err, yn) => {
    if (err) {
      console.error(exceptions.getUserMessage(err));
      process.exit(1);
      return;
    }

    if (yn.toLowerCase() === 'y') {
      console.log(`Removing "${key}"...`);
      utils.postJSON(config.host + config.data_unpublish_endpoint, { key: key }, function(err, res, body) {
        if (err) {
          console.error(exceptions.getUserMessage(err));
          process.exit(1);
        } else if (res.statusCode !== 200) {
          err = exceptions.fromResponse(res, body);
          console.error(exceptions.getUserMessage(err));
          process.exit(1);
        } else {
          console.log(`Successfully removed "${key}".`);
        }
      });
    } else {
      console.log(`Okay, did NOT remove "${key}".`);
    }
  });
};
Exemplo n.º 14
0
Runner.prototype._envIterator = function(container, memo, item, callback) {

  var parts = item.split("=");
  var key = parts[0];
  var value = parts[1];

  // first thing's first, try and substitute a real process.env value
  if(value == "-") {
    value = process.env[key];
  }

  // did we have one? great! bail early with the updated value
  if(value) {
    memo.push( "-e " + key + "=" + value);
    return callback(null, memo);
  }

  // if we got here we still don't have a value for this env var, so
  // we need to ask the user for it
  var options = {
    prompt: container.name + " requires a value for the env var '" + key + "':",
    silent: true,
    replace: "*"
  };
  return read(options, function(err, value) {
    memo.push( "-e " + key + "=" + value);
    return callback(err, memo);
  });
};
Exemplo n.º 15
0
                    }, function(er, currentPassword) {
                        if (er) {
                            console.log();
                            process.exit();
                        }
                        read({
                            prompt: "New Password: ",
                            silent: true
                        }, function(er, newPassword) {
                            if (er) {
                                console.log();
                                process.exit();
                            }
                            read({
                                prompt: "Confirm Password: ",
                                silent: true
                            }, function(er, confirmPassword) {
                                if (er) {
                                    console.log();
                                    process.exit();
                                }

                                changePassword({
                                    email: email,
                                    currentPassword: currentPassword,
                                    newPassword: newPassword,
                                    confirmPassword: confirmPassword,
                                    passMatch: (newPassword === confirmPassword)
                                })
                            });
                        });
                    });
Exemplo n.º 16
0
 return new Promise((resolve, reject) => {
   read(
     {
       prompt: `${this.format.dim('question')} ${question}: `,
       silent: !!options.password,
       output: this.stdout,
       input: this.stdin,
     },
     (err, answer) => {
       if (err) {
         if (err.message === 'canceled') {
           process.exitCode = 1;
         }
         reject(err);
       } else {
         if (!answer && options.required) {
           this.error(this.lang('answerRequired'));
           resolve(this.question(question, options));
         } else {
           resolve(answer);
         }
       }
     },
   );
 });
Exemplo n.º 17
0
function show_question(positionp){
  
  if(positionp <= object_array_q.arrayquestion.length-1)
  {
  	options = {
	prompt: object_array_q.arrayquestion[positionp].question_text
    }
    console.log("Question:");
	read(options, checkanswer);
           function checkanswer(err, input){
	          
	          if (object_array_q.arrayquestion[positionp].answer === input)
	          {
		           positionp = positionp + 1;
		           console.log("C O R R E C T");
		           show_question(positionp);
	          }
	          else
	          {
                  console.log ("E R R O R");
                  show_question(positionp);
              }
            };
  }
  else
  {
  	console.log ("G a m e   O v e r")
  }
};
Exemplo n.º 18
0
 getJSON('/companies').done(function(data) {
   self.companies = data;
   getJSON('/contacts').done(function(data) {
     self.contacts = data;
     callback(self);
   }).fail(errBk);
 }).fail(errBk);
Exemplo n.º 19
0
function input(prompt, cb, silent) {
    console.log("\x1b[32m"); // Switch to green
    read({prompt:prompt, silent: !!silent}, (err, answer) => {
        console.log("\x1b[0m"); // Reset console color
        cb(answer);
    });
}
Exemplo n.º 20
0
		c.on('verify', function(fingerprint, cb) {
			conf.fingerprint = fingerprint;

			var next = function(err) {
				console.log('');
				cb(err);
			};

			if (fingerprint === oldFingerprint || opts.yes) {
				console.log('Remote is already verified.')
				return next();
			}
			if (isKnownHost(url, fingerprint)) {
				console.log('Remote is verified by ~/.ssh/known_hosts.');
				return next();
			}

			console.log('Remote rsa fingerprint is: '+fingerprint);
			read({prompt: 'Do you want to continue (yes/no)? '}, function onanswer(err, answer) {
				if (err) return ui.error(err);
				if (answer === 'no') return next(new Error('Host could not be verified'));
				if (answer === 'yes') return next();
				read({prompt:'Please type \'yes\' or \'no\': '}, onanswer);
			});
		});
/**
 * Try to extract needed parameters
 */
function init(callback) {
  var argv = process.argv.slice(2);
  if (argv.length < 4) {
    console.log("Syntax: node txlive-import-tool.js <url> <project slug> <resource slug> <username> [<password>]");
    return;
  }

  var url_info = url.parse(settings.tx_url);
  settings.protocol = url_info.protocol;
  settings.host = url_info.hostname;
  settings.port = url_info.port ? parseInt(url_info.port) : null;
  settings.url = argv[0];
  settings.project_slug = argv[1];
  settings.resource_slug = argv[2];
  settings.username = argv[3];
  if (argv[4]) {
    settings.password = argv[4];
    callback();
  }
  else {
    read(
      {
        prompt: 'Password for ' + settings.protocol + "//" + settings.username + '@' + url_info.host + ": ",
        silent: true
      },
      function(e, password) {
        settings.password = password;
        callback();
      }
    )
  }
}
Exemplo n.º 22
0
function _startPromptAndInjectEventsScript(driver, next) {
  var recordingStartTime;
  var screenshotCount = 0;
  var screenshotEvents = [];

  // I'm sick of callbacks and promises, sync read this
  var scriptToInject = fs.readFileSync(
    path.join(__dirname, 'browser', 'actionsTracker.js'),
    'utf8'
  );

  driver.executeScript(scriptToInject);

  console.log('Begin record');
  console.log(
    'Type q to quit, l for taking a screenshot and marking a live playback ' +
    'point til next screenshot, and anything else to take a normal screenshot.'
  );

  read({prompt: '> '}, function handleKeyPress(err, key) {
    if (key === 'q') return next(null, screenshotEvents);

    var event = {
      action: consts.STEP_SCREENSHOT,
      timeStamp: Date.now(),
    };

    if (key === 'l') event.livePlayback = true;

    screenshotEvents.push(event);
    screenshotCount++;
    console.log(screenshotCount + ' screenshot recorded.');
    read({prompt: '> '}, handleKeyPress);
  });
}
Exemplo n.º 23
0
 function readField(field, default_, cb) {
     if (cb === undefined) {
         cb = default_;
         default_ = undefined;
     }
     assert.object(field, 'field');
     assert.func(cb);
     //TODO: 'required', don't allow empty string
     var readOpts = {
         prompt: field.name + ':',
         silent: field.hidden,
         default: default_
     };
     read(readOpts, function (rErr, val) {
         if (rErr)
             return cb(rErr);
         val = val.trim();
         if (!field.confirm) {
             cb(null, val);
         } else {
             readOpts.prompt = field.name + ' confirm:';
             read(readOpts, function (rErr2, val2) {
                 if (rErr2)
                     return cb(rErr2);
                 val2 = val2.trim();
                 if (val !== val2) {
                     cb(new Error(sprintf(
                         '%s values do not match', field.name)));
                 } else {
                     cb(null, val);
                 }
             });
         }
     });
 }
Exemplo n.º 24
0
function start(db) {
  read({ prompt: 'password:', silent: true }, function(err, password) {
    if (err) { console.error(err.message); process.exit(1); }

    read({ prompt: 'repeat:', silent: true }, function(err, password2) {
      if (err) { console.error(err.message); process.exit(1); }

      if (password !== password2) {
        console.log('passwords are not equal');
        process.exit(2);
      }

      var coll = db.db(program.database).collection(collectionName);
      try {
        User.register(coll, program.username, password, realm, function(err) {
          if (err) { console.error(err.message); process.exit(3); }

          process.exit();
        });
      } catch(err) {
        console.error(err.message);
        process.exit(4);
      }
    });
  });
}
Exemplo n.º 25
0
  grunt.registerMultiTask("phonegap-build", "Creates a ZIP archive and uploads it to build.phonegap.com to create a new build", function (args) {
    var opts = this.options({
      timeout: 60000,
      pollRate: 15000
    });

    if (!grunt.file.exists(opts.archive)) {
      grunt.log.fail("Archive at " + opts.archive + " does not exist! Forgot to run 'zip' task before? Did 'zip' succeed?");
      return false;
    }

    var done = this.async(),
        taskRefs = {
          log: grunt.log, options: opts, done: done,
          needle: null /* wrapped version added in start */
        };

    if (!opts.user.password && !opts.user.token) {
      grunt.log.write('\x07\x07');
      read({ prompt: 'Password: ', silent: true }, function (er, password) {
        opts.user.password = password;
        start(taskRefs);
      });
    } else {
      start(taskRefs);
    }
  });
Exemplo n.º 26
0
        .end(function(error, res) {
            spinner.stop();
            console.log(error, res)
            // cannot read property of null
            if (error && error.code === 'ENOTFOUND') {
                console.log('\nThere has been an error publishing your resume.'.red);
                console.log('Please check your network connection.'.cyan);
                process.exit();
                return;
            } else if (error || res.body.message === 'ERRORRRSSSS') {
                console.log(error, res.body.message);
                console.log('\nThere has been an error publishing your resume.'.red);
                // console.log('Details:', error, res.body.message);
                console.log('Please check you are using correct login details.'.blue);
            } else {

                console.log('\nYour resume theme has been successfully changed to ' + themeCredentials.theme + '.');
                read({
                    prompt: 'Would you like to view your new themed resume in the web browser? [y/n]: '
                }, function(er, answer) {
                    if (answer === 'y') {
                        open(res.body.url);
                        process.exit();
                    } else if (answer === 'n') {
                        process.exit();
                    }
                });

            }
        });
Exemplo n.º 27
0
        read(readOpts, function (rErr, val) {
            if (rErr) {
                return cbRead(rErr);
            }

            val = val.trim();
            if (!field.confirm) {
                return cbRead(null, val);
            }

            readOpts.prompt = field.name + ' confirm:';
            read(readOpts, function (rErr2, val2) {
                if (rErr2) {
                    return cbRead(rErr2);
                }

                val2 = val2.trim();
                if (val !== val2) {
                    cbRead(new Error(format(
                        '%s values do not match', field.name)));
                } else {
                    cbRead(null, val);
                }
            });
        });
Exemplo n.º 28
0
                themeMenu(function(theme) {
                    read({
                        prompt: "Email: ",
                        default: resumeJson.bio && resumeJson.bio.email && resumeJson.bio.email.personal || ''
                    }, function(er, email) {
                        if (er) {
                            console.log();
                            process.exit();
                        }
                        read({
                            prompt: "Password: ",
                            silent: true
                        }, function(er, password) {
                            if (er) {
                                console.log();
                                process.exit();
                            }

                            changeTheme({
                                email: email,
                                password: password,
                                theme: theme,
                                changeTheme: true
                            });
                        });
                    });
                });
Exemplo n.º 29
0
function readPassword (c, u, cb) {
  var v = userValidate.pw

  if (!c.changed) {
    u.p = c.p
    return cb()
  }
  read({prompt: "Password: ", silent: true}, function (er, pw) {
    if (er) {
      return cb(er.message === "cancelled" ? er.message : er)
    }

    if (!pw) {
      return readPassword(c, u, cb)
    }

    var error = v(pw)
    if (error) {
      log.warn(error.message)
      return readPassword(c, u, cb)
    }

    u.p = pw
    cb(er)
  })
}
Exemplo n.º 30
0
      function(cwd) {
        util.print('This operation will overwrite all local changes you have made.'.warn);
        read({ prompt: 'Do you want to continue? [y/N] ' }, function(error, answer) {
          if (error || answer.toLowerCase().charAt(0) !== 'y') {
            util.print('Aborting operation.');
            process.exit(1);
          }

          var nbrOfFiles = 0;

          monaca.downloadProject(cwd).then(
            function() {
              if (nbrOfFiles === 0) {
                util.print('No files downloaded since project is already in sync.');
              }
              else {
                util.print('Project successfully downloaded from Monaca Cloud!');
              }
            },
            function(error) {
              util.err('Download failed: ' + error);
            },
            function(progress) {
              var per = 100 * (progress.index + 1) / progress.total;
              per = per.toString().substr(0, 5) + '%';
              util.print(('[' + per + '] ').verbose + progress.path);

              nbrOfFiles++;
            }
          );
        });
      },