remove binary
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Jonathan Ong · committed by Jonathan Ong · parent dc5932d · Browse files · 3 files·+5 added−429 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+5 added−429 removed
- other:+5 added−429 removed
Provenance
- Commit
476f8de- Tree
6057f4a- Author
Jonathan Ong <jonathanrichardong@gmail.com>- Committer
Jonathan Ong <jonathanrichardong@gmail.com>- Parent
dc5932d
3 files changed+5 added−429 removed
deleted:bin/express-423 removed
1-#!/usr/bin/env node2-3-/**4- * Module dependencies.5- */6-7-var program = require('commander')8- , mkdirp = require('mkdirp')9- , pkg = require('../package.json')10- , version = pkg.version11- , os = require('os')12- , fs = require('fs');13-14-// CLI15-16-program17- .version(version)18- .usage('[options] [dir]')19- .option('-s, --sessions', 'add session support')20- .option('-e, --ejs', 'add ejs engine support (defaults to jade)')21- .option('-J, --jshtml', 'add jshtml engine support (defaults to jade)')22- .option('-H, --hogan', 'add hogan.js engine support')23- .option('-c, --css <engine>', 'add stylesheet <engine> support (less|stylus) (defaults to plain css)')24- .option('-f, --force', 'force on non-empty directory')25- .parse(process.argv);26-27-// Path28-29-var path = program.args.shift() || '.';30-31-// end-of-line code32-33-var eol = os.EOL34-35-// Template engine36-37-program.template = 'jade';38-if (program.ejs) program.template = 'ejs';39-if (program.jshtml) program.template = 'jshtml';40-if (program.hogan) program.template = 'hjs';41-42-/**43- * Routes index template.44- */45-46-var index = [47- ''48- , '/*'49- , ' * GET home page.'50- , ' */'51- , ''52- , 'exports.index = function(req, res){'53- , ' res.render(\'index\', { title: \'Express\' });'54- , '};'55-].join(eol);56-57-/**58- * Routes users template.59- */60-61-var users = [62- ''63- , '/*'64- , ' * GET users listing.'65- , ' */'66- , ''67- , 'exports.list = function(req, res){'68- , ' res.send("respond with a resource");'69- , '};'70-].join(eol);71-72-/**73- * Jade layout template.74- */75-76-var jadeLayout = [77- 'doctype html'78- , 'html'79- , ' head'80- , ' title= title'81- , ' link(rel=\'stylesheet\', href=\'/stylesheets/style.css\')'82- , ' body'83- , ' block content'84-].join(eol);85-86-/**87- * Jade index template.88- */89-90-var jadeIndex = [91- 'extends layout'92- , ''93- , 'block content'94- , ' h1= title'95- , ' p Welcome to #{title}'96-].join(eol);97-98-/**99- * EJS index template.100- */101-102-var ejsIndex = [103- '<!DOCTYPE html>'104- , '<html>'105- , ' <head>'106- , ' <title><%= title %></title>'107- , ' <link rel=\'stylesheet\' href=\'/stylesheets/style.css\' />'108- , ' </head>'109- , ' <body>'110- , ' <h1><%= title %></h1>'111- , ' <p>Welcome to <%= title %></p>'112- , ' </body>'113- , '</html>'114-].join(eol);115-116-/**117- * JSHTML layout template.118- */119-120-var jshtmlLayout = [121- '<!DOCTYPE html>'122- , '<html>'123- , ' <head>'124- , ' <title> @write(title) </title>'125- , ' <link rel=\'stylesheet\' href=\'/stylesheets/style.css\' />'126- , ' </head>'127- , ' <body>'128- , ' @write(body)'129- , ' </body>'130- , '</html>'131-].join(eol);132-133-/**134- * JSHTML index template.135- */136-137-var jshtmlIndex = [138- '<h1>@write(title)</h1>'139- , '<p>Welcome to @write(title)</p>'140-].join(eol);141-142-/**143- * Hogan.js index template.144- */145-var hoganIndex = [146- '<!DOCTYPE html>'147- , '<html>'148- , ' <head>'149- , ' <title>{{ title }}</title>'150- , ' <link rel=\'stylesheet\' href=\'/stylesheets/style.css\' />'151- , ' </head>'152- , ' <body>'153- , ' <h1>{{ title }}</h1>'154- , ' <p>Welcome to {{ title }}</p>'155- , ' </body>'156- , '</html>'157-].join(eol);158-159-/**160- * Default css template.161- */162-163-var css = [164- 'body {'165- , ' padding: 50px;'166- , ' font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;'167- , '}'168- , ''169- , 'a {'170- , ' color: #00B7FF;'171- , '}'172-].join(eol);173-174-/**175- * Default less template.176- */177-178-var less = [179- 'body {'180- , ' padding: 50px;'181- , ' font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;'182- , '}'183- , ''184- , 'a {'185- , ' color: #00B7FF;'186- , '}'187-].join(eol);188-189-/**190- * Default stylus template.191- */192-193-var stylus = [194- 'body'195- , ' padding: 50px'196- , ' font: 14px "Lucida Grande", Helvetica, Arial, sans-serif'197- , 'a'198- , ' color: #00B7FF'199-].join(eol);200-201-/**202- * App template.203- */204-205-var app = [206- ''207- , '/**'208- , ' * Module dependencies.'209- , ' */'210- , ''211- , 'var express = require(\'express\');'212- , 'var routes = require(\'./routes\');'213- , 'var user = require(\'./routes/user\');'214- , 'var http = require(\'http\');'215- , 'var path = require(\'path\');'216- , ''217- , 'var app = express();'218- , ''219- , '// all environments'220- , 'app.set(\'port\', process.env.PORT || 3000);'221- , 'app.set(\'views\', path.join(__dirname, \'views\'));'222- , 'app.set(\'view engine\', \':TEMPLATE\');'223- , 'app.use(express.favicon());'224- , 'app.use(express.logger(\'dev\'));'225- , 'app.use(express.json());'226- , 'app.use(express.urlencoded());'227- , 'app.use(express.methodOverride());{sess}'228- , 'app.use(app.router);{css}'229- , 'app.use(express.static(path.join(__dirname, \'public\')));'230- , ''231- , '// development only'232- , 'if (\'development\' == app.get(\'env\')) {'233- , ' app.use(express.errorHandler());'234- , '}'235- , ''236- , 'app.get(\'/\', routes.index);'237- , 'app.get(\'/users\', user.list);'238- , ''239- , 'http.createServer(app).listen(app.get(\'port\'), function(){'240- , ' console.log(\'Express server listening on port \' + app.get(\'port\'));'241- , '});'242- , ''243-].join(eol);244-245-// Generate application246-247-(function createApplication(path) {248- emptyDirectory(path, function(empty){249- if (empty || program.force) {250- createApplicationAt(path);251- } else {252- program.confirm('destination is not empty, continue? ', function(ok){253- if (ok) {254- process.stdin.destroy();255- createApplicationAt(path);256- } else {257- abort('aborting');258- }259- });260- }261- });262-})(path);263-264-/**265- * Create application at the given directory `path`.266- *267- * @param {String} path268- */269-270-function createApplicationAt(path) {271- console.log();272- process.on('exit', function(){273- console.log();274- console.log(' install dependencies:');275- console.log(' $ cd %s && npm install', path);276- console.log();277- console.log(' run the app:');278- console.log(' $ node app');279- console.log();280- });281-282- mkdir(path, function(){283- mkdir(path + '/public');284- mkdir(path + '/public/javascripts');285- mkdir(path + '/public/images');286- mkdir(path + '/public/stylesheets', function(){287- switch (program.css) {288- case 'less':289- write(path + '/public/stylesheets/style.less', less);290- break;291- case 'stylus':292- write(path + '/public/stylesheets/style.styl', stylus);293- break;294- default:295- write(path + '/public/stylesheets/style.css', css);296- }297- });298-299- mkdir(path + '/routes', function(){300- write(path + '/routes/index.js', index);301- write(path + '/routes/user.js', users);302- });303-304- mkdir(path + '/views', function(){305- switch (program.template) {306- case 'ejs':307- write(path + '/views/index.ejs', ejsIndex);308- break;309- case 'jade':310- write(path + '/views/layout.jade', jadeLayout);311- write(path + '/views/index.jade', jadeIndex);312- break;313- case 'jshtml':314- write(path + '/views/layout.jshtml', jshtmlLayout);315- write(path + '/views/index.jshtml', jshtmlIndex);316- break;317- case 'hjs':318- write(path + '/views/index.hjs', hoganIndex);319- break;320-321- }322- });323-324- // CSS Engine support325- switch (program.css) {326- case 'less':327- app = app.replace('{css}', eol + 'app.use(require(\'less-middleware\')({ src: path.join(__dirname, \'public\') }));');328- break;329- case 'stylus':330- app = app.replace('{css}', eol + 'app.use(require(\'stylus\').middleware(path.join(__dirname, \'public\')));');331- break;332- default:333- app = app.replace('{css}', '');334- }335-336- // Session support337- app = app.replace('{sess}', program.sessions338- ? eol + 'app.use(express.cookieParser(\'your secret here\'));' + eol + 'app.use(express.session());'339- : '');340-341- // Template support342- app = app.replace(':TEMPLATE', program.template);343-344- // package.json345- var pkg = {346- name: 'application-name'347- , version: '0.0.1'348- , private: true349- , scripts: { start: 'node app.js' }350- , dependencies: {351- express: version352- }353- }354-355- if (program.template) pkg.dependencies[program.template] = '*';356-357- // CSS Engine support358- switch (program.css) {359- case 'less':360- pkg.dependencies['less-middleware'] = '*';361- break;362- default:363- if (program.css) {364- pkg.dependencies[program.css] = '*';365- }366- }367-368- write(path + '/package.json', JSON.stringify(pkg, null, 2));369- write(path + '/app.js', app);370- });371-}372-373-/**374- * Check if the given directory `path` is empty.375- *376- * @param {String} path377- * @param {Function} fn378- */379-380-function emptyDirectory(path, fn) {381- fs.readdir(path, function(err, files){382- if (err && 'ENOENT' != err.code) throw err;383- fn(!files || !files.length);384- });385-}386-387-/**388- * echo str > path.389- *390- * @param {String} path391- * @param {String} str392- */393-394-function write(path, str) {395- fs.writeFile(path, str);396- console.log(' \x1b[36mcreate\x1b[0m : ' + path);397-}398-399-/**400- * Mkdir -p.401- *402- * @param {String} path403- * @param {Function} fn404- */405-406-function mkdir(path, fn) {407- mkdirp(path, 0755, function(err){408- if (err) throw err;409- console.log(' \033[36mcreate\033[0m : ' + path);410- fn && fn();411- });412-}413-414-/**415- * Exit with the given `str`.416- *417- * @param {String} str418- */419-420-function abort(str) {421- console.error(str);422- process.exit(1);423-}modified:History.md+5 added
1+4.0.0 /2+==================3+4+ * remove binary (moved to [express-generator](https://github.com/expressjs/generator))5+6 3.4.7 / 2013-12-107 ==================8 9 * update connect1248 unmodified linesmodified:package.json-6 removed
21 unmodified lines222324252626282728293024 unmodified lines5556575861626364596061625 unmodified lines21 unmodified lines } ], "dependencies": { "connect": "2.12.0", "commander": "1.3.2", "range-parser": "0.0.4", "mkdirp": "0.3.5", "cookie": "0.1.0", "buffer-crc32": "0.2.1", "fresh": "0.2.0", "methods": "0.1.0",24 unmodified lines "app", "api" ], "repository": "git://github.com/visionmedia/express", "main": "index", "bin": { "express": "./bin/express" }, "scripts": { "prepublish": "npm prune", "test": "make test" },5 unmodified lines