Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of git://github.com/mde/geddy

  • Loading branch information...
commit 5c0a299d4beb53081740bd953c46d466c7ec7831 2 parents a7e86f0 + f0c7bc1
@MiguelMadero authored
Showing with 92 additions and 27 deletions.
  1. +1 −1  Makefile
  2. +19 −21 bin/cli.js
  3. +2 −2 package.json
  4. +70 −3 templates/Jakefile
View
2  Makefile
@@ -29,7 +29,7 @@ install:
@mkdir -p $(DESTDIR)$(PREFIX)/bin && \
mkdir -p $(DESTDIR)$(PREFIX)/lib/node_modules/geddy && \
mkdir -p ./node_modules && \
- npm install utilities model barista && \
+ npm install jake utilities model barista && \
cp -R ./* $(DESTDIR)$(PREFIX)/lib/node_modules/geddy/ && \
ln -snf ../lib/node_modules/geddy/bin/cli.js $(DESTDIR)$(PREFIX)/bin/geddy && \
chmod 755 $(DESTDIR)$(PREFIX)/lib/node_modules/geddy/bin/cli.js && \
View
40 bin/cli.js
@@ -126,10 +126,12 @@ if (cmds.length) {
if (process.platform === 'win32') {
filepath = '"' + filepath + '"';
}
- cmd = 'jake -t -f ' + filepath + ' ';
+ cmd = '-t -f ' + filepath + ' ';
- // If command isn't secret and has no other argument
- if ((cmds[0] != 'secret' && cmds[0] != 'db:init') && !cmds[1]) {
+ // Some commands take only one arg
+ if (!(cmds[0] == 'secret' ||
+ cmds[0] == 'db:init' ||
+ cmds[0] == 'console') && !cmds[1]) {
throw new Error(cmds[0] + ' command requires another argument.');
}
@@ -149,33 +151,37 @@ if (cmds.length) {
// Add Jake argument based on commands
switch (cmds[0]) {
+ case 'console':
+ // Create DBs
+ cmd += 'console:start[' + (cmds[1] || 'development') + ']';
+ break;
case 'db:init':
// Create DBs
- cmd += '"db:init"';
+ cmd += 'db:init';
break;
case 'db:createTable':
// Create DBs
- cmd += '"db:createTable[' + cmds[1] + ']"';
+ cmd += 'db:createTable[' + cmds[1] + ']';
break;
case 'app':
// Generating application
- cmd += '"gen:app[' + cmds[1] + engineCmd + ']"';
+ cmd += 'gen:app[' + cmds[1] + engineCmd + ']';
break;
case 'resource':
// Generating resource
- cmd += '"gen:resource[' + cmds[1] + modelCmd + ']"';
+ cmd += 'gen:resource[' + cmds[1] + modelCmd + ']';
break;
case 'scaffold':
// Generating application
- cmd += '"gen:scaffold[' + cmds[1] + engineCmd + modelCmd + ']"';
+ cmd += 'gen:scaffold[' + cmds[1] + engineCmd + modelCmd + ']';
break;
case 'controller':
// Generating controller
- cmd += '"gen:bareController[' + cmds[1] + engineCmd + ']"';
+ cmd += 'gen:bareController[' + cmds[1] + engineCmd + ']';
break;
case 'model':
// Generating model
- cmd += '"gen:model[' + cmds[1] + modelCmd + ']"';
+ cmd += 'gen:model[' + cmds[1] + modelCmd + ']';
break;
case 'secret':
// Generating new app secret
@@ -189,17 +195,9 @@ if (cmds.length) {
cmd += ' --quiet';
}
- exec(cmd, function(err, stdout, stderr) {
- if(err) {
- throw err;
- }
- if (stderr) {
- console.log(utils.string.trim(stderr));
- }
- if (stdout) {
- console.log(utils.string.trim(stdout));
- }
- });
+ cmd = cmd.split(' ');
+ var jake = require('jake');
+ jake.run.apply(jake, cmd);
}
// Just `geddy` -- start the server
else {
View
4 package.json
@@ -7,10 +7,10 @@
"REST",
"MVC"
],
- "version": "0.4.7",
+ "version": "0.5.0",
"author": "Matthew Eernisse <mde@fleegix.org> (http://fleegix.org)",
"dependencies": {
- "jake": "0.3.x",
+ "jake": "0.4.x",
"utilities": "0.0.x",
"model": "0.0.x",
"barista": "0.0.x"
View
73 templates/Jakefile
@@ -9,13 +9,15 @@ var fs = require('fs')
, templato = new (require('../deps/templato'));
namespace('env', function () {
- task('init', function () {
+ task('init', function (environment) {
jake.addListener('complete', function (e) {
jake.Task['env:cleanup'].invoke();
});
- geddy.config = require('../lib/config').readConfig();
+ geddy.config = require('../lib/config').readConfig({
+ environment: environment || 'development'
+ });
geddy.model = require('model');
require('../lib/init').init(geddy, function () {
@@ -36,7 +38,72 @@ namespace('env', function () {
}
});
-}, {async: true});
+});
+
+namespace('console', function () {
+
+ task('start', ['env:init'], {async: true}, function (environment) {
+ var env = environment || 'development'
+ , t = jake.Task['env:init'];
+ t.addListener('complete', function () {
+ var readline = require('readline')
+ , rl = readline.createInterface({
+ input: process.stdin
+ , output: process.stdout
+ });
+ rl.setPrompt('>>> ');
+ rl.prompt();
+ rl.addListener('line', function (line) {
+ try {
+ console.log(global.eval(line));
+ }
+ catch (e) {
+ console.log(e.stack);
+ }
+ rl.prompt();
+ });
+ rl.addListener('close', function () {
+ console.log('Exiting ...');
+ return complete();
+ });
+ });
+
+ global.capture = function (err, data) {
+ return global.results = {
+ err: err
+ , data: data
+ };
+ }
+
+ global.echo = function (err, data) {
+ capture(err, data);
+ if (err) {
+ console.log('Error: ', err);
+ }
+ if (data) {
+ if (data.length) {
+ for (var i in data) {
+ if (data[i] && data[i].toData) {
+ console.log(data[i].toData());
+ } else {
+ console.log(data[i]);
+ }
+ }
+ } else {
+ if (data && data.toData) {
+ console.log(data.toData());
+ } else {
+ console.log(data);
+ }
+ }
+ } else {
+ console.log('No data');
+ }
+ }
+
+ t.invoke(env);
+ });
+});
namespace('db', function () {
Please sign in to comment.
Something went wrong with that request. Please try again.