Added app generation to bin/express
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 8beae06 · Browse files · 2 files·+89 added−10 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+89 added−10 removed
- other:+89 added−10 removed
Provenance
- Commit
8338432- Tree
41ad3b2- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
8beae06
2 files changed+89 added−10 removed
modified:bin/express+88 added-4 removed
21 unmodified lines22 + '\x1b[1mUsage\x1b[0m: express [options] [PATH]\n'23 + '\n'24 + '\x1b[1mOptions\x1b[0m:\n'25 + ' -v, --version Output framework version\n'26- + ' -h, --help Output help information\n'26+ + ' -h, --help Output help information\n';27 28+/**29+ * Jade layout template.30+ */31+32+var jadeLayout = [33+ '!!!',34+ 'html',35+ ' head',36+ ' title= title',37+ ' link(rel=\'stylesheet\', href=\'/stylesheets/style.css\')',38+ ' body!= body'39+].join('\n');40+41+/**42+ * Default sass template.43+ */44+45+var sass = [46+ 'body',47+ ' :padding 50px',48+ ' :font 14px "Lucida Grande", "Helvetica Nueue", Arial, sans-serif'49+].join('\n');50+51+/**52+ * Jade index template.53+ */54+55+var jadeIndex = [56+ 'h1= title',57+ 'p Welcome to #{title}'58+].join('\n');59+60+/**61+ * App template.62+ */63+64+var app = [65+ '',66+ '/**',67+ ' * Module dependencies.',68+ ' */',69+ '',70+ 'var express = require(\'express\'),',71+ ' connect = require(\'connect\');',72+ '',73+ '// Create and export Express app',74+ '',75+ 'var app = module.exports = express.createServer();',76+ '',77+ '// Configuration',78+ '',79+ 'app.configure(function(){',80+ ' app.use(\'/\', connect.redirect());',81+ ' app.use(\'/\', connect.bodyDecoder());',82+ ' app.use(\'/\', connect.compiler({ src: __dirname + \'/public\', enable: [\'sass\'] }));',83+ ' app.use(\'/\', connect.staticProvider(__dirname + \'/public\'));',84+ '});',85+ '',86+ 'app.configure(\'development\', function(){',87+ ' app.use(\'/\', connect.errorHandler({ dumpExceptions: true, showStack: true })); ',88+ '});',89+ '',90+ 'app.configure(\'production\', function(){',91+ ' app.use(\'/\', connect.errorHandler()); ',92+ '});',93+ '',94+ '// Routes',95+ '',96+ 'app.get(\'/\', function(req, res){',97+ ' res.render(\'index.jade\', {',98+ ' locals: {',99+ ' title: \'Express\'',100+ ' }',101+ ' });',102+ '});'103+].join('\n');104+105 // Parse arguments106 107 var args = process.argv.slice(2),108 path = '.';16 unmodified lines125 // Generate application126 127 (function createApplication(path) {128 mkdir(path, function(){52- write(path + '/app.js', 'app contents');53- mkdir(path + '/config');54- mkdir(path + '/views/partials');129+ mkdir(path + '/pids');130+ mkdir(path + '/logs');131+ mkdir(path + '/public/{javascripts,stylesheets,images}', function(){132+ write(path + '/public/stylesheets/style.sass', sass);133+ });134+ mkdir(path + '/views/partials', function(){135+ write(path + '/views/layout.jade', jadeLayout);136+ write(path + '/views/index.jade', jadeIndex);137+ });138+ write(path + '/app.js', app);139 });140 })(path);141 142 /**36 unmodified linesmodified:.pomo+1 added-6 removed
71 unmodified lines72 - !ruby/object:Pomo::Task 73 complete: false74 description: 75 length: 2576- name: next(err) from within view system?77-- !ruby/object:Pomo::Task 78- complete: false79- description: 80- length: 2576 name: view defaults / extension defaults77 - !ruby/object:Pomo::Task 78 complete: false79 description: 7 unmodified lines87 - !ruby/object:Pomo::Task 88 complete: false89 description: 90 length: 2596- name: view filters?91+ name: view helpers