├── .editorconfig ├── .gitattributes ├── .gitignore ├── .jshintrc ├── .travis.yml ├── .yo-rc.json ├── README.md ├── app ├── index.js └── templates │ ├── .settings │ └── tasks.json.tmpl │ ├── _.bowerrc │ ├── _.ng-ts.json │ ├── _README.md │ ├── _bower.json │ ├── _gulp.config.js │ ├── _gulpfile.js │ ├── _package.json │ ├── _tsconfig.json │ ├── _tsd.json │ ├── _tslint.json │ ├── editorconfig │ └── wwwroot │ ├── _index.html │ ├── app │ ├── app.module.ts.tmpl │ ├── blocks │ │ ├── exception │ │ │ ├── exception-handler.provider.ts.tmpl │ │ │ ├── exception.module.ts.tmpl │ │ │ └── exception.ts.tmpl │ │ ├── log │ │ │ ├── log.module.ts.tmpl │ │ │ └── logger.ts.tmpl │ │ └── router │ │ │ ├── router-helper.provider.ts.tmpl │ │ │ └── router.module.ts.tmpl │ ├── core │ │ ├── config.ts.tmpl │ │ ├── constants.ts.tmpl │ │ ├── core.module.ts.tmpl │ │ ├── core.route.ts.tmpl │ │ ├── notFound.controller.ts.tmpl │ │ └── notFound.html.tmpl │ └── home │ │ ├── home.controller.ts.tmpl │ │ ├── home.html.tmpl │ │ ├── home.module.ts.tmpl │ │ └── home.route.ts.tmpl │ ├── styles │ └── styles.css.tmpl │ └── typings │ └── tsd.d.ts ├── controller ├── index.js └── templates │ └── controller.ts.tmpl ├── directive ├── index.js └── templates │ ├── controller.ts.tmpl │ ├── directive.html.tmpl │ └── directive.ts.tmpl ├── module ├── index.js └── templates │ └── module.ts.tmpl ├── name-processor.js ├── ng-ts-environment.js ├── package.json └── subgenerator-base.js /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 4 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | *.log 3 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "esnext": true, 4 | "bitwise": true, 5 | "camelcase": true, 6 | "curly": true, 7 | "eqeqeq": true, 8 | "immed": true, 9 | "indent": 2, 10 | "latedef": true, 11 | "newcap": true, 12 | "noarg": true, 13 | "quotmark": "single", 14 | "undef": true, 15 | "unused": true, 16 | "strict": true 17 | } -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | node_js: 4 | - 'iojs' 5 | - '0.12' 6 | - '0.10' 7 | -------------------------------------------------------------------------------- /.yo-rc.json: -------------------------------------------------------------------------------- 1 | { 2 | "generator-generator": {} 3 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # generator-ng-ts [](https://travis-ci.org/olohmann/generator-ng-ts) 2 | 3 | > A [Yeoman](http://yeoman.io) generator for [Angular 1.x](https://angularjs.org/) [TypeScript](http://www.typescriptlang.org/) projects. 4 | 5 | ## Features 6 | 7 | * Creates a **complete Angular/TypeScript project setup**. Including a gulpfile that is able to maintain a standard [tsconfig.json](https://github.com/Microsoft/TypeScript/wiki/tsconfig.json) file for maxiumum editor compatibilty. There is no gulpfile TypeScript compiler magic involved! The gulp build task simply calls your installed TypeScript compiler which automatically picks up the setup in the `tsconfig.json` file. 8 | 9 | * Supports **Angular sub-generators**. So far directives, controllers and modules are covered. 10 | 11 | * It is **server framework agnostic**. That is, it just creates static HTML, JavaScript and CSS files in a sub-directory of your choice (e.g. `public` or `wwwroot`). Thus you can use the generator to in combination with a Node.JS or ASP.NET 5 backend. 12 | 13 | * Adheres to established **community guidelines**. That is, the structure and coding aims for compatibilty with [John Papa](http://www.johnpapa.net/)'s excellent [Angular styleguide](https://github.com/johnpapa/angular-styleguide). 14 | 15 | * Adopts some of the infrastructure components of [John Papa](http://www.johnpapa.net/)'s [HotTowel generator](https://github.com/johnpapa/generator-hottowel), but tries to avoid the template-throw-away-code. 16 | 17 | ## Currently Missing Features 18 | 19 | Features for future releases: 20 | 21 | * Complete minification flow (including vendor components) 22 | * LESS support 23 | * Item templates & gulp tasks for (unit) testing 24 | 25 | ## Getting Started 26 | 27 | ### Installation 28 | 29 | ```bash 30 | npm install -g tsd 31 | npm install -g typescript@1.5.0-beta 32 | npm install -g bower 33 | npm install -g yo 34 | npm install -g generator-ng-ts 35 | ``` 36 | 37 | You need to install tsd, bower and typescript as globals since the ng-ts generator toolchain relies on it. 38 | 39 | ### Scaffold an App 40 | ```bash 41 | mkdir app 42 | cd app 43 | yo ng-ts 44 | ``` 45 | 46 | Result: 47 | ``` 48 | +---.settings editor settings VS Code 49 | \---wwwroot static web root 50 | +---app angular app root 51 | | +---blocks infrastructure components 52 | | | +---exception 53 | | | +---log 54 | | | \---router 55 | | +---core routing and core app config 56 | | \---home the home module 57 | +---styles CSS 58 | +---typings TypeScript typings 59 | | +---angularjs 60 | | [... more typings ...] 61 | \---vendor 3rd party components (via bower) 62 | +---angular 63 | [... vendor components ...] 64 | ``` 65 | 66 | ### Scaffold a Module 67 | ``` 68 | cd wwwroot/app 69 | mkdir widgets 70 | cd widgets 71 | yo ng-ts:module 72 | ``` 73 | 74 | Creates a file `widgets.module.ts`. 75 | 76 | Scaffolding is conventional. The name of the module will be derived automaticall via inspecting your subfolder hierarchy. 77 | 78 | ### Scaffold a Directive 79 | ``` 80 | yo ng-ts:directive dateTimeNow 81 | ``` 82 | 83 | Creates three files: 84 | 85 | * `dateTimeNow.directive.controller.ts` 86 | * `dateTimeNow.directive.ts` 87 | * `dateTimeNow.directive.html` 88 | 89 | ### Gulp Tasks 90 | 91 | The gulpfile has a built-in help page that lists all the tasks and provides a short description: 92 | 93 | ```bash 94 | gulp help 95 | ``` 96 | 97 | ### Getting To Know Yeoman 98 | 99 | Read the complete [Getting Started Guide](https://github.com/yeoman/yeoman/wiki/Getting-Started). 100 | 101 | 102 | ## License 103 | 104 | MIT © [Oliver Lohmann](http://www.oliver-lohmann.me/) 105 | -------------------------------------------------------------------------------- /app/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var yeoman = require('yeoman-generator'); 3 | var chalk = require('chalk'); 4 | var yosay = require('yosay'); 5 | var path = require('path'); 6 | var nameProcessor = require('../name-processor'); 7 | var generators = yeoman.generators; 8 | 9 | module.exports = generators.Base.extend({ 10 | initializing: function () { 11 | this.pkg = require('../package.json'); 12 | this.mkdirp = require('mkdirp'); 13 | }, 14 | 15 | constructor: function() { 16 | // arguments and options should be 17 | // defined in the constructor. 18 | generators.Base.apply(this, arguments); 19 | this.argument('appName', { type: String, required: false }); 20 | this.argument('wwwRoot', { type: String, required: false }); 21 | }, 22 | 23 | welcome: function() { 24 | // Have Yeoman greet the user. 25 | this.log(yosay( 26 | 'Welcome to the stunning ' 27 | + chalk.red('ng ts') + 28 | ' generator! A lovely marriage of ' 29 | + chalk.green('AngularJS') + ' and ' 30 | + chalk.blue('TypeScript') 31 | )); 32 | }, 33 | 34 | prompting: function () { 35 | 36 | var done = this.async(); 37 | 38 | var prompts = [{ 39 | type: 'input', 40 | name: 'appName', 41 | message: 'What would you like to name the app?', 42 | default: this.appName || path.basename(process.cwd()) 43 | }, 44 | { 45 | type: 'input', 46 | name: 'wwwRoot', 47 | message: 'Which folder is the static content root of your app?', 48 | default: this.wwwRoot || 'wwwroot' 49 | }]; 50 | 51 | this.prompt(prompts, function (answers) { 52 | this.appName = answers.appName || 'ng-ts-app'; 53 | this.wwwRoot = answers.wwwRoot || 'wwwroot'; 54 | done(); 55 | }.bind(this)); 56 | }, 57 | 58 | displayName: function() { 59 | this.log('Creating ' + this.appName + ' app based on ng-ts.'); 60 | }, 61 | 62 | writing: { 63 | folders: function() { 64 | this.mkdirp('.settings'); 65 | this.mkdirp(this.wwwRoot); 66 | this.mkdirp(this.wwwRoot + '/app'); 67 | this.mkdirp(this.wwwRoot + '/styles'); 68 | this.mkdirp(this.wwwRoot + '/typings'); 69 | this.mkdirp(this.wwwRoot + '/vendor'); 70 | }, 71 | 72 | files: function () { 73 | var that = this; 74 | 75 | var ctx = { 76 | appName: nameProcessor.getCamelizedName(that.appName), 77 | appModuleName: nameProcessor.getModuleName(that.appName), 78 | appNameSlugified: nameProcessor.getSlugifiedName(that.appName), 79 | wwwRoot: that.wwwRoot 80 | }; 81 | 82 | var copyCmds = [ 83 | ['editorconfig','.editorconfig'], 84 | ['_.ng-ts.json','.ng-ts.json'], 85 | ['_tsconfig.json','tsconfig.json'], 86 | ['_tslint.json','tslint.json'], 87 | ['_README.md','README.md'], 88 | ['_package.json','package.json'], 89 | ['_bower.json','bower.json'], 90 | ['_tsd.json','tsd.json'], 91 | ['_gulpfile.js','gulpfile.js'], 92 | ['_gulp.config.js','gulp.config.js'], 93 | ['_.bowerrc','.bowerrc'], 94 | 95 | // VS Code Settings 96 | ['.settings/tasks.json.tmpl','./.settings/tasks.json'], 97 | 98 | ['wwwroot/_index.html', that.wwwRoot + '/index.html'], 99 | 100 | ['wwwroot/app/app.module.ts.tmpl', that.wwwRoot + '/app/app.module.ts'], 101 | 102 | ['wwwroot/app/blocks/exception/exception-handler.provider.ts.tmpl', that.wwwRoot + '/app/blocks/exception/exception-handler.provider.ts'], 103 | ['wwwroot/app/blocks/exception/exception.module.ts.tmpl', that.wwwRoot + '/app/blocks/exception/exception.module.ts'], 104 | ['wwwroot/app/blocks/exception/exception.ts.tmpl', that.wwwRoot + '/app/blocks/exception/exception.ts'], 105 | ['wwwroot/app/blocks/log/log.module.ts.tmpl', that.wwwRoot + '/app/blocks/log/log.module.ts'], 106 | ['wwwroot/app/blocks/log/logger.ts.tmpl', that.wwwRoot + '/app/blocks/log/logger.ts'], 107 | ['wwwroot/app/blocks/router/router-helper.provider.ts.tmpl', that.wwwRoot + '/app/blocks/router/router-helper.provider.ts'], 108 | ['wwwroot/app/blocks/router/router.module.ts.tmpl', that.wwwRoot + '/app/blocks/router/router.module.ts'], 109 | 110 | ['wwwroot/app/core/notFound.html.tmpl', that.wwwRoot + '/app/core/notFound.html'], 111 | ['wwwroot/app/core/notFound.controller.ts.tmpl', that.wwwRoot + '/app/core/notFound.controller.ts'], 112 | ['wwwroot/app/core/config.ts.tmpl', that.wwwRoot + '/app/core/config.ts'], 113 | ['wwwroot/app/core/constants.ts.tmpl', that.wwwRoot + '/app/core/constants.ts'], 114 | ['wwwroot/app/core/core.module.ts.tmpl', that.wwwRoot + '/app/core/core.module.ts'], 115 | ['wwwroot/app/core/core.route.ts.tmpl', that.wwwRoot + '/app/core/core.route.ts'], 116 | 117 | ['wwwroot/app/home/home.controller.ts.tmpl', that.wwwRoot + '/app/home/home.controller.ts'], 118 | ['wwwroot/app/home/home.route.ts.tmpl', that.wwwRoot + '/app/home/home.route.ts'], 119 | ['wwwroot/app/home/home.html.tmpl', that.wwwRoot + '/app/home/home.html'], 120 | ['wwwroot/app/home/home.module.ts.tmpl', that.wwwRoot + '/app/home/home.module.ts'], 121 | 122 | ['wwwroot/typings/tsd.d.ts', that.wwwRoot + '/typings/tsd.d.ts'], 123 | 124 | ['wwwroot/styles/styles.css.tmpl', that.wwwRoot + '/styles/styles.css'] 125 | ]; 126 | 127 | copyCmds.forEach(function(pair) { 128 | that.fs.copyTpl( 129 | that.templatePath(pair[0]), 130 | that.destinationPath(pair[1]), 131 | ctx 132 | ); 133 | }); 134 | } 135 | }, 136 | 137 | install: function() { 138 | var that = this; 139 | that.installDependencies(function() { 140 | that.log('Running ' + chalk.yellow.bold('tsd reinstall && tsd rebundle') + 141 | '. If this fails run the commands ' + 142 | 'yourself. tsd must be installed via `npm install -g tsd@next`.'); 143 | 144 | var tsdReinstall = that.spawnCommand('tsd', ['reinstall']); 145 | tsdReinstall.on('close', function(code) { 146 | var tsdRebundle = that.spawnCommand('tsd', ['rebundle']); 147 | tsdRebundle.on('close', function() { 148 | that.log('Running gulp tsbuild...'); 149 | that.spawnCommand('gulp', ['tsbuild']); 150 | }); 151 | }); 152 | }); 153 | 154 | } 155 | }); 156 | -------------------------------------------------------------------------------- /app/templates/.settings/tasks.json.tmpl: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.1.0", 3 | "command": "gulp", 4 | "isShellCommand": true, 5 | "args": [ 6 | "--no-color" 7 | ], 8 | "tasks": [ 9 | { 10 | "taskName": "build", 11 | "args": [], 12 | "isBuildCommand": true, 13 | "isWatching": false, 14 | "problemMatcher": [ 15 | "$lessCompile", 16 | "$tsc", 17 | "$jshint" 18 | ] 19 | }, 20 | { 21 | "taskName": "test", 22 | "args": [], 23 | "isTestCommand": true 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /app/templates/_.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "<%= wwwRoot %>/vendor", 3 | "scripts": { 4 | "postinstall": "gulp wiredep" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /app/templates/_.ng-ts.json: -------------------------------------------------------------------------------- 1 | { 2 | "appName": "<%= appName %>", 3 | "wwwRoot": "<%= wwwRoot %>" 4 | } 5 | -------------------------------------------------------------------------------- /app/templates/_README.md: -------------------------------------------------------------------------------- 1 | # <%= appName %> 2 | -------------------------------------------------------------------------------- /app/templates/_bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= appName %>", 3 | "version": "0.0.0", 4 | "dependencies": { 5 | "jquery": "^2.1.4", 6 | "angular": "^1.4.4", 7 | "angular-ui-router": "^0.2.15", 8 | "moment": "^2.10.6", 9 | "toastr": "^2.1.2" 10 | }, 11 | "ignore": [ 12 | "**/.*", 13 | "node_modules", 14 | "bower_components", 15 | "<%= wwwRoot %>/vendor", 16 | "test", 17 | "tests" 18 | ] 19 | } 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/templates/_gulp.config.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | var wiredep = require('wiredep'); 3 | 4 | module.exports = function() { 5 | var clientSrcRootName = '<%= wwwRoot %>'; 6 | var client = './' + clientSrcRootName +'/'; 7 | var clientApp = path.join(client, 'app'); 8 | var clientCompiledAppName = 'app.js'; 9 | var clientCompiledApp = path.join(client, clientCompiledAppName); 10 | 11 | var tsClient = [clientApp + '/**/*.ts']; 12 | var tsTypings = [client + '/typings/tsd.d.ts']; 13 | 14 | var config = { 15 | client: client, 16 | clientSrcRootName: clientSrcRootName, 17 | clientApp: clientApp, 18 | 19 | index: path.join(client, 'index.html'), 20 | 21 | tsClient: tsClient, 22 | tsTypings: tsTypings, 23 | tsAll: [].concat(tsTypings).concat(tsClient), 24 | tsOrder: [ 25 | '**/*.d.ts', 26 | '**/app.module.ts', 27 | '**/*.module.ts', 28 | '**/*.ts' 29 | ], 30 | 31 | clientCompiledAppName: clientCompiledAppName, 32 | clientCompiledApp: clientCompiledApp, 33 | 34 | js: [ 35 | clientCompiledApp 36 | ], 37 | 38 | jsOrder: undefined, 39 | 40 | css: [ 41 | client + '/styles/*.css' 42 | ], 43 | 44 | tsConfig: { 45 | "compilerOptions": { 46 | "target": "es5", 47 | "removeComments": true, 48 | "sourceMap": true, 49 | "noImplicitAny": true, 50 | "out": clientCompiledApp 51 | } 52 | } 53 | }; 54 | 55 | /* -- BOWER --*/ 56 | var bowerFiles = wiredep({devDependencies: true})['js']; 57 | var bower = { 58 | json: require('./bower.json'), 59 | directory: path.join(client, 'vendor'), 60 | ignorePath: [] 61 | }; 62 | 63 | config.bower = bower; 64 | 65 | config.getWiredepDefaultOptions = function() { 66 | var options = { 67 | bowerJson: config.bower.json, 68 | directory: config.bower.directory, 69 | ignorePath: config.bower.ignorePath 70 | }; 71 | 72 | return options; 73 | }; 74 | 75 | /* -----------*/ 76 | 77 | return config; 78 | }; 79 | -------------------------------------------------------------------------------- /app/templates/_gulpfile.js: -------------------------------------------------------------------------------- 1 | var args = require('yargs').argv; 2 | var config = require('./gulp.config')(); 3 | var runSequence = require('run-sequence'); 4 | 5 | var gulp = require('gulp-help')(require('gulp')); 6 | var $ = require('gulp-load-plugins')({lazy: true}); 7 | 8 | var colors = $.util.colors; 9 | 10 | // ------------- TASKS --------------------------------- 11 | 12 | gulp.task('default', 'Display this help text.', ['help']); 13 | 14 | gulp.task('wiredep', 'Wire all dependencies into index.html', function() { 15 | log(colors.green('Wiring dependencies into HTML')); 16 | 17 | var wiredep = require('wiredep').stream; 18 | var options = config.getWiredepDefaultOptions(); 19 | log('output: ' + config.client); 20 | return gulp 21 | .src(config.index) 22 | .pipe(wiredep(options)) 23 | .pipe(inject(config.js, '', config.jsOrder)) 24 | .pipe(inject(config.css)) 25 | .pipe(gulp.dest(config.client)); 26 | }); 27 | 28 | gulp.task('test', false /*'Execute tests as configured in Karma'*/, function() { 29 | log(colors.red('TODO: Not Implement.')); 30 | }); 31 | 32 | gulp.task('serve-and-watch', 33 | 'Serve the static files and watch for changes', ['serve', 'watch-ts-tsbuild']); 34 | 35 | gulp.task('serve', 'Serve the static files.', function () { 36 | return gulp.src(config.client) 37 | .pipe($.webserver({ 38 | livereload: { 39 | enable: true, 40 | filter: function(fileName) { 41 | if (fileName.match(/(\.map)|(\.ts)$/)) { 42 | return false; 43 | } else { 44 | return true; 45 | } 46 | }}, 47 | open: true, 48 | port: 1337 49 | })); 50 | }); 51 | 52 | gulp.task('build', 'Build the project.', ['tsbuild']); 53 | 54 | gulp.task('tsbuild', 'Build the TypeScript project (compile and wire).', function(cb) { 55 | runSequence('tscompile', 'wiredep', cb); 56 | }); 57 | 58 | gulp.task('tslint', 'Run the TypeScript linter.', function () { 59 | gulp.src(config.tsClient) 60 | .pipe($.tslint()) 61 | .pipe($.tslint.report('prose', { 62 | emitError: false 63 | })); 64 | }); 65 | 66 | gulp.task('tscompile', 'Compile the TypeScript project (no wiring).', ['tsconfig'], function(cb) { 67 | var cmd = new $.run.Command('tsc'); 68 | cmd.exec(cb); 69 | }); 70 | 71 | gulp.task('tsconfig', 'Create TypeScript project file (tsconfig.json).', function() { 72 | var tsConfig = $.tsconfig({ 73 | tsOrder: config.tsOrder, 74 | tsConfig: config.tsConfig 75 | }); 76 | 77 | return gulp.src(config.tsAll) 78 | .pipe(tsConfig()) 79 | .pipe(gulp.dest('.')); 80 | }); 81 | 82 | // ------------- Watchers --------------------------------- 83 | gulp.task('watch-ts-tsbuild', 'Watch TS files and run "tsbuild" on change', function () { 84 | var watcher = gulp.watch(config.tsAll, ['tsbuild'], {debounceDelay: 300}); 85 | 86 | watcher.on('change', function (event) { 87 | log('File ' + colors.red(event.path) + ' was ' + event.type + ', running tasks...'); 88 | }); 89 | }); 90 | 91 | gulp.task('watch-ts-tsconfig', 'Watch TS files and run "tsconfig" on change', function () { 92 | var watcher = gulp.watch(config.tsAll, ['tsconfig'], {debounceDelay: 300}); 93 | 94 | watcher.on('change', function (event) { 95 | log('File ' + colors.red(event.path) + ' was ' + event.type + ', running tasks...'); 96 | }); 97 | }); 98 | 99 | // ------------- TASK HELPERS -------------------------- 100 | /** 101 | * Inject files in a sorted sequence at a specified inject label 102 | * @param {Array} src glob pattern for source files 103 | * @param {String} label The label name 104 | * @param {Array} order glob pattern for sort order of the files 105 | * @returns {Stream} The stream 106 | */ 107 | function inject(src, label, order) { 108 | var options = {read: false, relative: true}; 109 | if (label) { 110 | options.name = 'inject:' + label; 111 | } 112 | 113 | return $.inject(orderSrc(src, order), options); 114 | } 115 | 116 | /** 117 | * Order a stream 118 | * @param {Stream} src The gulp.src stream 119 | * @param {Array} order Glob array pattern 120 | * @returns {Stream} The ordered stream 121 | */ 122 | function orderSrc (src, order) { 123 | //order = order || ['**/*']; 124 | return gulp 125 | .src(src) 126 | .pipe($.if(order, $.order(order))); 127 | } 128 | 129 | /** 130 | * Log a message 131 | * @param {Object} msg Message to log. 132 | */ 133 | function log(msg) { 134 | if (typeof(msg) === 'object') { 135 | for (var item in msg) { 136 | if (msg.hasOwnProperty(item)) { 137 | $.util.log(colors.blue(msg[item])); 138 | } 139 | } 140 | } else { 141 | $.util.log(colors.blue(msg)); 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /app/templates/_package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= appName %>", 3 | "description": "<%= appName %> Project Generated from ng-ts", 4 | "version": "0.0.0", 5 | "repository": {}, 6 | "dependencies": {}, 7 | "devDependencies": { 8 | "gulp": "^3.8.10", 9 | "gulp-concat": "^2.5.2", 10 | "gulp-help": "^1.3.4", 11 | "gulp-if": "^1.2.5", 12 | "gulp-inject": "^1.2.0", 13 | "gulp-insert": "^0.5.0", 14 | "gulp-load-plugins": "^0.7.0", 15 | "gulp-order": "^1.1.1", 16 | "gulp-print": "^1.1.0", 17 | "gulp-run": "^1.6.8", 18 | "gulp-tsconfig": "^0.1.0", 19 | "gulp-tslint": "^3.0.2-beta", 20 | "gulp-util": "^3.0.1", 21 | "gulp-webserver": "^0.9.1", 22 | "run-sequence": "^1.1.0", 23 | "vinyl": "^0.5.0", 24 | "wiredep": "^2.1.0", 25 | "yargs": "^3.19.0" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/templates/_tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "sourceMap": true, 4 | "noImplicitAny": true 5 | } 6 | } -------------------------------------------------------------------------------- /app/templates/_tsd.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "v4", 3 | "repo": "borisyankov/DefinitelyTyped", 4 | "ref": "master", 5 | "path": "<%= wwwRoot %>/typings", 6 | "bundle": "<%= wwwRoot %>/typings/tsd.d.ts", 7 | "installed": { 8 | "jquery/jquery.d.ts": { 9 | "commit": "8b7cc13f6dbabd0a49de7ccba75c342160e600ad" 10 | }, 11 | "angularjs/angular.d.ts": { 12 | "commit": "8b7cc13f6dbabd0a49de7ccba75c342160e600ad" 13 | }, 14 | "angular-ui-router/angular-ui-router.d.ts": { 15 | "commit": "8b7cc13f6dbabd0a49de7ccba75c342160e600ad" 16 | }, 17 | "moment/moment.d.ts": { 18 | "commit": "8b7cc13f6dbabd0a49de7ccba75c342160e600ad" 19 | }, 20 | "moment/moment-node.d.ts": { 21 | "commit": "8b7cc13f6dbabd0a49de7ccba75c342160e600ad" 22 | }, 23 | "toastr/toastr.d.ts": { 24 | "commit": "8b7cc13f6dbabd0a49de7ccba75c342160e600ad" 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/templates/_tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "class-name": true, 4 | "curly": true, 5 | "eofline": false, 6 | "forin": true, 7 | "indent": [true, 4], 8 | "label-position": true, 9 | "label-undefined": true, 10 | "max-line-length": [true, 140], 11 | "no-arg": true, 12 | "no-bitwise": true, 13 | "no-console": [true, 14 | "debug", 15 | "info", 16 | "time", 17 | "timeEnd", 18 | "trace" 19 | ], 20 | "no-construct": true, 21 | "no-debugger": true, 22 | "no-duplicate-key": true, 23 | "no-duplicate-variable": true, 24 | "no-empty": true, 25 | "no-eval": true, 26 | "no-imports": true, 27 | "no-string-literal": false, 28 | "no-trailing-comma": true, 29 | "no-trailing-whitespace": true, 30 | "no-unused-variable": false, 31 | "no-unreachable": true, 32 | "no-use-before-declare": true, 33 | "one-line": [true, 34 | "check-open-brace", 35 | "check-catch", 36 | "check-else", 37 | "check-whitespace" 38 | ], 39 | "quotemark": [true, "single"], 40 | "radix": true, 41 | "semicolon": true, 42 | "triple-equals": [true, "allow-null-check"], 43 | "variable-name": false, 44 | "whitespace": [true, 45 | "check-branch", 46 | "check-decl", 47 | "check-operator", 48 | "check-separator" 49 | ] 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/templates/editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 4 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /app/templates/wwwroot/_index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 9 |{{vm.msg}}
4 | -------------------------------------------------------------------------------- /app/templates/wwwroot/app/home/home.module.ts.tmpl: -------------------------------------------------------------------------------- 1 | module <%= appModuleName %>.Home { 2 | 'use strict'; 3 | 4 | angular.module('<%= appName %>.home', []); 5 | } 6 | -------------------------------------------------------------------------------- /app/templates/wwwroot/app/home/home.route.ts.tmpl: -------------------------------------------------------------------------------- 1 | module <%= appModuleName %>.Home { 2 | 'use strict'; 3 | 4 | var home = angular.module('<%= appName %>.home'); 5 | 6 | home.run(appRun); 7 | 8 | function appRun(routerHelper : Blocks.Router.IRouterHelper) { 9 | routerHelper.configureStates(getStates()); 10 | } 11 | 12 | function getStates() { 13 | return [ 14 | { 15 | state: 'home', 16 | config: { 17 | url: '/', 18 | templateUrl: 'app/home/home.html', 19 | title: 'Home', 20 | controller: 'homeController', 21 | controllerAs: 'vm' 22 | } 23 | } 24 | ]; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/templates/wwwroot/styles/styles.css.tmpl: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: sans-serif; 3 | } 4 | -------------------------------------------------------------------------------- /app/templates/wwwroot/typings/tsd.d.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olohmann/generator-ng-ts/1f8384dc0da9975db1983d32e885cd6687da4d9d/app/templates/wwwroot/typings/tsd.d.ts -------------------------------------------------------------------------------- /controller/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var subgeneratorBase = require('../subgenerator-base'); 3 | 4 | module.exports = subgeneratorBase.extend({ 5 | initializing: function () { 6 | this._initializing(); 7 | }, 8 | 9 | prompting: function () { 10 | this._prompting(); 11 | }, 12 | 13 | default: function() { 14 | this._default(); 15 | }, 16 | 17 | writing: function() { 18 | var that = this; 19 | console.dir(that.name + ' ' + that.module); 20 | this.fs.copyTpl( 21 | this.templatePath('controller.ts.tmpl'), 22 | this.destinationPath(that.nameCamelized + '.controller.ts'), { 23 | nameCamelized: that.nameCamelized, 24 | namePascalized: that.namePascalized, 25 | moduleNameCamelized: that.moduleNameCamelized, 26 | moduleNamePascalized: that.moduleNamePascalized 27 | } 28 | ); 29 | } 30 | }); 31 | -------------------------------------------------------------------------------- /controller/templates/controller.ts.tmpl: -------------------------------------------------------------------------------- 1 | module <%= moduleNamePascalized %> { 2 | 'use strict'; 3 | 4 | var ngModule = angular.module('<%= moduleNameCamelized %>'); 5 | 6 | export class <%= namePascalized %>Controller { 7 | static $inject =