Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Drone usage #347

Merged
merged 2 commits into from

3 participants

@chjj

These commits will display drone usage in apps view and apps list. Ignore the whitespace changes.

@AvianFlu AvianFlu merged commit efaa4d4 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 23 additions and 22 deletions.
  1. +5 −4 lib/jitsu/commands/apps.js
  2. +18 −18 lib/jitsu/common/index.js
View
9 lib/jitsu/commands/apps.js
@@ -314,7 +314,7 @@ apps.list = function (username, callback) {
if (err) {
return callback(err);
}
-
+
jitsu.commands.apps.list(username, callback);
});
}
@@ -324,7 +324,7 @@ apps.list = function (username, callback) {
if (err) {
return callback(err);
}
-
+
jitsu.commands.apps.list(username, callback);
});
}
@@ -351,8 +351,8 @@ apps.list = function (username, callback) {
return callback();
}
- var rows = [['name', 'state', 'subdomain', 'running snapshot']],
- colors = ['underline', 'underline', 'underline', 'underline'];
+ var rows = [['name', 'state', 'subdomain', 'drones', 'running snapshot']],
+ colors = ['underline', 'underline', 'underline', 'underline', 'underline'];
apps.forEach(function (app) {
app.state = jitsu.common.formatAppState(app.state);
@@ -369,6 +369,7 @@ apps.list = function (username, callback) {
app.name,
app.state,
app.subdomain,
+ app.drones + '/' + app.maxDrones,
snapshot
]);
});
View
36 lib/jitsu/common/index.js
@@ -4,7 +4,7 @@
* (C) 2010, Nodejitsu Inc.
*
*/
-
+
var fs = require('fs'),
path = require('path'),
util = require('util'),
@@ -14,11 +14,11 @@ var fs = require('fs'),
request = require('request'),
semver = require('semver'),
jitsu = require('../../jitsu');
-
+
var common = module.exports = flatiron.common.clone(flatiron.common);
//
-// ### function formatApp (app, exclude)
+// ### function formatApp (app, exclude)
// #### @app {Object} Application document to format
// #### @exclude {Array} **Optional** List of additional properties to exclude
// Formats the specified `app` by removing unnecessary properties combined with
@@ -26,7 +26,7 @@ var common = module.exports = flatiron.common.clone(flatiron.common);
//
common.formatApp = function (app, exclude) {
var snapshots = app.snapshots,
- remove = ['_id', '_rev', 'drones', 'id', 'maxDrones', 'resource'];
+ remove = ['_id', '_rev', 'id', 'resource'];
app.snapshots = !snapshots ? [] : snapshots.map(function (snap) {
var created = new Date(snap.ctime);
@@ -86,7 +86,7 @@ common.formatAppState = function (state) {
};
//
-// ### function missingKeys (source, target)
+// ### function missingKeys (source, target)
// #### @source {Array} List of keys for the current object
// #### @target {Array} List of keys for the new object
// Returns the complement of the intersection of the two arrays.
@@ -101,16 +101,16 @@ common.missingKeys = function (source, target) {
missing.push(key);
}
});
-
+
return missing;
};
//
-// ### function objectDiff (current, update, level)
+// ### function objectDiff (current, update, level)
// #### @current {Object} Current representation of the object.
// #### @update {Object} Updated representation of the object.
// #### @level {Number} Level in the object we are diffing.
-// Returns an incremental diff of the `current` object
+// Returns an incremental diff of the `current` object
// against the updated representation `update`
//
// e.g. { foo: 1, bar: 2 }, { foo: 2, bar: 2 } => { foo: 2 }
@@ -119,7 +119,7 @@ common.objectDiff = function (current, update, level) {
var ckeys = Object.keys(current),
ukeys = Object.keys(update),
diff = {};
-
+
//
// Ignore changes on the first level of the object.
//
@@ -129,10 +129,10 @@ common.objectDiff = function (current, update, level) {
diff[key] = undefined;
});
}
-
+
ukeys.forEach(function (key) {
var nested, i;
-
+
if (!current[key]) {
diff[key] = update[key];
}
@@ -160,13 +160,13 @@ common.objectDiff = function (current, update, level) {
}
}
});
-
+
return Object.keys(diff).length > 0 ? diff : null;
};
common.checkVersion = function (callback) {
var responded = false
-
+
//
// Check the GitHub tags for `jitsu` to see if the current
// version is outdated. If it is not make sure to message the user at the end.
@@ -177,7 +177,7 @@ common.checkVersion = function (callback) {
}, function (err, res, body) {
if (!responded) {
responded = true;
-
+
try {
var pkg = JSON.parse(body);
@@ -185,14 +185,14 @@ common.checkVersion = function (callback) {
jitsu.log.warn('A newer version of ' + 'jitsu'.magenta + ' is available. ' + 'please update immediately');
jitsu.log.help('To install the latest ' + 'jitsu'.magenta + ' type `[sudo] npm install jitsu -g`');
jitsu.log.warn('To ' + 'continue'.bold + ' without an update ' + 'type'.cyan + ' ' + '\'yes\''.magenta);
-
+
jitsu.prompt.confirm('Continue without updating? Bad things might happen (no)', function (err, result) {
return err ? callback() : callback(!result);
});
-
+
return;
- }
-
+ }
+
callback();
}
catch (ex) {
Something went wrong with that request. Please try again.