pax_global_header00006660000000000000000000000064123213303570014511gustar00rootroot0000000000000052 comment=6094ea64004d9fe765b7ac7aa14f5133969c5858 generator-4.0.0/000077500000000000000000000000001232133035700135005ustar00rootroot00000000000000generator-4.0.0/.gitignore000066400000000000000000000002511232133035700154660ustar00rootroot00000000000000coverage.html .DS_Store lib-cov *.seed *.log *.csv *.dat *.out *.pid *.swp *.swo benchmarks/graphs testing node_modules/ testing .coverage_data cover_html test.js .idea generator-4.0.0/LICENSE000066400000000000000000000021161232133035700145050ustar00rootroot00000000000000(The MIT License) Copyright (c) 2009-2013 TJ Holowaychuk Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.generator-4.0.0/README.md000066400000000000000000000033331232133035700147610ustar00rootroot00000000000000[![express logo](http://f.cl.ly/items/0V2S1n0K1i3y1c122g04/Screen%20Shot%202012-04-11%20at%209.59.42%20AM.png)](http://expressjs.com/) Fast, unopinionated, minimalist web framework for [node](http://nodejs.org). [![Gittip](http://img.shields.io/gittip/visionmedia.png)](https://www.gittip.com/visionmedia/) ## Quick Start The quickest way to get started with express is to utilize the executable `express(1)` to generate an application as shown below: Create the app: $ npm install -g express-generator $ express /tmp/foo && cd /tmp/foo Install dependencies: $ npm install Rock and Roll $ npm start ## License (The MIT License) Copyright (c) 2009-2012 TJ Holowaychuk <tj@vision-media.ca> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. generator-4.0.0/bin/000077500000000000000000000000001232133035700142505ustar00rootroot00000000000000generator-4.0.0/bin/express000077500000000000000000000151701232133035700156730ustar00rootroot00000000000000#!/usr/bin/env node var program = require('commander'); var mkdirp = require('mkdirp'); var os = require('os'); var fs = require('fs'); var path = require('path'); var pkg = require('../package.json'); var version = pkg.version; // CLI program .version(version) .usage('[options] [dir]') .option('-e, --ejs', 'add ejs engine support (defaults to jade)') .option('-H, --hogan', 'add hogan.js engine support') .option('-c, --css ', 'add stylesheet support (less|stylus|compass) (defaults to plain css)') .option('-f, --force', 'force on non-empty directory') .parse(process.argv); // Path var destination_path = program.args.shift() || '.'; // end-of-line code var eol = os.EOL // Template engine program.template = 'jade'; if (program.ejs) program.template = 'ejs'; if (program.hogan) program.template = 'hjs'; function load_template(name) { return fs.readFileSync(path.join(__dirname, '..', 'templates', name), 'utf-8'); } var index = load_template('js/routes/index.js'); var users = load_template('js/routes/users.js'); /// css var css = fs.readFileSync(__dirname + '/../templates/css/style.css', 'utf-8'); var less = fs.readFileSync(__dirname + '/../templates/css/style.less', 'utf-8'); var stylus = fs.readFileSync(__dirname + '/../templates/css/style.styl', 'utf-8'); var compass = fs.readFileSync(__dirname + '/../templates/css/style.scss', 'utf-8'); var app = fs.readFileSync(__dirname + '/../templates/js/app.js', 'utf-8'); var www = fs.readFileSync(__dirname + '/../templates/js/www', 'utf-8'); // Generate application (function createApplication(path) { emptyDirectory(path, function(empty){ if (empty || program.force) { createApplicationAt(path); } else { program.confirm('destination is not empty, continue? ', function(ok){ if (ok) { process.stdin.destroy(); createApplicationAt(path); } else { abort('aborting'); } }); } }); })(destination_path); /** * Create application at the given directory `path`. * * @param {String} path */ function createApplicationAt(path) { console.log(); process.on('exit', function(){ console.log(); console.log(' install dependencies:'); console.log(' $ cd %s && npm install', path); console.log(); console.log(' run the app:'); console.log(' $ DEBUG=my-application ./bin/www'); console.log(); }); mkdir(path, function(){ mkdir(path + '/public'); mkdir(path + '/public/javascripts'); mkdir(path + '/public/images'); mkdir(path + '/public/stylesheets', function(){ switch (program.css) { case 'less': write(path + '/public/stylesheets/style.less', less); break; case 'stylus': write(path + '/public/stylesheets/style.styl', stylus); break; case 'compass': write(path + '/public/stylesheets/style.scss', compass); break; default: write(path + '/public/stylesheets/style.css', css); } }); mkdir(path + '/routes', function(){ write(path + '/routes/index.js', index); write(path + '/routes/users.js', users); }); mkdir(path + '/views', function(){ switch (program.template) { case 'ejs': copy_template('ejs/index.ejs', path + '/views/index.ejs'); copy_template('ejs/error.ejs', path + '/views/error.ejs'); break; case 'jade': copy_template('jade/index.jade', path + '/views/index.jade'); copy_template('jade/layout.jade', path + '/views/layout.jade'); copy_template('jade/error.jade', path + '/views/error.jade'); break; case 'hjs': copy_template('hogan/index.hjs', path + '/views/index.hjs'); copy_template('hogan/error.hjs', path + '/views/error.hjs'); break; } }); // CSS Engine support switch (program.css) { case 'less': app = app.replace('{css}', eol + 'app.use(require(\'less-middleware\')({ src: path.join(__dirname, \'public\') }));'); break; case 'stylus': app = app.replace('{css}', eol + 'app.use(require(\'stylus\').middleware(path.join(__dirname, \'public\')));'); break; case 'compass': app = app.replace('{css}', eol + 'app.use(require(\'node-compass\')({mode: \'expanded\'}));'); break; default: app = app.replace('{css}', ''); } // Template support app = app.replace('{views}', program.template); // package.json var pkg = { name: 'application-name' , version: '0.0.1' , private: true , scripts: { start: 'node ./bin/www' } , dependencies: { 'express': '~4.0.0', 'static-favicon': '~1.0.0', 'morgan': '~1.0.0', 'cookie-parser': '~1.0.1', 'body-parser': '~1.0.0', 'debug': '~0.7.4' } } switch (program.template) { case 'jade': pkg.dependencies['jade'] = '~1.3.0'; break; case 'ejs': pkg.dependencies['ejs'] = '~0.8.5'; break; case 'hjs': pkg.dependencies['hjs'] = '~0.0.6'; break; default: } // CSS Engine support switch (program.css) { case 'less': pkg.dependencies['less-middleware'] = '0.1.15'; break; case 'compass': pkg.dependencies['node-compass'] = '0.2.3'; break; case 'stylus': pkg.dependencies['stylus'] = '0.42.3'; break; default: } write(path + '/package.json', JSON.stringify(pkg, null, 2)); write(path + '/app.js', app); mkdir(path + '/bin', function(){ write(path + '/bin/www', www, 0755); }); }); } function copy_template(from, to) { from = path.join(__dirname, '..', 'templates', from); write(to, fs.readFileSync(from, 'utf-8')); } /** * Check if the given directory `path` is empty. * * @param {String} path * @param {Function} fn */ function emptyDirectory(path, fn) { fs.readdir(path, function(err, files){ if (err && 'ENOENT' != err.code) throw err; fn(!files || !files.length); }); } /** * echo str > path. * * @param {String} path * @param {String} str */ function write(path, str, mode) { fs.writeFile(path, str, { mode: mode || 0666 }); console.log(' \x1b[36mcreate\x1b[0m : ' + path); } /** * Mkdir -p. * * @param {String} path * @param {Function} fn */ function mkdir(path, fn) { mkdirp(path, 0755, function(err){ if (err) throw err; console.log(' \033[36mcreate\033[0m : ' + path); fn && fn(); }); } /** * Exit with the given `str`. * * @param {String} str */ function abort(str) { console.error(str); process.exit(1); } generator-4.0.0/package.json000066400000000000000000000016051232133035700157700ustar00rootroot00000000000000{ "name": "express-generator", "description": "Express' application generator", "version": "4.0.0", "author": "TJ Holowaychuk ", "contributors": [ { "name": "TJ Holowaychuk", "email": "tj@vision-media.ca" }, { "name": "Aaron Heckmann", "email": "aaron.heckmann+github@gmail.com" }, { "name": "Ciaran Jessup", "email": "ciaranj@gmail.com" }, { "name": "Guillermo Rauch", "email": "rauchg@gmail.com" } ], "dependencies": { "commander": "1.3.2", "mkdirp": "0.3.5" }, "keywords": [ "express", "framework", "sinatra", "web", "rest", "restful", "router", "app", "api" ], "repository": "git://github.com/expressjs/generator", "main": "bin/express", "bin": { "express": "./bin/express" }, "engines": { "node": ">= 0.8.0" } } generator-4.0.0/templates/000077500000000000000000000000001232133035700154765ustar00rootroot00000000000000generator-4.0.0/templates/css/000077500000000000000000000000001232133035700162665ustar00rootroot00000000000000generator-4.0.0/templates/css/style.css000066400000000000000000000001561232133035700201420ustar00rootroot00000000000000body { padding: 50px; font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; } a { color: #00B7FF; }generator-4.0.0/templates/css/style.less000066400000000000000000000001561232133035700203200ustar00rootroot00000000000000body { padding: 50px; font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; } a { color: #00B7FF; }generator-4.0.0/templates/css/style.scss000066400000000000000000000002071232133035700203220ustar00rootroot00000000000000@import "compass/css3"; body { padding: 50px; font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; } a { color: #00B7FF; }generator-4.0.0/templates/css/style.styl000066400000000000000000000001421232133035700203400ustar00rootroot00000000000000body padding: 50px font: 14px "Lucida Grande", Helvetica, Arial, sans-serif a color: #00B7FFgenerator-4.0.0/templates/ejs/000077500000000000000000000000001232133035700162575ustar00rootroot00000000000000generator-4.0.0/templates/ejs/error.ejs000066400000000000000000000001231232133035700201070ustar00rootroot00000000000000

<%= message %>

<%= error.status %>

<%= error.stack %>
generator-4.0.0/templates/ejs/index.ejs000066400000000000000000000003361232133035700200730ustar00rootroot00000000000000 <%= title %>

<%= title %>

Welcome to <%= title %>

generator-4.0.0/templates/hogan/000077500000000000000000000000001232133035700165725ustar00rootroot00000000000000generator-4.0.0/templates/hogan/error.hjs000066400000000000000000000001201232133035700204220ustar00rootroot00000000000000

{{ message }}

{{ error.status }}

{{ error.stack }}
generator-4.0.0/templates/hogan/index.hjs000066400000000000000000000003321232133035700204050ustar00rootroot00000000000000 {{ title }}

{{ title }}

Welcome to {{ title }}

generator-4.0.0/templates/jade/000077500000000000000000000000001232133035700164015ustar00rootroot00000000000000generator-4.0.0/templates/jade/error.jade000066400000000000000000000001241232133035700203540ustar00rootroot00000000000000extends layout block content h1= message h2= error.status pre #{error.stack} generator-4.0.0/templates/jade/index.jade000066400000000000000000000001021232133035700203260ustar00rootroot00000000000000extends layout block content h1= title p Welcome to #{title} generator-4.0.0/templates/jade/layout.jade000066400000000000000000000001741232133035700205450ustar00rootroot00000000000000doctype html html head title= title link(rel='stylesheet', href='/stylesheets/style.css') body block contentgenerator-4.0.0/templates/js/000077500000000000000000000000001232133035700161125ustar00rootroot00000000000000generator-4.0.0/templates/js/app.js000066400000000000000000000025531232133035700172350ustar00rootroot00000000000000var express = require('express'); var path = require('path'); var favicon = require('static-favicon'); var logger = require('morgan'); var cookieParser = require('cookie-parser'); var bodyParser = require('body-parser'); var routes = require('./routes/index'); var users = require('./routes/users'); var app = express(); // view engine setup app.set('views', path.join(__dirname, 'views')); app.set('view engine', '{views}'); app.use(favicon()); app.use(logger('dev')); app.use(bodyParser.json()); app.use(bodyParser.urlencoded()); app.use(cookieParser());{css} app.use(express.static(path.join(__dirname, 'public'))); app.use('/', routes); app.use('/users', users); /// catch 404 and forwarding to error handler app.use(function(req, res, next) { var err = new Error('Not Found'); err.status = 404; next(err); }); /// error handlers // development error handler // will print stacktrace if (app.get('env') === 'development') { app.use(function(err, req, res, next) { res.status(err.status || 500); res.render('error', { message: err.message, error: err }); }); } // production error handler // no stacktraces leaked to user app.use(function(err, req, res, next) { res.status(err.status || 500); res.render('error', { message: err.message, error: {} }); }); module.exports = app; generator-4.0.0/templates/js/routes/000077500000000000000000000000001232133035700174335ustar00rootroot00000000000000generator-4.0.0/templates/js/routes/index.js000066400000000000000000000003071232133035700211000ustar00rootroot00000000000000var express = require('express'); var router = express.Router(); /* GET home page. */ router.get('/', function(req, res) { res.render('index', { title: 'Express' }); }); module.exports = router; generator-4.0.0/templates/js/routes/users.js000066400000000000000000000003051232133035700211300ustar00rootroot00000000000000var express = require('express'); var router = express.Router(); /* GET users listing. */ router.get('/', function(req, res) { res.send('respond with a resource'); }); module.exports = router; generator-4.0.0/templates/js/www000077500000000000000000000004161232133035700166650ustar00rootroot00000000000000#!/usr/bin/env node var debug = require('debug')('my-application'); var app = require('../app'); app.set('port', process.env.PORT || 3000); var server = app.listen(app.get('port'), function() { debug('Express server listening on port ' + server.address().port); });