├── .gitignore ├── LICENSE ├── README.md ├── angular2xjspm.png ├── gulpfile.js ├── jspm.config.js ├── karma.conf.js ├── package.json ├── src ├── app │ ├── services │ │ └── gist.service.ts │ └── starter │ │ ├── starter.component.spec.ts │ │ └── starter.component.ts ├── index.html ├── index.ts └── typings │ ├── chai.d.ts │ ├── es6-shim.d.ts │ └── mocha.d.ts ├── tasks ├── bundle.js ├── clean.js ├── constant.js ├── copy.js ├── exit.js ├── karma.js ├── server.js ├── template.js ├── transpile.js └── watch.js ├── tsconfig.json └── tslint.json /.gitignore: -------------------------------------------------------------------------------- 1 | /.tmp 2 | /dist 3 | /node_modules 4 | /src/jspm_packages 5 | 6 | npm-debug.log 7 | 8 | .DS_Store 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Samuel Vaillant 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 all 13 | 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 THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | Angular2 JSPM starter 3 |

4 | 5 | # Angular 2 JSPM starter [![devDependency Status](https://david-dm.org/samouss/angular2-jspm-starter/dev-status.svg?style=flat-square)](https://david-dm.org/samouss/angular2-jspm-starter#info=devDependencies) 6 | 7 | Angular 2 starter build with [JSPM](https://github.com/jspm/jspm-cli), [Gulp 4](https://github.com/gulpjs/gulp/tree/4.0), [TypeScript](https://github.com/Microsoft/TypeScript), [Karma](https://github.com/karma-runner/karma), [Mocha](https://github.com/mochajs/mocha), [Chaï](https://github.com/chaijs/chai). 8 | 9 | ## Installation 10 | 11 | Clone the repository and then run the following command: 12 | 13 | ``` 14 | npm install 15 | ``` 16 | 17 | ## Run the application 18 | 19 | For build the dev application and launch a server in watch mode on `localhost:3000`: 20 | 21 | ``` 22 | npm start -- [options] 23 | ``` 24 | > --no-open: avoid to open new window in your browser 25 | > --port: specify which port you want use 26 | 27 | ## Bundle the application 28 | 29 | For build your application for production: 30 | 31 | ``` 32 | npm run build 33 | ``` 34 | 35 | For build your application for production and run a server: 36 | 37 | ``` 38 | npm start:prod 39 | ``` 40 | 41 | ## Run the test for your application 42 | 43 | Your tests will be executed in single run mode: 44 | 45 | ``` 46 | npm test 47 | ``` 48 | 49 | For run in watch mode: 50 | 51 | ``` 52 | npm test:watch 53 | ``` 54 | 55 | ## Run a command 56 | 57 | If you want to run a specific command: 58 | 59 | ``` 60 | npm run gulp [command_name] -- [options] 61 | ``` 62 | 63 | List all commands availables: 64 | 65 | ``` 66 | npm run gulp -- --tasks-simple 67 | ``` 68 | -------------------------------------------------------------------------------- /angular2xjspm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/samouss/angular2-jspm-starter/67cd1bde50d32e6362d6cad635230aaf2c4027bd/angular2xjspm.png -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const gulp = require('gulp'); 4 | const HubRegistry = require('gulp-hub'); 5 | 6 | const hub = new HubRegistry(['./tasks/*.js']); 7 | 8 | gulp.task('default', gulp.series( 9 | 'clean', 10 | gulp.parallel('transpile:dist', 'copy:dist:dev') 11 | )); 12 | 13 | gulp.task('start', gulp.series( 14 | 'default', 15 | 'server', 16 | 'watch' 17 | )); 18 | 19 | gulp.task('build', gulp.series( 20 | 'clean', 21 | gulp.parallel('transpile:tmp', 'copy:tmp'), 22 | gulp.parallel('bundle', 'copy:dist:prod'), 23 | gulp.parallel('template', 'clean:tmp') 24 | )); 25 | 26 | gulp.task('test', gulp.series( 27 | 'clean:tmp', 28 | gulp.parallel('transpile:tmp', 'copy:tmp'), 29 | 'karma', 30 | 'clean:tmp', 31 | // Hack for kill the process 32 | 'exit' 33 | )); 34 | 35 | gulp.task('test:watch', gulp.series( 36 | 'clean:tmp', 37 | gulp.parallel('transpile:tmp', 'copy:tmp'), 38 | 'watch:test', 39 | 'karma:watch', 40 | 'clean:tmp', 41 | 'exit' 42 | )); 43 | -------------------------------------------------------------------------------- /jspm.config.js: -------------------------------------------------------------------------------- 1 | System.config({ 2 | baseURL: "/", 3 | defaultJSExtensions: true, 4 | transpiler: false, 5 | paths: { 6 | "github:*": "jspm_packages/github/*", 7 | "npm:*": "jspm_packages/npm/*" 8 | }, 9 | 10 | map: { 11 | "angular2": "npm:angular2@2.0.0-beta.8", 12 | "bootstrap": "github:twbs/bootstrap@3.3.6", 13 | "clean-css": "npm:clean-css@3.4.10", 14 | "css": "github:systemjs/plugin-css@0.1.20", 15 | "rxjs": "npm:rxjs@5.0.0-beta.2", 16 | "github:jspm/nodelibs-assert@0.1.0": { 17 | "assert": "npm:assert@1.3.0" 18 | }, 19 | "github:jspm/nodelibs-buffer@0.1.0": { 20 | "buffer": "npm:buffer@3.6.0" 21 | }, 22 | "github:jspm/nodelibs-constants@0.1.0": { 23 | "constants-browserify": "npm:constants-browserify@0.0.1" 24 | }, 25 | "github:jspm/nodelibs-crypto@0.1.0": { 26 | "crypto-browserify": "npm:crypto-browserify@3.11.0" 27 | }, 28 | "github:jspm/nodelibs-events@0.1.1": { 29 | "events": "npm:events@1.0.2" 30 | }, 31 | "github:jspm/nodelibs-http@1.7.1": { 32 | "Base64": "npm:Base64@0.2.1", 33 | "events": "github:jspm/nodelibs-events@0.1.1", 34 | "inherits": "npm:inherits@2.0.1", 35 | "stream": "github:jspm/nodelibs-stream@0.1.0", 36 | "url": "github:jspm/nodelibs-url@0.1.0", 37 | "util": "github:jspm/nodelibs-util@0.1.0" 38 | }, 39 | "github:jspm/nodelibs-https@0.1.0": { 40 | "https-browserify": "npm:https-browserify@0.0.0" 41 | }, 42 | "github:jspm/nodelibs-os@0.1.0": { 43 | "os-browserify": "npm:os-browserify@0.1.2" 44 | }, 45 | "github:jspm/nodelibs-path@0.1.0": { 46 | "path-browserify": "npm:path-browserify@0.0.0" 47 | }, 48 | "github:jspm/nodelibs-process@0.1.2": { 49 | "process": "npm:process@0.11.2" 50 | }, 51 | "github:jspm/nodelibs-stream@0.1.0": { 52 | "stream-browserify": "npm:stream-browserify@1.0.0" 53 | }, 54 | "github:jspm/nodelibs-string_decoder@0.1.0": { 55 | "string_decoder": "npm:string_decoder@0.10.31" 56 | }, 57 | "github:jspm/nodelibs-url@0.1.0": { 58 | "url": "npm:url@0.10.3" 59 | }, 60 | "github:jspm/nodelibs-util@0.1.0": { 61 | "util": "npm:util@0.10.3" 62 | }, 63 | "github:jspm/nodelibs-vm@0.1.0": { 64 | "vm-browserify": "npm:vm-browserify@0.0.4" 65 | }, 66 | "github:twbs/bootstrap@3.3.6": { 67 | "jquery": "github:components/jquery@2.2.1" 68 | }, 69 | "npm:amdefine@1.0.0": { 70 | "fs": "github:jspm/nodelibs-fs@0.1.2", 71 | "module": "github:jspm/nodelibs-module@0.1.0", 72 | "path": "github:jspm/nodelibs-path@0.1.0", 73 | "process": "github:jspm/nodelibs-process@0.1.2" 74 | }, 75 | "npm:angular2@2.0.0-beta.8": { 76 | "crypto": "github:jspm/nodelibs-crypto@0.1.0", 77 | "es6-promise": "npm:es6-promise@3.1.2", 78 | "es6-shim": "npm:es6-shim@0.33.13", 79 | "process": "github:jspm/nodelibs-process@0.1.2", 80 | "reflect-metadata": "npm:reflect-metadata@0.1.2", 81 | "rxjs": "npm:rxjs@5.0.0-beta.2", 82 | "zone.js": "npm:zone.js@0.5.15" 83 | }, 84 | "npm:asn1.js@4.5.1": { 85 | "assert": "github:jspm/nodelibs-assert@0.1.0", 86 | "bn.js": "npm:bn.js@4.10.5", 87 | "buffer": "github:jspm/nodelibs-buffer@0.1.0", 88 | "fs": "github:jspm/nodelibs-fs@0.1.2", 89 | "inherits": "npm:inherits@2.0.1", 90 | "minimalistic-assert": "npm:minimalistic-assert@1.0.0", 91 | "vm": "github:jspm/nodelibs-vm@0.1.0" 92 | }, 93 | "npm:assert@1.3.0": { 94 | "util": "npm:util@0.10.3" 95 | }, 96 | "npm:bn.js@4.10.5": { 97 | "buffer": "github:jspm/nodelibs-buffer@0.1.0" 98 | }, 99 | "npm:browserify-aes@1.0.6": { 100 | "buffer": "github:jspm/nodelibs-buffer@0.1.0", 101 | "buffer-xor": "npm:buffer-xor@1.0.3", 102 | "cipher-base": "npm:cipher-base@1.0.2", 103 | "create-hash": "npm:create-hash@1.1.2", 104 | "crypto": "github:jspm/nodelibs-crypto@0.1.0", 105 | "evp_bytestokey": "npm:evp_bytestokey@1.0.0", 106 | "fs": "github:jspm/nodelibs-fs@0.1.2", 107 | "inherits": "npm:inherits@2.0.1", 108 | "systemjs-json": "github:systemjs/plugin-json@0.1.0" 109 | }, 110 | "npm:browserify-cipher@1.0.0": { 111 | "browserify-aes": "npm:browserify-aes@1.0.6", 112 | "browserify-des": "npm:browserify-des@1.0.0", 113 | "buffer": "github:jspm/nodelibs-buffer@0.1.0", 114 | "crypto": "github:jspm/nodelibs-crypto@0.1.0", 115 | "evp_bytestokey": "npm:evp_bytestokey@1.0.0" 116 | }, 117 | "npm:browserify-des@1.0.0": { 118 | "buffer": "github:jspm/nodelibs-buffer@0.1.0", 119 | "cipher-base": "npm:cipher-base@1.0.2", 120 | "crypto": "github:jspm/nodelibs-crypto@0.1.0", 121 | "des.js": "npm:des.js@1.0.0", 122 | "inherits": "npm:inherits@2.0.1" 123 | }, 124 | "npm:browserify-rsa@4.0.1": { 125 | "bn.js": "npm:bn.js@4.10.5", 126 | "buffer": "github:jspm/nodelibs-buffer@0.1.0", 127 | "constants": "github:jspm/nodelibs-constants@0.1.0", 128 | "crypto": "github:jspm/nodelibs-crypto@0.1.0", 129 | "randombytes": "npm:randombytes@2.0.3" 130 | }, 131 | "npm:browserify-sign@4.0.0": { 132 | "bn.js": "npm:bn.js@4.10.5", 133 | "browserify-rsa": "npm:browserify-rsa@4.0.1", 134 | "buffer": "github:jspm/nodelibs-buffer@0.1.0", 135 | "create-hash": "npm:create-hash@1.1.2", 136 | "create-hmac": "npm:create-hmac@1.1.4", 137 | "crypto": "github:jspm/nodelibs-crypto@0.1.0", 138 | "elliptic": "npm:elliptic@6.2.3", 139 | "inherits": "npm:inherits@2.0.1", 140 | "parse-asn1": "npm:parse-asn1@5.0.0", 141 | "stream": "github:jspm/nodelibs-stream@0.1.0" 142 | }, 143 | "npm:buffer-xor@1.0.3": { 144 | "buffer": "github:jspm/nodelibs-buffer@0.1.0", 145 | "systemjs-json": "github:systemjs/plugin-json@0.1.0" 146 | }, 147 | "npm:buffer@3.6.0": { 148 | "base64-js": "npm:base64-js@0.0.8", 149 | "child_process": "github:jspm/nodelibs-child_process@0.1.0", 150 | "fs": "github:jspm/nodelibs-fs@0.1.2", 151 | "ieee754": "npm:ieee754@1.1.6", 152 | "isarray": "npm:isarray@1.0.0", 153 | "process": "github:jspm/nodelibs-process@0.1.2" 154 | }, 155 | "npm:cipher-base@1.0.2": { 156 | "buffer": "github:jspm/nodelibs-buffer@0.1.0", 157 | "inherits": "npm:inherits@2.0.1", 158 | "stream": "github:jspm/nodelibs-stream@0.1.0", 159 | "string_decoder": "github:jspm/nodelibs-string_decoder@0.1.0" 160 | }, 161 | "npm:clean-css@3.4.10": { 162 | "buffer": "github:jspm/nodelibs-buffer@0.1.0", 163 | "commander": "npm:commander@2.8.1", 164 | "fs": "github:jspm/nodelibs-fs@0.1.2", 165 | "http": "github:jspm/nodelibs-http@1.7.1", 166 | "https": "github:jspm/nodelibs-https@0.1.0", 167 | "os": "github:jspm/nodelibs-os@0.1.0", 168 | "path": "github:jspm/nodelibs-path@0.1.0", 169 | "process": "github:jspm/nodelibs-process@0.1.2", 170 | "source-map": "npm:source-map@0.4.4", 171 | "url": "github:jspm/nodelibs-url@0.1.0", 172 | "util": "github:jspm/nodelibs-util@0.1.0" 173 | }, 174 | "npm:commander@2.8.1": { 175 | "child_process": "github:jspm/nodelibs-child_process@0.1.0", 176 | "events": "github:jspm/nodelibs-events@0.1.1", 177 | "fs": "github:jspm/nodelibs-fs@0.1.2", 178 | "graceful-readlink": "npm:graceful-readlink@1.0.1", 179 | "path": "github:jspm/nodelibs-path@0.1.0", 180 | "process": "github:jspm/nodelibs-process@0.1.2" 181 | }, 182 | "npm:constants-browserify@0.0.1": { 183 | "systemjs-json": "github:systemjs/plugin-json@0.1.0" 184 | }, 185 | "npm:core-util-is@1.0.2": { 186 | "buffer": "github:jspm/nodelibs-buffer@0.1.0" 187 | }, 188 | "npm:create-ecdh@4.0.0": { 189 | "bn.js": "npm:bn.js@4.10.5", 190 | "buffer": "github:jspm/nodelibs-buffer@0.1.0", 191 | "crypto": "github:jspm/nodelibs-crypto@0.1.0", 192 | "elliptic": "npm:elliptic@6.2.3" 193 | }, 194 | "npm:create-hash@1.1.2": { 195 | "buffer": "github:jspm/nodelibs-buffer@0.1.0", 196 | "cipher-base": "npm:cipher-base@1.0.2", 197 | "crypto": "github:jspm/nodelibs-crypto@0.1.0", 198 | "fs": "github:jspm/nodelibs-fs@0.1.2", 199 | "inherits": "npm:inherits@2.0.1", 200 | "ripemd160": "npm:ripemd160@1.0.1", 201 | "sha.js": "npm:sha.js@2.4.5" 202 | }, 203 | "npm:create-hmac@1.1.4": { 204 | "buffer": "github:jspm/nodelibs-buffer@0.1.0", 205 | "create-hash": "npm:create-hash@1.1.2", 206 | "crypto": "github:jspm/nodelibs-crypto@0.1.0", 207 | "inherits": "npm:inherits@2.0.1", 208 | "stream": "github:jspm/nodelibs-stream@0.1.0" 209 | }, 210 | "npm:crypto-browserify@3.11.0": { 211 | "browserify-cipher": "npm:browserify-cipher@1.0.0", 212 | "browserify-sign": "npm:browserify-sign@4.0.0", 213 | "create-ecdh": "npm:create-ecdh@4.0.0", 214 | "create-hash": "npm:create-hash@1.1.2", 215 | "create-hmac": "npm:create-hmac@1.1.4", 216 | "diffie-hellman": "npm:diffie-hellman@5.0.2", 217 | "inherits": "npm:inherits@2.0.1", 218 | "pbkdf2": "npm:pbkdf2@3.0.4", 219 | "public-encrypt": "npm:public-encrypt@4.0.0", 220 | "randombytes": "npm:randombytes@2.0.3" 221 | }, 222 | "npm:des.js@1.0.0": { 223 | "buffer": "github:jspm/nodelibs-buffer@0.1.0", 224 | "inherits": "npm:inherits@2.0.1", 225 | "minimalistic-assert": "npm:minimalistic-assert@1.0.0" 226 | }, 227 | "npm:diffie-hellman@5.0.2": { 228 | "bn.js": "npm:bn.js@4.10.5", 229 | "buffer": "github:jspm/nodelibs-buffer@0.1.0", 230 | "crypto": "github:jspm/nodelibs-crypto@0.1.0", 231 | "miller-rabin": "npm:miller-rabin@4.0.0", 232 | "randombytes": "npm:randombytes@2.0.3", 233 | "systemjs-json": "github:systemjs/plugin-json@0.1.0" 234 | }, 235 | "npm:elliptic@6.2.3": { 236 | "bn.js": "npm:bn.js@4.10.5", 237 | "brorand": "npm:brorand@1.0.5", 238 | "hash.js": "npm:hash.js@1.0.3", 239 | "inherits": "npm:inherits@2.0.1", 240 | "systemjs-json": "github:systemjs/plugin-json@0.1.0" 241 | }, 242 | "npm:es6-promise@3.1.2": { 243 | "process": "github:jspm/nodelibs-process@0.1.2" 244 | }, 245 | "npm:es6-shim@0.33.13": { 246 | "process": "github:jspm/nodelibs-process@0.1.2" 247 | }, 248 | "npm:evp_bytestokey@1.0.0": { 249 | "buffer": "github:jspm/nodelibs-buffer@0.1.0", 250 | "create-hash": "npm:create-hash@1.1.2", 251 | "crypto": "github:jspm/nodelibs-crypto@0.1.0" 252 | }, 253 | "npm:graceful-readlink@1.0.1": { 254 | "fs": "github:jspm/nodelibs-fs@0.1.2" 255 | }, 256 | "npm:hash.js@1.0.3": { 257 | "inherits": "npm:inherits@2.0.1" 258 | }, 259 | "npm:https-browserify@0.0.0": { 260 | "http": "github:jspm/nodelibs-http@1.7.1" 261 | }, 262 | "npm:inherits@2.0.1": { 263 | "util": "github:jspm/nodelibs-util@0.1.0" 264 | }, 265 | "npm:miller-rabin@4.0.0": { 266 | "bn.js": "npm:bn.js@4.10.5", 267 | "brorand": "npm:brorand@1.0.5" 268 | }, 269 | "npm:os-browserify@0.1.2": { 270 | "os": "github:jspm/nodelibs-os@0.1.0" 271 | }, 272 | "npm:parse-asn1@5.0.0": { 273 | "asn1.js": "npm:asn1.js@4.5.1", 274 | "browserify-aes": "npm:browserify-aes@1.0.6", 275 | "buffer": "github:jspm/nodelibs-buffer@0.1.0", 276 | "create-hash": "npm:create-hash@1.1.2", 277 | "evp_bytestokey": "npm:evp_bytestokey@1.0.0", 278 | "pbkdf2": "npm:pbkdf2@3.0.4", 279 | "systemjs-json": "github:systemjs/plugin-json@0.1.0" 280 | }, 281 | "npm:path-browserify@0.0.0": { 282 | "process": "github:jspm/nodelibs-process@0.1.2" 283 | }, 284 | "npm:pbkdf2@3.0.4": { 285 | "buffer": "github:jspm/nodelibs-buffer@0.1.0", 286 | "child_process": "github:jspm/nodelibs-child_process@0.1.0", 287 | "create-hmac": "npm:create-hmac@1.1.4", 288 | "crypto": "github:jspm/nodelibs-crypto@0.1.0", 289 | "path": "github:jspm/nodelibs-path@0.1.0", 290 | "process": "github:jspm/nodelibs-process@0.1.2", 291 | "systemjs-json": "github:systemjs/plugin-json@0.1.0" 292 | }, 293 | "npm:process@0.11.2": { 294 | "assert": "github:jspm/nodelibs-assert@0.1.0" 295 | }, 296 | "npm:public-encrypt@4.0.0": { 297 | "bn.js": "npm:bn.js@4.10.5", 298 | "browserify-rsa": "npm:browserify-rsa@4.0.1", 299 | "buffer": "github:jspm/nodelibs-buffer@0.1.0", 300 | "create-hash": "npm:create-hash@1.1.2", 301 | "crypto": "github:jspm/nodelibs-crypto@0.1.0", 302 | "parse-asn1": "npm:parse-asn1@5.0.0", 303 | "randombytes": "npm:randombytes@2.0.3" 304 | }, 305 | "npm:punycode@1.3.2": { 306 | "process": "github:jspm/nodelibs-process@0.1.2" 307 | }, 308 | "npm:randombytes@2.0.3": { 309 | "buffer": "github:jspm/nodelibs-buffer@0.1.0", 310 | "crypto": "github:jspm/nodelibs-crypto@0.1.0", 311 | "process": "github:jspm/nodelibs-process@0.1.2" 312 | }, 313 | "npm:readable-stream@1.1.13": { 314 | "buffer": "github:jspm/nodelibs-buffer@0.1.0", 315 | "core-util-is": "npm:core-util-is@1.0.2", 316 | "events": "github:jspm/nodelibs-events@0.1.1", 317 | "inherits": "npm:inherits@2.0.1", 318 | "isarray": "npm:isarray@0.0.1", 319 | "process": "github:jspm/nodelibs-process@0.1.2", 320 | "stream-browserify": "npm:stream-browserify@1.0.0", 321 | "string_decoder": "npm:string_decoder@0.10.31" 322 | }, 323 | "npm:reflect-metadata@0.1.2": { 324 | "assert": "github:jspm/nodelibs-assert@0.1.0", 325 | "process": "github:jspm/nodelibs-process@0.1.2" 326 | }, 327 | "npm:ripemd160@1.0.1": { 328 | "buffer": "github:jspm/nodelibs-buffer@0.1.0", 329 | "process": "github:jspm/nodelibs-process@0.1.2" 330 | }, 331 | "npm:rxjs@5.0.0-beta.2": { 332 | "buffer": "github:jspm/nodelibs-buffer@0.1.0", 333 | "process": "github:jspm/nodelibs-process@0.1.2" 334 | }, 335 | "npm:sha.js@2.4.5": { 336 | "buffer": "github:jspm/nodelibs-buffer@0.1.0", 337 | "fs": "github:jspm/nodelibs-fs@0.1.2", 338 | "inherits": "npm:inherits@2.0.1", 339 | "process": "github:jspm/nodelibs-process@0.1.2" 340 | }, 341 | "npm:source-map@0.4.4": { 342 | "amdefine": "npm:amdefine@1.0.0", 343 | "process": "github:jspm/nodelibs-process@0.1.2" 344 | }, 345 | "npm:stream-browserify@1.0.0": { 346 | "events": "github:jspm/nodelibs-events@0.1.1", 347 | "inherits": "npm:inherits@2.0.1", 348 | "readable-stream": "npm:readable-stream@1.1.13" 349 | }, 350 | "npm:string_decoder@0.10.31": { 351 | "buffer": "github:jspm/nodelibs-buffer@0.1.0" 352 | }, 353 | "npm:url@0.10.3": { 354 | "assert": "github:jspm/nodelibs-assert@0.1.0", 355 | "punycode": "npm:punycode@1.3.2", 356 | "querystring": "npm:querystring@0.2.0", 357 | "util": "github:jspm/nodelibs-util@0.1.0" 358 | }, 359 | "npm:util@0.10.3": { 360 | "inherits": "npm:inherits@2.0.1", 361 | "process": "github:jspm/nodelibs-process@0.1.2" 362 | }, 363 | "npm:vm-browserify@0.0.4": { 364 | "indexof": "npm:indexof@0.0.1" 365 | }, 366 | "npm:zone.js@0.5.15": { 367 | "es6-promise": "npm:es6-promise@3.1.2", 368 | "process": "github:jspm/nodelibs-process@0.1.2" 369 | } 370 | } 371 | }); 372 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | module.exports = function(config) { 2 | config.set({ 3 | 4 | // Frameworks used with Karma 5 | frameworks: [ 6 | 'mocha', 7 | 'chai', 8 | 'jspm', 9 | ], 10 | 11 | // Load Angular2 and Babel polyfills 12 | files: [ 13 | // './.tmp/jspm_packages/npm/angular2@*/bundles/angular2-polyfills.js', 14 | './node_modules/babel-polyfill/browser.js', 15 | './node_modules/angular2/bundles/angular2-polyfills.js', 16 | ], 17 | 18 | // JSPM configurations 19 | // see in karma.js for this 20 | jspm: {}, 21 | 22 | // Alias for JSPM 23 | proxies: { 24 | '/.tmp/': '/base/.tmp/', 25 | '/jspm_packages/': '/.tmp/jspm_packages/', 26 | }, 27 | 28 | browsers: ['PhantomJS'], 29 | reporters: ['mocha'], 30 | logLevel: config.LOG_INFO, 31 | singleRun: true, 32 | }) 33 | } 34 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular2-jspm-starter", 3 | "version": "1.0.0", 4 | "description": "Angular 2 starter build with JSPM, Gulp, TypeScript.", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "postinstall": "jspm install", 8 | "start": "./node_modules/gulp/bin/gulp.js start", 9 | "start:prod": "npm run build && ./node_modules/gulp/bin/gulp.js server", 10 | "test": "./node_modules/gulp/bin/gulp.js test", 11 | "test:watch": "./node_modules/gulp/bin/gulp.js test:watch", 12 | "build": "./node_modules/gulp/bin/gulp.js build", 13 | "gulp": "./node_modules/gulp/bin/gulp.js" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "git+https://github.com/samouss/angular2-jspm-starter.git" 18 | }, 19 | "author": "Samuel Vaillant ", 20 | "license": "MIT", 21 | "bugs": { 22 | "url": "https://github.com/samouss/angular2-jspm-starter/issues" 23 | }, 24 | "homepage": "https://github.com/samouss/angular2-jspm-starter#readme", 25 | "engines": { 26 | "node": ">=v4.0.0", 27 | "npm": ">=3.0.0" 28 | }, 29 | "devDependencies": { 30 | "angular2": "2.0.0-beta.8", 31 | "babel-polyfill": "6.6.1", 32 | "browser-sync": "2.11.1", 33 | "chai": "3.5.0", 34 | "del": "2.2.0", 35 | "gulp": "github:gulpjs/gulp#4.0", 36 | "gulp-changed": "1.3.0", 37 | "gulp-html-replace": "1.5.5", 38 | "gulp-hub": "0.7.1", 39 | "gulp-notify": "2.2.0", 40 | "gulp-plumber": "1.1.0", 41 | "gulp-replace": "0.5.4", 42 | "gulp-sourcemaps": "1.6.0", 43 | "gulp-tslint": "4.3.3", 44 | "gulp-typescript": "2.12.1", 45 | "jspm": "0.16.30", 46 | "karma": "0.13.21", 47 | "karma-chai": "0.1.0", 48 | "karma-jspm": "2.0.2", 49 | "karma-mocha": "0.2.2", 50 | "karma-mocha-reporter": "1.2.3", 51 | "karma-phantomjs-launcher": "1.0.0", 52 | "lodash": "4.6.1", 53 | "merge-stream": "1.0.0", 54 | "mocha": "2.4.5", 55 | "phantomjs-prebuilt": "2.1.4", 56 | "require-dir": "0.3.0", 57 | "rxjs": "5.0.0-beta.2", 58 | "systemjs-builder": "0.15.10", 59 | "through": "2.3.8", 60 | "tslint": "3.5.0", 61 | "typescript": "1.8.7", 62 | "yargs": "4.2.0" 63 | }, 64 | "jspm": { 65 | "directories": { 66 | "baseURL": "src" 67 | }, 68 | "configFile": "jspm.config.js", 69 | "dependencies": { 70 | "angular2": "npm:angular2@2.0.0-beta.8", 71 | "bootstrap": "github:twbs/bootstrap@3.3.6", 72 | "css": "github:systemjs/plugin-css@0.1.20", 73 | "rxjs": "npm:rxjs@5.0.0-beta.2" 74 | }, 75 | "devDependencies": { 76 | "clean-css": "npm:clean-css@^3.4.9" 77 | }, 78 | "overrides": { 79 | "npm:angular2@2.0.0-beta.1": { 80 | "shim": { 81 | "bundles/angular2-polyfills.min": { 82 | "format": "global" 83 | } 84 | } 85 | } 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/app/services/gist.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from 'angular2/core'; 2 | import { Http } from 'angular2/http'; 3 | import { Observable } from 'rxjs/Rx'; 4 | 5 | @Injectable() 6 | export default class GistService { 7 | 8 | /** 9 | * @constructor 10 | * @param {Http} _http 11 | */ 12 | constructor(private _http: Http) {} 13 | 14 | /** 15 | * @name getGists 16 | * @return {Observable} 17 | */ 18 | getGists(): Observable { 19 | return this._http 20 | .get('https://api.github.com/gists') 21 | .map((res) => res.json()); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/app/starter/starter.component.spec.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable:no-unused-variable */ 2 | import StarterComponent from './starter.component'; 3 | 4 | const expect = chai.expect; 5 | 6 | describe('# Starter component', () => { 7 | it('- Property name should be equal to "Angular2 JSPM Starter"', () => { 8 | expect(true).to.be.equal(true); 9 | }); 10 | }); 11 | -------------------------------------------------------------------------------- /src/app/starter/starter.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from 'angular2/core'; 2 | import GistService from '../services/gist.service'; 3 | 4 | @Component({ 5 | selector: 'starter', 6 | providers: [GistService], 7 | template: ` 8 |
9 |
10 |

{{ name }}

11 | 12 |
13 |
14 |
    15 |
  • {{ author }}
  • 16 |
17 |
18 |
19 | `, 20 | }) 21 | export default class StarterComponent { 22 | 23 | /** 24 | * @name name 25 | * @type {string} 26 | */ 27 | name: string = 'Github Gists Authors'; 28 | 29 | /** 30 | * @name gistsAuthors 31 | * @type {Array} 32 | */ 33 | gistsAuthors: Array = []; 34 | 35 | /** 36 | * @constructor 37 | * @param {GistService} _GistService 38 | */ 39 | constructor(private _GistService: GistService) {} 40 | 41 | /** 42 | * @name getGists 43 | * @return {void} 44 | */ 45 | getGistsAuthors(): void { 46 | this._GistService.getGists() 47 | .map((res: any) => { 48 | return res 49 | .filter((res: any) => res.owner) 50 | .map((res: any) => res.owner.login); 51 | }) 52 | .subscribe((res: any) => { 53 | this.gistsAuthors = this.gistsAuthors.concat(res); 54 | }); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Angular 2 JSPM starter 6 | 7 | 8 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | // Import CSS via SystemJS plugin CSS 2 | import 'bootstrap/css/bootstrap.min.css!'; 3 | 4 | // Import peer dependency 5 | import 'rxjs/add/operator/map'; 6 | 7 | // Import Angular 2 modules 8 | import { bootstrap } from 'angular2/platform/browser'; 9 | import { HTTP_PROVIDERS } from 'angular2/http'; 10 | 11 | import StarterComponent from './app/starter/starter.component'; 12 | 13 | bootstrap(StarterComponent, [HTTP_PROVIDERS]); 14 | -------------------------------------------------------------------------------- /src/typings/chai.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for chai 3.4.0 2 | // Project: http://chaijs.com/ 3 | // Definitions by: Jed Mao , 4 | // Bart van der Schoor , 5 | // Andrew Brown , 6 | // Olivier Chevet , 7 | // Matt Wistrand 8 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 9 | 10 | // 11 | 12 | declare module Chai { 13 | 14 | interface ChaiStatic { 15 | expect: ExpectStatic; 16 | should(): Should; 17 | /** 18 | * Provides a way to extend the internals of Chai 19 | */ 20 | use(fn: (chai: any, utils: any) => void): ChaiStatic; 21 | assert: AssertStatic; 22 | config: Config; 23 | AssertionError: typeof AssertionError; 24 | } 25 | 26 | export interface ExpectStatic extends AssertionStatic { 27 | fail(actual?: any, expected?: any, message?: string, operator?: string): void; 28 | } 29 | 30 | export interface AssertStatic extends Assert { 31 | } 32 | 33 | export interface AssertionStatic { 34 | (target: any, message?: string): Assertion; 35 | } 36 | 37 | interface ShouldAssertion { 38 | equal(value1: any, value2: any, message?: string): void; 39 | Throw: ShouldThrow; 40 | throw: ShouldThrow; 41 | exist(value: any, message?: string): void; 42 | } 43 | 44 | interface Should extends ShouldAssertion { 45 | not: ShouldAssertion; 46 | fail(actual: any, expected: any, message?: string, operator?: string): void; 47 | } 48 | 49 | interface ShouldThrow { 50 | (actual: Function): void; 51 | (actual: Function, expected: string|RegExp, message?: string): void; 52 | (actual: Function, constructor: Error|Function, expected?: string|RegExp, message?: string): void; 53 | } 54 | 55 | interface Assertion extends LanguageChains, NumericComparison, TypeComparison { 56 | not: Assertion; 57 | deep: Deep; 58 | any: KeyFilter; 59 | all: KeyFilter; 60 | a: TypeComparison; 61 | an: TypeComparison; 62 | include: Include; 63 | includes: Include; 64 | contain: Include; 65 | contains: Include; 66 | ok: Assertion; 67 | true: Assertion; 68 | false: Assertion; 69 | null: Assertion; 70 | undefined: Assertion; 71 | NaN: Assertion; 72 | exist: Assertion; 73 | empty: Assertion; 74 | arguments: Assertion; 75 | Arguments: Assertion; 76 | equal: Equal; 77 | equals: Equal; 78 | eq: Equal; 79 | eql: Equal; 80 | eqls: Equal; 81 | property: Property; 82 | ownProperty: OwnProperty; 83 | haveOwnProperty: OwnProperty; 84 | ownPropertyDescriptor: OwnPropertyDescriptor; 85 | haveOwnPropertyDescriptor: OwnPropertyDescriptor; 86 | length: Length; 87 | lengthOf: Length; 88 | match: Match; 89 | matches: Match; 90 | string(string: string, message?: string): Assertion; 91 | keys: Keys; 92 | key(string: string): Assertion; 93 | throw: Throw; 94 | throws: Throw; 95 | Throw: Throw; 96 | respondTo: RespondTo; 97 | respondsTo: RespondTo; 98 | itself: Assertion; 99 | satisfy: Satisfy; 100 | satisfies: Satisfy; 101 | closeTo: CloseTo; 102 | approximately: CloseTo; 103 | members: Members; 104 | increase: PropertyChange; 105 | increases: PropertyChange; 106 | decrease: PropertyChange; 107 | decreases: PropertyChange; 108 | change: PropertyChange; 109 | changes: PropertyChange; 110 | extensible: Assertion; 111 | sealed: Assertion; 112 | frozen: Assertion; 113 | oneOf(list: any[], message?: string): Assertion; 114 | } 115 | 116 | interface LanguageChains { 117 | to: Assertion; 118 | be: Assertion; 119 | been: Assertion; 120 | is: Assertion; 121 | that: Assertion; 122 | which: Assertion; 123 | and: Assertion; 124 | has: Assertion; 125 | have: Assertion; 126 | with: Assertion; 127 | at: Assertion; 128 | of: Assertion; 129 | same: Assertion; 130 | } 131 | 132 | interface NumericComparison { 133 | above: NumberComparer; 134 | gt: NumberComparer; 135 | greaterThan: NumberComparer; 136 | least: NumberComparer; 137 | gte: NumberComparer; 138 | below: NumberComparer; 139 | lt: NumberComparer; 140 | lessThan: NumberComparer; 141 | most: NumberComparer; 142 | lte: NumberComparer; 143 | within(start: number, finish: number, message?: string): Assertion; 144 | } 145 | 146 | interface NumberComparer { 147 | (value: number, message?: string): Assertion; 148 | } 149 | 150 | interface TypeComparison { 151 | (type: string, message?: string): Assertion; 152 | instanceof: InstanceOf; 153 | instanceOf: InstanceOf; 154 | } 155 | 156 | interface InstanceOf { 157 | (constructor: Object, message?: string): Assertion; 158 | } 159 | 160 | interface CloseTo { 161 | (expected: number, delta: number, message?: string): Assertion; 162 | } 163 | 164 | interface Deep { 165 | equal: Equal; 166 | include: Include; 167 | property: Property; 168 | members: Members; 169 | } 170 | 171 | interface KeyFilter { 172 | keys: Keys; 173 | } 174 | 175 | interface Equal { 176 | (value: any, message?: string): Assertion; 177 | } 178 | 179 | interface Property { 180 | (name: string, value?: any, message?: string): Assertion; 181 | } 182 | 183 | interface OwnProperty { 184 | (name: string, message?: string): Assertion; 185 | } 186 | 187 | interface OwnPropertyDescriptor { 188 | (name: string, descriptor: PropertyDescriptor, message?: string): Assertion; 189 | (name: string, message?: string): Assertion; 190 | } 191 | 192 | interface Length extends LanguageChains, NumericComparison { 193 | (length: number, message?: string): Assertion; 194 | } 195 | 196 | interface Include { 197 | (value: Object, message?: string): Assertion; 198 | (value: string, message?: string): Assertion; 199 | (value: number, message?: string): Assertion; 200 | keys: Keys; 201 | members: Members; 202 | any: KeyFilter; 203 | all: KeyFilter; 204 | } 205 | 206 | interface Match { 207 | (regexp: RegExp|string, message?: string): Assertion; 208 | } 209 | 210 | interface Keys { 211 | (...keys: string[]): Assertion; 212 | (keys: any[]): Assertion; 213 | (keys: Object): Assertion; 214 | } 215 | 216 | interface Throw { 217 | (): Assertion; 218 | (expected: string, message?: string): Assertion; 219 | (expected: RegExp, message?: string): Assertion; 220 | (constructor: Error, expected?: string, message?: string): Assertion; 221 | (constructor: Error, expected?: RegExp, message?: string): Assertion; 222 | (constructor: Function, expected?: string, message?: string): Assertion; 223 | (constructor: Function, expected?: RegExp, message?: string): Assertion; 224 | } 225 | 226 | interface RespondTo { 227 | (method: string, message?: string): Assertion; 228 | } 229 | 230 | interface Satisfy { 231 | (matcher: Function, message?: string): Assertion; 232 | } 233 | 234 | interface Members { 235 | (set: any[], message?: string): Assertion; 236 | } 237 | 238 | interface PropertyChange { 239 | (object: Object, prop: string, msg?: string): Assertion; 240 | } 241 | 242 | export interface Assert { 243 | /** 244 | * @param expression Expression to test for truthiness. 245 | * @param message Message to display on error. 246 | */ 247 | (expression: any, message?: string): void; 248 | 249 | fail(actual?: any, expected?: any, msg?: string, operator?: string): void; 250 | 251 | ok(val: any, msg?: string): void; 252 | isOk(val: any, msg?: string): void; 253 | notOk(val: any, msg?: string): void; 254 | isNotOk(val: any, msg?: string): void; 255 | 256 | equal(act: any, exp: any, msg?: string): void; 257 | notEqual(act: any, exp: any, msg?: string): void; 258 | 259 | strictEqual(act: any, exp: any, msg?: string): void; 260 | notStrictEqual(act: any, exp: any, msg?: string): void; 261 | 262 | deepEqual(act: any, exp: any, msg?: string): void; 263 | notDeepEqual(act: any, exp: any, msg?: string): void; 264 | 265 | isTrue(val: any, msg?: string): void; 266 | isFalse(val: any, msg?: string): void; 267 | 268 | isNotTrue(val: any, msg?: string): void; 269 | isNotFalse(val: any, msg?: string): void; 270 | 271 | isNull(val: any, msg?: string): void; 272 | isNotNull(val: any, msg?: string): void; 273 | 274 | isUndefined(val: any, msg?: string): void; 275 | isDefined(val: any, msg?: string): void; 276 | 277 | isNaN(val: any, msg?: string): void; 278 | isNotNaN(val: any, msg?: string): void; 279 | 280 | isAbove(val: number, abv: number, msg?: string): void; 281 | isBelow(val: number, blw: number, msg?: string): void; 282 | 283 | isAtLeast(val: number, atlst: number, msg?: string): void; 284 | isAtMost(val: number, atmst: number, msg?: string): void; 285 | 286 | isFunction(val: any, msg?: string): void; 287 | isNotFunction(val: any, msg?: string): void; 288 | 289 | isObject(val: any, msg?: string): void; 290 | isNotObject(val: any, msg?: string): void; 291 | 292 | isArray(val: any, msg?: string): void; 293 | isNotArray(val: any, msg?: string): void; 294 | 295 | isString(val: any, msg?: string): void; 296 | isNotString(val: any, msg?: string): void; 297 | 298 | isNumber(val: any, msg?: string): void; 299 | isNotNumber(val: any, msg?: string): void; 300 | 301 | isBoolean(val: any, msg?: string): void; 302 | isNotBoolean(val: any, msg?: string): void; 303 | 304 | typeOf(val: any, type: string, msg?: string): void; 305 | notTypeOf(val: any, type: string, msg?: string): void; 306 | 307 | instanceOf(val: any, type: Function, msg?: string): void; 308 | notInstanceOf(val: any, type: Function, msg?: string): void; 309 | 310 | include(exp: string, inc: any, msg?: string): void; 311 | include(exp: any[], inc: any, msg?: string): void; 312 | 313 | notInclude(exp: string, inc: any, msg?: string): void; 314 | notInclude(exp: any[], inc: any, msg?: string): void; 315 | 316 | match(exp: any, re: RegExp, msg?: string): void; 317 | notMatch(exp: any, re: RegExp, msg?: string): void; 318 | 319 | property(obj: Object, prop: string, msg?: string): void; 320 | notProperty(obj: Object, prop: string, msg?: string): void; 321 | deepProperty(obj: Object, prop: string, msg?: string): void; 322 | notDeepProperty(obj: Object, prop: string, msg?: string): void; 323 | 324 | propertyVal(obj: Object, prop: string, val: any, msg?: string): void; 325 | propertyNotVal(obj: Object, prop: string, val: any, msg?: string): void; 326 | 327 | deepPropertyVal(obj: Object, prop: string, val: any, msg?: string): void; 328 | deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string): void; 329 | 330 | lengthOf(exp: any, len: number, msg?: string): void; 331 | //alias frenzy 332 | throw(fn: Function, msg?: string): void; 333 | throw(fn: Function, regExp: RegExp): void; 334 | throw(fn: Function, errType: Function, msg?: string): void; 335 | throw(fn: Function, errType: Function, regExp: RegExp): void; 336 | 337 | throws(fn: Function, msg?: string): void; 338 | throws(fn: Function, regExp: RegExp): void; 339 | throws(fn: Function, errType: Function, msg?: string): void; 340 | throws(fn: Function, errType: Function, regExp: RegExp): void; 341 | 342 | Throw(fn: Function, msg?: string): void; 343 | Throw(fn: Function, regExp: RegExp): void; 344 | Throw(fn: Function, errType: Function, msg?: string): void; 345 | Throw(fn: Function, errType: Function, regExp: RegExp): void; 346 | 347 | doesNotThrow(fn: Function, msg?: string): void; 348 | doesNotThrow(fn: Function, regExp: RegExp): void; 349 | doesNotThrow(fn: Function, errType: Function, msg?: string): void; 350 | doesNotThrow(fn: Function, errType: Function, regExp: RegExp): void; 351 | 352 | operator(val: any, operator: string, val2: any, msg?: string): void; 353 | closeTo(act: number, exp: number, delta: number, msg?: string): void; 354 | approximately(act: number, exp: number, delta: number, msg?: string): void; 355 | 356 | sameMembers(set1: any[], set2: any[], msg?: string): void; 357 | sameDeepMembers(set1: any[], set2: any[], msg?: string): void; 358 | includeMembers(superset: any[], subset: any[], msg?: string): void; 359 | 360 | ifError(val: any, msg?: string): void; 361 | 362 | isExtensible(obj: {}, msg?: string): void; 363 | extensible(obj: {}, msg?: string): void; 364 | isNotExtensible(obj: {}, msg?: string): void; 365 | notExtensible(obj: {}, msg?: string): void; 366 | 367 | isSealed(obj: {}, msg?: string): void; 368 | sealed(obj: {}, msg?: string): void; 369 | isNotSealed(obj: {}, msg?: string): void; 370 | notSealed(obj: {}, msg?: string): void; 371 | 372 | isFrozen(obj: Object, msg?: string): void; 373 | frozen(obj: Object, msg?: string): void; 374 | isNotFrozen(obj: Object, msg?: string): void; 375 | notFrozen(obj: Object, msg?: string): void; 376 | 377 | oneOf(inList: any, list: any[], msg?: string): void; 378 | } 379 | 380 | export interface Config { 381 | includeStack: boolean; 382 | } 383 | 384 | export class AssertionError { 385 | constructor(message: string, _props?: any, ssf?: Function); 386 | name: string; 387 | message: string; 388 | showDiff: boolean; 389 | stack: string; 390 | } 391 | } 392 | 393 | declare var chai: Chai.ChaiStatic; 394 | 395 | declare module "chai" { 396 | export = chai; 397 | } 398 | 399 | interface Object { 400 | should: Chai.Assertion; 401 | } 402 | -------------------------------------------------------------------------------- /src/typings/es6-shim.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for es6-shim v0.31.2 2 | // Project: https://github.com/paulmillr/es6-shim 3 | // Definitions by: Ron Buckton 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | declare type PropertyKey = string | number | symbol; 7 | 8 | interface IteratorResult { 9 | done: boolean; 10 | value?: T; 11 | } 12 | 13 | interface IterableShim { 14 | /** 15 | * Shim for an ES6 iterable. Not intended for direct use by user code. 16 | */ 17 | "_es6-shim iterator_"(): Iterator; 18 | } 19 | 20 | interface Iterator { 21 | next(value?: any): IteratorResult; 22 | return?(value?: any): IteratorResult; 23 | throw?(e?: any): IteratorResult; 24 | } 25 | 26 | interface IterableIteratorShim extends IterableShim, Iterator { 27 | /** 28 | * Shim for an ES6 iterable iterator. Not intended for direct use by user code. 29 | */ 30 | "_es6-shim iterator_"(): IterableIteratorShim; 31 | } 32 | 33 | interface StringConstructor { 34 | /** 35 | * Return the String value whose elements are, in order, the elements in the List elements. 36 | * If length is 0, the empty string is returned. 37 | */ 38 | fromCodePoint(...codePoints: number[]): string; 39 | 40 | /** 41 | * String.raw is intended for use as a tag function of a Tagged Template String. When called 42 | * as such the first argument will be a well formed template call site object and the rest 43 | * parameter will contain the substitution values. 44 | * @param template A well-formed template string call site representation. 45 | * @param substitutions A set of substitution values. 46 | */ 47 | raw(template: TemplateStringsArray, ...substitutions: any[]): string; 48 | } 49 | 50 | interface String { 51 | /** 52 | * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point 53 | * value of the UTF-16 encoded code point starting at the string element at position pos in 54 | * the String resulting from converting this object to a String. 55 | * If there is no element at that position, the result is undefined. 56 | * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos. 57 | */ 58 | codePointAt(pos: number): number; 59 | 60 | /** 61 | * Returns true if searchString appears as a substring of the result of converting this 62 | * object to a String, at one or more positions that are 63 | * greater than or equal to position; otherwise, returns false. 64 | * @param searchString search string 65 | * @param position If position is undefined, 0 is assumed, so as to search all of the String. 66 | */ 67 | includes(searchString: string, position?: number): boolean; 68 | 69 | /** 70 | * Returns true if the sequence of elements of searchString converted to a String is the 71 | * same as the corresponding elements of this object (converted to a String) starting at 72 | * endPosition – length(this). Otherwise returns false. 73 | */ 74 | endsWith(searchString: string, endPosition?: number): boolean; 75 | 76 | /** 77 | * Returns a String value that is made from count copies appended together. If count is 0, 78 | * T is the empty String is returned. 79 | * @param count number of copies to append 80 | */ 81 | repeat(count: number): string; 82 | 83 | /** 84 | * Returns true if the sequence of elements of searchString converted to a String is the 85 | * same as the corresponding elements of this object (converted to a String) starting at 86 | * position. Otherwise returns false. 87 | */ 88 | startsWith(searchString: string, position?: number): boolean; 89 | 90 | /** 91 | * Returns an HTML anchor element and sets the name attribute to the text value 92 | * @param name 93 | */ 94 | anchor(name: string): string; 95 | 96 | /** Returns a HTML element */ 97 | big(): string; 98 | 99 | /** Returns a HTML element */ 100 | blink(): string; 101 | 102 | /** Returns a HTML element */ 103 | bold(): string; 104 | 105 | /** Returns a HTML element */ 106 | fixed(): string 107 | 108 | /** Returns a HTML element and sets the color attribute value */ 109 | fontcolor(color: string): string 110 | 111 | /** Returns a HTML element and sets the size attribute value */ 112 | fontsize(size: number): string; 113 | 114 | /** Returns a HTML element and sets the size attribute value */ 115 | fontsize(size: string): string; 116 | 117 | /** Returns an HTML element */ 118 | italics(): string; 119 | 120 | /** Returns an HTML element and sets the href attribute value */ 121 | link(url: string): string; 122 | 123 | /** Returns a HTML element */ 124 | small(): string; 125 | 126 | /** Returns a HTML element */ 127 | strike(): string; 128 | 129 | /** Returns a HTML element */ 130 | sub(): string; 131 | 132 | /** Returns a HTML element */ 133 | sup(): string; 134 | 135 | /** 136 | * Shim for an ES6 iterable. Not intended for direct use by user code. 137 | */ 138 | "_es6-shim iterator_"(): IterableIteratorShim; 139 | } 140 | 141 | interface ArrayConstructor { 142 | /** 143 | * Creates an array from an array-like object. 144 | * @param arrayLike An array-like object to convert to an array. 145 | * @param mapfn A mapping function to call on every element of the array. 146 | * @param thisArg Value of 'this' used to invoke the mapfn. 147 | */ 148 | from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): Array; 149 | 150 | /** 151 | * Creates an array from an iterable object. 152 | * @param iterable An iterable object to convert to an array. 153 | * @param mapfn A mapping function to call on every element of the array. 154 | * @param thisArg Value of 'this' used to invoke the mapfn. 155 | */ 156 | from(iterable: IterableShim, mapfn: (v: T, k: number) => U, thisArg?: any): Array; 157 | 158 | /** 159 | * Creates an array from an array-like object. 160 | * @param arrayLike An array-like object to convert to an array. 161 | */ 162 | from(arrayLike: ArrayLike): Array; 163 | 164 | /** 165 | * Creates an array from an iterable object. 166 | * @param iterable An iterable object to convert to an array. 167 | */ 168 | from(iterable: IterableShim): Array; 169 | 170 | /** 171 | * Returns a new array from a set of elements. 172 | * @param items A set of elements to include in the new array object. 173 | */ 174 | of(...items: T[]): Array; 175 | } 176 | 177 | interface Array { 178 | /** 179 | * Returns the value of the first element in the array where predicate is true, and undefined 180 | * otherwise. 181 | * @param predicate find calls predicate once for each element of the array, in ascending 182 | * order, until it finds one where predicate returns true. If such an element is found, find 183 | * immediately returns that element value. Otherwise, find returns undefined. 184 | * @param thisArg If provided, it will be used as the this value for each invocation of 185 | * predicate. If it is not provided, undefined is used instead. 186 | */ 187 | find(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): T; 188 | 189 | /** 190 | * Returns the index of the first element in the array where predicate is true, and undefined 191 | * otherwise. 192 | * @param predicate find calls predicate once for each element of the array, in ascending 193 | * order, until it finds one where predicate returns true. If such an element is found, find 194 | * immediately returns that element value. Otherwise, find returns undefined. 195 | * @param thisArg If provided, it will be used as the this value for each invocation of 196 | * predicate. If it is not provided, undefined is used instead. 197 | */ 198 | findIndex(predicate: (value: T) => boolean, thisArg?: any): number; 199 | 200 | /** 201 | * Returns the this object after filling the section identified by start and end with value 202 | * @param value value to fill array section with 203 | * @param start index to start filling the array at. If start is negative, it is treated as 204 | * length+start where length is the length of the array. 205 | * @param end index to stop filling the array at. If end is negative, it is treated as 206 | * length+end. 207 | */ 208 | fill(value: T, start?: number, end?: number): T[]; 209 | 210 | /** 211 | * Returns the this object after copying a section of the array identified by start and end 212 | * to the same array starting at position target 213 | * @param target If target is negative, it is treated as length+target where length is the 214 | * length of the array. 215 | * @param start If start is negative, it is treated as length+start. If end is negative, it 216 | * is treated as length+end. 217 | * @param end If not specified, length of the this object is used as its default value. 218 | */ 219 | copyWithin(target: number, start: number, end?: number): T[]; 220 | 221 | /** 222 | * Returns an array of key, value pairs for every entry in the array 223 | */ 224 | entries(): IterableIteratorShim<[number, T]>; 225 | 226 | /** 227 | * Returns an list of keys in the array 228 | */ 229 | keys(): IterableIteratorShim; 230 | 231 | /** 232 | * Returns an list of values in the array 233 | */ 234 | values(): IterableIteratorShim; 235 | 236 | /** 237 | * Shim for an ES6 iterable. Not intended for direct use by user code. 238 | */ 239 | "_es6-shim iterator_"(): IterableIteratorShim; 240 | } 241 | 242 | interface NumberConstructor { 243 | /** 244 | * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 245 | * that is representable as a Number value, which is approximately: 246 | * 2.2204460492503130808472633361816 x 10‍−‍16. 247 | */ 248 | EPSILON: number; 249 | 250 | /** 251 | * Returns true if passed value is finite. 252 | * Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a 253 | * number. Only finite values of the type number, result in true. 254 | * @param number A numeric value. 255 | */ 256 | isFinite(number: number): boolean; 257 | 258 | /** 259 | * Returns true if the value passed is an integer, false otherwise. 260 | * @param number A numeric value. 261 | */ 262 | isInteger(number: number): boolean; 263 | 264 | /** 265 | * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a 266 | * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter 267 | * to a number. Only values of the type number, that are also NaN, result in true. 268 | * @param number A numeric value. 269 | */ 270 | isNaN(number: number): boolean; 271 | 272 | /** 273 | * Returns true if the value passed is a safe integer. 274 | * @param number A numeric value. 275 | */ 276 | isSafeInteger(number: number): boolean; 277 | 278 | /** 279 | * The value of the largest integer n such that n and n + 1 are both exactly representable as 280 | * a Number value. 281 | * The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1. 282 | */ 283 | MAX_SAFE_INTEGER: number; 284 | 285 | /** 286 | * The value of the smallest integer n such that n and n − 1 are both exactly representable as 287 | * a Number value. 288 | * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)). 289 | */ 290 | MIN_SAFE_INTEGER: number; 291 | 292 | /** 293 | * Converts a string to a floating-point number. 294 | * @param string A string that contains a floating-point number. 295 | */ 296 | parseFloat(string: string): number; 297 | 298 | /** 299 | * Converts A string to an integer. 300 | * @param s A string to convert into a number. 301 | * @param radix A value between 2 and 36 that specifies the base of the number in numString. 302 | * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. 303 | * All other strings are considered decimal. 304 | */ 305 | parseInt(string: string, radix?: number): number; 306 | } 307 | 308 | interface ObjectConstructor { 309 | /** 310 | * Copy the values of all of the enumerable own properties from one or more source objects to a 311 | * target object. Returns the target object. 312 | * @param target The target object to copy to. 313 | * @param sources One or more source objects to copy properties from. 314 | */ 315 | assign(target: any, ...sources: any[]): any; 316 | 317 | /** 318 | * Returns true if the values are the same value, false otherwise. 319 | * @param value1 The first value. 320 | * @param value2 The second value. 321 | */ 322 | is(value1: any, value2: any): boolean; 323 | 324 | /** 325 | * Sets the prototype of a specified object o to object proto or null. Returns the object o. 326 | * @param o The object to change its prototype. 327 | * @param proto The value of the new prototype or null. 328 | * @remarks Requires `__proto__` support. 329 | */ 330 | setPrototypeOf(o: any, proto: any): any; 331 | } 332 | 333 | interface RegExp { 334 | /** 335 | * Returns a string indicating the flags of the regular expression in question. This field is read-only. 336 | * The characters in this string are sequenced and concatenated in the following order: 337 | * 338 | * - "g" for global 339 | * - "i" for ignoreCase 340 | * - "m" for multiline 341 | * - "u" for unicode 342 | * - "y" for sticky 343 | * 344 | * If no flags are set, the value is the empty string. 345 | */ 346 | flags: string; 347 | } 348 | 349 | interface Math { 350 | /** 351 | * Returns the number of leading zero bits in the 32-bit binary representation of a number. 352 | * @param x A numeric expression. 353 | */ 354 | clz32(x: number): number; 355 | 356 | /** 357 | * Returns the result of 32-bit multiplication of two numbers. 358 | * @param x First number 359 | * @param y Second number 360 | */ 361 | imul(x: number, y: number): number; 362 | 363 | /** 364 | * Returns the sign of the x, indicating whether x is positive, negative or zero. 365 | * @param x The numeric expression to test 366 | */ 367 | sign(x: number): number; 368 | 369 | /** 370 | * Returns the base 10 logarithm of a number. 371 | * @param x A numeric expression. 372 | */ 373 | log10(x: number): number; 374 | 375 | /** 376 | * Returns the base 2 logarithm of a number. 377 | * @param x A numeric expression. 378 | */ 379 | log2(x: number): number; 380 | 381 | /** 382 | * Returns the natural logarithm of 1 + x. 383 | * @param x A numeric expression. 384 | */ 385 | log1p(x: number): number; 386 | 387 | /** 388 | * Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of 389 | * the natural logarithms). 390 | * @param x A numeric expression. 391 | */ 392 | expm1(x: number): number; 393 | 394 | /** 395 | * Returns the hyperbolic cosine of a number. 396 | * @param x A numeric expression that contains an angle measured in radians. 397 | */ 398 | cosh(x: number): number; 399 | 400 | /** 401 | * Returns the hyperbolic sine of a number. 402 | * @param x A numeric expression that contains an angle measured in radians. 403 | */ 404 | sinh(x: number): number; 405 | 406 | /** 407 | * Returns the hyperbolic tangent of a number. 408 | * @param x A numeric expression that contains an angle measured in radians. 409 | */ 410 | tanh(x: number): number; 411 | 412 | /** 413 | * Returns the inverse hyperbolic cosine of a number. 414 | * @param x A numeric expression that contains an angle measured in radians. 415 | */ 416 | acosh(x: number): number; 417 | 418 | /** 419 | * Returns the inverse hyperbolic sine of a number. 420 | * @param x A numeric expression that contains an angle measured in radians. 421 | */ 422 | asinh(x: number): number; 423 | 424 | /** 425 | * Returns the inverse hyperbolic tangent of a number. 426 | * @param x A numeric expression that contains an angle measured in radians. 427 | */ 428 | atanh(x: number): number; 429 | 430 | /** 431 | * Returns the square root of the sum of squares of its arguments. 432 | * @param values Values to compute the square root for. 433 | * If no arguments are passed, the result is +0. 434 | * If there is only one argument, the result is the absolute value. 435 | * If any argument is +Infinity or -Infinity, the result is +Infinity. 436 | * If any argument is NaN, the result is NaN. 437 | * If all arguments are either +0 or −0, the result is +0. 438 | */ 439 | hypot(...values: number[]): number; 440 | 441 | /** 442 | * Returns the integral part of the a numeric expression, x, removing any fractional digits. 443 | * If x is already an integer, the result is x. 444 | * @param x A numeric expression. 445 | */ 446 | trunc(x: number): number; 447 | 448 | /** 449 | * Returns the nearest single precision float representation of a number. 450 | * @param x A numeric expression. 451 | */ 452 | fround(x: number): number; 453 | 454 | /** 455 | * Returns an implementation-dependent approximation to the cube root of number. 456 | * @param x A numeric expression. 457 | */ 458 | cbrt(x: number): number; 459 | } 460 | 461 | interface PromiseLike { 462 | /** 463 | * Attaches callbacks for the resolution and/or rejection of the Promise. 464 | * @param onfulfilled The callback to execute when the Promise is resolved. 465 | * @param onrejected The callback to execute when the Promise is rejected. 466 | * @returns A Promise for the completion of which ever callback is executed. 467 | */ 468 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; 469 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; 470 | } 471 | 472 | /** 473 | * Represents the completion of an asynchronous operation 474 | */ 475 | interface Promise { 476 | /** 477 | * Attaches callbacks for the resolution and/or rejection of the Promise. 478 | * @param onfulfilled The callback to execute when the Promise is resolved. 479 | * @param onrejected The callback to execute when the Promise is rejected. 480 | * @returns A Promise for the completion of which ever callback is executed. 481 | */ 482 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; 483 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): Promise; 484 | 485 | /** 486 | * Attaches a callback for only the rejection of the Promise. 487 | * @param onrejected The callback to execute when the Promise is rejected. 488 | * @returns A Promise for the completion of the callback. 489 | */ 490 | catch(onrejected?: (reason: any) => T | PromiseLike): Promise; 491 | catch(onrejected?: (reason: any) => void): Promise; 492 | } 493 | 494 | interface PromiseConstructor { 495 | /** 496 | * A reference to the prototype. 497 | */ 498 | prototype: Promise; 499 | 500 | /** 501 | * Creates a new Promise. 502 | * @param executor A callback used to initialize the promise. This callback is passed two arguments: 503 | * a resolve callback used resolve the promise with a value or the result of another promise, 504 | * and a reject callback used to reject the promise with a provided reason or error. 505 | */ 506 | new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): Promise; 507 | 508 | /** 509 | * Creates a Promise that is resolved with an array of results when all of the provided Promises 510 | * resolve, or rejected when any Promise is rejected. 511 | * @param values An array of Promises. 512 | * @returns A new Promise. 513 | */ 514 | all(values: IterableShim>): Promise; 515 | 516 | /** 517 | * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved 518 | * or rejected. 519 | * @param values An array of Promises. 520 | * @returns A new Promise. 521 | */ 522 | race(values: IterableShim>): Promise; 523 | 524 | /** 525 | * Creates a new rejected promise for the provided reason. 526 | * @param reason The reason the promise was rejected. 527 | * @returns A new rejected Promise. 528 | */ 529 | reject(reason: any): Promise; 530 | 531 | /** 532 | * Creates a new rejected promise for the provided reason. 533 | * @param reason The reason the promise was rejected. 534 | * @returns A new rejected Promise. 535 | */ 536 | reject(reason: any): Promise; 537 | 538 | /** 539 | * Creates a new resolved promise for the provided value. 540 | * @param value A promise. 541 | * @returns A promise whose internal state matches the provided promise. 542 | */ 543 | resolve(value: T | PromiseLike): Promise; 544 | 545 | /** 546 | * Creates a new resolved promise . 547 | * @returns A resolved promise. 548 | */ 549 | resolve(): Promise; 550 | } 551 | 552 | declare var Promise: PromiseConstructor; 553 | 554 | interface Map { 555 | clear(): void; 556 | delete(key: K): boolean; 557 | forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; 558 | get(key: K): V; 559 | has(key: K): boolean; 560 | set(key: K, value?: V): Map; 561 | size: number; 562 | entries(): IterableIteratorShim<[K, V]>; 563 | keys(): IterableIteratorShim; 564 | values(): IterableIteratorShim; 565 | } 566 | 567 | interface MapConstructor { 568 | new (): Map; 569 | new (iterable: IterableShim<[K, V]>): Map; 570 | prototype: Map; 571 | } 572 | 573 | declare var Map: MapConstructor; 574 | 575 | interface Set { 576 | add(value: T): Set; 577 | clear(): void; 578 | delete(value: T): boolean; 579 | forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; 580 | has(value: T): boolean; 581 | size: number; 582 | entries(): IterableIteratorShim<[T, T]>; 583 | keys(): IterableIteratorShim; 584 | values(): IterableIteratorShim; 585 | } 586 | 587 | interface SetConstructor { 588 | new (): Set; 589 | new (iterable: IterableShim): Set; 590 | prototype: Set; 591 | } 592 | 593 | declare var Set: SetConstructor; 594 | 595 | interface WeakMap { 596 | delete(key: K): boolean; 597 | get(key: K): V; 598 | has(key: K): boolean; 599 | set(key: K, value?: V): WeakMap; 600 | } 601 | 602 | interface WeakMapConstructor { 603 | new (): WeakMap; 604 | new (iterable: IterableShim<[K, V]>): WeakMap; 605 | prototype: WeakMap; 606 | } 607 | 608 | declare var WeakMap: WeakMapConstructor; 609 | 610 | interface WeakSet { 611 | add(value: T): WeakSet; 612 | delete(value: T): boolean; 613 | has(value: T): boolean; 614 | } 615 | 616 | interface WeakSetConstructor { 617 | new (): WeakSet; 618 | new (iterable: IterableShim): WeakSet; 619 | prototype: WeakSet; 620 | } 621 | 622 | declare var WeakSet: WeakSetConstructor; 623 | 624 | declare module Reflect { 625 | function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; 626 | function construct(target: Function, argumentsList: ArrayLike): any; 627 | function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; 628 | function deleteProperty(target: any, propertyKey: PropertyKey): boolean; 629 | function enumerate(target: any): IterableIteratorShim; 630 | function get(target: any, propertyKey: PropertyKey, receiver?: any): any; 631 | function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; 632 | function getPrototypeOf(target: any): any; 633 | function has(target: any, propertyKey: PropertyKey): boolean; 634 | function isExtensible(target: any): boolean; 635 | function ownKeys(target: any): Array; 636 | function preventExtensions(target: any): boolean; 637 | function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; 638 | function setPrototypeOf(target: any, proto: any): boolean; 639 | } 640 | 641 | declare module "es6-shim" { 642 | var String: StringConstructor; 643 | var Array: ArrayConstructor; 644 | var Number: NumberConstructor; 645 | var Math: Math; 646 | var Object: ObjectConstructor; 647 | var Map: MapConstructor; 648 | var Set: SetConstructor; 649 | var WeakMap: WeakMapConstructor; 650 | var WeakSet: WeakSetConstructor; 651 | var Promise: PromiseConstructor; 652 | module Reflect { 653 | function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; 654 | function construct(target: Function, argumentsList: ArrayLike): any; 655 | function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; 656 | function deleteProperty(target: any, propertyKey: PropertyKey): boolean; 657 | function enumerate(target: any): Iterator; 658 | function get(target: any, propertyKey: PropertyKey, receiver?: any): any; 659 | function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; 660 | function getPrototypeOf(target: any): any; 661 | function has(target: any, propertyKey: PropertyKey): boolean; 662 | function isExtensible(target: any): boolean; 663 | function ownKeys(target: any): Array; 664 | function preventExtensions(target: any): boolean; 665 | function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; 666 | function setPrototypeOf(target: any, proto: any): boolean; 667 | } 668 | } 669 | -------------------------------------------------------------------------------- /src/typings/mocha.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for mocha 2.2.5 2 | // Project: http://mochajs.org/ 3 | // Definitions by: Kazi Manzur Rashid , otiai10 , jt000 , Vadim Macagon 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | interface MochaSetupOptions { 7 | //milliseconds to wait before considering a test slow 8 | slow?: number; 9 | 10 | // timeout in milliseconds 11 | timeout?: number; 12 | 13 | // ui name "bdd", "tdd", "exports" etc 14 | ui?: string; 15 | 16 | //array of accepted globals 17 | globals?: any[]; 18 | 19 | // reporter instance (function or string), defaults to `mocha.reporters.Spec` 20 | reporter?: any; 21 | 22 | // bail on the first test failure 23 | bail?: boolean; 24 | 25 | // ignore global leaks 26 | ignoreLeaks?: boolean; 27 | 28 | // grep string or regexp to filter tests with 29 | grep?: any; 30 | } 31 | 32 | interface MochaDone { 33 | (error?: Error): void; 34 | } 35 | 36 | declare var mocha: Mocha; 37 | declare var describe: Mocha.IContextDefinition; 38 | declare var xdescribe: Mocha.IContextDefinition; 39 | // alias for `describe` 40 | declare var context: Mocha.IContextDefinition; 41 | // alias for `describe` 42 | declare var suite: Mocha.IContextDefinition; 43 | declare var it: Mocha.ITestDefinition; 44 | declare var xit: Mocha.ITestDefinition; 45 | // alias for `it` 46 | declare var test: Mocha.ITestDefinition; 47 | 48 | declare function before(action: () => void): void; 49 | 50 | declare function before(action: (done: MochaDone) => void): void; 51 | 52 | declare function before(description: string, action: () => void): void; 53 | 54 | declare function before(description: string, action: (done: MochaDone) => void): void; 55 | 56 | declare function setup(action: () => void): void; 57 | 58 | declare function setup(action: (done: MochaDone) => void): void; 59 | 60 | declare function after(action: () => void): void; 61 | 62 | declare function after(action: (done: MochaDone) => void): void; 63 | 64 | declare function after(description: string, action: () => void): void; 65 | 66 | declare function after(description: string, action: (done: MochaDone) => void): void; 67 | 68 | declare function teardown(action: () => void): void; 69 | 70 | declare function teardown(action: (done: MochaDone) => void): void; 71 | 72 | declare function beforeEach(action: () => void): void; 73 | 74 | declare function beforeEach(action: (done: MochaDone) => void): void; 75 | 76 | declare function beforeEach(description: string, action: () => void): void; 77 | 78 | declare function beforeEach(description: string, action: (done: MochaDone) => void): void; 79 | 80 | declare function suiteSetup(action: () => void): void; 81 | 82 | declare function suiteSetup(action: (done: MochaDone) => void): void; 83 | 84 | declare function afterEach(action: () => void): void; 85 | 86 | declare function afterEach(action: (done: MochaDone) => void): void; 87 | 88 | declare function afterEach(description: string, action: () => void): void; 89 | 90 | declare function afterEach(description: string, action: (done: MochaDone) => void): void; 91 | 92 | declare function suiteTeardown(action: () => void): void; 93 | 94 | declare function suiteTeardown(action: (done: MochaDone) => void): void; 95 | 96 | declare class Mocha { 97 | constructor(options?: { 98 | grep?: RegExp; 99 | ui?: string; 100 | reporter?: string; 101 | timeout?: number; 102 | bail?: boolean; 103 | }); 104 | 105 | /** Setup mocha with the given options. */ 106 | setup(options: MochaSetupOptions): Mocha; 107 | bail(value?: boolean): Mocha; 108 | addFile(file: string): Mocha; 109 | /** Sets reporter by name, defaults to "spec". */ 110 | reporter(name: string): Mocha; 111 | /** Sets reporter constructor, defaults to mocha.reporters.Spec. */ 112 | reporter(reporter: (runner: Mocha.IRunner, options: any) => any): Mocha; 113 | ui(value: string): Mocha; 114 | grep(value: string): Mocha; 115 | grep(value: RegExp): Mocha; 116 | invert(): Mocha; 117 | ignoreLeaks(value: boolean): Mocha; 118 | checkLeaks(): Mocha; 119 | /** 120 | * Function to allow assertion libraries to throw errors directly into mocha. 121 | * This is useful when running tests in a browser because window.onerror will 122 | * only receive the 'message' attribute of the Error. 123 | */ 124 | throwError(error: Error): void; 125 | /** Enables growl support. */ 126 | growl(): Mocha; 127 | globals(value: string): Mocha; 128 | globals(values: string[]): Mocha; 129 | useColors(value: boolean): Mocha; 130 | useInlineDiffs(value: boolean): Mocha; 131 | timeout(value: number): Mocha; 132 | slow(value: number): Mocha; 133 | enableTimeouts(value: boolean): Mocha; 134 | asyncOnly(value: boolean): Mocha; 135 | noHighlighting(value: boolean): Mocha; 136 | /** Runs tests and invokes `onComplete()` when finished. */ 137 | run(onComplete?: (failures: number) => void): Mocha.IRunner; 138 | } 139 | 140 | // merge the Mocha class declaration with a module 141 | declare module Mocha { 142 | /** Partial interface for Mocha's `Runnable` class. */ 143 | interface IRunnable { 144 | title: string; 145 | fn: Function; 146 | async: boolean; 147 | sync: boolean; 148 | timedOut: boolean; 149 | } 150 | 151 | /** Partial interface for Mocha's `Suite` class. */ 152 | interface ISuite { 153 | parent: ISuite; 154 | title: string; 155 | 156 | fullTitle(): string; 157 | } 158 | 159 | /** Partial interface for Mocha's `Test` class. */ 160 | interface ITest extends IRunnable { 161 | parent: ISuite; 162 | pending: boolean; 163 | 164 | fullTitle(): string; 165 | } 166 | 167 | /** Partial interface for Mocha's `Runner` class. */ 168 | interface IRunner {} 169 | 170 | interface IContextDefinition { 171 | (description: string, spec: () => void): ISuite; 172 | only(description: string, spec: () => void): ISuite; 173 | skip(description: string, spec: () => void): void; 174 | timeout(ms: number): void; 175 | } 176 | 177 | interface ITestDefinition { 178 | (expectation: string, assertion?: () => void): ITest; 179 | (expectation: string, assertion?: (done: MochaDone) => void): ITest; 180 | only(expectation: string, assertion?: () => void): ITest; 181 | only(expectation: string, assertion?: (done: MochaDone) => void): ITest; 182 | skip(expectation: string, assertion?: () => void): void; 183 | skip(expectation: string, assertion?: (done: MochaDone) => void): void; 184 | timeout(ms: number): void; 185 | } 186 | 187 | export module reporters { 188 | export class Base { 189 | stats: { 190 | suites: number; 191 | tests: number; 192 | passes: number; 193 | pending: number; 194 | failures: number; 195 | }; 196 | 197 | constructor(runner: IRunner); 198 | } 199 | 200 | export class Doc extends Base {} 201 | export class Dot extends Base {} 202 | export class HTML extends Base {} 203 | export class HTMLCov extends Base {} 204 | export class JSON extends Base {} 205 | export class JSONCov extends Base {} 206 | export class JSONStream extends Base {} 207 | export class Landing extends Base {} 208 | export class List extends Base {} 209 | export class Markdown extends Base {} 210 | export class Min extends Base {} 211 | export class Nyan extends Base {} 212 | export class Progress extends Base { 213 | /** 214 | * @param options.open String used to indicate the start of the progress bar. 215 | * @param options.complete String used to indicate a complete test on the progress bar. 216 | * @param options.incomplete String used to indicate an incomplete test on the progress bar. 217 | * @param options.close String used to indicate the end of the progress bar. 218 | */ 219 | constructor(runner: IRunner, options?: { 220 | open?: string; 221 | complete?: string; 222 | incomplete?: string; 223 | close?: string; 224 | }); 225 | } 226 | export class Spec extends Base {} 227 | export class TAP extends Base {} 228 | export class XUnit extends Base { 229 | constructor(runner: IRunner, options?: any); 230 | } 231 | } 232 | } 233 | 234 | declare module "mocha" { 235 | export = Mocha; 236 | } 237 | -------------------------------------------------------------------------------- /tasks/bundle.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const gulp = require('gulp'); 4 | const path = require('path'); 5 | const Builder = require('systemjs-builder'); 6 | const dependencies = require('../package.json').jspm.dependencies; 7 | const PATHS = require('./constant').PATHS; 8 | const BUNDLE = require('./constant').BUNDLE; 9 | 10 | gulp.task('bundle', () => { 11 | const builder = new Builder(PATHS.TMP_PATH, 'jspm.config.js'); 12 | 13 | return builder.buildStatic('index', path.join(PATHS.DIST_PATH, BUNDLE.NAME_BUNDLE), { 14 | minify: true, 15 | mangle: true, 16 | sourceMaps: 'inline', 17 | lowResSourceMaps: true, 18 | runtime: false, 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /tasks/clean.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const gulp = require('gulp'); 4 | const del = require('del'); 5 | const PATHS = require('./constant').PATHS; 6 | 7 | gulp.task('clean:dist', () => del(PATHS.DIST_PATH)); 8 | 9 | gulp.task('clean:tmp', () => del(PATHS.TMP_PATH)); 10 | 11 | gulp.task('clean', gulp.parallel( 12 | 'clean:dist', 13 | 'clean:tmp' 14 | )); 15 | -------------------------------------------------------------------------------- /tasks/constant.js: -------------------------------------------------------------------------------- 1 | const TMP_PATH = './.tmp'; 2 | const DIST_PATH = './dist'; 3 | 4 | const NAME_BUNDLE = 'app.bundle.js'; 5 | 6 | module.exports = { 7 | PATHS: { TMP_PATH, DIST_PATH }, 8 | BUNDLE: { NAME_BUNDLE }, 9 | }; 10 | -------------------------------------------------------------------------------- /tasks/copy.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const gulp = require('gulp'); 4 | const mergeStream = require('merge-stream'); 5 | const glob = require('glob'); 6 | const PATHS = require('./constant').PATHS; 7 | 8 | function copy(paths) { 9 | return Object.keys(paths).reduce((acc, path) => { 10 | return mergeStream(acc, gulp.src(path).pipe(gulp.dest(paths[path]))); 11 | }, gulp.src('.')); 12 | } 13 | 14 | /** 15 | * Dist 16 | */ 17 | 18 | gulp.task('copy:dist:static:dev', () => { 19 | return copy({ 20 | './jspm.config.js': PATHS.DIST_PATH, 21 | './src/jspm_packages/**/*': `${ PATHS.DIST_PATH }/jspm_packages`, 22 | }); 23 | }); 24 | 25 | gulp.task('copy:dist:static:prod', () => { 26 | return copy({ 27 | [glob.sync('./src/jspm_packages/npm/angular2@*/bundles/angular2-polyfills.min.js')[0]]: PATHS.DIST_PATH, 28 | }); 29 | }); 30 | 31 | gulp.task('copy:dist:template', () => { 32 | return copy({ 33 | './src/index.html': PATHS.DIST_PATH, 34 | './src/app/**/*.html': PATHS.DIST_PATH, 35 | }); 36 | }); 37 | 38 | /** 39 | * Tmp 40 | */ 41 | 42 | gulp.task('copy:tmp:static', () => { 43 | return copy({ 44 | './jspm.config.js': PATHS.TMP_PATH, 45 | './src/jspm_packages/**/*': `${ PATHS.TMP_PATH }/jspm_packages`, 46 | }); 47 | }); 48 | 49 | gulp.task('copy:dist:static', gulp.parallel('copy:dist:static:dev', 'copy:dist:static:prod')) 50 | 51 | gulp.task('copy:dist:dev', gulp.parallel('copy:dist:static', 'copy:dist:template')); 52 | 53 | gulp.task('copy:dist:prod', gulp.parallel('copy:dist:static:prod', 'copy:dist:template')); 54 | 55 | gulp.task('copy:tmp', gulp.parallel('copy:tmp:static')); 56 | -------------------------------------------------------------------------------- /tasks/exit.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const gulp = require('gulp'); 4 | 5 | gulp.task('exit', (done) => { 6 | done(); 7 | process.exit(); 8 | }); 9 | -------------------------------------------------------------------------------- /tasks/karma.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const _ = require('lodash'); 4 | const gulp = require('gulp'); 5 | const notify = require('gulp-notify'); 6 | const through = require('through'); 7 | const path = require('path'); 8 | const Server = require('karma').Server; 9 | const argv = require('yargs').argv; 10 | 11 | const jspmConfig = { 12 | baseURL: './.tmp', 13 | config: 'jspm.config.js', 14 | loadFiles: [ 15 | '.tmp/**/*.spec.js', 16 | ], 17 | serveFiles: [ 18 | '.tmp/**/!(*.spec).js', 19 | ], 20 | }; 21 | 22 | function buildServer(options, done) { 23 | return new Server(_.assign({ 24 | configFile: path.join(__dirname + '/../karma.conf.js') 25 | }, options), done); 26 | } 27 | 28 | /** 29 | * Run test once and exit 30 | */ 31 | gulp.task('karma:watch', (done) => { 32 | const fileOveride = (argv.file) ? { loadFiles: [argv.file] } : {}; 33 | 34 | const server = buildServer(_.assign({ 35 | singleRun: false, 36 | watch: true, 37 | jspm: _.assign(jspmConfig, fileOveride), 38 | }), () => { 39 | done(); 40 | }); 41 | 42 | server.on('run_complete', (browser, results) => { 43 | if (results.error) { 44 | gulp.src('.') 45 | .pipe(through(function () { 46 | this.emit('error', new Error('Test failed!')) 47 | })) 48 | .on('error', notify.onError('<%= error.message %>')); 49 | } 50 | }); 51 | 52 | return server.start(); 53 | }); 54 | 55 | /** 56 | * Run test once and exit 57 | */ 58 | gulp.task('karma', (done) => { 59 | return buildServer({ jspm: jspmConfig }, done).start(); 60 | }); 61 | -------------------------------------------------------------------------------- /tasks/server.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const gulp = require('gulp'); 4 | const notify = require('gulp-notify'); 5 | const bs = require('browser-sync').create('server'); 6 | const argv = require('yargs').argv; 7 | const PATHS = require('./constant').PATHS; 8 | 9 | gulp.task('server:reload', done => { 10 | bs.reload(); 11 | done(); 12 | }); 13 | 14 | 15 | gulp.task('server', done => { 16 | bs.init({ 17 | server: { 18 | baseDir: PATHS.DIST_PATH, 19 | }, 20 | open: (argv.open === undefined || argv.open) ? true : false, 21 | port: (argv.port) ? argv.port : 3000, 22 | }); 23 | done(); 24 | }); 25 | 26 | bs.emitter.on('init', () => gulp.src('.').pipe(notify('Server is running!'))); 27 | -------------------------------------------------------------------------------- /tasks/template.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const gulp = require('gulp'); 4 | const htmlReplace = require('gulp-html-replace'); 5 | const path = require('path'); 6 | const PATHS = require('./constant').PATHS; 7 | const BUNDLE = require('./constant').BUNDLE; 8 | 9 | gulp.task('template', () => { 10 | return gulp.src([ 11 | path.join(PATHS.DIST_PATH, 'index.html'), 12 | ]) 13 | .pipe(htmlReplace({ 14 | 'js': `./${ BUNDLE.NAME_BUNDLE }`, 15 | })) 16 | .pipe(gulp.dest(path.join(PATHS.DIST_PATH))) 17 | }); 18 | -------------------------------------------------------------------------------- /tasks/transpile.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const gulp = require('gulp'); 4 | const ts = require('gulp-typescript'); 5 | const tslint = require('gulp-tslint'); 6 | const changed = require('gulp-changed'); 7 | const plumber = require('gulp-plumber'); 8 | const sourcemaps = require('gulp-sourcemaps'); 9 | const notify = require('gulp-notify'); 10 | const bs = require('browser-sync'); 11 | const PATHS = require('./constant').PATHS; 12 | 13 | const files = [ 14 | "./src/**/*.ts", 15 | "!./src/jspm_packages/**/*", 16 | ]; 17 | const config = require('../tsconfig.json'); 18 | 19 | /** 20 | * @name transpileTS 21 | * @desc Tanspile TypeScript file 22 | * @return {Stream} 23 | */ 24 | function transpileTS(name, destPath) { 25 | return function transpileTS() { 26 | return gulp.src(files) 27 | .pipe(changed(destPath, { extension: '.js' })) 28 | .pipe(plumber({errorHandler: notify.onError("TS compilation failed !")})) 29 | .pipe(sourcemaps.init()) 30 | .pipe(ts(config.compilerOptions)) 31 | .pipe(sourcemaps.write()) 32 | .pipe(gulp.dest(destPath)) 33 | .pipe(bs.get('server').stream()); 34 | } 35 | } 36 | 37 | /** 38 | * @name lintTS 39 | * @desc Lint TypeScript file 40 | * @return {Stream} 41 | */ 42 | function lintTS(name) { 43 | return function lintTS() { 44 | return gulp.src(files.concat('!./src/typings/**/*'), { since: gulp.lastRun(name) }) 45 | .pipe(plumber({errorHandler: notify.onError("TS linting failed !")})) 46 | .pipe(tslint()) 47 | .pipe(tslint.report('prose')); 48 | }; 49 | } 50 | 51 | gulp.task('lintTS', lintTS('lintTS')); 52 | 53 | gulp.task('transpile:dist', gulp.series('lintTS', transpileTS('transpile:dist', PATHS.DIST_PATH))); 54 | 55 | gulp.task('transpile:tmp', gulp.series('lintTS', transpileTS('transpile:tmp', PATHS.TMP_PATH))); 56 | -------------------------------------------------------------------------------- /tasks/watch.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const gulp = require('gulp'); 4 | const excludes = ['!./src/jspm_packages/**']; 5 | 6 | gulp.task('watch', (done) => { 7 | 8 | gulp.watch(['./src/**/*.ts'].concat(excludes), gulp.series('transpile:dist')); 9 | 10 | gulp.watch(['./src/**/*.html'].concat(excludes), gulp.series('copy:dist:template', 'server:reload')); 11 | 12 | done(); 13 | 14 | }); 15 | 16 | gulp.task('watch:test', (done) => { 17 | 18 | gulp.watch('./src/**/*.ts', gulp.series('transpile:tmp')); 19 | 20 | done(); 21 | 22 | }); 23 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "system", 5 | "moduleResolution": "node", 6 | "emitDecoratorMetadata": true, 7 | "experimentalDecorators": true, 8 | "noImplicitAny": true, 9 | "noEmitOnError": true 10 | }, 11 | "filesGlob": [ 12 | "./src/**/*.ts", 13 | "!./src/jspm_packages/**/*" 14 | ], 15 | "files": [ 16 | "./src/app/services/gist.service.ts", 17 | "./src/app/starter/starter.component.spec.ts", 18 | "./src/app/starter/starter.component.ts", 19 | "./src/index.ts", 20 | "./src/typings/chai.d.ts", 21 | "./src/typings/es6-shim.d.ts", 22 | "./src/typings/mocha.d.ts" 23 | ], 24 | "compileOnSave": false, 25 | "buildOnSave": false, 26 | "atom": { 27 | "rewriteTsconfig": true 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "align": false, 4 | "ban": false, 5 | "class-name": true, 6 | "comment-format": false, 7 | "curly": true, 8 | "eofline": true, 9 | "forin": false, 10 | "indent": [ 11 | true, 12 | "spaces" 13 | ], 14 | "interface-name": false, 15 | "jsdoc-format": false, 16 | "label-position": true, 17 | "label-undefined": true, 18 | "max-line-length": false, 19 | "member-access": false, 20 | "member-ordering": [ 21 | true, 22 | "static-before-instance", 23 | "variables-before-functions" 24 | ], 25 | "no-any": false, 26 | "no-arg": true, 27 | "no-bitwise": false, 28 | "no-conditional-assignment": true, 29 | "no-consecutive-blank-lines": true, 30 | "no-console": false, 31 | "no-construct": true, 32 | "no-constructor-vars": false, 33 | "no-debugger": false, 34 | "no-duplicate-key": true, 35 | "no-duplicate-variable": true, 36 | "no-empty": true, 37 | "no-eval": true, 38 | "no-inferrable-types": false, 39 | "no-internal-module": true, 40 | "no-null-keyword": false, 41 | "no-require-imports": true, 42 | "no-shadowed-variable": false, 43 | "no-string-literal": true, 44 | "no-switch-case-fall-through": true, 45 | "no-trailing-whitespace": false, 46 | "no-unreachable": true, 47 | "no-unused-expression": true, 48 | "no-unused-variable": true, 49 | "no-use-before-declare": true, 50 | "no-var-keyword": true, 51 | "no-var-requires": true, 52 | "object-literal-sort-keys": false, 53 | "one-line": [ 54 | true, 55 | "check-open-brace", 56 | "check-catch", 57 | "check-else", 58 | "check-whitespace" 59 | ], 60 | "quotemark": [ 61 | true, 62 | "single", 63 | "avoid-escape" 64 | ], 65 | "radix": false, 66 | "semicolon": true, 67 | "switch-default": true, 68 | "trailing-comma": [ 69 | true, 70 | { 71 | "multiline": "always", 72 | "singleline": "never" 73 | } 74 | ], 75 | "triple-equals": [ 76 | true, 77 | "allow-null-check" 78 | ], 79 | "typedef": [ 80 | true, 81 | "call-signature", 82 | "property-declaration", 83 | "member-variable-declaration" 84 | ], 85 | "typedef-whitespace": [ 86 | true, 87 | { 88 | "call-signature": "nospace", 89 | "index-signature": "nospace", 90 | "parameter": "nospace", 91 | "property-declaration": "nospace", 92 | "variable-declaration": "nospace" 93 | } 94 | ], 95 | "use-strict": false, 96 | "variable-name": [ 97 | true, 98 | "ban-keywords" 99 | ], 100 | "whitespace": [ 101 | true, 102 | "check-branch", 103 | "check-decl", 104 | "check-operator", 105 | "check-separator" 106 | ] 107 | } 108 | } 109 | --------------------------------------------------------------------------------