Comparing version 0.7.1 to 0.7.2
@@ -163,6 +163,16 @@ /* | ||
// | ||
if(command[0] === 'init'){ | ||
if (command[0] === 'init'){ | ||
command[0] = 'install'; | ||
} | ||
// Alias db to databases | ||
if (command[0] === 'db'){ | ||
command[0] = 'databases'; | ||
} | ||
// Allow `jitsu logs` as a shortcut for `jitsu logs app` | ||
if (command[0] === 'logs' && command.length === 1) { | ||
command[1] = 'app'; | ||
} | ||
winston.info('Executing command ' + command.join(' ').magenta); | ||
@@ -169,0 +179,0 @@ jitsu.commands.run(command, function (err, shallow) { |
@@ -156,2 +156,3 @@ /* | ||
var name; | ||
var dir = process.cwd(); | ||
@@ -191,13 +192,6 @@ if (!callback) { | ||
winston.info('Checking app availability ' + pkg.name.magenta); | ||
jitsu.apps.available(pkg, function (err, result) { | ||
function createApp (err, result) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
if (!result.available) { | ||
winston.error('Error creating ' + pkg.name.magenta); | ||
winston.error(result.message); | ||
return callback(new Error()); | ||
} | ||
winston.info('Creating app ' + pkg.name.magenta); | ||
@@ -208,2 +202,13 @@ jitsu.apps.create(pkg, function (err, res, result) { | ||
}); | ||
} | ||
winston.info('Checking app availability ' + pkg.name.magenta); | ||
jitsu.package.available(pkg, dir, createApp, function createPackage (err, result) { | ||
if (err) { | ||
winston.error('Error creating ' + pkg.name.magenta); | ||
winston.error(result.message); | ||
return callback(new Error()); | ||
} | ||
jitsu.package.available(result, dir, createApp, createPackage); | ||
}); | ||
@@ -210,0 +215,0 @@ }); |
var jitsu = require('../../jitsu'), | ||
@@ -78,3 +77,3 @@ winston = require('winston'), | ||
} | ||
ncp.ncp(thisPath + '/node_modules/' + nodeapps[starterName].package, thisPath, function (err) { | ||
ncp.ncp(path.join(thisPath, 'node_modules', nodeapps[starterName].package), thisPath, function (err) { | ||
if (err) { | ||
@@ -81,0 +80,0 @@ return cb(err); |
@@ -94,3 +94,2 @@ /* | ||
} | ||
putLogs(results, appName, amount); | ||
@@ -101,22 +100,36 @@ callback(); | ||
function getAppName(callback) { | ||
jitsu.package.read(process.cwd(), function (err, pkg) { | ||
if (!err) { | ||
return callback(null, pkg.name); | ||
} | ||
jitsu.commands.commands.apps.list(function (err) { | ||
if (err) { | ||
return callback(err); | ||
} else { | ||
winston.error('You need to provide an app name'); | ||
jitsu.prompt.get(["app name"], function (err, result) { | ||
if (err) { | ||
// Handle the error | ||
winston.error('Prompt error:'); | ||
return callback(err); | ||
} else { | ||
// Plug in the app name and go | ||
appName = result["app name"]; | ||
callback(null, appName); | ||
} | ||
}); | ||
} | ||
}); | ||
}); | ||
} | ||
// Handle missing arguments | ||
if (typeof appName === 'function') { | ||
callback = appName; | ||
jitsu.commands.commands.apps.list( function (err) { | ||
getAppName(function (err, name) { | ||
if (err) { | ||
return callback(err); | ||
} else { | ||
winston.error('You need to pass an app name'); | ||
jitsu.prompt.get(["app name"], function (err, result) { | ||
if (err) { | ||
// Handle the error | ||
winston.error('Prompt error:'); | ||
return callback(err); | ||
} else { | ||
// Plug in the app name and go | ||
appName = result["app name"]; | ||
byApp(appName, 100, callback); | ||
} | ||
}); | ||
} | ||
byApp(name, 100, callback); | ||
}); | ||
@@ -150,2 +163,6 @@ } else if (callback === undefined) { | ||
function putLogs (results, appName, amount, showApp) { | ||
results.data = results.data.filter(function (item) { | ||
return item.json && item.json.hasOwnProperty('desc'); | ||
}); | ||
if (results.data.length === 0) { | ||
@@ -155,6 +172,7 @@ return winston.warn('No logs for ' + appName.magenta + ' in specified timespan'); | ||
var logged = 0, | ||
loglength = jitsu.config.get('loglength'); | ||
results.data.forEach(function (datum) { | ||
results.data.reverse().forEach(function (datum) { | ||
if (datum.json && datum.json.desc != null) { | ||
@@ -161,0 +179,0 @@ datum.json.desc.split('\n').forEach(function (line) { |
@@ -133,3 +133,3 @@ /* | ||
winston.warn('There in no valid package.json file in ' + dir.grey); | ||
winston.warn('Creating package.json at ' + (dir + '/package.json').grey); | ||
winston.warn('Creating package.json at ' + (path.join(dir, '/package.json')).grey); | ||
@@ -444,3 +444,3 @@ help.forEach(function (line) { | ||
warning: 'Start script was not found in ' + dir.magenta, | ||
default: 'server.js' | ||
default: searchStartScript(dir) | ||
}, | ||
@@ -455,2 +455,52 @@ { | ||
// | ||
// ### function available (pkg, dir, callback, createPackage) | ||
// #### @pkg {Object} Current package.json file on disk | ||
// #### @dir {string} Directory in which the package.json properties are being used | ||
// #### @callback {function} Continuation to respond to when complete. | ||
// #### @createPackage {function} Function needed to make it recursive | ||
// Prompts for appname and subdomain until the combination is available | ||
// | ||
package.available = function (pkg, dir, callback, createPackage) { | ||
jitsu.apps.available(pkg, function (err, isAvailable) { | ||
var props, fields = []; | ||
if (err) { | ||
winston.error('There was an error while checking app name / subdomain availability.'); | ||
return callback(err); | ||
} | ||
if (!isAvailable.available) { | ||
if (isAvailable.appname === false) { | ||
delete pkg.name; | ||
fields.push('name'); | ||
} | ||
if (isAvailable.subdomain === false) { | ||
delete pkg.subdomain; | ||
fields.push('subdomain'); | ||
} | ||
props = package.properties(dir).filter(function (p) { | ||
return fields.indexOf(p.name) !== -1; | ||
}); | ||
if (fields.indexOf('name') !== -1) { | ||
winston.error('The application name you have requested is already in use.'); | ||
} | ||
if (fields.indexOf('subdomain') !== -1) { | ||
winston.error('The subdomain you have requested is already in use.'); | ||
} | ||
jitsu.prompt.addProperties(pkg, props, createPackage); | ||
return; | ||
} | ||
callback(null, pkg); | ||
}); | ||
} | ||
function searchStartScript(dir) { | ||
var scripts = ['server.js', 'bin/server', 'app.js', 'index.js']; | ||
for (i in scripts) { | ||
if (path.existsSync(path.join(dir, scripts[i]))) { | ||
return scripts[i]; | ||
} | ||
} | ||
} | ||
function tryAnalyze (target, dir, callback) { | ||
@@ -516,33 +566,4 @@ if (target.analyzed) { | ||
result.scripts = result.scripts || {}; | ||
jitsu.apps.available(result, function (err, isAvailable) { | ||
var props, fields = []; | ||
if (err) { | ||
winston.error('There was an error while checking app name / subdomain availability.'); | ||
return callback(err); | ||
} | ||
if (!isAvailable.available) { | ||
if (isAvailable.appname === false) { | ||
delete result.name; | ||
fields.push('name'); | ||
} | ||
if (isAvailable.subdomain === false) { | ||
delete result.subdomain; | ||
fields.push('subdomain'); | ||
} | ||
props = package.properties(dir).filter(function (p) { | ||
return fields.indexOf(p.name) !== -1; | ||
}); | ||
if (fields.indexOf('name') !== -1) { | ||
winston.error('The application name you have requested is already in use.'); | ||
} | ||
if (fields.indexOf('subdomain') !== -1) { | ||
winston.error('The subdomain you have requested is already in use.'); | ||
} | ||
jitsu.prompt.addProperties(result, props, createPackage); | ||
return; | ||
} | ||
callback(null, result); | ||
}); | ||
package.available(result, dir, callback, createPackage); | ||
}); | ||
} |
@@ -11,3 +11,3 @@ { | ||
], | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"author": "Nodejitsu Inc. <support@nodejitsu.com>", | ||
@@ -26,3 +26,3 @@ "repository": { | ||
"npm": ">= 1.0.100 < 1.1.0", | ||
"ncp": "0.1.x", | ||
"ncp": "0.2.x", | ||
"optimist": "0.2.x", | ||
@@ -29,0 +29,0 @@ "nodejitsu-api": "0.2.x", |
@@ -139,3 +139,13 @@ # jitsu | ||
##jitsu behind proxy | ||
If you are behind a proxy and you haven't configured jitsu to use it, `jitsu` will throw an error, `Jitsu requires you to connect to Nodejitsu's stack (api.nodejitsu.com)`. | ||
In order to solve this issue, you can configure jitsu to use a proxy by executing the following command. | ||
jitsu config set proxy http://proxy.domain.com:3128/ | ||
If you need to authenticate yourselves to the proxy, you can try this command. | ||
jitsu config set proxy http://user:pass@proxy.domain.com:3128/ | ||
<a name="Libraries"></a> | ||
@@ -142,0 +152,0 @@ ## Libraries |
@@ -74,3 +74,3 @@ /* | ||
}) | ||
.put('/apps/mickey/application')) | ||
.put('/apps/mickey/mickey/application')) | ||
}).addBatch({ | ||
@@ -92,3 +92,3 @@ 'env set delete test': runJitsuCommand( | ||
}) | ||
.put('/apps/mickey/application')) | ||
.put('/apps/mickey/mickey/application')) | ||
}).export(module); |
827885
4649
166