Permalink
Browse files

Started prompt properties

  • Loading branch information...
1 parent eaa5226 commit a6d3bac69a950d39191c0c0a9dfcdd2aa6117943 @pksunkara committed Jan 17, 2012
Showing with 57 additions and 25 deletions.
  1. +11 −10 lib/police.js
  2. +36 −7 lib/police/ask.js
  3. +1 −1 lib/police/auth.js
  4. +3 −4 lib/police/check.js
  5. +3 −3 lib/police/config.js
  6. +3 −0 lib/police/help.js
View
@@ -25,7 +25,7 @@ police.start = function (argv, callback) {
* Declare some flags
*/
var maincmd = true
- , otheruser = false;
+ , otheruser = false;
winston.info('Welcome to ' + 'Police'.grey);
winston.info('It worked if it ends with ' + 'Police'.grey + ' ok'.green.bold);
@@ -35,23 +35,24 @@ police.start = function (argv, callback) {
/*
* Requiring necessary modules
*/
- police.config = require('./police/config').load();
- police.help = require('./police/help');
- police.auth = require('./police/auth');
- police.github = require('./police/github');
- police.check = require('./police/check');
- police.ask = require('./police/ask');
- police.prompt = require('prompt');
- police.async = require('async');
+ police.config = require('./police/config').load();
+ police.help = require('./police/help');
+ police.auth = require('./police/auth');
+ police.github = require('./police/github');
+ police.check = require('./police/check');
+ police.ask = require('./police/ask');
+ police.prompt = require('prompt');
+ police.async = require('async');
police.request = require('request');
+ police.semver = require('semver');
police.inspect = require('eyes').inspector({ styles: {all: 'grey', string: 'yellow'}, maxLength: 8192});
police.winston = winston;
/*
* Some variables
*/
var command = argv._[0] || ''
- , name = police.config.get('name');
+ , name = police.config.get('name');
/*
* Print version of this tool
View
@@ -10,14 +10,18 @@ var ask = module.exports;
* Requiring modules
*/
var path = require('path')
- , fs = require('fs')
- , semver = require('semver')
- , police = require('../police');
+ , fs = require('fs')
+ , police = require('../police');
/*
* Properties of keywords
*/
-var prop = {};
+var prop = [];
+
+/*
+ * Github data for keywords
+ */
+var gh = {};
/*
* Lock until we get github data
@@ -30,13 +34,13 @@ var ghlock = false;
ask.properties = function (pkg, gh) {
ghlock = true;
police.github.get('/users/' + gh.user, function (user) {
- prop.user = user;
+ gh.user = user;
police.github.get('/repos/' + gh.name, function (repo) {
- prop.repo = repo;
+ gh.repo = repo;
police.github.v2('/repos/show/' + gh.name + '/contributors', function (contrib) {
- prop.contrib = contrib.contributors;
+ gh.contrib = contrib.contributors;
ghlock = false;
});
});
@@ -48,6 +52,31 @@ ask.properties = function (pkg, gh) {
*/
ask.keywords = function (pkg, fields, callback) {
ask.release(function () {
+ if (!pkg.dependencies) pkg.dependencies = {};
+ if (!pkg.devDependencies) pkg.devDependencies = {};
+
+ if (!pkg.name) {
+ prop.push({
+ message: 'Module name',
+ name: 'name',
+ validator: /^[a-zA-Z0-9\-_\.]+$/,
+ warning: 'Module name must be valid',
+ empty: false,
+ default: gh.repo.name
+ });
+ }
+
+ if (!pkg.version) {
+ prop.push({
+ message: 'Module version',
+ name: 'version',
+ validator: function (v) { return police.sermver.valid(v); },
+ warning: 'Version must conform to semver',
+ empty: false,
+ default: '0.1.0'
+ });
+ }
+
callback();
});
}
View
@@ -17,7 +17,7 @@ var police = require('../police');
var properties = [
{
name: 'username',
- validator: /^[a-zA-Z0-9][a-zA-Z\-]+$/,
+ validator: /^[a-zA-Z0-9][a-zA-Z0-9\-]+$/,
warning: 'Username must be a github username',
empty: false
},
View
@@ -10,9 +10,8 @@ var check = module.exports;
* Requiring modules
*/
var path = require('path')
- , fs = require('fs')
- , semver = require('semver')
- , police = require('../police');
+ , fs = require('fs')
+ , police = require('../police');
/*
* Required fields
@@ -122,7 +121,7 @@ check.npm = function (dep, callback) {
callback(1);
} else {
body = JSON.parse(body);
- if (!semver.satisfies(body.version, dep.version)) {
+ if (!police.semver.satisfies(body.version, dep.version)) {
police.winston.info(''.red.bold + ' Need to update ' + dep.name.blue + ' to ' + body.version.yellow);
} else {
police.winston.info(''.green.bold + ' Checked ' + dep.name.blue);
@@ -10,9 +10,9 @@ var config = module.exports;
* Requiring modules
*/
var nconf = require('nconf')
- , winston = require('winston')
- , fs = require('fs')
- , path = require('path');
+ , winston = require('winston')
+ , fs = require('fs')
+ , path = require('path');
config.load = function () {
/*
View
@@ -11,6 +11,9 @@ var help = module.exports;
*/
var police = require('../police');
+/*
+ * Help usage text
+ */
help.usage = [
'',
' __ __ '.cyan,

0 comments on commit a6d3bac

Please sign in to comment.