Skip to content

Commit

Permalink
Add gen upgrade task
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Ng committed Jul 22, 2013
1 parent df8d10c commit c14b8a1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
34 changes: 34 additions & 0 deletions gen/jakelib/gen.jake
Expand Up @@ -212,6 +212,40 @@ namespace('gen', function () {
console.log('Created app ' + name + '.');
});

// Upgrades an app with older scaffolding
task('upgrade', function (engine, realtime) {
var basePath = path.join(genDirname, 'base')
, appViewDir = path.join('app', 'views')
, appLayoutDir = path.join('app', 'views', 'layouts')
, templateErrorsDir
, templateLayoutsDir
, errorLayouts = [
'errors.html.ejs'
, 'layout_footer.html.ejs'
, 'layout_header.html.ejs'
];

if (!engine || engine == 'default') {
engine = 'ejs';
}

// Get view paths
templateErrorsDir = realtime === 'realtime' ?
path.join(basePath, 'realtime', 'views', engine, 'errors') :
path.join(basePath, 'views', engine, 'errors');
templateLayoutsDir = realtime === 'realtime' ?
path.join(basePath, 'realtime', 'views', engine, 'layouts') :
path.join(basePath, 'views', engine, 'layouts');

// Copy in errors dir
jake.cpR(path.join(templateErrorsDir), path.join(appViewDir), {silent: true});

// Copy in stuff in layout folder
errorLayouts.forEach(function (filename) {
jake.cpR(path.join(templateLayoutsDir, filename), path.join(appLayoutDir, filename), {silent: true});
});
});

// Creates a resource with a model, controller and a resource route
task('resource', function (name, modelProperties) {
var names
Expand Down
2 changes: 2 additions & 0 deletions lib/cmd.js
Expand Up @@ -20,6 +20,7 @@ var _taskArgsMap = {
, 'auth': ['template']
, 'auth:update': []
, 'migration': ['primary']
, 'upgrade': ['template','rt']
};

cmd = new (function () {
Expand All @@ -36,6 +37,7 @@ cmd = new (function () {
, 'controller': true
, 'model': true
, 'migration': true
, 'upgrade': true
};

jakeCmds = {
Expand Down

0 comments on commit c14b8a1

Please sign in to comment.