├── .editorconfig ├── .eslintrc ├── .gitattributes ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── generators └── app │ ├── index.js │ └── templates │ ├── basic │ ├── .vscode │ │ ├── launch.json │ │ └── tasks.json │ └── src │ │ ├── app.ts │ │ ├── bin │ │ └── www.ts │ │ └── routes │ │ └── index.ts │ ├── shared │ ├── _.gitignore │ ├── bower.json │ ├── package.json │ ├── process.json │ └── tsconfig.json │ └── views │ ├── ejs │ ├── error.html │ ├── footer.html │ ├── index.html │ └── layout.html │ └── pug │ ├── error.pug │ ├── index.pug │ └── layout.pug ├── gulpfile.js ├── package.json └── test └── app.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.md] 11 | trim_trailing_whitespace = false 12 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "eslint:recommended", 3 | "env": { 4 | "node": true, 5 | "mocha": true 6 | }, 7 | "rules": { 8 | "array-bracket-spacing": [ 9 | 2, 10 | "never" 11 | ], 12 | "brace-style": [ 13 | 2, 14 | "1tbs" 15 | ], 16 | "consistent-return": 0, 17 | "indent": [ 18 | 2, 19 | 2, 20 | { 21 | "SwitchCase": 1 22 | } 23 | ], 24 | "no-multiple-empty-lines": [ 25 | 2, 26 | { 27 | "max": 2 28 | } 29 | ], 30 | "no-use-before-define": [ 31 | 2, 32 | "nofunc" 33 | ], 34 | "one-var": [ 35 | 2, 36 | "never" 37 | ], 38 | "quote-props": [ 39 | 2, 40 | "as-needed" 41 | ], 42 | "quotes": [ 43 | 2, 44 | "single" 45 | ], 46 | "space-before-blocks": [ 47 | 2, 48 | "always" 49 | ], 50 | "keyword-spacing": [ 51 | 2 52 | ], 53 | "space-before-function-paren": [ 54 | 2, 55 | { 56 | "anonymous": "always", 57 | "named": "never" 58 | } 59 | ], 60 | "space-in-parens": [ 61 | 2, 62 | "never" 63 | ], 64 | "strict": [ 65 | 2, 66 | "global" 67 | ], 68 | "curly": [ 69 | 2, 70 | "all" 71 | ], 72 | "eol-last": 2, 73 | "key-spacing": [ 74 | 2, 75 | { 76 | "beforeColon": false, 77 | "afterColon": true 78 | } 79 | ], 80 | "no-eval": 2, 81 | "no-with": 2, 82 | "space-infix-ops": 2, 83 | "dot-notation": [ 84 | 2, 85 | { 86 | "allowKeywords": true 87 | } 88 | ], 89 | "eqeqeq": [ 90 | 2, 91 | "allow-null" 92 | ], 93 | "no-alert": 2, 94 | "no-caller": 2, 95 | "no-console": 0, 96 | "no-extend-native": 2, 97 | "no-extra-bind": 2, 98 | "no-implied-eval": 2, 99 | "no-iterator": 2, 100 | "no-label-var": 2, 101 | "no-labels": 2, 102 | "no-lone-blocks": 2, 103 | "no-loop-func": 2, 104 | "no-multi-spaces": 2, 105 | "no-multi-str": 2, 106 | "no-native-reassign": 2, 107 | "no-new": 2, 108 | "no-new-func": 2, 109 | "no-new-wrappers": 2, 110 | "no-octal-escape": 2, 111 | "no-proto": 2, 112 | "no-return-assign": 2, 113 | "no-script-url": 2, 114 | "no-sequences": 2, 115 | "no-unused-expressions": 2, 116 | "yoda": 2, 117 | "no-shadow": 2, 118 | "no-shadow-restricted-names": 2, 119 | "no-undef-init": 2, 120 | "camelcase": 2, 121 | "comma-spacing": 2, 122 | "new-cap": 2, 123 | "new-parens": 2, 124 | "no-array-constructor": 2, 125 | "no-extra-parens": 2, 126 | "no-new-object": 2, 127 | "no-spaced-func": 2, 128 | "no-trailing-spaces": 2, 129 | "semi": 2, 130 | "semi-spacing": [ 131 | 2, 132 | { 133 | "before": false, 134 | "after": true 135 | } 136 | ] 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | coverage 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - v5 4 | - v4 5 | - '0.12' 6 | - '0.10' 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 caryfff (https://github.com/CaryFFF) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # generator-express-ts 2 | [![NPM version][npm-image]][npm-url] [![NPM downloads](https://img.shields.io/badge/download-100%2B%2Fmonth-green.svg?style=flat)](https://www.npmjs.com/package/generator-express-ts) 3 | > Yeoman generator for creating an application using Express and TypeScript. 4 | 5 | ## Installation 6 | 7 | First, install [Yeoman](http://yeoman.io) and generator-express-ts using [npm](https://www.npmjs.com/) (we'll assume you have pre-installed [node.js](https://nodejs.org/)). 8 | 9 | ```bash 10 | npm install -g yo typescript 11 | npm install -g generator-express-ts 12 | ``` 13 | 14 | Then generate your new project: 15 | 16 | ```bash 17 | yo express-ts 18 | ``` 19 | 20 | After generating your project, cd into it, compile TypeScript files into JavaScript files: 21 | ```bash 22 | tsc 23 | ``` 24 | 25 | After everything is finished, run your project: 26 | ``` 27 | node app/bin/www.js --harmony 28 | ``` 29 | 30 | ## Getting To Know Yeoman 31 | 32 | Yeoman has a heart of gold. He's a person with feelings and opinions, but he's very easy to work with. If you think he's too opinionated, he can be easily convinced. Feel free to [learn more about him](http://yeoman.io/). 33 | 34 | ## License 35 | 36 | MIT © [infeng](https://github.com/infeng) 37 | 38 | 39 | [npm-image]: https://badge.fury.io/js/generator-express-ts.svg 40 | [npm-url]: https://npmjs.org/package/generator-express-ts 41 | [travis-image]: https://travis-ci.org/infeng/generator-express-ts.svg?branch=master 42 | [travis-url]: https://travis-ci.org/infeng/generator-express-ts 43 | [daviddm-image]: https://david-dm.org/infeng/generator-express-ts.svg?theme=shields.io 44 | [daviddm-url]: https://david-dm.org/infeng/generator-express-ts 45 | [coveralls-image]: https://coveralls.io/repos/infeng/generator-express-ts/badge.svg 46 | [coveralls-url]: https://coveralls.io/r/infeng/generator-express-ts 47 | -------------------------------------------------------------------------------- /generators/app/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var yeoman = require('yeoman-generator'); 3 | var path = require('path'); 4 | var glob = require('glob'); 5 | var mkdirp = require('mkdirp'); 6 | var generators = require('yeoman-generator'); 7 | 8 | module.exports = yeoman.Base.extend({ 9 | constructor: function () { 10 | generators.Base.apply(this, arguments); 11 | 12 | // add option to skip install 13 | this.option('skip-install'); 14 | 15 | }, 16 | prompting: { 17 | 18 | dir: function () { 19 | if (this.options.createDirectory !== undefined) { 20 | return true; 21 | } 22 | 23 | var done = this.async(); 24 | var prompt = [{ 25 | type: 'confirm', 26 | name: 'createDirectory', 27 | message: 'Would you like to create a new directory for your project?', 28 | default: true 29 | }]; 30 | 31 | this.prompt(prompt, function (response) { 32 | this.options.createDirectory = response.createDirectory; 33 | done(); 34 | }.bind(this)); 35 | }, 36 | dirname: function () { 37 | if (!this.options.createDirectory || this.options.dirname) { 38 | return true; 39 | } 40 | 41 | var done = this.async(); 42 | var prompt = [{ 43 | type: 'input', 44 | name: 'dirname', 45 | message: 'Enter directory name' 46 | }]; 47 | 48 | this.prompt(prompt, function (response) { 49 | this.options.dirname = response.dirname; 50 | done(); 51 | }.bind(this)); 52 | }, 53 | viewEngine: function () { 54 | if (this.options.viewEngine) { 55 | return true; 56 | } 57 | 58 | var done = this.async(); 59 | var prompt = [{ 60 | type: 'list', 61 | name: 'viewEngine', 62 | message: 'Select a view engine to use', 63 | choices: [ 64 | 'pug', 65 | 'ejs' 66 | ], 67 | store: true 68 | }]; 69 | 70 | this.prompt(prompt, function (response) { 71 | this.options.viewEngine = response.viewEngine.toLowerCase(); 72 | done(); 73 | }.bind(this)); 74 | } 75 | }, 76 | 77 | writing: { 78 | buildEnv: function () { 79 | 80 | //create directory 81 | if (this.options.createDirectory) { 82 | this.destinationRoot(this.options.dirname); 83 | this.appname = this.options.appname; 84 | } 85 | 86 | //shared across all generators 87 | this.sourceRoot(path.join(__dirname, 'templates', 'shared')); 88 | glob.sync('**', {cwd: this.sourceRoot()}).map(function (file) { 89 | this.template(file, file.replace(/^_/, '')); 90 | }, this); 91 | 92 | //basic 93 | this.sourceRoot(path.join(__dirname, 'templates', 'basic')); 94 | this.template('.', '.'); 95 | 96 | //.vscode 97 | mkdirp.sync('.vscode'); 98 | this.sourceRoot(path.join(__dirname, 'templates', 'basic', '.vscode')); 99 | this.template('.', '.vscode'); 100 | 101 | //views 102 | var views = this.options.viewEngine; 103 | this.sourceRoot(path.join(__dirname, 'templates', 'views', views)); 104 | if (this.options.viewEngine === 'ejs') { 105 | this.bulkDirectory('.', 'app/views'); 106 | } else { 107 | this.directory('.', 'app/views'); 108 | } 109 | }, 110 | assetDirs: function () { 111 | mkdirp.sync('app/public'); 112 | mkdirp.sync('app/public/javascripts'); 113 | mkdirp.sync('app/public/stylesheets'); 114 | mkdirp.sync('app/public/images'); 115 | } 116 | }, 117 | 118 | install: function () { 119 | if (!this.options['skip-install']) { 120 | this.installDependencies({ 121 | npm: true, 122 | bower: false, 123 | }); 124 | } 125 | } 126 | }); 127 | -------------------------------------------------------------------------------- /generators/app/templates/basic/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Launch", 6 | "type": "node", 7 | "request": "launch", 8 | "program": "${workspaceRoot}/app/bin/www.js", 9 | "stopOnEntry": false, 10 | "args": [], 11 | "cwd": "${workspaceRoot}/", 12 | "runtimeExecutable": null, 13 | "runtimeArgs": [ 14 | "--nolazy", 15 | "--harmony" 16 | ], 17 | "env": { 18 | "NODE_ENV": "development", 19 | "PORT": "3000" 20 | }, 21 | "externalConsole": false, 22 | "sourceMaps": true, 23 | "outDir": "${workspaceRoot}/app" 24 | }, 25 | { 26 | "name": "Attach", 27 | "type": "node", 28 | "request": "attach", 29 | "port": 5858 30 | } 31 | ] 32 | } -------------------------------------------------------------------------------- /generators/app/templates/basic/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "0.1.0", 5 | "command": "tsc", 6 | "isShellCommand": true, 7 | "args": ["-w", "-p", "."], 8 | "showOutput": "silent", 9 | "isBackground": true, 10 | "problemMatcher": "$tsc-watch" 11 | } -------------------------------------------------------------------------------- /generators/app/templates/basic/src/app.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import * as express from 'express'; 4 | import * as path from 'path'; 5 | import * as favicon from 'serve-favicon'; 6 | import * as logger from 'morgan'; 7 | import * as cookieParser from 'cookie-parser'; 8 | import * as bodyParser from 'body-parser'; 9 | import index from './routes/index';<% if(options.viewEngine == 'ejs'){ %> 10 | import * as ejs from 'ejs';<% } %> 11 | 12 | const app: express.Express = express(); 13 | 14 | //view engine setup 15 | <% if(options.viewEngine == 'pug'){ %>app.set('views',path.join(__dirname,'views')); 16 | app.set('view engine','pug');<% }else if(options.viewEngine == 'ejs'){ %> 17 | app.set('views',path.join(__dirname,'views')); 18 | app.engine('.html',ejs.renderFile); 19 | app.set('view engine','html');<% } %> 20 | 21 | //uncomment after placing your favicon in /public 22 | //app.use(favicon(path.join(__dirname,'public','favicon.ico'))); 23 | app.use(logger('dev')); 24 | app.use(bodyParser.json()); 25 | app.use(bodyParser.urlencoded({extended: false})); 26 | app.use(cookieParser()); 27 | app.use(express.static(path.join(__dirname,'public'))); 28 | 29 | app.use('/',index); 30 | 31 | //catch 404 and forward to error handler 32 | app.use((req,res,next) => { 33 | var err = new Error('Not Found'); 34 | err['status'] = 404; 35 | next(err); 36 | }); 37 | 38 | //error handlers 39 | 40 | //development error handler 41 | //will print stacktrace 42 | if(process.env.NODE_ENV === 'development') { 43 | app.use((err: Error,req,res,next) => { 44 | res.status(err['status'] || 500); 45 | res.render('error',{ 46 | title: 'error', 47 | message: err.message, 48 | error: err 49 | }); 50 | }); 51 | } 52 | 53 | //production error handler 54 | // no stacktrace leaked to user 55 | app.use((err: Error,req,res,next) => { 56 | res.status(err['status'] || 500); 57 | res.render('error',{ 58 | title: 'error', 59 | message: err.message, 60 | error: {} 61 | }); 62 | }); 63 | 64 | export default app; 65 | -------------------------------------------------------------------------------- /generators/app/templates/basic/src/bin/www.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | /** 3 | * Module dependencies. 4 | */ 5 | 6 | import app from '../app'; 7 | import * as http from 'http'; 8 | 9 | /** 10 | * Get port from environment and store in Express. 11 | */ 12 | 13 | const port = normalizePort(process.env.PORT || 3000); 14 | app.set('port',port); 15 | 16 | /** 17 | * Create HTTP server. 18 | */ 19 | 20 | var server = http.createServer(app); 21 | 22 | /** 23 | * Listen on provided port,on all network interfaces. 24 | */ 25 | 26 | server.listen(port, onListening); 27 | server.on('error',onError); 28 | 29 | /** 30 | * Normalize a port into a number,string,or false. 31 | */ 32 | function normalizePort(val : any): number|string|boolean { 33 | let port = parseInt(val,10); 34 | 35 | if(isNaN(port)){ 36 | //name pipe 37 | return val; 38 | } 39 | 40 | if(port >= 0){ 41 | return port; 42 | } 43 | 44 | return false; 45 | } 46 | 47 | /** 48 | * Event listener for HTTP server "error" event. 49 | */ 50 | function onError(error) { 51 | if (error.syscall != 'listen') { 52 | throw error; 53 | } 54 | 55 | var bind = typeof port === 'string' ? 'Pipe ' + port : 'Port ' + port; 56 | 57 | //handle specific listen errors with friendly messages 58 | switch(error.code) { 59 | case 'EACCES': 60 | console.error(bind + 'requires elevated privileges'); 61 | process.exit(1); 62 | break; 63 | case 'EADDRINUSE': 64 | console.error(bind + 'is already in use'); 65 | process.exit(1); 66 | break; 67 | default: 68 | throw error; 69 | } 70 | } 71 | 72 | /** 73 | * Event listener for HTTP server "listening" event. 74 | */ 75 | function onListening() { 76 | var addr = server.address(); 77 | var bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port; 78 | console.log('Listening on ' + bind); 79 | } -------------------------------------------------------------------------------- /generators/app/templates/basic/src/routes/index.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import * as express from 'express'; 4 | const router = express.Router(); 5 | 6 | /* GET home page. */ 7 | router.get('/',(req,res,next) => { 8 | res.render('index', {title: 'Express'}); 9 | }); 10 | 11 | export default router; -------------------------------------------------------------------------------- /generators/app/templates/shared/_.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/* 2 | typings/* 3 | npm-debug.log 4 | .settings/* 5 | .git/* 6 | bower_components/* 7 | -------------------------------------------------------------------------------- /generators/app/templates/shared/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "app", 3 | "version": "0.0.1", 4 | "ignore": [ 5 | "**/.*", 6 | "node_modules", 7 | "components" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /generators/app/templates/shared/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "app", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "start": "node app/bin/www.js" 7 | }, 8 | "dependencies": { 9 | "body-parser": "^1.17.1", 10 | "cookie-parser": "^1.4.3", 11 | "express": "^4.15.2",<% if(options.viewEngine == 'pug'){ %> 12 | "pug": "^2.0.0-beta11",<% }else if(options.viewEngine == 'ejs'){ %> 13 | "ejs": "^2.5.6",<% }%> 14 | "morgan": "^1.8.1", 15 | "serve-favicon": "^2.4.1" 16 | }, 17 | "devDependencies": { 18 | "@types/body-parser": "1.16.1", 19 | "@types/cookie-parser": "^1.3.30", 20 | "@types/ejs": "^2.3.33", 21 | "@types/express": "^4.0.35", 22 | "@types/morgan": "^1.7.32", 23 | "@types/node": "^7.0.10", 24 | "@types/serve-favicon": "^2.2.28" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /generators/app/templates/shared/process.json: -------------------------------------------------------------------------------- 1 | { 2 | "apps": [{ 3 | "name": "app", 4 | "script": "app/bin/www.js", 5 | "node_args": "--harmony", 6 | "log_date_format": "YYYY - MM - DD HH: mm Z", 7 | "env": { 8 | "NODE_ENV" : "production", 9 | "PORT": 3000 10 | } 11 | }] 12 | } -------------------------------------------------------------------------------- /generators/app/templates/shared/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "removeComments": true, 6 | "sourceMap": true, 7 | "outDir": "app", 8 | "rootDir": "src" 9 | }, 10 | "exclude":[ 11 | "node_modules" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /generators/app/templates/views/ejs/error.html: -------------------------------------------------------------------------------- 1 | <%- include('./layout.html') -%> 2 | 3 |

<%= message %>

4 |

<%= error.status %>

5 |
<%= error.stack %>
6 | 7 | <%- include('./footer.html') -%> -------------------------------------------------------------------------------- /generators/app/templates/views/ejs/footer.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /generators/app/templates/views/ejs/index.html: -------------------------------------------------------------------------------- 1 | <%- include('./layout.html') -%> 2 | 3 |

<%= title %>

4 |

Welcome to <%= title %>

5 | 6 | <%- include('./footer.html') -%> -------------------------------------------------------------------------------- /generators/app/templates/views/ejs/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%= title %> 5 | 6 | 7 | -------------------------------------------------------------------------------- /generators/app/templates/views/pug/error.pug: -------------------------------------------------------------------------------- 1 | extends layout 2 | 3 | block content 4 | h1= message 5 | h2= error.status 6 | pre #{error.stack} -------------------------------------------------------------------------------- /generators/app/templates/views/pug/index.pug: -------------------------------------------------------------------------------- 1 | extends layout 2 | 3 | block content 4 | h1= title 5 | p Welcome to #{title} -------------------------------------------------------------------------------- /generators/app/templates/views/pug/layout.pug: -------------------------------------------------------------------------------- 1 | doctype html 2 | html 3 | head 4 | meta(charset='utf-8') 5 | title= title 6 | body 7 | block content -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var path = require('path'); 3 | var gulp = require('gulp'); 4 | var eslint = require('gulp-eslint'); 5 | var excludeGitignore = require('gulp-exclude-gitignore'); 6 | var mocha = require('gulp-mocha'); 7 | var istanbul = require('gulp-istanbul'); 8 | var nsp = require('gulp-nsp'); 9 | var coveralls = require('gulp-coveralls'); 10 | 11 | gulp.task('static', function () { 12 | return gulp.src('**/*.js') 13 | .pipe(excludeGitignore()) 14 | .pipe(eslint()) 15 | .pipe(eslint.format()) 16 | .pipe(eslint.failAfterError()); 17 | }); 18 | 19 | gulp.task('nsp', function (done) { 20 | nsp({package: path.resolve('package.json')}, done); 21 | }); 22 | 23 | gulp.task('pre-test', function () { 24 | return gulp.src('generators/**/*.js') 25 | .pipe(istanbul({ 26 | includeUntested: true 27 | })) 28 | .pipe(istanbul.hookRequire()); 29 | }); 30 | 31 | gulp.task('test', ['pre-test'], function () { 32 | 33 | return gulp.src('test/**/*.js', {read: false}) 34 | .pipe(mocha({reporter: 'spec'})) 35 | .pipe(istanbul.writeReports()); 36 | }); 37 | 38 | gulp.task('coveralls', ['test'], function () { 39 | if (!process.env.CI) { 40 | return; 41 | } 42 | 43 | return gulp.src(path.join(__dirname, 'coverage/lcov.info')) 44 | .pipe(coveralls()); 45 | }); 46 | 47 | gulp.task('prepublish', ['nsp']); 48 | gulp.task('default', ['static', 'test', 'coveralls']); 49 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "generator-express-ts", 3 | "version": "1.0.6", 4 | "description": "Yeoman generator for creating an application,using express and typescript.", 5 | "homepage": "https://github.com/infeng/generator-express-ts", 6 | "author": { 7 | "name": "infeng", 8 | "email": "fzhihao@outlook.com", 9 | "url": "https://github.com/infeng" 10 | }, 11 | "files": [ 12 | "generators" 13 | ], 14 | "main": "generators\\index.js", 15 | "keywords": [ 16 | "yeoman-generator", 17 | "express", 18 | "typescript" 19 | ], 20 | "dependencies": { 21 | "glob": "latest", 22 | "lodash": "latest", 23 | "mkdirp": "latest", 24 | "yeoman-generator": "^0.21.1" 25 | }, 26 | "devDependencies": { 27 | "yeoman-assert": "latest", 28 | "gulp": "latest", 29 | "gulp-eslint": "latest", 30 | "gulp-exclude-gitignore": "latest", 31 | "gulp-istanbul": "latest", 32 | "gulp-mocha": "latest", 33 | "gulp-plumber": "latest", 34 | "gulp-nsp": "latest", 35 | "gulp-coveralls": "latest", 36 | "yeoman-test": "latest", 37 | "async": "latest" 38 | }, 39 | "repository": "https://github.com/infeng/generator-express-ts", 40 | "scripts": { 41 | "prepublish": "gulp prepublish", 42 | "test": "gulp" 43 | }, 44 | "license": "MIT" 45 | } 46 | -------------------------------------------------------------------------------- /test/app.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var path = require('path'); 3 | var helpers = require('yeoman-test'); 4 | var async = require('async'); 5 | 6 | describe('generator-express-ts:app', function () { 7 | this.timeout(0); // Because the tests take a pretty long time 8 | it('runs with each view engine as options', function (done) { 9 | // Runs for each view engine 10 | async.each(['ejs', 'pug'], function (viewengine, callback) { 11 | helpers.run(path.join(__dirname, '../generators/app')) 12 | .withOptions({createDirectory: true, dirname: 'generator-express-ts', viewEngine: viewengine}) 13 | .on('end', callback); 14 | }, function (err) { 15 | done(err); 16 | }); 17 | }); 18 | it('runs with each view engine as prompts', function (done) { 19 | // Runs for each view engine 20 | async.each(['ejs', 'pug'], function (viewengine, callback) { 21 | helpers.run(path.join(__dirname, '../generators/app')) 22 | .withPrompts({createDirectory: true, dirname: 'generator-express-ts', viewEngine: viewengine}) 23 | .on('end', callback); 24 | }, function (err) { 25 | done(err); 26 | }); 27 | }); 28 | it('runs without skip-install', function (done) { 29 | // Runs for each view engine 30 | async.each(['ejs', 'pug'], function (viewengine, callback) { 31 | helpers.run(path.join(__dirname, '../generators/app')) 32 | .withOptions({viewEngine: viewengine, 'skip-install': false}).on('end', callback); 33 | }, function (err) { 34 | done(err); 35 | }); 36 | }); 37 | it('runs without a subdirectory', function (done) { 38 | // Runs for each view engine 39 | async.each(['ejs', 'pug'], function (viewengine, callback) { 40 | helpers.run(path.join(__dirname, '../generators/app')) 41 | .withOptions({viewEngine: viewengine}).on('end', callback); 42 | }, function (err) { 43 | done(err); 44 | }); 45 | }); 46 | }); 47 | 48 | --------------------------------------------------------------------------------