├── .coveralls.yml ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── docs └── contributing.md ├── gulpfile.js ├── package.json ├── publish.sh ├── slushfile.js ├── tasks ├── app.js ├── constant.js ├── controller.js ├── decorator.js ├── directive.js ├── factory.js ├── filter.js ├── module.js ├── provider.js ├── route.js ├── service.js ├── value.js └── view.js ├── templates ├── app │ ├── README.md │ ├── _bowerrc │ ├── _csslintrc │ ├── _editorconfig │ ├── _gitignore │ ├── _jshintrc │ ├── bower.json │ ├── gulpfile.js │ ├── karma.conf.js │ ├── package.json │ └── src │ │ └── app │ │ ├── app.css │ │ ├── app.js │ │ ├── assets │ │ ├── _gitkeep │ │ └── slush-angular-gulp.png │ │ ├── heat │ │ ├── aheat.js │ │ ├── heat-controller.js │ │ ├── heat-route.js │ │ ├── service │ │ │ └── heat_service.js │ │ └── view │ │ │ └── heat.html │ │ ├── index.html │ │ ├── styles │ │ └── _base.css │ │ └── todo │ │ ├── todo-controller.js │ │ ├── todo-controller.spec.js │ │ ├── todo-route.js │ │ ├── todo.css │ │ ├── todo.html │ │ └── todo.js ├── constant │ └── constant.js ├── controller │ ├── controller.js │ └── controller.spec.js ├── decorator │ └── decorator.js ├── directive │ └── directive.js ├── factory │ └── factory.js ├── filter │ ├── filter.js │ └── filter.spec.js ├── module │ ├── config.js │ ├── module.js │ ├── routes.js │ └── styles.css ├── provider │ └── provider.js ├── route │ └── route.js ├── service │ └── service.js ├── value │ └── value.js └── view │ └── view.html ├── test.sh ├── test ├── cases │ ├── app.spec.js │ ├── constant.spec.js │ ├── controller.spec.js │ ├── controller.test.spec.js │ ├── decorator.spec.js │ ├── directive.spec.js │ ├── factory.spec.js │ ├── filter.spec.js │ ├── module.config.spec.js │ ├── module.route.spec.js │ ├── negative.spec.js │ ├── provider.spec.js │ ├── route.spec.js │ ├── service.spec.js │ ├── value.spec.js │ └── view.spec.js ├── common.js ├── default.spec.js ├── testing_util.js └── top.js └── util.js /.coveralls.yml: -------------------------------------------------------------------------------- 1 | service_name: travis-org 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .tmp/ 3 | reports/ 4 | coverage.html 5 | npm-debug.log 6 | .idea -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '4' 4 | - '5' 5 | - '6' 6 | 7 | after_success: 8 | # Publish the coverage to coveralls.io 9 | - npm run coveralls 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2015, Venkateswara Venkatraman Prasanna 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #slush-angular-gulp 2 | === 3 | 4 | [![Greenkeeper badge](https://badges.greenkeeper.io/reflexdemon/slush-angular-gulp.svg)](https://greenkeeper.io/) 5 | 6 | ##Badges 7 | --- 8 | 9 | [![GitHub version](https://badge.fury.io/gh/reflexdemon%2Fslush-angular-gulp.png)](http://badge.fury.io/gh/reflexdemon%2Fslush-angular-gulp) 10 | 11 | [![npm version](https://badge.fury.io/js/slush-angular-gulp.png)](http://badge.fury.io/js/slush-angular-gulp) 12 | 13 | [![Dependency Status](https://david-dm.org/reflexdemon/slush-angular-gulp.png)](https://david-dm.org/reflexdemon/slush-angular-gulp) 14 | [![devDependency Status](https://david-dm.org/reflexdemon/slush-angular-gulp/dev-status.png)](https://david-dm.org/reflexdemon/slush-angular-gulp#info=devDependencies) 15 | 16 | 17 | [![Build Status](https://travis-ci.org/reflexdemon/slush-angular-gulp.svg?branch=master)](https://travis-ci.org/reflexdemon/slush-angular-gulp) 18 | 19 | [![Coverage Status](https://coveralls.io/repos/reflexdemon/slush-angular-gulp/badge.svg?branch=master&service=github)](https://coveralls.io/github/reflexdemon/slush-angular-gulp?branch=master) 20 | 21 | --- 22 | 23 | 24 | > A [slush](http://slushjs.github.io) generator for AngularJS using the [Google Angular App Structure Recommendations](https://docs.google.com/document/d/1XXMvReO8-Awi1EZXAXS4PzDzdNvV6pGcuaF4Q9821Es/pub) 25 | 26 | ![Slush Angular Gulp](https://github.com/reflexdemon/slush-angular-gulp/raw/master/templates/app/src/app/assets/slush-angular-gulp.png "Slush Angular Gulp") 27 | 28 | # Introduction 29 | 30 | All, would like to tell you [slush-angular-gulp](http://reflexdemon.github.io/slush-angular-gulp) is build with inspiration from the below projects. 31 | 32 | 1. [slush-angular](https://www.npmjs.com/package/slush-angular) 33 | 2. [angular-styleguide](https://github.com/johnpapa/angular-styleguide) 34 | 3. [Yomen generator-angular](https://github.com/yeoman/generator-angular) 35 | 36 | Moreover, this is just a first step towards integration of all the goodies of the above mentioned projects and expect more on future releases. 37 | 38 | ## Installation 39 | 40 | Install [slush-angular-gulp](http://reflexdemon.github.io/slush-angular-gulp) globally: 41 | 42 | ```bash 43 | npm install -g slush-angular-gulp 44 | ``` 45 | 46 | You'll also need to have `bower`, `slush` and `gulp` installed globally for a smooth installation 47 | 48 | ```bash 49 | npm install -g bower gulp slush 50 | ``` 51 | 52 | ### Bower dependency 53 | 54 | Here is the list of dependencies that are pre selected. 55 | 56 | 1. Angular 1.4 57 | 2. Bootstrap 58 | 59 | ### CSS Preprocessor 60 | 61 | `LESS`, `Stylus`, and `Sass` to use as the CSS Preprocessor for your project. 62 | 63 | *Note* All `_*.styl`, `_*.less`, or `_*.scss` files will be considered "partials" and must be imported in another stylesheet file (without a leading "_") to be compiled. 64 | 65 | ### Project structure 66 | 67 | You will also have the option to generate a simple Todo list app in your project as well, to be used as a live example of how to structure your app. 68 | 69 | The project structure with the Todo list example included will look like this: 70 | 71 | ``` 72 | my-angular-app/ 73 | ├── README.md 74 | ├── bower.json 75 | ├── gulpfile.js # See "Gulpfile" below 76 | ├── karma.conf.js 77 | ├── package.json 78 | └── src 79 | └── app 80 | ├── app.js # Main app module and configuration 81 | ├── app.styl/less/scss # Main app stylesheet 82 | ├── assets # A folder meant for images and such... 83 | │   └── slush-angular-gulp.png 84 | ├── components 85 | │   ├── heat 86 | │   │   ├── aheat.js 87 | │   │   ├── heat-controller.js 88 | │   │   ├── heat-route.js 89 | │   │   ├── service 90 | │   │   │   └── heat_service.js 91 | │   │   └── view 92 | │   │   └── heat.html 93 | │   └── todo 94 | │   ├── todo-controller.js # The todo controller 95 | │   ├── todo-controller.spec.js # Karma test for the todo controller 96 | │   ├── todo-route.js # Todo module route configuration 97 | │   ├── todo.html # The todo list template 98 | │   ├── todo.js # The todo module 99 | │   └── todo.styl/less/scss # Todo module specific styles 100 | ├── index.html # The index.html / app layout template 101 | └── styles 102 | └── _base.styl/less/scss # A stylesheet partial with base styles 103 | 104 | ``` 105 | Link to [Gulpfile](#gulpfile) 106 | 107 | ## Generators 108 | 109 | Available generators: 110 | 111 | * [angular-gulp](#app) (aka [angular-gulp:app](#app)) 112 | * [angular-gulp:controller](#controller) 113 | * [angular-gulp:module](#module) 114 | * [angular-gulp:directive](#directive) 115 | * [angular-gulp:filter](#filter) 116 | * [angular-gulp:route](#route) 117 | * [angular-gulp:service](#service) 118 | * [angular-gulp:provider](#provider) 119 | * [angular-gulp:factory](#factory) 120 | * [angular-gulp:value](#value) 121 | * [angular-gulp:constant](#constant) 122 | * [angular-gulp:decorator](#decorator) 123 | * [angular-gulp:view](#view) 124 | 125 | ### App 126 | 127 | Sets up a new AngularJS app, generating all the boilerplate you need to get started. The app generator also optionally installs Bootstrap and additional AngularJS modules, such as angular-resource (installed by default). 128 | 129 | Create a new folder for your project: 130 | 131 | ```bash 132 | mkdir my-angular-app 133 | ``` 134 | 135 | Run the generator from within the new folder: 136 | 137 | ```bash 138 | cd my-angular-app 139 | 140 | slush angular-gulp 141 | ``` 142 | or 143 | 144 | ```bash 145 | cd my-angular-app 146 | 147 | slush angular-gulp:app 148 | ``` 149 | 150 | You will now be prompted to give your new AngularJS app a name, which will be dasherized and used in its `bower.json` and `package.json` respectively. The chosen name will be camelized and used as the main angular module as well, inside `src/app/app.js`. 151 | 152 | 153 | 154 | ### Controller 155 | Generates a controller in `src/app/components/`. 156 | 157 | Syntax: 158 | 159 | ```bash 160 | slush angular-gulp:controller 161 | ``` 162 | 163 | Example: 164 | 165 | ```bash 166 | slush angular-gulp:controller login 167 | ``` 168 | 169 | ```log 170 | [06:33:12] Starting 'angular-gulp:controller'... 171 | ? What is the name of your controller? login 172 | ? What is your AngularJS module name? user 173 | ? Do you want to include unit testing? Yes 174 | [06:33:41] [conflict] Creating login-controller.js 175 | [06:33:41] [conflict] Creating login-controller.spec.js 176 | [06:33:41] Finished 'angular-gulp:controller' after 29 s 177 | [slush] Scaffolding done 178 | ``` 179 | 180 | Produces `src/app/user/login-controller.js`: 181 | ```javascript 182 | (function() { 183 | 'use strict'; 184 | 185 | angular 186 | .module('myAngularApp.user') 187 | .controller('LoginCtrl', LoginCtrl); 188 | ////////////////////// 189 | 190 | /** 191 | * @ngdoc function 192 | * @name myAngularApp.user.controller:LoginCtrl 193 | * @description 194 | * # LoginCtrl 195 | * Controller of the myAngularApp.user 196 | * @ngInject 197 | */ 198 | function LoginCtrl() { 199 | this.awesomeThings = [ 200 | 'HTML5 Boilerplate', 201 | 'AngularJS', 202 | 'Karma' 203 | ]; 204 | } 205 | 206 | })(); 207 | 208 | ``` 209 | and 210 | Produce `src/app/user/login-controller.spec.js` 211 | ```javascript 212 | 'use strict'; 213 | /** 214 | * Simple test class for LoginCtrl on myAngularApp.user 215 | */ 216 | describe('Controller: LoginCtrl', function () { 217 | 218 | // load the controller's module 219 | beforeEach(module('myAngularApp.user')); 220 | 221 | var LoginCtrl; 222 | 223 | // Initialize the controller and a mock scope 224 | beforeEach(inject(function ($controller, $rootScope) { 225 | LoginCtrl = $controller('LoginCtrl', { 226 | // place here mocked dependencies 227 | }); 228 | })); 229 | 230 | it('should attach a list of awesomeThings to the scope', function () { 231 | expect(LoginCtrl.awesomeThings.length).toBe(3); 232 | }); 233 | }); 234 | 235 | 236 | ``` 237 | 238 | ### Module 239 | Generates a module in `src/app/components/`. 240 | 241 | Syntax: 242 | 243 | ```bash 244 | slush angular-gulp:module 245 | ``` 246 | 247 | Example: 248 | 249 | ```bash 250 | slush angular-gulp:module user 251 | ``` 252 | 253 | ```log 254 | [21:55:01] Starting 'angular-gulp:module'... 255 | ? What is the name of your module? user 256 | ? Which configuration files would you like to be seperate? config, routes 257 | [21:55:36] [conflict] Creating user-module.js 258 | [21:55:36] [conflict] Creating user-config.js 259 | [21:55:36] [conflict] Creating user-routes.js 260 | [21:55:36] Finished 'angular-gulp:module' after 36 s 261 | [slush] Scaffolding done 262 | ``` 263 | 264 | Produces `src/app/components/user/user-module.js`: 265 | ```javascript 266 | /** 267 | * Creates and initilizes the module user 268 | */ 269 | 270 | (function() { 271 | 'use strict'; 272 | 273 | angular.module('myAngular.user', [], moduleConfiguration); 274 | 275 | /* @ngInject */ 276 | function moduleConfiguration() { 277 | //TODO Have any module specific configurator here 278 | }); 279 | } 280 | 281 | })(); 282 | 283 | ``` 284 | 285 | or if configs were separated out 286 | Produces `src/app/components/user/user-module.js`: 287 | ``` 288 | /** 289 | * Creates and initilizes the module user 290 | */ 291 | 292 | (function() { 293 | 'use strict'; 294 | 295 | angular.module('myAngular.user', []); 296 | } 297 | 298 | })(); 299 | ``` 300 | `src/app/components/user/user-config.js`: 301 | ``` 302 | /** 303 | * Configuration for the module user 304 | */ 305 | 306 | (function() { 307 | 'use strict'; 308 | 309 | 310 | angular 311 | .module('myAngular.user') 312 | .config(config); 313 | 314 | /* @ngInject */ 315 | function config(){ 316 | // Configurations 317 | } 318 | 319 | })(); 320 | ``` 321 | `src/app/components/user/user-routes.js`: 322 | ``` 323 | /** 324 | * Sets routes for the module user 325 | */ 326 | 327 | (function() { 328 | 'use strict'; 329 | 330 | 331 | angular 332 | .module('myAngular.user') 333 | .run(appRun); 334 | 335 | /* @ngInject */ 336 | function appRun(){ 337 | // Routing 338 | } 339 | 340 | })(); 341 | ``` 342 | 343 | ### Directive 344 | Generates a directive in `src/app/components/`. 345 | 346 | Syntax: 347 | 348 | ```bash 349 | slush angular-gulp:directive 350 | ``` 351 | 352 | Example: 353 | 354 | ```bash 355 | slush angular-gulp:directive awesome-thing 356 | ``` 357 | 358 | ```log 359 | [06:37:03] Starting 'angular-gulp:directive'... 360 | ? What is the name of your directive? awesome-thing 361 | ? What is your AngularJS module name? user 362 | [06:37:07] [conflict] Creating awesome-thing-directive.js 363 | [06:37:07] Finished 'angular-gulp:directive' after 4.57 s 364 | [slush] Scaffolding done 365 | ``` 366 | 367 | Produces `src/app/component/user/awesome-thing-directive.js`: 368 | ```javascript 369 | 370 | /** 371 | * @desc Please provide useful information regarding the directive with a proper example 372 | * @example
373 | */ 374 | (function() { 375 | angular 376 | .module('myAngularApp.user') 377 | .directive('awesomeThing', awesomeThing ); 378 | 379 | function awesomeThing () { 380 | /* implementation details */ 381 | } 382 | 383 | })(); 384 | 385 | 386 | 387 | ``` 388 | 389 | ### Filter 390 | Generates a filter in `src/app/components/`. 391 | 392 | Syntax: 393 | 394 | ```bash 395 | slush angular-gulp:filter 396 | ``` 397 | 398 | Example: 399 | 400 | ```bash 401 | slush angular-gulp:filter checkmark 402 | ``` 403 | 404 | ```log 405 | [06:39:02] Starting 'angular-gulp:filter'... 406 | ? What is the name of your filter? checkmark 407 | ? What is your AngularJS module name? user 408 | ? Do you want to include unit testing? Yes 409 | [06:39:11] [conflict] Creating checkmark-filter.js 410 | [06:39:11] [conflict] Creating checkmark-filter.spec.js 411 | [06:39:11] Finished 'angular-gulp:filter' after 9.3 s 412 | [slush] Scaffolding done 413 | ``` 414 | 415 | Produces `src/app/component/user/checkmark-filter.js`: 416 | ```javascript 417 | (function() { 418 | 'use strict'; 419 | 420 | angular 421 | .module('myAngularApp.user').filter('checkmark', checkmarkFilter); 422 | //////////////////// 423 | 424 | function checkmark() { 425 | return function (input) { 426 | return input ? '\u2713' : '\u2718'; 427 | }; 428 | } 429 | })(); 430 | 431 | ``` 432 | 433 | and 434 | 435 | Produces `src/app/component/user/checkmark-filter.spec.js`: 436 | ```javascript 437 | 438 | 'use strict'; 439 | 440 | describe('filter', function() { 441 | 442 | beforeEach(module('myAngularApp.user')); 443 | 444 | describe('checkmark', function() { 445 | 446 | it('should convert boolean values to unicode checkmark or cross', 447 | inject(function(checkmarkFilter) { 448 | expect(checkmarkFilter(true)).toBe('\u2713'); 449 | expect(checkmarkFilter(false)).toBe('\u2718'); 450 | })); 451 | }); 452 | }); 453 | 454 | 455 | ``` 456 | 457 | 458 | ### Route 459 | Generates a route in `src/app/components/`. 460 | 461 | Syntax: 462 | 463 | ```bash 464 | slush angular-gulp:route 465 | ``` 466 | 467 | Example: 468 | 469 | ```bash 470 | slush angular-gulp:route user 471 | ``` 472 | 473 | ```log 474 | [06:41:04] Starting 'angular-gulp:route'... 475 | ? What is the name of your route? user 476 | ? What is your AngularJS module name? user 477 | [06:41:07] [conflict] Creating user-route.js 478 | [06:41:07] Finished 'angular-gulp:route' after 2.96 s 479 | [slush] Scaffolding done 480 | ``` 481 | 482 | Produces `src/app/component/user/user-route.js`: 483 | ```javascript 484 | (function() { 485 | 'use strict'; 486 | 487 | angular 488 | .module('myAngularApp.user') 489 | .config( userRoute); 490 | 491 | 492 | /* @ngInject */ 493 | function userRoute($routeProvider) { 494 | $routeProvider 495 | .when('/user', { //Default 496 | controller: 'UserCtrl', 497 | templateUrl: 'user/user.html' 498 | }); 499 | 500 | } 501 | 502 | })(); 503 | ``` 504 | ### Service 505 | Generates a service in `src/app/components/`. 506 | 507 | Syntax: 508 | 509 | ```bash 510 | slush angular-gulp:service 511 | ``` 512 | 513 | Example: 514 | 515 | ```bash 516 | slush angular-gulp:service session 517 | ``` 518 | 519 | ```log 520 | [06:43:42] Starting 'angular-gulp:service'... 521 | ? What is the name of your service? session 522 | ? What is your AngularJS module name? user 523 | [06:43:48] [conflict] Creating session-service.js 524 | [06:43:48] Finished 'angular-gulp:service' after 5.58 s 525 | [slush] Scaffolding done 526 | ``` 527 | 528 | Produces `src/app/user/session-service.js`: 529 | ```javascript 530 | (function() { 531 | 'use strict'; 532 | 533 | angular 534 | .module('myAngularApp.user') 535 | .service('sessionService', sessionService); 536 | 537 | 538 | /* @ngInject */ 539 | function sessionService() { 540 | var someValue = ''; 541 | var service = { 542 | save: save, 543 | someValue: someValue, 544 | validate: validate 545 | }; 546 | return service; 547 | 548 | //////////// 549 | 550 | function save() { 551 | /* */ 552 | } 553 | 554 | function validate() { 555 | /* */ 556 | } 557 | } 558 | 559 | })(); 560 | 561 | ``` 562 | 563 | ### Factory 564 | Generates a factory in `src/app/components/`. 565 | 566 | Syntax: 567 | 568 | ```bash 569 | slush angular-gulp:factory 570 | ``` 571 | 572 | Example: 573 | 574 | ```bash 575 | slush angular-gulp:factory session 576 | ``` 577 | 578 | ```log 579 | [06:46:32] Starting 'angular-gulp:factory'... 580 | ? What is the name of your factory? session 581 | ? What is your AngularJS module name? user 582 | [06:46:38] [conflict] Creating session-factory.js 583 | [06:46:38] Finished 'angular-gulp:factory' after 6.07 s 584 | [slush] Scaffolding done 585 | ``` 586 | 587 | Produces `src/app/home/session-factory.js`: 588 | ```javascript 589 | (function() { 590 | 'use strict'; 591 | 592 | angular 593 | .module('myAngularApp.user') 594 | .factory('sessionFactory', sessionFactory); 595 | 596 | 597 | /* @ngInject */ 598 | function sessionFactory() { 599 | var someValue = ''; 600 | var factory = { 601 | save: save, 602 | someValue: someValue, 603 | validate: validate 604 | }; 605 | return factory; 606 | 607 | //////////// 608 | 609 | function save() { 610 | /* */ 611 | }; 612 | 613 | function validate() { 614 | /* */ 615 | }; 616 | } 617 | 618 | })(); 619 | 620 | 621 | ``` 622 | 623 | ### Provider 624 | Generates a provider in `src/app/components/`. 625 | 626 | Syntax: 627 | 628 | ```bash 629 | slush angular-gulp:provider 630 | ``` 631 | 632 | Example: 633 | 634 | ```bash 635 | slush angular-gulp:provider game 636 | ``` 637 | 638 | ```log 639 | [14:16:32] Starting 'angular-gulp:provider'... 640 | ? What is the name of your provider? game 641 | ? What is your AngularJS module name? user 642 | [14:16:47] [conflict] Creating game-provider.js 643 | [14:16:48] Finished 'angular-gulp:provider' after 16 s 644 | [slush] Scaffolding done 645 | ``` 646 | 647 | Produces `src/app/home/game-provider.js`: 648 | 649 | ```javascript 650 | (function() { 651 | 'use strict'; 652 | 653 | angular 654 | .module('myAngular.user') 655 | .provider('game', gameProvider); 656 | 657 | /* @ngInject */ 658 | function gameProvider() { 659 | var someValue = ''; 660 | var provider = { 661 | save: save, 662 | someValue: someValue, 663 | validate: validate 664 | }; 665 | return provider; 666 | 667 | //////////// 668 | 669 | function save() { 670 | /* */ 671 | } 672 | 673 | function validate() { 674 | /* */ 675 | } 676 | } 677 | })(); 678 | 679 | ``` 680 | 681 | ### Constant 682 | Generates a constant in `src/app/components/`. 683 | 684 | Syntax: 685 | 686 | ```bash 687 | slush angular-gulp:constant 688 | ``` 689 | 690 | Example: 691 | 692 | ```bash 693 | slush angular-gulp:constant apiKey 694 | ``` 695 | 696 | ```log 697 | [06:47:37] Starting 'angular-gulp:constant'... 698 | ? What is the name of your constant? apiKey 699 | ? What is your AngularJS module name? user 700 | [06:47:44] [conflict] Creating apiKey-constant.js 701 | [06:47:44] Finished 'angular-gulp:constant' after 7.11 s 702 | [slush] Scaffolding done 703 | ``` 704 | 705 | Produces `src/app/component/user/appKey-constant.js`: 706 | 707 | ```javascript 708 | (function() { 709 | 'use strict'; 710 | 711 | angular 712 | .module('myAngularApp.user') 713 | .constant('apiKey', 'apiKey'); 714 | 715 | 716 | })(); 717 | 718 | 719 | ``` 720 | ### Value 721 | Generates a value in `src/app/components/`. 722 | 723 | Syntax: 724 | 725 | ```bash 726 | slush angular-gulp:value 727 | ``` 728 | 729 | Example: 730 | 731 | ```bash 732 | slush angular-gulp:value baseUrl 733 | ``` 734 | 735 | ```log 736 | [06:49:57] Starting 'angular-gulp:value'... 737 | ? What is the name of your value? baseUrl 738 | ? What is your AngularJS module name? user 739 | [06:50:01] [conflict] Creating baseUrl-value.js 740 | [06:50:01] Finished 'angular-gulp:value' after 3.64 s 741 | [slush] Scaffolding done 742 | ``` 743 | 744 | Produces `src/app/component/user/baseUrl-value.js`: 745 | 746 | ```javascript 747 | (function() { 748 | 'use strict'; 749 | 750 | var baseUrlValue = {}; 751 | 752 | angular 753 | .module('myAngularApp.user') 754 | .value('baseUrl', baseUrlValue); 755 | 756 | 757 | })(); 758 | 759 | ``` 760 | 761 | ### Decorator 762 | Generates a decorator in `src/app/components/`. 763 | 764 | Syntax: 765 | 766 | ```bash 767 | slush angular-gulp:decorator 768 | ``` 769 | 770 | Example: 771 | 772 | ```bash 773 | slush angular-gulp:decorator exception 774 | ``` 775 | 776 | ```log 777 | [06:52:06] Starting 'angular-gulp:decorator'... 778 | ? What is the name of your decorator? exception 779 | ? What is your AngularJS module name? user 780 | [06:52:11] [conflict] Creating exception-decorator.js 781 | [06:52:11] Finished 'angular-gulp:decorator' after 4.52 s 782 | [slush] Scaffolding done 783 | ``` 784 | 785 | Produces `src/app/component/user/exception-decorator.js`: 786 | 787 | ```javascript 788 | 789 | (function () { 790 | 'use strict' 791 | 792 | angular 793 | .module('myAngularApp.user') 794 | .config(exceptionConfig); 795 | 796 | /* @ngInject */ 797 | function exceptionConfig($provide) { 798 | $provide.decorator('$exceptionHandler', extendexceptionHandler); 799 | } 800 | 801 | /* @ngInject */ 802 | function extendexceptionHandler($delegate) { 803 | return function(exception, cause) { 804 | $delegate(exception, cause); 805 | var data = { 806 | exception: exception 807 | }; 808 | }; 809 | } 810 | 811 | })(); 812 | 813 | 814 | ``` 815 | 816 | ### View 817 | Generates a view in `src/app/components/`. 818 | 819 | Syntax: 820 | 821 | ```bash 822 | slush angular-gulp:view 823 | ``` 824 | 825 | Example: 826 | 827 | ```bash 828 | slush angular-gulp:view user 829 | ``` 830 | 831 | ```log 832 | [06:54:05] Starting 'angular-gulp:view'... 833 | ? What is the name of your view? user 834 | ? What is your AngularJS module name? user 835 | [06:54:17] [conflict] Creating user-view.html 836 | [06:54:17] Finished 'angular-gulp:view' after 12 s 837 | [slush] Scaffolding done 838 | ``` 839 | 840 | Produces `src/app/component/user/user-view.html`: 841 | 842 | ```html 843 |

This is the user view

844 | ``` 845 | 846 | 847 | 848 | 849 | ### Gulpfile 850 | 851 | #### Development 852 | 853 | To start developing in your new generated project run: 854 | 855 | ```bash 856 | gulp serve 857 | ``` 858 | 859 | Then head to `http://localhost:3000` in your browser. 860 | 861 | The `serve` tasks starts a static file server, which serves your AngularJS application, and a watch task which watches your files for changes and lints, builds and injects them into your index.html accordingly. 862 | 863 | #### Tests 864 | 865 | To run tests run: 866 | 867 | ```bash 868 | gulp test 869 | ``` 870 | 871 | #### Production ready build - a.k.a. dist 872 | 873 | To make the app ready for deploy to production run: 874 | 875 | ```bash 876 | gulp dist 877 | ``` 878 | 879 | #### Testing Production ready build - a.k.a. dist 880 | 881 | To make the app ready for deploy to production run: 882 | 883 | ```bash 884 | gulp serve-dist 885 | ``` 886 | 887 | Now you have a `./dist` folder with all your scripts and stylesheets concatenated and minified, also third party libraries installed with bower will be concatenated and minified into `vendors.min.js` and `vendors.min.css` respectively. 888 | 889 | ## Contributing guideline 890 | 891 | The Contributing guideline can be found here [Contributing](https://github.com/reflexdemon/slush-angular-gulp/blob/master/docs/contributing.md). 892 | 893 | ## Changelog 894 | 895 | The Changelog can be found on the [releases section](https://github.com/reflexdemon/slush-angular-gulp/releases). 896 | 897 | ## License 898 | 899 | [MIT](https://github.com/reflexdemon/slush-angular-gulp/blob/master/LICENSE) 900 | -------------------------------------------------------------------------------- /docs/contributing.md: -------------------------------------------------------------------------------- 1 | # Request for contributions 2 | 3 | Please contribute to this repository if any of the following is true: 4 | - You have expertise in community development, communication, or education 5 | - You want open source communities to be more collaborative and inclusive 6 | - You want to help lower the burden to first time contributors 7 | 8 | # How to contribute 9 | 10 | Prerequisites: 11 | 12 | - familiarity with [GitHub PRs](https://help.github.com/articles/using-pull-requests) (pull requests) and issues 13 | - knowledge of Markdown for editing `.md` documents 14 | - Ensure the `nps test` shows all pass. 15 | 16 | In particular, this community seeks the following types of contributions: 17 | 18 | - ideas: participate in an Issues thread or start your own to have your voice 19 | heard 20 | - resources: submit a PR to add to [README.md](/README.md) with links to related content 21 | - outline sections: help us ensure that this repository is comprehensive. if 22 | there is a topic that is overlooked, please add it, even if it is just a stub 23 | in the form of a header and single sentence. Initially, most things fall into 24 | this category 25 | - write: contribute your expertise in an area by helping us expand the included 26 | content 27 | - copy editing: fix typos, clarify language, and generally improve the quality 28 | of the content 29 | - formatting: help keep content easy to read with consistent formatting 30 | - code: Fix issues or contribute new features to this or any related projects 31 | 32 | # Conduct 33 | 34 | We are committed to providing a friendly, safe and welcoming environment for 35 | all, regardless of gender, sexual orientation, disability, ethnicity, religion, 36 | or similar personal characteristic. 37 | 38 | On IRC, please avoid using overtly sexual nicknames or other nicknames that 39 | might detract from a friendly, safe and welcoming environment for all. 40 | 41 | Please be kind and courteous. There's no need to be mean or rude. 42 | Respect that people have differences of opinion and that every design or 43 | implementation choice carries a trade-off and numerous costs. There is seldom 44 | a right answer, merely an optimal answer given a set of values and 45 | circumstances. 46 | 47 | Please keep unstructured critique to a minimum. If you have solid ideas you 48 | want to experiment with, make a fork and see how it works. 49 | 50 | We will exclude you from interaction if you insult, demean or harass anyone. 51 | That is not welcome behaviour. We interpret the term "harassment" as 52 | including the definition in the 53 | [Citizen Code of Conduct](http://citizencodeofconduct.org/); 54 | if you have any lack of clarity about what might be included in that concept, 55 | please read their definition. In particular, we don't tolerate behavior that 56 | excludes people in socially marginalized groups. 57 | 58 | Private harassment is also unacceptable. No matter who you are, if you feel 59 | you have been or are being harassed or made uncomfortable by a community 60 | member, please contact [reflexdemon](https://github.com/reflexdemon). Whether 61 | you're a regular contributor or a newcomer, we care about 62 | making this community a safe place for you and we've got your back. 63 | 64 | Likewise any spamming, trolling, flaming, baiting or other attention-stealing 65 | behaviour is not welcome. 66 | 67 | 68 | # Communication 69 | 70 | 71 | GitHub issues are the primary way for communicating about specific proposed 72 | changes to this project. 73 | 74 | Please follow the conduct guidelines above. Language issues 75 | are often contentious and we'd like to keep discussion brief, civil and focused 76 | on what we're actually doing, not wandering off into too much imaginary stuff. 77 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'); 2 | var mocha = require('gulp-mocha'); 3 | var stripDebug = require('gulp-strip-debug'); 4 | var gutil = require('gulp-util'); 5 | var cover = require('gulp-coverage'); 6 | 7 | gutil.log = gutil.noop; 8 | 9 | gulp.task('test', function() { 10 | gulp.src('test/default.spec.js') 11 | .pipe(stripDebug()) 12 | .pipe(mocha({ 13 | reporter: 'html-cov', 14 | clearRequireCache: true, 15 | ignoreLeaks: true 16 | })); 17 | }); 18 | 19 | gulp.task('coverage', function() { 20 | return gulp.src(['./slushfile.js', './tasks/*.js'], { 21 | read: false 22 | }) 23 | .pipe(cover.instrument({ 24 | pattern: ['./test/*.spec.js'], 25 | debugDirectory: 'debug' 26 | })) 27 | .pipe(mocha({ 28 | reporter: 'html-cov', 29 | ignoreLeaks: true 30 | })) 31 | .pipe(cover.gather()) 32 | .pipe(cover.format()) 33 | .pipe(gulp.dest('reports')); 34 | }); 35 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "slush-angular-gulp", 3 | "version": "0.4.4", 4 | "description": "Gulp, Angular, Less with Web server, this generator is build with inspiration from the below projects. slush-angular, angular-styleguide and generator-angular", 5 | "main": "slushfile.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/reflexdemon/slush-angular-gulp" 9 | }, 10 | "scripts": { 11 | "test": "NODE_ENV=test mocha -R spec test/top.js", 12 | "posttest": "NODE_ENV=test mocha -R travis-cov test/top.js", 13 | "old": "NODE_ENV=test mocha -R spec test/*.spec.js", 14 | "old-travis": "NODE_ENV=test mocha -R travis-cov test/*.spec.js", 15 | "report": "NODE_ENV=test mocha test/top.js -R html-cov > coverage.html", 16 | "coveralls": "NODE_ENV=test ./node_modules/.bin/mocha test/top.js -R mocha-lcov-reporter | ./node_modules/coveralls/bin/coveralls.js" 17 | }, 18 | "config": { 19 | "travis-cov": { 20 | "threshold": 90 21 | } 22 | }, 23 | "keywords": [ 24 | "slushgenerator", 25 | "angular", 26 | "angularjs", 27 | "google", 28 | "gulp", 29 | "gulpfile", 30 | "less", 31 | "saas", 32 | "stylus", 33 | "moca", 34 | "bootstrap", 35 | "bower", 36 | "webserver", 37 | "livereload", 38 | "middleware", 39 | "fontawesome", 40 | "modular" 41 | ], 42 | "author": "Venkateswara Venkatraman Prasanna", 43 | "license": "MIT", 44 | "bugs": { 45 | "url": "https://github.com/reflexdemon/slush-angular-gulp/issues" 46 | }, 47 | "homepage": "https://github.com/reflexdemon/slush-angular-gulp", 48 | "dependencies": { 49 | "gulp": "^3.8.11", 50 | "gulp-conflict": "^0.4.0", 51 | "gulp-install": "^1.1.0", 52 | "gulp-load-tasks": "^0.8.3", 53 | "gulp-rename": "^1.2.0", 54 | "gulp-template": "^4.0.0", 55 | "include-all": "^4.0.3", 56 | "lodash": "^4.7.0", 57 | "underscore.string": "^3.0.3", 58 | "yargs": "^9.0.1", 59 | "inquirer": "^4.0.0" 60 | }, 61 | "devDependencies": { 62 | "assertthat": "^0.11.0", 63 | "blanket": "^1.1.7", 64 | "chai": "*", 65 | "coveralls": "^2.11.3", 66 | "gulp-coverage": "^0.3.36", 67 | "gulp-coveralls": "^0.1.4", 68 | "gulp-mocha": "^4.3.1", 69 | "gulp-strip-debug": "^1.0.2", 70 | "gulp-util": "^3.0.6", 71 | "mocha": "*", 72 | "mocha-lcov-reporter": "1.3.0", 73 | "mock-gulp-dest": "~0.1.0", 74 | "travis-cov": "^0.2.5" 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /publish.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | npm publish 4 | -------------------------------------------------------------------------------- /slushfile.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | var gulp = require('gulp'); 4 | 5 | var includeAll = require('include-all'); 6 | /** 7 | * Loads task modules from a relative path. 8 | */ 9 | function loadTasks(relPath) { 10 | return includeAll({ 11 | dirname: require('path').resolve(__dirname, relPath), 12 | filter: /(.+)\.js$/ 13 | }) || {}; 14 | } 15 | // * 16 | // * Invokes the function from a Gulp configuration module with 17 | // * a single argument - the `gulp` object. 18 | 19 | function addTasks(tasks) { 20 | for (var taskName in tasks) { 21 | if (tasks.hasOwnProperty(taskName)) { 22 | tasks[taskName](gulp); 23 | } 24 | } 25 | } 26 | /** 27 | * Add all Gulp tasks to the gulpfile. 28 | * Tasks are in `tasks/` 29 | */ 30 | addTasks(loadTasks('tasks/')); 31 | 32 | // require('gulp-load-tasks')(__dirname + '/tasks'); 33 | gulp.task('default', ['app']); 34 | 35 | })(); 36 | -------------------------------------------------------------------------------- /tasks/app.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | /** 3 | * App Task 4 | * This is the main task that is invoked for the processing of the slushfile.js 5 | */ 6 | var gulp = require('gulp'), 7 | install = require('gulp-install'), 8 | conflict = require('gulp-conflict'), 9 | template = require('gulp-template'), 10 | rename = require('gulp-rename'), 11 | inquirer = require('inquirer'), 12 | _ = require('lodash'); 13 | 14 | //Local dependencies 15 | var util = require('../util'); 16 | 17 | module.exports = function (gulp) { 18 | 'use strict'; 19 | _.extend(_, require('underscore.string')); 20 | var examples = ["todo", "heat"]; 21 | 22 | gulp.task('app', function (done) { 23 | var _this = this; 24 | //User Input 25 | inquirer.prompt([{ 26 | type: 'input', 27 | name: 'name', 28 | message: 'What do you want to name your AngularJS app?', 29 | default: util.getDefaultOption(_this.args, 0) || util.getNameProposal() 30 | }, { 31 | type: 'list', 32 | name: 'csstype', 33 | message: 'What CSS preprocessor do you want to use?', 34 | default: 2, 35 | choices: [{ 36 | name: 'LESS', 37 | short: 'less' 38 | }, { 39 | name: 'Stylus', 40 | short: 'styl' 41 | }, { 42 | name: 'Sass', 43 | short: 'sass' 44 | }], 45 | filter: function (val) { 46 | return val.toLowerCase(); 47 | } 48 | }, { 49 | type: 'confirm', 50 | name: 'middleware', 51 | message: 'Do you want to use middleware for proxy support?', 52 | default: true 53 | }]).then(function (answers) { 54 | //Hande for user response 55 | answers.nameDashed = _.slugify(answers.name); 56 | answers.modulename = _.camelize(answers.nameDashed); 57 | var files = [__dirname + '/../templates/app/**']; 58 | var exclude = []; 59 | _.each(exclude, function (choice) { 60 | files.push('!' + __dirname + '/../templates/app/src/app/' + choice + '/**'); 61 | files.push('!' + __dirname + '/../templates/app/src/app/' + choice); 62 | }); 63 | answers.exampleSettings = {}; 64 | _.each(examples, function (item) { 65 | answers.exampleSettings[item] = item; 66 | }); 67 | answers.styleData = util.cssTypeData[answers.csstype]; 68 | console.log(JSON.stringify(answers, null, ' ')); 69 | return gulp.src(files) 70 | .pipe(template(answers)) 71 | .pipe(rename(function (file) { 72 | if (file.extname === '.css') { 73 | file.extname = '.' + answers.styleData.extension; 74 | } else if (file.basename[0] === '_') { 75 | file.basename = '.' + file.basename.slice(1); 76 | } 77 | })) 78 | .pipe(conflict('./')) 79 | .pipe(gulp.dest('./')) 80 | .pipe(install()) 81 | .on('finish', function () { 82 | done(); 83 | }); 84 | }); 85 | }); 86 | } 87 | 88 | })(); 89 | -------------------------------------------------------------------------------- /tasks/constant.js: -------------------------------------------------------------------------------- 1 | /** 2 | * constant Task 3 | * This is the main task that is invoked for the processing of the slushfile.js 4 | */ 5 | 6 | (function () { 7 | var gulp = require('gulp'), 8 | install = require('gulp-install'), 9 | conflict = require('gulp-conflict'), 10 | template = require('gulp-template'), 11 | rename = require('gulp-rename'), 12 | inquirer = require('inquirer') 13 | _ = require('underscore.string'); 14 | 15 | //Local dependencies 16 | var util = require('../util'); 17 | 18 | module.exports = function (gulp) { 19 | 'use strict'; 20 | 21 | gulp.task('constant', function (done) { 22 | var _this = this; 23 | var name = util.getDefaultOption(_this.args, 0); 24 | var options = util.getGlobalOptions(); 25 | var modules = util.getModuleProposal(options.appDir); 26 | 27 | if (modules.length === 0) { 28 | throw new Error('constant must be created in a module, but no modules exist. Create a module using "slush angular-gulp:module ".'); 29 | } 30 | 31 | inquirer.prompt([{ 32 | type: 'input', 33 | name: 'fileName', 34 | message: 'What is the name of your constant?', 35 | default: name 36 | }, { 37 | type: 'list', 38 | name: 'module', 39 | message: 'What is your AngularJS module name?', 40 | choices: modules 41 | }]).then(function (answers) { 42 | //Init 43 | answers.nameDashed = _.slugify(util.getNameProposal()); 44 | answers.scriptAppName = _.camelize(answers.nameDashed) + '.' + answers.module; 45 | answers.classedName = _.camelize(answers.fileName); 46 | answers.classedNameDashed = _.slugify(answers.fileName); 47 | answers.classedModule = _.capitalize(_.camelize(answers.module)); 48 | ; 49 | 50 | //Source 51 | gulp.src(__dirname + '/../templates/constant/constant.js') 52 | .pipe(template(answers)) 53 | .pipe(rename(answers.fileName + '-constant.js')) 54 | .pipe(conflict(options.base + options.appDir + '/' + answers.module)) 55 | .pipe(gulp.dest(options.base + options.appDir + '/' + answers.module)) 56 | .on('finish', function() { 57 | done(); 58 | }); 59 | }); 60 | }); 61 | } 62 | })(); 63 | -------------------------------------------------------------------------------- /tasks/controller.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Controller Task 3 | * This is the main task that is invoked for the processing of the slushfile.js 4 | */ 5 | 6 | (function () { 7 | var gulp = require('gulp'), 8 | install = require('gulp-install'), 9 | conflict = require('gulp-conflict'), 10 | template = require('gulp-template'), 11 | rename = require('gulp-rename'), 12 | inquirer = require('inquirer') 13 | _ = require('underscore.string'); 14 | 15 | //Local dependencies 16 | var util = require('../util'); 17 | 18 | module.exports = function (gulp) { 19 | 'use strict'; 20 | 21 | gulp.task('controller', function (done) { 22 | var _this = this; 23 | var name = util.getDefaultOption(_this.args, 0); 24 | var options = util.getGlobalOptions(); 25 | var modules = util.getModuleProposal(options.appDir); 26 | 27 | if (modules.length === 0) { 28 | throw new Error('Controller must be created in a module, but no modules exist. Create a module using "slush angular-gulp:module ".'); 29 | } 30 | 31 | inquirer.prompt([{ 32 | type: 'input', 33 | name: 'fileName', 34 | message: 'What is the name of your controller?' 35 | }, { 36 | type: 'list', 37 | name: 'module', 38 | message: 'What is your AngularJS module name?', 39 | choices: modules 40 | }, { 41 | type: 'confirm', 42 | name: 'spec', 43 | message: 'Do you want to include unit testing?', 44 | default: true 45 | }]).then(function (answers) { 46 | //Init 47 | answers.nameDashed = _.slugify(util.getNameProposal()); 48 | answers.scriptAppName = _.camelize(answers.nameDashed) + '.' + answers.module; 49 | answers.classedName = _.capitalize(_.camelize(answers.fileName)); 50 | //console.log('answers:', answers); 51 | // test 52 | if (answers.spec === true) { 53 | var counter = 0; 54 | 55 | gulp.src(__dirname + '/../templates/controller/controller.spec.js') 56 | .pipe(template(answers)) 57 | .pipe(rename(answers.fileName + '-controller.spec.js')) 58 | .pipe(conflict(options.base + options.appDir + '/' + answers.module)) 59 | .pipe(gulp.dest(options.base + options.appDir + '/' + answers.module)) 60 | .on('finish', function() { 61 | if (++counter > 1) { 62 | done(); 63 | } 64 | }); 65 | 66 | gulp.src(__dirname + '/../templates/controller/controller.js') 67 | .pipe(template(answers)) 68 | .pipe(rename(answers.fileName + '-controller.js')) 69 | .pipe(conflict(options.base + options.appDir + '/' + answers.module)) 70 | .pipe(gulp.dest(options.base + options.appDir + '/' + answers.module)) 71 | .on('finish', function() { 72 | if (++counter > 1) { 73 | done(); 74 | } 75 | }); 76 | 77 | } else { 78 | gulp.src(__dirname + '/../templates/controller/controller.js') 79 | .pipe(template(answers)) 80 | .pipe(rename(answers.fileName + '-controller.js')) 81 | .pipe(conflict(options.base + options.appDir + '/' + answers.module)) 82 | .pipe(gulp.dest(options.base + options.appDir + '/' + answers.module)) 83 | .on('finish', function () { 84 | done(); 85 | }); 86 | 87 | } 88 | // //Source 89 | // gulp.src(__dirname + '/../templates/controller/controller.js') 90 | // .pipe(template(answers)) 91 | // .pipe(rename(answers.fileName + '-controller.js')) 92 | // .pipe(conflict(options.base + options.appDir + '/' + answers.module)) 93 | // .pipe(gulp.dest(options.base + options.appDir + '/' + answers.module)) 94 | // .on('finish', function() { 95 | // done(); 96 | // }); 97 | }); 98 | }); 99 | } 100 | })(); 101 | -------------------------------------------------------------------------------- /tasks/decorator.js: -------------------------------------------------------------------------------- 1 | /** 2 | * decorator Task 3 | * This is the main task that is invoked for the processing of the slushfile.js 4 | */ 5 | 6 | (function () { 7 | var gulp = require('gulp'), 8 | install = require('gulp-install'), 9 | conflict = require('gulp-conflict'), 10 | template = require('gulp-template'), 11 | rename = require('gulp-rename'), 12 | inquirer = require('inquirer') 13 | _ = require('underscore.string'); 14 | 15 | //Local dependencies 16 | var util = require('../util'); 17 | 18 | module.exports = function (gulp) { 19 | 'use strict'; 20 | 21 | gulp.task('decorator', function (done) { 22 | var _this = this; 23 | var name = util.getDefaultOption(_this.args, 0); 24 | var options = util.getGlobalOptions(); 25 | var modules = util.getModuleProposal(options.appDir); 26 | 27 | if (modules.length === 0) { 28 | throw new Error('decorator must be created in a module, but no modules exist. Create a module using "slush angular-gulp:module ".'); 29 | } 30 | 31 | inquirer.prompt([{ 32 | type: 'input', 33 | name: 'fileName', 34 | message: 'What is the name of your decorator?', 35 | default: name 36 | }, { 37 | type: 'list', 38 | name: 'module', 39 | message: 'What is your AngularJS module name?', 40 | choices: modules 41 | }]).then(function (answers) { 42 | //Init 43 | answers.nameDashed = _.slugify(util.getNameProposal()); 44 | answers.scriptAppName = _.camelize(answers.nameDashed) + '.' + answers.module; 45 | answers.classedName = _.camelize(answers.fileName); 46 | answers.classedNameDashed = _.slugify(answers.fileName); 47 | answers.classedModule = _.capitalize(_.camelize(answers.module)); 48 | 49 | //Source 50 | gulp.src(__dirname + '/../templates/decorator/decorator.js') 51 | .pipe(template(answers)) 52 | .pipe(rename(answers.fileName + '-decorator.js')) 53 | .pipe(conflict(options.base + options.appDir + '/' + answers.module)) 54 | .pipe(gulp.dest(options.base + options.appDir + '/' + answers.module)) 55 | .on('finish', function () { 56 | done(); 57 | }); 58 | }); 59 | }); 60 | } 61 | })(); 62 | -------------------------------------------------------------------------------- /tasks/directive.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Controller Task 3 | * This is the main task that is invoked for the processing of the slushfile.js 4 | */ 5 | 6 | (function () { 7 | var gulp = require('gulp'), 8 | install = require('gulp-install'), 9 | conflict = require('gulp-conflict'), 10 | template = require('gulp-template'), 11 | rename = require('gulp-rename'), 12 | inquirer = require('inquirer') 13 | _ = require('underscore.string'); 14 | 15 | //Local dependencies 16 | var util = require('../util'); 17 | 18 | module.exports = function (gulp) { 19 | 'use strict'; 20 | 21 | gulp.task('directive', function (done) { 22 | var _this = this; 23 | var name = util.getDefaultOption(_this.args, 0); 24 | var options = util.getGlobalOptions(); 25 | var modules = util.getModuleProposal(options.appDir); 26 | 27 | if (modules.length === 0) { 28 | throw new Error('Directive must be created in a module, but no modules exist. Create a module using "slush angular-gulp:module ".'); 29 | } 30 | 31 | inquirer.prompt([{ 32 | type: 'input', 33 | name: 'fileName', 34 | message: 'What is the name of your directive?', 35 | default: name 36 | }, { 37 | type: 'list', 38 | name: 'module', 39 | message: 'What is your AngularJS module name?', 40 | choices: modules 41 | }]).then(function (answers) { 42 | //Init 43 | answers.nameDashed = _.slugify(util.getNameProposal()); 44 | answers.scriptAppName = _.camelize(answers.nameDashed) + '.' + answers.module; 45 | answers.classedName = _.camelize(answers.fileName); 46 | answers.classedNameDashed = _.slugify(answers.fileName); 47 | 48 | //Source 49 | gulp.src(__dirname + '/../templates/directive/directive.js') 50 | .pipe(template(answers)) 51 | .pipe(rename(answers.fileName + '-directive.js')) 52 | .pipe(conflict(options.base + options.appDir + '/' + answers.module)) 53 | .pipe(gulp.dest(options.base + options.appDir + '/' + answers.module)) 54 | .on('finish', function () { 55 | done(); 56 | }); 57 | }); 58 | }); 59 | } 60 | })(); 61 | -------------------------------------------------------------------------------- /tasks/factory.js: -------------------------------------------------------------------------------- 1 | /** 2 | * factory Task 3 | * This is the main task that is invoked for the processing of the slushfile.js 4 | */ 5 | 6 | (function () { 7 | var gulp = require('gulp'), 8 | install = require('gulp-install'), 9 | conflict = require('gulp-conflict'), 10 | template = require('gulp-template'), 11 | rename = require('gulp-rename'), 12 | inquirer = require('inquirer') 13 | _ = require('underscore.string'); 14 | 15 | //Local dependencies 16 | var util = require('../util'); 17 | 18 | module.exports = function (gulp) { 19 | 'use strict'; 20 | 21 | gulp.task('factory', function (done) { 22 | var _this = this; 23 | var name = util.getDefaultOption(_this.args, 0); 24 | var options = util.getGlobalOptions(); 25 | var modules = util.getModuleProposal(options.appDir); 26 | 27 | if (modules.length === 0) { 28 | throw new Error('factory must be created in a module, but no modules exist. Create a module using "slush angular-gulp:module ".'); 29 | } 30 | 31 | inquirer.prompt([{ 32 | type: 'input', 33 | name: 'fileName', 34 | message: 'What is the name of your factory?', 35 | default: name 36 | }, { 37 | type: 'list', 38 | name: 'module', 39 | message: 'What is your AngularJS module name?', 40 | choices: modules 41 | }]).then(function (answers) { 42 | //Init 43 | answers.nameDashed = _.slugify(util.getNameProposal()); 44 | answers.scriptAppName = _.camelize(answers.nameDashed) + '.' + answers.module; 45 | answers.classedName = _.camelize(answers.fileName); 46 | answers.classedNameDashed = _.slugify(answers.fileName); 47 | answers.classedModule = _.capitalize(_.camelize(answers.module)); 48 | ; 49 | 50 | //Source 51 | gulp.src(__dirname + '/../templates/factory/factory.js') 52 | .pipe(template(answers)) 53 | .pipe(rename(answers.fileName + '-factory.js')) 54 | .pipe(conflict(options.base + options.appDir + '/' + answers.module)) 55 | .pipe(gulp.dest(options.base + options.appDir + '/' + answers.module)) 56 | .on('finish', function () { 57 | done(); 58 | }); 59 | }); 60 | }); 61 | } 62 | })(); 63 | -------------------------------------------------------------------------------- /tasks/filter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * filter Task 3 | * This is the main task that is invoked for the processing of the slushfile.js 4 | */ 5 | 6 | (function () { 7 | var gulp = require('gulp'), 8 | install = require('gulp-install'), 9 | conflict = require('gulp-conflict'), 10 | template = require('gulp-template'), 11 | rename = require('gulp-rename'), 12 | inquirer = require('inquirer') 13 | _ = require('underscore.string'); 14 | 15 | //Local dependencies 16 | var util = require('../util'); 17 | 18 | module.exports = function (gulp) { 19 | 'use strict'; 20 | 21 | gulp.task('filter', function (done) { 22 | var _this = this; 23 | var name = util.getDefaultOption(_this.args, 0); 24 | var options = util.getGlobalOptions(); 25 | var modules = util.getModuleProposal(options.appDir); 26 | 27 | if (modules.length === 0) { 28 | throw new Error('filter must be created in a module, but no modules exist. Create a module using "slush angular-gulp:module ".'); 29 | } 30 | 31 | inquirer.prompt([{ 32 | type: 'input', 33 | name: 'fileName', 34 | message: 'What is the name of your filter?', 35 | default: name 36 | }, { 37 | type: 'list', 38 | name: 'module', 39 | message: 'What is your AngularJS module name?', 40 | choices: modules 41 | }, { 42 | type: 'confirm', 43 | name: 'test', 44 | message: 'Do you want to include unit testing?', 45 | default: true 46 | }]).then(function (answers) { 47 | //Init 48 | answers.nameDashed = _.slugify(util.getNameProposal()); 49 | answers.scriptAppName = _.camelize(answers.nameDashed) + '.' + answers.module; 50 | answers.classedName = _.camelize(answers.fileName); 51 | answers.classedNameDashed = _.slugify(answers.fileName); 52 | 53 | // test 54 | if (answers.test) { 55 | gulp.src(__dirname + '/../templates/filter/filter.spec.js') 56 | .pipe(template(answers)) 57 | .pipe(rename(answers.fileName + '-filter.spec.js')) 58 | .pipe(conflict(options.base + options.appDir + '/' + answers.module)) 59 | .pipe(gulp.dest(options.base + options.appDir + '/' + answers.module)) 60 | } 61 | 62 | //Source 63 | gulp.src(__dirname + '/../templates/filter/filter.js') 64 | .pipe(template(answers)) 65 | .pipe(rename(answers.fileName + '-filter.js')) 66 | .pipe(conflict(options.base + options.appDir + '/' + answers.module)) 67 | .pipe(gulp.dest(options.base + options.appDir + '/' + answers.module)) 68 | .on('finish', function () { 69 | done(); 70 | }); 71 | }); 72 | }); 73 | } 74 | })(); 75 | -------------------------------------------------------------------------------- /tasks/module.js: -------------------------------------------------------------------------------- 1 | /** 2 | * module Task 3 | * This is the main task that is invoked for the processing of the slushfile.js 4 | */ 5 | (function () { 6 | 7 | var gulp = require('gulp'), 8 | install = require('gulp-install'), 9 | conflict = require('gulp-conflict'), 10 | template = require('gulp-template'), 11 | rename = require('gulp-rename'), 12 | inquirer = require('inquirer'), 13 | _ = require('underscore.string'); 14 | 15 | //Local dependencies 16 | var util = require('../util'); 17 | 18 | module.exports = function (gulp) { 19 | 'use strict'; 20 | 21 | gulp.task('module', function (done) { 22 | var _this = this; 23 | var options = util.getGlobalOptions(); 24 | 25 | inquirer.prompt([{ 26 | type: 'input', 27 | name: 'module', 28 | message: 'What is the name of your module?', 29 | default: util.getDefaultOption(_this.args, 0) 30 | }, { 31 | type: 'confirm', 32 | name: 'configConfirm', 33 | message: 'Do you wish to have routes?', 34 | default: false 35 | }/*, 36 | { 37 | type: 'checkbox', 38 | name: 'config', 39 | message: 'Which configuration files would you like to be separate?', 40 | choices: [{ 41 | name: 'config', 42 | value: 'config' 43 | }, { 44 | name: 'routes', 45 | value: 'routes' 46 | }] 47 | },{ 48 | type: 'confirm', 49 | name: 'css', 50 | message: 'Will this module encapsulate its own styles?', 51 | default: false 52 | }*/ 53 | ]).then(function (answers) { 54 | //Init 55 | answers.nameDashed = _.slugify(util.getNameProposal()); 56 | answers.scriptAppName = _.camelize(answers.nameDashed) + '.' + answers.module; 57 | //Generate 58 | if (answers.configConfirm) { 59 | answers.config='config'; 60 | gulp.src(__dirname + '/../templates/module/config.js') 61 | .pipe(template(answers)) 62 | .pipe(rename(answers.module + '-config.js')) 63 | .pipe(conflict(options.base + options.appDir + '/' + answers.module)) 64 | .pipe(gulp.dest(options.base + options.appDir + '/' + answers.module)) 65 | } else { 66 | answers.config='route'; 67 | gulp.src(__dirname + '/../templates/module/routes.js') 68 | .pipe(template(answers)) 69 | .pipe(rename(answers.module + '-routes.js')) 70 | .pipe(conflict(options.base + options.appDir + '/' + answers.module)) 71 | .pipe(gulp.dest(options.base + options.appDir + '/' + answers.module)) 72 | } 73 | /* todo(Aquila) check what preprocessor is being used and name files appropriately 74 | if(answers.css) { 75 | gulp.src(__dirname + '/../templates/module/styles.css') 76 | .pipe(rename(answers.module + '.css')) 77 | .pipe(conflict(options.base + options.appDir +'/'+ answers.module)) 78 | .pipe(gulp.dest(options.base + options.appDir +'/'+ answers.module)) 79 | }*/ 80 | gulp.src(__dirname + '/../templates/module/module.js') 81 | .pipe(template(answers)) 82 | .pipe(rename(answers.module + '-module.js')) 83 | .pipe(conflict(options.base + options.appDir + '/' + answers.module)) 84 | .pipe(gulp.dest(options.base + options.appDir + '/' + answers.module)) 85 | .on('finish', function () { 86 | done(); 87 | }); 88 | }); 89 | }); 90 | } 91 | 92 | })(); 93 | -------------------------------------------------------------------------------- /tasks/provider.js: -------------------------------------------------------------------------------- 1 | /** 2 | * provider Task 3 | * This is the main task that is invoked for the processing of the slushfile.js 4 | */ 5 | 6 | (function () { 7 | var gulp = require('gulp'), 8 | install = require('gulp-install'), 9 | conflict = require('gulp-conflict'), 10 | template = require('gulp-template'), 11 | rename = require('gulp-rename'), 12 | inquirer = require('inquirer') 13 | _ = require('underscore.string'); 14 | 15 | //Local dependencies 16 | var util = require('../util'); 17 | 18 | module.exports = function (gulp) { 19 | 'use strict'; 20 | 21 | gulp.task('provider', function (done) { 22 | var _this = this; 23 | var name = util.getDefaultOption(_this.args, 0); 24 | var options = util.getGlobalOptions(); 25 | var modules = util.getModuleProposal(options.appDir); 26 | 27 | if (modules.length === 0) { 28 | throw new Error('provider must be created in a module, but no modules exist. Create a module using "slush angular-gulp:module ".'); 29 | } 30 | 31 | inquirer.prompt([{ 32 | type: 'input', 33 | name: 'fileName', 34 | message: 'What is the name of your provider?', 35 | default: name 36 | }, { 37 | type: 'list', 38 | name: 'module', 39 | message: 'What is your AngularJS module name?', 40 | choices: modules 41 | }]).then(function (answers) { 42 | //Init 43 | answers.nameDashed = _.slugify(util.getNameProposal()); 44 | answers.scriptAppName = _.camelize(answers.nameDashed) + '.' + answers.module; 45 | answers.classedName = _.camelize(answers.fileName); 46 | answers.classedNameDashed = _.slugify(answers.fileName); 47 | answers.classedModule = _.capitalize(_.camelize(answers.module)); 48 | ; 49 | 50 | //Source 51 | gulp.src(__dirname + '/../templates/provider/provider.js') 52 | .pipe(template(answers)) 53 | .pipe(rename(answers.fileName + '-provider.js')) 54 | .pipe(conflict(options.base + options.appDir + '/' + answers.module)) 55 | .pipe(gulp.dest(options.base + options.appDir + '/' + answers.module)) 56 | .on('finish', function () { 57 | done(); 58 | }); 59 | }); 60 | }); 61 | } 62 | })(); 63 | -------------------------------------------------------------------------------- /tasks/route.js: -------------------------------------------------------------------------------- 1 | /** 2 | * route Task 3 | * This is the main task that is invoked for the processing of the slushfile.js 4 | */ 5 | 6 | (function () { 7 | var gulp = require('gulp'), 8 | install = require('gulp-install'), 9 | conflict = require('gulp-conflict'), 10 | template = require('gulp-template'), 11 | rename = require('gulp-rename'), 12 | inquirer = require('inquirer') 13 | _ = require('underscore.string'); 14 | 15 | //Local dependencies 16 | var util = require('../util'); 17 | 18 | module.exports = function (gulp) { 19 | 'use strict'; 20 | 21 | gulp.task('route', function (done) { 22 | var _this = this; 23 | var name = util.getDefaultOption(_this.args, 0); 24 | var options = util.getGlobalOptions(); 25 | var modules = util.getModuleProposal(options.appDir); 26 | 27 | if (modules.length === 0) { 28 | throw new Error('route must be created in a module, but no modules exist. Create a module using "slush angular-gulp:module ".'); 29 | } 30 | 31 | inquirer.prompt([{ 32 | type: 'input', 33 | name: 'fileName', 34 | message: 'What is the name of your route?', 35 | default: name 36 | }, { 37 | type: 'list', 38 | name: 'module', 39 | message: 'What is your AngularJS module name?', 40 | choices: modules 41 | }]).then(function (answers) { 42 | //Init 43 | answers.nameDashed = _.slugify(util.getNameProposal()); 44 | answers.scriptAppName = _.camelize(answers.nameDashed) + '.' + answers.module; 45 | answers.classedName = _.camelize(answers.fileName); 46 | answers.classedNameDashed = _.slugify(answers.fileName); 47 | answers.classedModule = _.capitalize(_.camelize(answers.module)); 48 | ; 49 | 50 | //Source 51 | gulp.src(__dirname + '/../templates/route/route.js') 52 | .pipe(template(answers)) 53 | .pipe(rename(answers.fileName + '-route.js')) 54 | .pipe(conflict(options.base + options.appDir + '/' + answers.module)) 55 | .pipe(gulp.dest(options.base + options.appDir + '/' + answers.module)) 56 | .on('finish', function () { 57 | done(); 58 | }); 59 | }); 60 | }); 61 | } 62 | })(); 63 | -------------------------------------------------------------------------------- /tasks/service.js: -------------------------------------------------------------------------------- 1 | /** 2 | * service Task 3 | * This is the main task that is invoked for the processing of the slushfile.js 4 | */ 5 | 6 | (function () { 7 | var gulp = require('gulp'), 8 | install = require('gulp-install'), 9 | conflict = require('gulp-conflict'), 10 | template = require('gulp-template'), 11 | rename = require('gulp-rename'), 12 | inquirer = require('inquirer') 13 | _ = require('underscore.string'); 14 | 15 | //Local dependencies 16 | var util = require('../util'); 17 | 18 | module.exports = function (gulp) { 19 | 'use strict'; 20 | 21 | gulp.task('service', function (done) { 22 | var _this = this; 23 | var name = util.getDefaultOption(_this.args, 0); 24 | var options = util.getGlobalOptions(); 25 | var modules = util.getModuleProposal(options.appDir); 26 | 27 | if (modules.length === 0) { 28 | throw new Error('service must be created in a module, but no modules exist. Create a module using "slush angular-gulp:module ".'); 29 | } 30 | 31 | inquirer.prompt([{ 32 | type: 'input', 33 | name: 'fileName', 34 | message: 'What is the name of your service?', 35 | default: name 36 | }, { 37 | type: 'list', 38 | name: 'module', 39 | message: 'What is your AngularJS module name?', 40 | choices: modules 41 | }]).then(function (answers) { 42 | //Init 43 | answers.nameDashed = _.slugify(util.getNameProposal()); 44 | answers.scriptAppName = _.camelize(answers.nameDashed) + '.' + answers.module; 45 | answers.classedName = _.camelize(answers.fileName); 46 | answers.classedNameDashed = _.slugify(answers.fileName); 47 | answers.classedModule = _.capitalize(_.camelize(answers.module)); 48 | ; 49 | 50 | //Source 51 | gulp.src(__dirname + '/../templates/service/service.js') 52 | .pipe(template(answers)) 53 | .pipe(rename(answers.fileName + '-service.js')) 54 | .pipe(conflict(options.base + options.appDir + '/' + answers.module)) 55 | .pipe(gulp.dest(options.base + options.appDir + '/' + answers.module)) 56 | .on('finish', function () { 57 | done(); 58 | }); 59 | }); 60 | }); 61 | } 62 | })(); 63 | -------------------------------------------------------------------------------- /tasks/value.js: -------------------------------------------------------------------------------- 1 | /** 2 | * value Task 3 | * This is the main task that is invoked for the processing of the slushfile.js 4 | */ 5 | 6 | (function () { 7 | var gulp = require('gulp'), 8 | install = require('gulp-install'), 9 | conflict = require('gulp-conflict'), 10 | template = require('gulp-template'), 11 | rename = require('gulp-rename'), 12 | inquirer = require('inquirer') 13 | _ = require('underscore.string'); 14 | 15 | //Local dependencies 16 | var util = require('../util'); 17 | 18 | module.exports = function (gulp) { 19 | 'use strict'; 20 | 21 | gulp.task('value', function (done) { 22 | var _this = this; 23 | var name = util.getDefaultOption(_this.args, 0); 24 | var options = util.getGlobalOptions(); 25 | var modules = util.getModuleProposal(options.appDir); 26 | 27 | if (modules.length === 0) { 28 | throw new Error('value must be created in a module, but no modules exist. Create a module using "slush angular-gulp:module ".'); 29 | } 30 | 31 | inquirer.prompt([{ 32 | type: 'input', 33 | name: 'fileName', 34 | message: 'What is the name of your value?', 35 | default: name 36 | }, { 37 | type: 'list', 38 | name: 'module', 39 | message: 'What is your AngularJS module name?', 40 | choices: modules 41 | }]).then(function (answers) { 42 | //Init 43 | answers.nameDashed = _.slugify(util.getNameProposal()); 44 | answers.scriptAppName = _.camelize(answers.nameDashed) + '.' + answers.module; 45 | answers.classedName = _.camelize(answers.fileName); 46 | answers.classedNameDashed = _.slugify(answers.fileName); 47 | answers.classedModule = _.capitalize(_.camelize(answers.module)); 48 | ; 49 | 50 | //Source 51 | gulp.src(__dirname + '/../templates/value/value.js') 52 | .pipe(template(answers)) 53 | .pipe(rename(answers.fileName + '-value.js')) 54 | .pipe(conflict(options.base + options.appDir + '/' + answers.module)) 55 | .pipe(gulp.dest(options.base + options.appDir + '/' + answers.module)) 56 | .on('finish', function () { 57 | done(); 58 | }); 59 | }); 60 | }); 61 | } 62 | })(); 63 | -------------------------------------------------------------------------------- /tasks/view.js: -------------------------------------------------------------------------------- 1 | /** 2 | * view Task 3 | * This is the main task that is invoked for the processing of the slushfile.js 4 | */ 5 | 6 | (function () { 7 | var gulp = require('gulp'), 8 | install = require('gulp-install'), 9 | conflict = require('gulp-conflict'), 10 | template = require('gulp-template'), 11 | rename = require('gulp-rename'), 12 | inquirer = require('inquirer') 13 | _ = require('underscore.string'); 14 | 15 | //Local dependencies 16 | var util = require('../util'); 17 | 18 | module.exports = function (gulp) { 19 | 'use strict'; 20 | 21 | gulp.task('view', function (done) { 22 | var _this = this; 23 | var name = util.getDefaultOption(_this.args, 0); 24 | var options = util.getGlobalOptions(); 25 | var modules = util.getModuleProposal(options.appDir); 26 | 27 | if (modules.length === 0) { 28 | throw new Error('view must be created in a module, but no modules exist. Create a module using "slush angular-gulp:module ".'); 29 | } 30 | 31 | inquirer.prompt([{ 32 | type: 'input', 33 | name: 'fileName', 34 | message: 'What is the name of your view?', 35 | default: name 36 | }, { 37 | type: 'list', 38 | name: 'module', 39 | message: 'What is your AngularJS module name?', 40 | choices: modules 41 | }]).then(function (answers) { 42 | //Init 43 | answers.nameDashed = _.slugify(util.getNameProposal()); 44 | answers.scriptAppName = _.camelize(answers.nameDashed) + '.' + answers.module; 45 | answers.classedName = _.camelize(answers.fileName); 46 | answers.classedNameDashed = _.slugify(answers.fileName); 47 | answers.classedModule = _.capitalize(_.camelize(answers.module)); 48 | ; 49 | 50 | //Source 51 | gulp.src(__dirname + '/../templates/view/view.html') 52 | .pipe(template(answers)) 53 | .pipe(rename(answers.fileName + '-view.html')) 54 | .pipe(conflict(options.base + options.appDir + '/' + answers.module)) 55 | .pipe(gulp.dest(options.base + options.appDir + '/' + answers.module)) 56 | .on('finish', function () { 57 | done(); 58 | }); 59 | }); 60 | }); 61 | } 62 | })(); 63 | -------------------------------------------------------------------------------- /templates/app/README.md: -------------------------------------------------------------------------------- 1 | <%= name %> 2 | ============ 3 | 4 | ## Development 5 | 6 | To start developing in the project run: 7 | 8 | ```bash 9 | gulp serve 10 | ``` 11 | 12 | Then head to `http://localhost:3000` in your browser. 13 | 14 | The `serve` tasks starts a static file server, which serves the AngularJS application, and a watch task which watches all files for changes and lints, builds and injects them into the index.html accordingly. 15 | 16 | ## Tests 17 | 18 | To run tests run: 19 | 20 | ```bash 21 | gulp test 22 | ``` 23 | 24 | **Or** first inject all test files into `karma.conf.js` with: 25 | 26 | ```bash 27 | gulp karma-conf 28 | ``` 29 | 30 | Then you're able to run Karma directly. Example: 31 | 32 | ```bash 33 | karma start --single-run 34 | ``` 35 | 36 | ## Production ready build - a.k.a. dist 37 | 38 | To make the app ready for deploy to production run: 39 | 40 | ```bash 41 | gulp dist 42 | ``` 43 | 44 | Now there's a `./dist` folder with all scripts and stylesheets concatenated and minified, also third party libraries installed with bower will be concatenated and minified into `vendors.min.js` and `vendors.min.css` respectively. 45 | 46 | ## Test production ready code 47 | 48 | To make the app ready for deploy to production run: 49 | 50 | ```bash 51 | gulp serve-dist 52 | ``` 53 | -------------------------------------------------------------------------------- /templates/app/_bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "bower_components" 3 | } 4 | -------------------------------------------------------------------------------- /templates/app/_csslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "box-model": false, 3 | "fallback-colors": false, 4 | "box-sizing": false, 5 | "compatible-vendor-prefixes": false, 6 | "gradients": false, 7 | "adjoining-classes": false, 8 | "outline-none" : false 9 | } 10 | -------------------------------------------------------------------------------- /templates/app/_editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /templates/app/_gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | bower_components/ 3 | .tmp/ 4 | dist/ 5 | release/ 6 | -------------------------------------------------------------------------------- /templates/app/_jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "bitwise": true, 3 | "camelcase": true, 4 | "curly": true, 5 | "eqeqeq": true, 6 | "es3": false, 7 | "forin": true, 8 | "freeze": true, 9 | "immed": true, 10 | "indent": 4, 11 | "latedef": "nofunc", 12 | "newcap": true, 13 | "noarg": true, 14 | "noempty": true, 15 | "nonbsp": true, 16 | "nonew": true, 17 | "plusplus": false, 18 | "quotmark": "single", 19 | "undef": true, 20 | "unused": false, 21 | "strict": false, 22 | "maxparams": 10, 23 | "maxdepth": 5, 24 | "maxstatements": 40, 25 | "maxcomplexity": 8, 26 | "maxlen": 120, 27 | "asi": false, 28 | "boss": false, 29 | "debug": false, 30 | "eqnull": true, 31 | "esnext": false, 32 | "evil": false, 33 | "expr": false, 34 | "funcscope": false, 35 | "globalstrict": false, 36 | "iterator": false, 37 | "lastsemic": false, 38 | "laxbreak": false, 39 | "laxcomma": false, 40 | "loopfunc": true, 41 | "maxerr": false, 42 | "moz": false, 43 | "multistr": false, 44 | "notypeof": false, 45 | "proto": false, 46 | "scripturl": false, 47 | "shadow": false, 48 | "sub": true, 49 | "supernew": false, 50 | "validthis": false, 51 | "noyield": false, 52 | 53 | "browser": true, 54 | "node": true, 55 | 56 | "globals": { 57 | "angular": false, 58 | "$": false 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /templates/app/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= nameDashed %>", 3 | "main": [ 4 | "/dist/<%= nameDashed %>.min.js", 5 | "/dist/<%= nameDashed %>.min.css" 6 | ], 7 | "version": "0.1.0", 8 | "description": "TODO", 9 | "authors": [ 10 | "TODO" 11 | ], 12 | "ignore": [ 13 | "**/.*", 14 | "package.json", 15 | "klei.json", 16 | "gulpfile.js", 17 | "node_modules", 18 | "bower_components", 19 | "src" 20 | ], 21 | "dependencies": { 22 | "angular": "~1.4.0", 23 | "angular-route": "~1.2.14", 24 | "bootstrap": "~3.3.1", 25 | "angular-resource": "~1.3.10", 26 | "angular-ui-grid": "~3.0.0-rc.19", 27 | "ngDialog": "~0.3.11", 28 | "fontawesome": "~4.3.0", 29 | "less": "~2.4.0", 30 | "angular-bootstrap-slider": "~0.1.1", 31 | "angulartics": "~0.17.2" 32 | }, 33 | "devDependencies": { 34 | "angular-mocks": "~1.2.29" 35 | }, 36 | "resolutions": { 37 | "angular": "~1.4.0" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /templates/app/gulpfile.js: -------------------------------------------------------------------------------- 1 | /* jshint node: true */ 2 | 'use strict'; 3 | 4 | var gulp = require('gulp'), 5 | g = require('gulp-load-plugins')({lazy: false}), 6 | noop = g.util.noop, 7 | es = require('event-stream'), 8 | bowerFiles = require('main-bower-files'), 9 | rimraf = require('rimraf'), 10 | queue = require('streamqueue'), 11 | lazypipe = require('lazypipe'), 12 | stylish = require('jshint-stylish'), 13 | bower = require('./bower'), 14 | connect = require('gulp-connect'), 15 | flatten = require('gulp-flatten'), 16 | <%if(middleware){%> 17 | proxy = require('proxy-middleware'), 18 | url = require('url'), 19 | _ = require('lodash'), 20 | <%}%> 21 | isWatching = false; 22 | 23 | //Configure your proxy for integrating with services 24 | // 25 | var configuration = { 26 | <%if(middleware){%> 27 | proxyOptions: _.extend(url.parse('http://demo-venkatvp.rhcloud.com/services'), { 28 | route: '/services', 29 | headers: { 30 | 'custom': 'My Custom Header', 31 | 'Origin': 'http://yourdomain.com', 32 | 'Access-Control-Request-Method': 'GET', 33 | 'Access-Control-Request-Headers': 'X-Custom-Header' 34 | } 35 | }), 36 | <%}%> 37 | htmlminOpts: { 38 | removeComments: true, 39 | collapseWhitespace: true, 40 | removeEmptyAttributes: false, 41 | collapseBooleanAttributes: true, 42 | removeRedundantAttributes: true 43 | }, 44 | distBowerFileList: [ 45 | './bower_components/**/*.png', 46 | './bower_components/**/*.gif', 47 | './bower_components/**/*.svg', 48 | './bower_components/**/*.jpg', 49 | './bower_components/angular-ui-grid/**/*.eot', 50 | './bower_components/angular-ui-grid/**/*.ttf', 51 | './bower_components/angular-ui-grid/**/*.woff', 52 | './bower_components/angular-ui-grid/**/*.woff2' 53 | ], 54 | distBowerFontsFiles: [ 55 | './bower_components/fontawesome/**/*.eot', 56 | './bower_components/fontawesome/**/*.ttf', 57 | './bower_components/fontawesome/**/*.woff', 58 | './bower_components/fontawesome/**/*.woff2' 59 | ] 60 | }; 61 | 62 | /** 63 | * JS Hint 64 | */ 65 | gulp.task('jshint', function () { 66 | return gulp.src([ 67 | './gulpfile.js', 68 | './src/app/**/*.js' 69 | ]) 70 | .pipe(g.cached('jshint')) 71 | .pipe(jshint('./.jshintrc')) 72 | .pipe(livereload()); 73 | }); 74 | 75 | /** 76 | * CSS 77 | */ 78 | gulp.task('clean-css', function (done) { 79 | rimraf('./.tmp/css', function() {}); 80 | rimraf('./.tmp/fonts', done); 81 | }); 82 | 83 | gulp.task('fonts', function () { 84 | return gulp.src([ 85 | './bower_components/bootstrap/fonts/**/*', 86 | './bower_components/bootstrap-sass/assets/fonts/**/*', 87 | './bower_components/fontawesome/fonts/**/*' 88 | ]).pipe(gulp.dest('./.tmp/fonts/')); 89 | }); 90 | 91 | gulp.task('styles', ['clean-css', 'fonts'], function () { 92 | return gulp.src([ 93 | './src/app/**/*.<%= styleData.extension %>', 94 | '!./src/app/**/_*.<%= styleData.extension %>' 95 | ]) 96 | .pipe(<%= styleData.pipeCommand %>) 97 | .pipe(gulp.dest('./.tmp/css/')) 98 | .pipe(g.cached('built-css')) 99 | .pipe(livereload()); 100 | }); 101 | 102 | gulp.task('styles-dist', ['styles'], function () { 103 | return cssFiles().pipe(dist('css', bower.name)); 104 | }); 105 | 106 | gulp.task('csslint', ['styles'], function () { 107 | return cssFiles() 108 | .pipe(g.cached('csslint')) 109 | .pipe(g.csslint('./.csslintrc')) 110 | .pipe(g.csslint.reporter()); 111 | }); 112 | /** 113 | * Scripts 114 | */ 115 | gulp.task('scripts-dist', ['templates-dist'], function () { 116 | return appFiles().pipe(dist('js', bower.name, {ngAnnotate: true})); 117 | }); 118 | 119 | /** 120 | * Templates 121 | */ 122 | gulp.task('templates', function () { 123 | return templateFiles().pipe(buildTemplates()); 124 | }); 125 | 126 | gulp.task('templates-dist', function () { 127 | return gulp.src([ 128 | './src/app/**/*.html', 129 | '!./src/app/index.html' 130 | ]) 131 | .pipe(gulp.dest('./dist')); 132 | }); 133 | 134 | /** 135 | * Vendors 136 | */ 137 | gulp.task('vendors', function () { 138 | var files = bowerFiles(); 139 | var vendorJs = fileTypeFilter(files, 'js'); 140 | var vendorCss = fileTypeFilter(files, 'css'); 141 | var q = new queue({objectMode: true}); 142 | if (vendorJs.length) { 143 | q.queue(gulp.src(vendorJs).pipe(dist('js', 'vendors'))); 144 | } 145 | if (vendorCss.length) { 146 | q.queue(gulp.src(vendorCss).pipe(dist('css', 'vendors'))); 147 | } 148 | return q.done(); 149 | }); 150 | 151 | /** 152 | * Index 153 | */ 154 | gulp.task('index', index); 155 | gulp.task('build-all', ['styles', 'templates'], index); 156 | 157 | function index () { 158 | var opt = {read: false}; 159 | return gulp.src('./src/app/index.html') 160 | .pipe(g.inject(gulp.src(bowerFiles(), opt), {ignorePath: 'bower_components', starttag: ''})) 161 | .pipe(g.inject(es.merge(appFiles(), cssFiles(opt)), {ignorePath: ['.tmp', 'src/app']})) 162 | .pipe(gulp.dest('./src/app/')) 163 | .pipe(g.embedlr()) 164 | .pipe(gulp.dest('./.tmp/')) 165 | .pipe(livereload()); 166 | } 167 | 168 | /** 169 | * Assets 170 | */ 171 | gulp.task('assets', function () { 172 | return gulp.src('./src/app/assets/**') 173 | .pipe(gulp.dest('./dist/assets')); 174 | }); 175 | 176 | gulp.task('bower-assets-dist', function() { 177 | return distBowerAssets(); 178 | }); 179 | 180 | /** 181 | * Dist 182 | */ 183 | gulp.task('dist', ['vendors', 'assets', 'styles-dist', 'scripts-dist', 'bower-assets-dist'], function() { 184 | return gulp.src('./src/app/index.html') 185 | .pipe(g.inject(gulp.src('./dist/vendors.min.{js,css}'), { 186 | ignorePath: 'dist', 187 | starttag: '' 188 | })) 189 | .pipe(g.inject(gulp.src('./dist/' + bower.name + '.min.{js,css}'), { 190 | ignorePath: 'dist' 191 | })) 192 | .pipe(g.htmlmin(configuration.htmlminOpts)) 193 | .pipe(gulp.dest('./dist/')); 194 | }); 195 | 196 | /** 197 | * Clean dist 198 | * */ 199 | gulp.task('clean-dist', function(done) { 200 | rimraf('./dist', done); 201 | }); 202 | 203 | <%if(middleware){%> 204 | /** 205 | * Static file server 206 | */ 207 | gulp.task('statics', function() { 208 | connect.server({ 209 | root: ['./.tmp', './.tmp/src/app', './src/app', './bower_components'], 210 | port: 3000, 211 | livereload: true, 212 | middleware: function() { 213 | return [(function() { 214 | return proxy(configuration.proxyOptions); 215 | })()]; 216 | } 217 | }); 218 | }); 219 | 220 | /** 221 | * Static dist server for testing production code. 222 | */ 223 | gulp.task('serve-dist', function() { 224 | connect.server({ 225 | root: ['./dist'], 226 | port: 4000, 227 | livereload: true, 228 | middleware: function() { 229 | return [(function() { 230 | return proxy(configuration.proxyOptions); 231 | })()]; 232 | } 233 | }); 234 | }); 235 | 236 | /** 237 | * Watch 238 | */ 239 | gulp.task('serve', ['watch']); 240 | gulp.task('watch', ['statics', 'default'], function () { 241 | isWatching = true; 242 | // Initiate livereload server: 243 | gulp.watch('./src/app/**/*.js', ['jshint']); 244 | gulp.watch('./src/app/index.html', ['index']); 245 | gulp.watch(['./src/app/**/*.html', '!./src/app/index.html'], ['templates']); 246 | gulp.watch(['./src/app/**/*.<%= styleData.extension %>'], ['csslint']); 247 | }); 248 | <%} else {%> 249 | 250 | /** 251 | * Static file server 252 | */ 253 | gulp.task('statics', function() { 254 | connect.server({ 255 | root: ['./.tmp', './.tmp/src/app', './src/app', './bower_components'], 256 | port: 3000, 257 | livereload: true 258 | }); 259 | }); 260 | 261 | /** 262 | * Static dist server for testing production code. 263 | */ 264 | gulp.task('serve-dist', function() { 265 | connect.server({ 266 | root: ['./dist'], 267 | port: 4000, 268 | livereload: true 269 | }); 270 | }); 271 | /** 272 | * Watch 273 | */ 274 | gulp.task('serve', ['watch']); 275 | gulp.task('watch', ['statics', 'default'], function () { 276 | isWatching = true; 277 | // Initiate livereload server: 278 | gulp.watch('./src/app/**/*.js', ['jshint']); 279 | gulp.watch('./src/app/index.html', ['index']); 280 | gulp.watch(['./src/app/**/*.html', '!./src/app/index.html'], ['templates']); 281 | gulp.watch(['./src/app/**/*.<%= styleData.extension %>'], ['csslint']); 282 | }); 283 | <%} %> 284 | 285 | /** 286 | * Default task 287 | */ 288 | gulp.task('default', ['lint', 'build-all']); 289 | 290 | /** 291 | * Lint everything 292 | */ 293 | gulp.task('lint', ['jshint', 'csslint']); 294 | 295 | /** 296 | * Test 297 | */ 298 | gulp.task('test', ['templates'], function () { 299 | return testFiles() 300 | .pipe(g.karma({ 301 | configFile: 'karma.conf.js', 302 | action: 'run' 303 | })); 304 | }); 305 | 306 | /** 307 | * Inject all files for tests into karma.conf.js 308 | * to be able to run `karma` without gulp. 309 | */ 310 | gulp.task('karma-conf', ['templates'], function () { 311 | return gulp.src('./karma.conf.js') 312 | .pipe(g.inject(testFiles(), { 313 | starttag: 'files: [', 314 | endtag: ']', 315 | addRootSlash: false, 316 | transform: function (filepath, file, i, length) { 317 | return ' \'' + filepath + '\'' + (i + 1 < length ? ',' : ''); 318 | } 319 | })) 320 | .pipe(gulp.dest('./')); 321 | }); 322 | 323 | /** 324 | * Test files 325 | */ 326 | function testFiles() { 327 | return new queue({objectMode: true}) 328 | .queue(gulp.src(fileTypeFilter(bowerFiles(), 'js'))) 329 | .queue(gulp.src('./bower_components/angular-mocks/angular-mocks.js')) 330 | .queue(appFiles()) 331 | .queue(gulp.src(['./src/app/**/*.spec.js', './.tmp/src/app/**/*.spec.js'])) 332 | .done(); 333 | } 334 | 335 | /** 336 | * All CSS files as a stream 337 | */ 338 | function cssFiles (opt) { 339 | return gulp.src('./.tmp/css/**/*.css', opt); 340 | } 341 | 342 | /** 343 | * All AngularJS application files as a stream 344 | */ 345 | function appFiles () { 346 | var files = [ 347 | './.tmp/' + bower.name + '-templates.js', 348 | './.tmp/src/app/**/*.js', 349 | '!./.tmp/src/app/**/*.spec.js', 350 | './src/app/**/*.js', 351 | '!./src/app/**/*.spec.js' 352 | ]; 353 | return gulp.src(files) 354 | .pipe(g.angularFilesort()); 355 | } 356 | 357 | /** 358 | * All AngularJS templates/partials as a stream 359 | */ 360 | function templateFiles (opt) { 361 | return gulp.src(['./src/app/**/*.html', '!./src/app/index.html'], opt) 362 | .pipe(opt && opt.min ? g.htmlmin(configuration.htmlminOpts) : noop()); 363 | } 364 | 365 | function distBowerAssets() { 366 | gulp.src(configuration.distBowerFileList) 367 | .pipe(flatten()) 368 | .pipe(gulp.dest('./dist/assets', { 369 | base: '*' 370 | })); 371 | return gulp.src(configuration.distBowerFontsFiles) 372 | .pipe(flatten()) 373 | .pipe(gulp.dest('./dist/fonts', { 374 | base: '*' 375 | })); 376 | } 377 | 378 | /** 379 | * Build AngularJS templates/partials 380 | */ 381 | function buildTemplates () { 382 | return lazypipe() 383 | .pipe(g.ngHtml2js, { 384 | moduleName: bower.name, 385 | // prefix: '/' + bower.name + '/', 386 | stripPrefix: '/src/app' 387 | }) 388 | .pipe(g.concat, bower.name + '-templates.js') 389 | .pipe(gulp.dest, './.tmp') 390 | .pipe(livereload)(); 391 | } 392 | 393 | /** 394 | * Filter an array of files according to file type 395 | * 396 | * @param {Array} files 397 | * @param {String} extension 398 | * @return {Array} 399 | */ 400 | function fileTypeFilter (files, extension) { 401 | var regExp = new RegExp('\\.' + extension + '$'); 402 | return files.filter(regExp.test.bind(regExp)); 403 | } 404 | 405 | /** 406 | * Concat, rename, minify 407 | * 408 | * @param {String} ext 409 | * @param {String} name 410 | * @param {Object} opt 411 | */ 412 | function dist (ext, name, opt) { 413 | opt = opt || {}; 414 | return lazypipe() 415 | .pipe(g.concat, name + '.' + ext) 416 | .pipe(gulp.dest, './dist') 417 | .pipe(opt.ngAnnotate ? g.ngAnnotate : noop) 418 | .pipe(opt.ngAnnotate ? g.rename : noop, name + '.annotated.' + ext) 419 | .pipe(opt.ngAnnotate ? gulp.dest : noop, './dist') 420 | .pipe(ext === 'js' ? g.uglify : g.cleanCss) 421 | .pipe(g.rename, name + '.min.' + ext) 422 | .pipe(gulp.dest, './dist')(); 423 | } 424 | 425 | /** 426 | * Livereload (or noop if not run by watch) 427 | */ 428 | function livereload() { <% 429 | if (middleware) { %> 430 | return lazypipe() 431 | .pipe(isWatching ? connect.reload : noop)(); <% 432 | } else { %> 433 | return lazypipe() 434 | .pipe(isWatching ? g.livereload : noop)(); <% 435 | } %> 436 | } 437 | /** 438 | * Jshint with stylish reporter 439 | */ 440 | function jshint (jshintfile) { 441 | return lazypipe() 442 | .pipe(g.jshint, jshintfile) 443 | .pipe(g.jshint.reporter, stylish)(); 444 | } 445 | -------------------------------------------------------------------------------- /templates/app/karma.conf.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = function ( karma ) { 3 | process.env.PHANTOMJS_BIN = 'node_modules/karma-phantomjs-launcher/node_modules/.bin/phantomjs'; 4 | 5 | karma.set({ 6 | /** 7 | * From where to look for files, starting with the location of this file. 8 | */ 9 | basePath: './', 10 | 11 | /** 12 | * Filled by the task `gulp karma-conf` 13 | */ 14 | files: [ 15 | ], 16 | 17 | frameworks: [ 'mocha', 'chai', 'sinon' ], 18 | plugins: [ 'karma-mocha', 'karma-chai', 'karma-sinon', 'karma-phantomjs-launcher', 'karma-chrome-launcher' ], 19 | 20 | /** 21 | * How to report, by default. 22 | */ 23 | reporters: 'progress', 24 | 25 | /** 26 | * Show colors in output? 27 | */ 28 | colors: true, 29 | 30 | /** 31 | * On which port should the browser connect, on which port is the test runner 32 | * operating, and what is the URL path for the browser to use. 33 | */ 34 | port: 9099, 35 | runnerPort: 9100, 36 | urlRoot: '/', 37 | 38 | /** 39 | * Disable file watching by default. 40 | */ 41 | autoWatch: false, 42 | 43 | /** 44 | * The list of browsers to launch to test on. This includes only "Firefox" by 45 | * default, but other browser names include: 46 | * Chrome, ChromeCanary, Firefox, Opera, Safari, PhantomJS 47 | * 48 | * Note that you can also use the executable name of the browser, like "chromium" 49 | * or "firefox", but that these vary based on your operating system. 50 | * 51 | * You may also leave this blank and manually navigate your browser to 52 | * http://localhost:9099/ when you're running tests. The window/tab can be left 53 | * open and the tests will automatically occur there during the build. This has 54 | * the aesthetic advantage of not launching a browser every time you save. 55 | */ 56 | browsers: [ 57 | //'PhantomJS' 58 | 'Chrome' 59 | ] 60 | }); 61 | }; 62 | -------------------------------------------------------------------------------- /templates/app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= nameDashed %>", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "start": "gulp serve", 7 | "test": "gulp test" 8 | }, 9 | "dependencies": { 10 | }, 11 | "devDependencies": { 12 | "gulp": "^3.7.0", 13 | "gulp-util": "^2.2.14", 14 | "gulp-jshint": "^1.6.1", 15 | "gulp-load-plugins": "~0.5.1", 16 | "jshint-stylish": "~0.4.0", 17 | "gulp-rename": "^1.2.0", 18 | "main-bower-files": "^1.0.1", 19 | "gulp-angular-filesort": "^1.0.3", 20 | "lazypipe": "~0.2.1", 21 | "gulp-cached": "^1.0.1", 22 | "gulp-embedlr": "~0.5.2", 23 | "gulp-flatten": "0.0.4", 24 | "gulp-livereload": "^2.1.0", 25 | "gulp-header": "^1.0.2", 26 | "gulp-inject": "^1.0.1", 27 | "gulp-serve": "~0.2.0", 28 | "gulp-concat": "^2.2.0", 29 | "rimraf": "^2.2.8", 30 | "<%= styleData.plugin %>": "<%= styleData.pluginVersion %>",<% if (styleData.extraDependencies) { 31 | Object.keys(styleData.extraDependencies).map(function (name) { %> 32 | "<%= name %>": "<%= styleData.extraDependencies[name] %>",<% 33 | }); 34 | } %> 35 | "gulp-clean-css": "~2.0.4", 36 | "gulp-csslint": "~0.1.4", 37 | "event-stream": "^3.1.5", 38 | "streamqueue": "~0.1.1", 39 | "gulp-uglify": "~0.3.0", 40 | "gulp-htmlmin": "~0.1.2", 41 | "gulp-ng-html2js": "~0.1.7", 42 | "gulp-ng-annotate": "~0.2.0", 43 | "gulp-karma": "~0.0.4", 44 | "karma-chai": "~0.1.0", 45 | "karma-mocha": "~0.1.3", 46 | "karma-sinon": "^1.0.4", 47 | "karma-phantomjs-launcher": "~0.1.4", 48 | "karma-script-launcher": "~0.1.0", 49 | "karma-chrome-launcher": "~0.1.4", 50 | "karma-firefox-launcher": "~0.1.3", 51 | "gulp-connect": "^2.2.0", 52 | "karma": "~0.12.16"<% if (middleware) { %>, 53 | "proxy-middleware": "^0.9.0", 54 | "url": "^0.10.2", 55 | "lodash": "^3.0.0"<% } %> 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /templates/app/src/app/app.css: -------------------------------------------------------------------------------- 1 | @import "styles/_base"; 2 | -------------------------------------------------------------------------------- /templates/app/src/app/app.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | //This is the basic entry point of the applicaion 4 | angular.module('<%= modulename %>', [ 5 | 'ngRoute', 'ngResource'<% if (exampleSettings['todo'] == 'todo') { %>, 6 | '<%= modulename %>.todo'<% } %><% if (exampleSettings['heat'] == 'heat') { %>, 7 | '<%= modulename %>.heat'<% } %> 8 | ]); 9 | 10 | })(); 11 | -------------------------------------------------------------------------------- /templates/app/src/app/assets/_gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reflexdemon/slush-angular-gulp/2d1e8903b36db00036e1e06e196c832cf9b26760/templates/app/src/app/assets/_gitkeep -------------------------------------------------------------------------------- /templates/app/src/app/assets/slush-angular-gulp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reflexdemon/slush-angular-gulp/2d1e8903b36db00036e1e06e196c832cf9b26760/templates/app/src/app/assets/slush-angular-gulp.png -------------------------------------------------------------------------------- /templates/app/src/app/heat/aheat.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular.module('<%= modulename %>.heat', ['ui.bootstrap-slider']); 5 | 6 | })(); 7 | -------------------------------------------------------------------------------- /templates/app/src/app/heat/heat-controller.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Controller 3 | */ 4 | (function() { 5 | 'use strict'; 6 | //Defenition 7 | angular 8 | .module('<%= modulename %>.heat').controller('HeatCtrl', HeatCtrl); 9 | 10 | // HeatCtrl.$inject = ['$scope', 'HeatService']; 11 | 12 | /** 13 | * [HeatCtrl description] 14 | * @ngInject 15 | */ 16 | function HeatCtrl($scope, heatService) { 17 | /*jshint validthis: true */ 18 | var vm = this; 19 | vm.f2c = f2c; 20 | vm.c2f = c2f; 21 | init(); 22 | 23 | 24 | /** 25 | * Inits the ctrl. 26 | */ 27 | function init() { 28 | $scope.defaultValue = { 29 | celsius: 0.0, 30 | fahrenheit: 0.0 31 | }; 32 | $scope.testOptions = { 33 | min: -273, 34 | step: 1, 35 | max: 273, 36 | value: 0, 37 | tooltip: 'show' 38 | }; 39 | $scope.heat = $scope.defaultValue; 40 | } 41 | 42 | function f2c() { 43 | heatService.toCelsius($scope.heat.fahrenheit).success(function(heat) { 44 | $scope.heat = heat; 45 | }).error(function(error) { 46 | $scope.messsage = error; 47 | $scope.heat = $scope.defaultValue; 48 | }); 49 | } 50 | 51 | function c2f() { 52 | heatService.toFahrenheit($scope.heat.celsius).success(function(heat) { 53 | $scope.heat = heat; 54 | }).error(function(error) { 55 | $scope.messsage = error; 56 | $scope.heat = $scope.defaultValue; 57 | }); 58 | } 59 | 60 | } 61 | })(); 62 | -------------------------------------------------------------------------------- /templates/app/src/app/heat/heat-route.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('<%= modulename %>.heat') 6 | .config(configure); 7 | 8 | 9 | /* @ngInject */ 10 | function configure($routeProvider) { 11 | //Heat module 12 | $routeProvider 13 | .when('/heat', { 14 | controller: 'HeatCtrl', 15 | templateUrl: '/heat/view/heat.html', 16 | controllerAs: 'vm' 17 | }); 18 | } 19 | 20 | })(); 21 | -------------------------------------------------------------------------------- /templates/app/src/app/heat/service/heat_service.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | angular 4 | .module('<%= modulename %>.heat').service('heatService', HeatService); 5 | 6 | /* @ngInject */ 7 | function HeatService($http) { 8 | 9 | //RESTful webservice base URL 10 | var urlBase = '/services'; 11 | 12 | var service = { 13 | toFahrenheit: toFahrenheit, 14 | toCelsius: toCelsius 15 | 16 | }; 17 | return service; 18 | 19 | /////////////////// 20 | 21 | /** 22 | * Convert from fahrenheit to celsius 23 | * @param Number celsius 24 | * @return Heat model 25 | */ 26 | function toFahrenheit(celsius) { 27 | return $http.get(urlBase + '/c2f/' + celsius); 28 | } 29 | /** 30 | * Convert from celsius to fahrenheit 31 | * @param Number fahrenheit 32 | * @return Heat model 33 | */ 34 | function toCelsius(fahrenheit) { 35 | return $http.get(urlBase + '/f2c/' + fahrenheit); 36 | } 37 | } 38 | } 39 | )(); 40 | -------------------------------------------------------------------------------- /templates/app/src/app/heat/view/heat.html: -------------------------------------------------------------------------------- 1 |

Temperature Conversion Utility

2 | 7 |
8 |
9 |
10 |
11 | 12 | 13 | 14 | 15 |
16 |
17 | 18 | 19 | 20 | 21 |
22 |
23 |
24 |
25 | -------------------------------------------------------------------------------- /templates/app/src/app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <%= modulename %> 6 | 7 | 8 | 9 | 10 | 11 | 12 |

<%= modulename %>

13 | 14 |

Your new AngularJS app is now ready...

15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /templates/app/src/app/styles/_base.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding: 50px; 3 | font: 20px/150% "Helvetica Neue", "Lucida Grande", Verdana, sans-serif; 4 | color: #666; 5 | background: #fcfcfc; 6 | } 7 | 8 | input, 9 | textarea, 10 | button { 11 | font: inherit; 12 | } 13 | -------------------------------------------------------------------------------- /templates/app/src/app/todo/todo-controller.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('<%= modulename %>.todo') 6 | .controller('TodoCtrl', TodoCtrl); 7 | 8 | /* @ngInject */ 9 | function TodoCtrl($scope, $window) { 10 | $scope.todos = JSON.parse($window.localStorage.getItem('todos') || '[]'); 11 | $scope.$watch('todos', todosListner, true); 12 | 13 | $scope.add = function() { 14 | var todo = { 15 | label: $scope.label, 16 | isDone: false 17 | }; 18 | $scope.todos.push(todo); 19 | $window.localStorage.setItem('todos', JSON.stringify(angular.copy($scope.todos))); 20 | $scope.label = ''; 21 | }; 22 | 23 | $scope.check = function(ctx) { 24 | ctx.isDone = !ctx.isDone; 25 | }; 26 | 27 | $scope.removeChecked = function() { 28 | var todos = []; 29 | for (var i = $scope.todos.length - 1; i >= 0; i--) { 30 | if (!$scope.todos[i].isDone) { 31 | todos.push($scope.todos[i]); 32 | } 33 | } 34 | $scope.todos = todos; 35 | $window.localStorage.setItem('todos', JSON.stringify(angular.copy($scope.todos))); 36 | }; 37 | 38 | function todosListner(newTodos, oldTodos) { 39 | if (newTodos !== oldTodos) { 40 | $window.localStorage.setItem('todos', JSON.stringify(angular.copy($scope.todos))); 41 | } 42 | } 43 | } 44 | 45 | })(); 46 | -------------------------------------------------------------------------------- /templates/app/src/app/todo/todo-controller.spec.js: -------------------------------------------------------------------------------- 1 | /* jshint strict:false, globalstrict:false */ 2 | /* global describe, it, beforeEach, inject, module */ 3 | describe('TodoCtrl', function () { 4 | var todoCtrl, 5 | scope; 6 | 7 | beforeEach(module('<%= modulename %>')); 8 | 9 | beforeEach(inject(function ($injector) { 10 | scope = $injector.get('$rootScope'); 11 | 12 | todoCtrl = function () { 13 | return $injector.get('$controller')('TodoCtrl', {'$scope': scope}); 14 | }; 15 | })); 16 | 17 | it('should add new todos on add()', function () { 18 | var todo = {label: 'A new todo', isDone: false}; 19 | todoCtrl(); 20 | scope.label = todo.label; 21 | scope.add(); 22 | scope.label.length.should.equal(0); 23 | scope.todos.length.should.equal(1); 24 | scope.todos[scope.todos.length - 1].label.should.equal(todo.label); 25 | scope.todos[scope.todos.length - 1].isDone.should.equal(false); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /templates/app/src/app/todo/todo-route.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('<%= modulename %>.todo') 6 | .config(configure); 7 | 8 | 9 | /* @ngInject */ 10 | function configure($routeProvider) { 11 | $routeProvider 12 | .when('/todo', { 13 | controller: 'TodoCtrl', 14 | templateUrl: '/todo/todo.html' 15 | }); 16 | } 17 | 18 | })(); 19 | -------------------------------------------------------------------------------- /templates/app/src/app/todo/todo.css: -------------------------------------------------------------------------------- 1 | 2 | .todo-list { 3 | list-style: none; 4 | text-indent: 0; 5 | padding: 0; 6 | } 7 | 8 | .todo-item { 9 | padding: 0.5em; 10 | } 11 | 12 | .todo-done { 13 | text-decoration: line-through; 14 | font-style: italic; 15 | color: #999; 16 | } 17 | -------------------------------------------------------------------------------- /templates/app/src/app/todo/todo.html: -------------------------------------------------------------------------------- 1 |

Todo

2 |
    3 |
  • 4 | 5 |
  • 6 |
  • 7 |
    8 | 9 | 10 |
    11 |
  • 12 |
13 | 14 | -------------------------------------------------------------------------------- /templates/app/src/app/todo/todo.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | 'use strict'; 3 | //Module declaration 4 | angular.module('<%= modulename %>.todo', []); 5 | 6 | })(); 7 | -------------------------------------------------------------------------------- /templates/constant/constant.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('<%= scriptAppName %>') 6 | .constant('<%= classedName %>', '<%= classedName %>'); 7 | 8 | 9 | })(); 10 | -------------------------------------------------------------------------------- /templates/controller/controller.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('<%= scriptAppName %>') 6 | .controller('<%= classedName %>Ctrl', <%= classedName %>Ctrl); 7 | ////////////////////// 8 | 9 | /** 10 | * @ngdoc function 11 | * @name <%= scriptAppName %>.controller:<%= classedName %>Ctrl 12 | * @description 13 | * # <%= classedName %>Ctrl 14 | * Controller of the <%= scriptAppName %> 15 | * @ngInject 16 | */ 17 | function <%= classedName %>Ctrl() { 18 | this.awesomeThings = [ 19 | 'HTML5 Boilerplate', 20 | 'AngularJS', 21 | 'Karma' 22 | ]; 23 | } 24 | 25 | })(); 26 | -------------------------------------------------------------------------------- /templates/controller/controller.spec.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | /** 3 | * Simple test class for <%= classedName %>Ctrl on <%= scriptAppName %> 4 | */ 5 | describe('Controller: <%= classedName %>Ctrl', function () { 6 | 7 | // load the controller's module 8 | beforeEach(module('<%= scriptAppName %>')); 9 | 10 | var <%= classedName %>Ctrl; 11 | 12 | // Initialize the controller and a mock scope 13 | beforeEach(inject(function ($controller, $rootScope) { 14 | <%= classedName %>Ctrl = $controller('<%= classedName %>Ctrl', { 15 | // place here mocked dependencies 16 | }); 17 | })); 18 | 19 | it('should attach a list of awesomeThings to the scope', function () { 20 | expect(<%= classedName %>Ctrl.awesomeThings.length).to.equal(3); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /templates/decorator/decorator.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | 'use strict' 3 | 4 | angular 5 | .module('<%= scriptAppName %>') 6 | .config(<%= classedName %>Config); 7 | 8 | /* @ngInject */ 9 | function <%= classedName %>Config($provide) { 10 | $provide.decorator('$<%= classedName %>Handler', extend<%= classedName %>Handler); 11 | } 12 | 13 | /* @ngInject */ 14 | function extend<%= classedName %>Handler($delegate) { 15 | return function(<%= classedName %>, cause) { 16 | $delegate(<%= classedName %>, cause); 17 | var data = { 18 | <%= classedName %>: <%= classedName %> 19 | }; 20 | }; 21 | } 22 | 23 | })(); 24 | -------------------------------------------------------------------------------- /templates/directive/directive.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('<%= scriptAppName %>') 6 | .directive('<%= classedName %>', <%= classedName %>); 7 | 8 | /* @ngInject */ 9 | function <%= classedName %> () { 10 | // Usage: 11 | // 12 | // Creates: 13 | // 14 | var directive = { 15 | bindToController: true, 16 | controller: Controller, 17 | controllerAs: 'vm', 18 | link: link, 19 | restrict: 'A', 20 | scope: { 21 | } 22 | }; 23 | return directive; 24 | 25 | function link(scope, element, attrs) { 26 | } 27 | } 28 | 29 | /* @ngInject */ 30 | function Controller () { 31 | 32 | } 33 | })(); 34 | -------------------------------------------------------------------------------- /templates/factory/factory.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('<%= scriptAppName %>') 6 | .factory('<%= classedName %>Factory', <%= classedName %>Factory); 7 | 8 | 9 | /* @ngInject */ 10 | function <%= classedName %>Factory() { 11 | var someValue = ''; 12 | var factory = { 13 | save: save, 14 | someValue: someValue, 15 | validate: validate 16 | }; 17 | return factory; 18 | 19 | //////////// 20 | 21 | function save() { 22 | /* */ 23 | }; 24 | 25 | function validate() { 26 | /* */ 27 | }; 28 | } 29 | 30 | })(); 31 | -------------------------------------------------------------------------------- /templates/filter/filter.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('<%= scriptAppName %>').filter('<%= classedName %>', <%= classedName %>); 6 | 7 | function <%= classedName %>() { 8 | return <%= classedName %>Filter; 9 | } 10 | 11 | /////////////////// 12 | function <%= classedName %>Filter(input) { 13 | return input ? '\u2713' : '\u2718'; 14 | } 15 | })(); 16 | -------------------------------------------------------------------------------- /templates/filter/filter.spec.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | describe('filter', function() { 4 | 5 | beforeEach(module('<%= scriptAppName %>')); 6 | 7 | describe('checkmark', function() { 8 | 9 | it('should convert boolean values to unicode checkmark or cross', 10 | inject(function(checkmarkFilter) { 11 | expect(checkmarkFilter(true)).toBe('\u2713'); 12 | expect(checkmarkFilter(false)).toBe('\u2718'); 13 | })); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /templates/module/config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Configuration for the module <%= module %> 3 | */ 4 | 5 | (function() { 6 | 'use strict'; 7 | 8 | 9 | angular 10 | .module('<%= scriptAppName %>') 11 | .config(config); 12 | 13 | /* @ngInject */ 14 | function config(){ 15 | // Configurations 16 | } 17 | 18 | })(); -------------------------------------------------------------------------------- /templates/module/module.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates and initilizes the module <%= module %> 3 | */ 4 | 5 | (function() { 6 | 'use strict'; 7 | 8 | <% if (config.indexOf('config')>-1){ %> 9 | angular 10 | .module('<%= scriptAppName %>', []); 11 | <% } else { %> 12 | angular 13 | .module('<%= scriptAppName %>', [], moduleConfiguration); 14 | 15 | /* @ngInject */ 16 | function moduleConfiguration() { 17 | //TODO Have any module specific configurator here 18 | } 19 | <% } %> 20 | })(); 21 | -------------------------------------------------------------------------------- /templates/module/routes.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sets routes for the module <%= module %> 3 | */ 4 | 5 | (function() { 6 | 'use strict'; 7 | 8 | 9 | angular 10 | .module('<%= scriptAppName %>') 11 | .run(appRun); 12 | 13 | /* @ngInject */ 14 | function appRun(){ 15 | // Routing 16 | } 17 | 18 | })(); -------------------------------------------------------------------------------- /templates/module/styles.css: -------------------------------------------------------------------------------- 1 | /* Styles for the module <%= module %> */ -------------------------------------------------------------------------------- /templates/provider/provider.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('<%= scriptAppName %>') 6 | .provider('<%= classedName %>', <%= classedName %>Provider); 7 | 8 | /* @ngInject */ 9 | function <%= classedName %>Provider() { 10 | var someValue = ''; 11 | var provider = { 12 | save: save, 13 | someValue: someValue, 14 | validate: validate 15 | }; 16 | return provider; 17 | 18 | //////////// 19 | 20 | function save() { 21 | /* */ 22 | } 23 | 24 | function validate() { 25 | /* */ 26 | } 27 | } 28 | })(); 29 | -------------------------------------------------------------------------------- /templates/route/route.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('<%= scriptAppName %>') 6 | .config( <%= classedName %>Route); 7 | 8 | 9 | /* @ngInject */ 10 | function <%= classedName %>Route($routeProvider) { 11 | $routeProvider 12 | .when('/<%= module %>', { //Default 13 | controller: '<%= classedModule %>Ctrl', 14 | templateUrl: '<%= module %>/<%= module %>.html' 15 | }); 16 | 17 | } 18 | 19 | })(); 20 | -------------------------------------------------------------------------------- /templates/service/service.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('<%= scriptAppName %>') 6 | .service('<%= classedName %>Service', <%= classedName %>Service); 7 | 8 | 9 | /* @ngInject */ 10 | function <%= classedName %>Service() { 11 | var someValue = ''; 12 | var service = { 13 | save: save, 14 | someValue: someValue, 15 | validate: validate 16 | }; 17 | return service; 18 | 19 | //////////// 20 | 21 | function save() { 22 | /* */ 23 | } 24 | 25 | function validate() { 26 | /* */ 27 | } 28 | } 29 | 30 | })(); 31 | -------------------------------------------------------------------------------- /templates/value/value.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('<%= scriptAppName %>') 6 | .value('<%= classedName %>', <%= classedName %>Value); 7 | 8 | 9 | var <%= classedName %>Value = {}; 10 | 11 | 12 | })(); 13 | -------------------------------------------------------------------------------- /templates/view/view.html: -------------------------------------------------------------------------------- 1 |

This is the <%= classedName %> view

2 | -------------------------------------------------------------------------------- /test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env 2 | 3 | 4 | ERR_LOG=/tmp/err.log 5 | TMP_FILE=.tmp/coverage.tmp 6 | OUT_DIR=reports 7 | OUT_FILE=$OUT_DIR/coverage.html 8 | 9 | rm- rf $OUT_DIR 10 | 11 | gulp test --silent >$TMP_FILE 2>$ERR_LOG 12 | 13 | cat $TMP_FILE | grep -v "\[conflict\]" > $OUT_FILE 14 | -------------------------------------------------------------------------------- /test/cases/app.spec.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | var common = require("../common"); 5 | var options = common.options; 6 | var assert = common.assert; 7 | var testingUtil = common.testingUtil; 8 | var util = common.util; 9 | var mockGulpDest = common.mockGulpDest; 10 | var gulp = common.gulp; 11 | 12 | 13 | function beforeEach() { 14 | process.chdir(__dirname); 15 | testingUtil.mockPrompt({ 16 | name: 'module' 17 | }); 18 | util.setRuntimeMode('TEST'); 19 | } 20 | 21 | 22 | it('should put all project files in current working directory', function(done) { 23 | beforeEach(); 24 | gulp.start('default').once('finish', function() { 25 | // mockGulpDest.cwd().should.equal(__dirname); 26 | // mockGulpDest.basePath().should.equal(__dirname); 27 | 28 | assert.that(mockGulpDest.cwd()).is.equalTo(__dirname); 29 | assert.that(mockGulpDest.basePath()).is.equalTo(__dirname); 30 | done(); 31 | }); 32 | }); 33 | it('should add dot files to project root', function(done) { 34 | beforeEach(); 35 | gulp.start('default').once('finish', function() { 36 | mockGulpDest.assertDestContains([ 37 | '.bowerrc', 38 | '.csslintrc', 39 | '.editorconfig', 40 | '.gitignore', 41 | '.jshintrc' 42 | ]); 43 | done(); 44 | }); 45 | }); 46 | it('should add bower.json and package.json to project root', function(done) { 47 | beforeEach(); 48 | gulp.start('default').once('finish', function() { 49 | mockGulpDest.assertDestContains([ 50 | 'package.json', 51 | 'bower.json' 52 | ]); 53 | done(); 54 | }); 55 | }); 56 | it('should add a gulpfile to project root', function(done) { 57 | beforeEach(); 58 | gulp.start('default').once('finish', function() { 59 | mockGulpDest.assertDestContains('gulpfile.js'); 60 | done(); 61 | }); 62 | }); 63 | it('should add a karma config file to project root', function(done) { 64 | beforeEach(); 65 | gulp.start('default').once('finish', function() { 66 | mockGulpDest.assertDestContains('karma.conf.js'); 67 | done(); 68 | }); 69 | }); 70 | it('should add a readme file to project root', function(done) { 71 | beforeEach(); 72 | gulp.start('default').once('finish', function() { 73 | mockGulpDest.assertDestContains('README.md'); 74 | done(); 75 | }); 76 | }); 77 | it('should add an index.html to the app folder', function(done) { 78 | beforeEach(); 79 | gulp.start('default').once('finish', function() { 80 | mockGulpDest.assertDestContains('src/app/index.html'); 81 | done(); 82 | }); 83 | }); 84 | it('should add a JavaScript app module definition file by default', function(done) { 85 | testingUtil.mockPrompt({ 86 | name: 'module' 87 | }); 88 | beforeEach(); 89 | gulp.start('default').once('finish', function() { 90 | mockGulpDest.assertDestContains('src/app/app.js'); 91 | done(); 92 | }); 93 | }); 94 | it('should create a gitkeep file in the app assets dir', function(done) { 95 | beforeEach(); 96 | gulp.start('default').once('finish', function() { 97 | mockGulpDest.assertDestContains('src/app/assets/.gitkeep'); 98 | done(); 99 | }); 100 | }); 101 | 102 | //Deep example 103 | describe('Todo example', function() { 104 | it('should not add any todo example files by default', function(done) { 105 | testingUtil.mockPrompt({ 106 | name: 'module' 107 | }); 108 | gulp.start('default').once('finish', function() { 109 | mockGulpDest.assertDestNotContains({ 110 | 'src/app/todo': [ 111 | 'todo.js', 112 | 'todo.html', 113 | 'todo.css', 114 | 'todo-route.js', 115 | 'todo-controller.spec.js', 116 | 'todo-controller.js' 117 | ] 118 | }); 119 | done(); 120 | }); 121 | }); 122 | describe('When Todo example is included', function() { 123 | function beforeEachTODO() { 124 | testingUtil.mockPrompt({ 125 | name: 'module', 126 | example: ['todo'] 127 | }); 128 | } 129 | it('should add a module specific template', function(done) { 130 | beforeEachTODO(); 131 | gulp.start('default').once('finish', function() { 132 | mockGulpDest.assertDestContains('src/app/todo/todo.html'); 133 | done(); 134 | }); 135 | }); 136 | it('should add a module definition file for the Todo module', function(done) { 137 | beforeEachTODO(); 138 | gulp.start('default').once('finish', function() { 139 | mockGulpDest.assertDestContains('src/app/todo/todo.js'); 140 | done(); 141 | }); 142 | }); 143 | it('should add a Todo controller with a corresponding test file', function(done) { 144 | beforeEachTODO(); 145 | gulp.start('default').once('finish', function() { 146 | mockGulpDest.assertDestContains([ 147 | 'src/app/todo/todo-controller.js', 148 | 'src/app/todo/todo-controller.spec.js' 149 | ]); 150 | done(); 151 | }); 152 | }); 153 | }); 154 | }); 155 | describe('CSS files', function() { 156 | it('should add less stylesheets by default', function(done) { 157 | testingUtil.mockPrompt({ 158 | name: 'module', 159 | example: ['todo'] 160 | }); 161 | gulp.start('default').once('finish', function() { 162 | mockGulpDest.assertDestContains([ 163 | 'src/app/app.less', 164 | 'src/app/styles/_base.less', 165 | 'src/app/todo/todo.less' 166 | ]); 167 | done(); 168 | }); 169 | }); 170 | it('should add LESS stylesheets when LESS is chosen', function(done) { 171 | testingUtil.mockPrompt({ 172 | name: 'module', 173 | csstype: 'less', 174 | example: ['todo'] 175 | }); 176 | gulp.start('default').once('finish', function() { 177 | mockGulpDest.assertDestContains([ 178 | 'src/app/app.less', 179 | 'src/app/styles/_base.less', 180 | 'src/app/todo/todo.less' 181 | ]); 182 | done(); 183 | }); 184 | }); 185 | it('should add Sass stylesheets when Sass is chosen', function(done) { 186 | testingUtil.mockPrompt({ 187 | name: 'module', 188 | csstype: 'sass', 189 | example: ['todo'] 190 | }); 191 | gulp.start('default').once('finish', function() { 192 | mockGulpDest.assertDestContains([ 193 | 'src/app/app.scss', 194 | 'src/app/styles/_base.scss', 195 | 'src/app/todo/todo.scss' 196 | ]); 197 | done(); 198 | }); 199 | }); 200 | }); 201 | 202 | })(); 203 | -------------------------------------------------------------------------------- /test/cases/constant.spec.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | var common = require("../common"); 5 | var options = common.options; 6 | var assert = common.assert; 7 | var testingUtil = common.testingUtil; 8 | var util = common.util; 9 | var mockGulpDest = common.mockGulpDest; 10 | var gulp = common.gulp; 11 | 12 | function beforeEach() { 13 | process.chdir(__dirname); 14 | testingUtil.mockPrompt({ 15 | module: 'module1', 16 | fileName: 'myconstant' 17 | }); 18 | util.setRuntimeMode('TEST'); 19 | } 20 | 21 | it('should put the constant file in the correct directory', function(done) { 22 | beforeEach(); 23 | gulp.start('constant').once('stop', function() { 24 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/module1'); 25 | done(); 26 | }); 27 | }); 28 | it('should put the correct constant filename', function(done) { 29 | beforeEach(); 30 | gulp.start('constant').once('stop', function() { 31 | mockGulpDest.assertDestContains('myconstant-constant.js') 32 | done(); 33 | }); 34 | }); 35 | 36 | })(); 37 | -------------------------------------------------------------------------------- /test/cases/controller.spec.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | var common = require("../common"); 5 | var options = common.options; 6 | var assert = common.assert; 7 | var testingUtil = common.testingUtil; 8 | var util = common.util; 9 | var _ = common._; 10 | var mockGulpDest = common.mockGulpDest; 11 | var gulp = common.gulp; 12 | 13 | function beforeEach() { 14 | process.chdir(__dirname); 15 | testingUtil.mockPrompt({ 16 | module: 'module1', 17 | fileName: 'mycontroller', 18 | spec: false 19 | }); 20 | util.setRuntimeMode('TEST'); 21 | } 22 | 23 | it('should put the controller file in the correct directory', function(done) { 24 | beforeEach(); 25 | gulp.start('controller').once('stop', function() { 26 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/module1'); 27 | done(); 28 | }); 29 | }); 30 | it('should put the correct controller filename', function(done) { 31 | beforeEach(); 32 | gulp.start('controller').once('stop', function() { 33 | // console.log('mockGulpDest', mockGulpDest.files()); 34 | mockGulpDest.assertDestContains('mycontroller-controller.js'); 35 | done(); 36 | }); 37 | }); 38 | 39 | })(); 40 | -------------------------------------------------------------------------------- /test/cases/controller.test.spec.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | var common = require("../common"); 5 | var options = common.options; 6 | var assert = common.assert; 7 | var testingUtil = common.testingUtil; 8 | var util = common.util; 9 | var _ = common._; 10 | var mockGulpDest = common.mockGulpDest; 11 | var gulp = common.gulp; 12 | 13 | function beforeEach() { 14 | process.chdir(__dirname); 15 | testingUtil.mockPrompt({ 16 | module: 'module1', 17 | fileName: 'mycontroller', 18 | spec: true 19 | }); 20 | util.setRuntimeMode('TEST'); 21 | } 22 | 23 | it('should put the controller file in the correct directory', function(done) { 24 | beforeEach(); 25 | gulp.task('controller', function() { 26 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/module1'); 27 | done(); 28 | }); 29 | }); 30 | it('should put the correct controller filename', function(done) { 31 | beforeEach(); 32 | gulp.task('controller', function() { 33 | var files = []; 34 | // _.each(mockGulpDest.files(), function (item) { 35 | // console.log('mockGulpDest', item); 36 | // }); 37 | mockGulpDest.assertDestContains('mycontroller-controller.js'); 38 | mockGulpDest.assertDestContains('mycontroller-controller.spec.js'); 39 | done(); 40 | }); 41 | }); 42 | 43 | })(); 44 | -------------------------------------------------------------------------------- /test/cases/decorator.spec.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | var common = require("../common"); 5 | var options = common.options; 6 | var assert = common.assert; 7 | var testingUtil = common.testingUtil; 8 | var mockGulpDest = common.mockGulpDest; 9 | var gulp = common.gulp; 10 | var util = common.util; 11 | 12 | function beforeEach() { 13 | process.chdir(__dirname); 14 | testingUtil.mockPrompt({ 15 | module: 'module1', 16 | fileName: 'mydecorator' 17 | }); 18 | util.setRuntimeMode('TEST'); 19 | } 20 | 21 | it('should put the decorator file in the correct directory', function(done) { 22 | beforeEach(); 23 | gulp.start('decorator').once('stop', function() { 24 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/module1'); 25 | done(); 26 | }); 27 | }); 28 | it('should put the correct decorator filename', function(done) { 29 | beforeEach(); 30 | gulp.start('decorator').once('stop', function() { 31 | mockGulpDest.assertDestContains('mydecorator-decorator.js'); 32 | done(); 33 | }); 34 | }); 35 | 36 | })(); 37 | -------------------------------------------------------------------------------- /test/cases/directive.spec.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | var common = require("../common"); 5 | var options = common.options; 6 | var assert = common.assert; 7 | var testingUtil = common.testingUtil; 8 | var mockGulpDest = common.mockGulpDest; 9 | var gulp = common.gulp; 10 | var util = common.util; 11 | 12 | function beforeEach() { 13 | process.chdir(__dirname); 14 | testingUtil.mockPrompt({ 15 | module: 'module1', 16 | fileName: 'mydirective' 17 | }); 18 | util.setRuntimeMode('TEST'); 19 | } 20 | 21 | it('should put the directive file in the correct directory', function(done) { 22 | beforeEach(); 23 | gulp.start('directive').once('stop', function() { 24 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/module1'); 25 | done(); 26 | }); 27 | }); 28 | it('should put the correct directive filename', function(done) { 29 | beforeEach(); 30 | gulp.start('directive').once('stop', function() { 31 | mockGulpDest.assertDestContains('mydirective-directive.js'); 32 | done(); 33 | }); 34 | }); 35 | 36 | })(); 37 | -------------------------------------------------------------------------------- /test/cases/factory.spec.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | var common = require("../common"); 5 | var options = common.options; 6 | var assert = common.assert; 7 | var testingUtil = common.testingUtil; 8 | var mockGulpDest = common.mockGulpDest; 9 | var gulp = common.gulp; 10 | var util = common.util; 11 | 12 | function beforeEach() { 13 | process.chdir(__dirname); 14 | testingUtil.mockPrompt({ 15 | module: 'module1', 16 | fileName: 'myfactory' 17 | }); 18 | util.setRuntimeMode('TEST'); 19 | } 20 | 21 | it('should put the factory file in the correct directory', function(done) { 22 | beforeEach(); 23 | gulp.start('factory').once('stop', function() { 24 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/module1'); 25 | done(); 26 | }); 27 | }); 28 | it('should put the correct factory filename', function(done) { 29 | beforeEach(); 30 | gulp.start('factory').once('stop', function() { 31 | mockGulpDest.assertDestContains('myfactory-factory.js'); 32 | done(); 33 | }); 34 | }); 35 | 36 | })(); 37 | -------------------------------------------------------------------------------- /test/cases/filter.spec.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | var common = require("../common"); 5 | var options = common.options; 6 | var assert = common.assert; 7 | var testingUtil = common.testingUtil; 8 | var mockGulpDest = common.mockGulpDest; 9 | var gulp = common.gulp; 10 | var util = common.util; 11 | 12 | function beforeEach() { 13 | process.chdir(__dirname); 14 | testingUtil.mockPrompt({ 15 | module: 'module1', 16 | fileName: 'myfilter' 17 | }); 18 | util.setRuntimeMode('TEST'); 19 | } 20 | 21 | it('should put the filter file in the correct directory', function(done) { 22 | beforeEach(); 23 | gulp.start('filter').once('stop', function() { 24 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/module1'); 25 | done(); 26 | }); 27 | }); 28 | it('should put the correct filter filename', function(done) { 29 | beforeEach(); 30 | gulp.start('filter').once('stop', function() { 31 | mockGulpDest.assertDestContains('myfilter-filter.js'); 32 | done(); 33 | }); 34 | }); 35 | 36 | })(); 37 | -------------------------------------------------------------------------------- /test/cases/module.config.spec.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | var common = require("../common"); 5 | var options = common.options; 6 | var assert = common.assert; 7 | var testingUtil = common.testingUtil; 8 | var mockGulpDest = common.mockGulpDest; 9 | var gulp = common.gulp; 10 | var util = common.util; 11 | 12 | function beforeEach() { 13 | process.chdir(__dirname); 14 | testingUtil.mockPrompt({ 15 | module: 'mymodule', 16 | config: 'config' 17 | }); 18 | util.setRuntimeMode('TEST'); 19 | } 20 | 21 | it('should put the module file in the correct directory', function(done) { 22 | beforeEach(); 23 | gulp.start('module').once('stop', function() { 24 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/mymodule'); 25 | done(); 26 | }); 27 | }); 28 | it('should put the correct module filename', function(done) { 29 | beforeEach(); 30 | gulp.start('module').once('stop', function() { 31 | mockGulpDest.assertDestContains('mymodule-config.js'); 32 | done(); 33 | }); 34 | }); 35 | 36 | })(); 37 | -------------------------------------------------------------------------------- /test/cases/module.route.spec.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | var common = require("../common"); 5 | var options = common.options; 6 | var assert = common.assert; 7 | var testingUtil = common.testingUtil; 8 | var mockGulpDest = common.mockGulpDest; 9 | var gulp = common.gulp; 10 | var util = common.util; 11 | 12 | function beforeEach() { 13 | process.chdir(__dirname); 14 | testingUtil.mockPrompt({ 15 | module: 'mymodule', 16 | config: 'routes' 17 | }); 18 | util.setRuntimeMode('TEST'); 19 | } 20 | 21 | it('should put the module file in the correct directory', function(done) { 22 | beforeEach(); 23 | gulp.start('module').once('stop', function() { 24 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/mymodule'); 25 | done(); 26 | }); 27 | }); 28 | it('should put the correct module filename', function(done) { 29 | beforeEach(); 30 | gulp.start('module').once('stop', function() { 31 | mockGulpDest.assertDestContains('mymodule-routes.js'); 32 | done(); 33 | }); 34 | }); 35 | 36 | })(); 37 | -------------------------------------------------------------------------------- /test/cases/negative.spec.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | var common = require("../common"); 5 | var options = common.options; 6 | var assert = common.assert; 7 | var testingUtil = common.testingUtil; 8 | var mockGulpDest = common.mockGulpDest; 9 | var gulp = common.gulp; 10 | var util = common.util; 11 | 12 | function beforeEach() { 13 | testingUtil.mockPrompt({ 14 | module: 'module1', 15 | fileName: 'strangefilename', 16 | test: true 17 | }); 18 | util.setRuntimeMode('LIVE'); 19 | } 20 | 21 | it('test for error constant', function(done) { 22 | beforeEach(); 23 | assert.that(function() { 24 | done(); 25 | gulp.start('constant'); 26 | }).is.throwing(); 27 | }); 28 | it('test for error controller', function(done) { 29 | beforeEach(); 30 | assert.that(function() { 31 | done(); 32 | gulp.start('controller'); 33 | }).is.throwing(); 34 | }); 35 | it('test for error service', function(done) { 36 | beforeEach(); 37 | assert.that(function() { 38 | done(); 39 | gulp.start('service'); 40 | }).is.throwing(); 41 | }); 42 | it('test for error decorator', function(done) { 43 | beforeEach(); 44 | assert.that(function() { 45 | done(); 46 | gulp.start('decorator'); 47 | }).is.throwing(); 48 | }); 49 | it('test for error directive', function(done) { 50 | beforeEach(); 51 | assert.that(function() { 52 | done(); 53 | gulp.start('directive'); 54 | }).is.throwing(); 55 | }); 56 | it('test for error factory', function(done) { 57 | beforeEach(); 58 | assert.that(function() { 59 | done(); 60 | gulp.start('factory'); 61 | }).is.throwing(); 62 | }); 63 | it('test for error filter', function(done) { 64 | beforeEach(); 65 | assert.that(function() { 66 | done(); 67 | gulp.start('filter'); 68 | }).is.throwing(); 69 | }); 70 | it('test for error provider', function(done) { 71 | beforeEach(); 72 | assert.that(function() { 73 | done(); 74 | gulp.start('provider'); 75 | }).is.throwing(); 76 | }); 77 | it('test for error route', function(done) { 78 | beforeEach(); 79 | assert.that(function() { 80 | done(); 81 | gulp.start('route'); 82 | }).is.throwing(); 83 | }); 84 | it('test for error value', function(done) { 85 | beforeEach(); 86 | assert.that(function() { 87 | done(); 88 | gulp.start('value'); 89 | }).is.throwing(); 90 | }); 91 | it('test for error view', function(done) { 92 | beforeEach(); 93 | assert.that(function() { 94 | done(); 95 | gulp.start('view'); 96 | }).is.throwing(); 97 | }); 98 | 99 | })(); 100 | -------------------------------------------------------------------------------- /test/cases/provider.spec.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | var common = require("../common"); 5 | var options = common.options; 6 | var assert = common.assert; 7 | var testingUtil = common.testingUtil; 8 | var mockGulpDest = common.mockGulpDest; 9 | var gulp = common.gulp; 10 | var util = common.util; 11 | 12 | function beforeEach() { 13 | process.chdir(__dirname); 14 | testingUtil.mockPrompt({ 15 | module: 'module1', 16 | fileName: 'myprovider' 17 | }); 18 | util.setRuntimeMode('TEST'); 19 | } 20 | 21 | it('should put the provider file in the correct directory', function(done) { 22 | beforeEach(); 23 | gulp.start('provider').once('stop', function() { 24 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/module1'); 25 | done(); 26 | }); 27 | }); 28 | it('should put the correct provider filename', function(done) { 29 | beforeEach(); 30 | gulp.start('provider').once('stop', function() { 31 | mockGulpDest.assertDestContains('myprovider-provider.js'); 32 | done(); 33 | }); 34 | }); 35 | 36 | })(); 37 | -------------------------------------------------------------------------------- /test/cases/route.spec.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | var common = require("../common"); 5 | var options = common.options; 6 | var assert = common.assert; 7 | var testingUtil = common.testingUtil; 8 | var mockGulpDest = common.mockGulpDest; 9 | var gulp = common.gulp; 10 | var util = common.util; 11 | 12 | function beforeEach() { 13 | process.chdir(__dirname); 14 | testingUtil.mockPrompt({ 15 | module: 'module1', 16 | fileName: 'myroute' 17 | }); 18 | util.setRuntimeMode('TEST'); 19 | } 20 | 21 | it('should put the route file in the correct directory', function(done) { 22 | beforeEach(); 23 | gulp.start('route').once('stop', function() { 24 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/module1'); 25 | done(); 26 | }); 27 | }); 28 | it('should put the correct route filename', function(done) { 29 | beforeEach(); 30 | gulp.start('route').once('stop', function() { 31 | mockGulpDest.assertDestContains('myroute-route.js'); 32 | done(); 33 | }); 34 | }); 35 | 36 | })(); 37 | -------------------------------------------------------------------------------- /test/cases/service.spec.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | var common = require("../common"); 5 | var options = common.options; 6 | var assert = common.assert; 7 | var testingUtil = common.testingUtil; 8 | var mockGulpDest = common.mockGulpDest; 9 | var gulp = common.gulp; 10 | var util = common.util; 11 | 12 | function beforeEach() { 13 | process.chdir(__dirname); 14 | testingUtil.mockPrompt({ 15 | module: 'module1', 16 | fileName: 'myservice' 17 | }); 18 | util.setRuntimeMode('TEST'); 19 | } 20 | 21 | it('should put the service file in the correct directory', function(done) { 22 | beforeEach(); 23 | gulp.start('service').once('stop', function() { 24 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/module1'); 25 | done(); 26 | }); 27 | }); 28 | it('should put the correct service filename', function(done) { 29 | beforeEach(); 30 | gulp.start('service').once('stop', function() { 31 | mockGulpDest.assertDestContains('myservice-service.js'); 32 | done(); 33 | }); 34 | }); 35 | 36 | })(); 37 | -------------------------------------------------------------------------------- /test/cases/value.spec.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | var common = require("../common"); 5 | var options = common.options; 6 | var assert = common.assert; 7 | var testingUtil = common.testingUtil; 8 | var mockGulpDest = common.mockGulpDest; 9 | var gulp = common.gulp; 10 | var util = common.util; 11 | 12 | function beforeEach() { 13 | process.chdir(__dirname); 14 | testingUtil.mockPrompt({ 15 | module: 'module1', 16 | fileName: 'myvalue' 17 | }); 18 | util.setRuntimeMode('TEST'); 19 | } 20 | 21 | it('should put the value file in the correct directory', function(done) { 22 | beforeEach(); 23 | gulp.start('value').once('stop', function() { 24 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/module1'); 25 | done(); 26 | }); 27 | }); 28 | it('should put the correct value filename', function(done) { 29 | beforeEach(); 30 | gulp.start('value').once('stop', function() { 31 | mockGulpDest.assertDestContains('myvalue-value.js'); 32 | done(); 33 | }); 34 | }); 35 | 36 | })(); 37 | -------------------------------------------------------------------------------- /test/cases/view.spec.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | var common = require("../common"); 5 | var options = common.options; 6 | var assert = common.assert; 7 | var testingUtil = common.testingUtil; 8 | var mockGulpDest = common.mockGulpDest; 9 | var gulp = common.gulp; 10 | var util = common.util; 11 | 12 | function beforeEach() { 13 | process.chdir(__dirname); 14 | testingUtil.mockPrompt({ 15 | module: 'module1', 16 | fileName: 'myview' 17 | }); 18 | util.setRuntimeMode('TEST'); 19 | } 20 | 21 | it('should put the view file in the correct directory', function(done) { 22 | beforeEach(); 23 | gulp.start('view').once('stop', function() { 24 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/module1'); 25 | done(); 26 | }); 27 | }); 28 | it('should put the correct view filename', function(done) { 29 | beforeEach(); 30 | gulp.start('view').once('stop', function() { 31 | mockGulpDest.assertDestContains('myview-view.html'); 32 | done(); 33 | }); 34 | }); 35 | 36 | })(); 37 | -------------------------------------------------------------------------------- /test/common.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | var chai = require("chai"); 4 | 5 | var gulp = require('gulp'), 6 | testingUtil = require('./testing_util'), 7 | util = require('../util'), 8 | _ = require('lodash'), 9 | mockGulpDest = require('mock-gulp-dest')(gulp); 10 | 11 | var assert = require('assertthat') 12 | 13 | var options = { 14 | runtime : 'TEST' 15 | }; 16 | 17 | 18 | exports._ = _; 19 | exports.assert = assert; 20 | exports.chai = chai; 21 | exports.gulp = gulp; 22 | exports.mockGulpDest = mockGulpDest; 23 | exports.testingUtil = testingUtil; 24 | exports.util = util; 25 | 26 | exports.options = options; 27 | 28 | })(); 29 | -------------------------------------------------------------------------------- /test/default.spec.js: -------------------------------------------------------------------------------- 1 | /* jshint node:true */ 2 | /** 3 | * MIT licensed, see LICENSE file 4 | * Copyright (c) Venkateswara VP 5 | */ 6 | // mocha test/default.spec.js -R html-cov > coverage.html 7 | (function() { 8 | 'use strict'; 9 | require('blanket')({ 10 | pattern: function(filename) { 11 | return !/node_modules/.test(filename); 12 | } 13 | }); 14 | var gulp = require('gulp'), 15 | testingUtil = require('./testing_util'), 16 | util = require('../util'), 17 | _ = require('lodash'), 18 | mockGulpDest = require('mock-gulp-dest')(gulp); 19 | 20 | var assert = require('assertthat'); 21 | 22 | require('../slushfile'); 23 | describe('slush-angular-gulp', function() { 24 | before(function() { 25 | process.chdir(__dirname); 26 | }); 27 | describe('default generator', function() { 28 | beforeEach(function() { 29 | testingUtil.mockPrompt({ 30 | name: 'module' 31 | }); 32 | }); 33 | it('should put all project files in current working directory', function(done) { 34 | gulp.start('default').once('stop', function() { 35 | // mockGulpDest.cwd().should.equal(__dirname); 36 | // mockGulpDest.basePath().should.equal(__dirname); 37 | 38 | assert.that(mockGulpDest.cwd()).is.equalTo(__dirname); 39 | assert.that(mockGulpDest.basePath()).is.equalTo(__dirname); 40 | done(); 41 | }); 42 | }); 43 | it('should add dot files to project root', function(done) { 44 | gulp.start('default').once('stop', function() { 45 | mockGulpDest.assertDestContains([ 46 | '.bowerrc', 47 | '.csslintrc', 48 | '.editorconfig', 49 | '.gitignore', 50 | '.jshintrc' 51 | ]); 52 | done(); 53 | }); 54 | }); 55 | it('should add bower.json and package.json to project root', function(done) { 56 | gulp.start('default').once('stop', function() { 57 | mockGulpDest.assertDestContains([ 58 | 'package.json', 59 | 'bower.json' 60 | ]); 61 | done(); 62 | }); 63 | }); 64 | it('should add a gulpfile to project root', function(done) { 65 | gulp.start('default').once('stop', function() { 66 | mockGulpDest.assertDestContains('gulpfile.js'); 67 | done(); 68 | }); 69 | }); 70 | it('should add a karma config file to project root', function(done) { 71 | gulp.start('default').once('stop', function() { 72 | mockGulpDest.assertDestContains('karma.conf.js'); 73 | done(); 74 | }); 75 | }); 76 | it('should add a readme file to project root', function(done) { 77 | gulp.start('default').once('stop', function() { 78 | mockGulpDest.assertDestContains('README.md'); 79 | done(); 80 | }); 81 | }); 82 | it('should add an index.html to the app folder', function(done) { 83 | gulp.start('default').once('stop', function() { 84 | mockGulpDest.assertDestContains('src/app/index.html'); 85 | done(); 86 | }); 87 | }); 88 | it('should add a JavaScript app module definition file by default', function(done) { 89 | testingUtil.mockPrompt({ 90 | name: 'module' 91 | }); 92 | gulp.start('default').once('stop', function() { 93 | mockGulpDest.assertDestContains('src/app/app.js'); 94 | done(); 95 | }); 96 | }); 97 | it('should create a gitkeep file in the app assets dir', function(done) { 98 | gulp.start('default').once('stop', function() { 99 | mockGulpDest.assertDestContains('src/app/assets/.gitkeep'); 100 | done(); 101 | }); 102 | }); 103 | describe('Todo example', function() { 104 | it('should not add any todo example files by default', function(done) { 105 | testingUtil.mockPrompt({ 106 | name: 'module' 107 | }); 108 | gulp.start('default').once('stop', function() { 109 | mockGulpDest.assertDestNotContains({ 110 | 'src/app/components/todo': [ 111 | 'todo.js', 112 | 'todo.html', 113 | 'todo.css', 114 | 'todo-route.js', 115 | 'todo-controller.spec.js', 116 | 'todo-controller.js' 117 | ] 118 | }); 119 | done(); 120 | }); 121 | }); 122 | describe('When Todo example is included', function() { 123 | beforeEach(function() { 124 | testingUtil.mockPrompt({ 125 | name: 'module', 126 | example: ['todo'] 127 | }); 128 | }); 129 | it('should add a module specific template', function(done) { 130 | gulp.start('default').once('stop', function() { 131 | mockGulpDest.assertDestContains('src/app/components/todo/todo.html'); 132 | done(); 133 | }); 134 | }); 135 | it('should add a module definition file for the Todo module', function(done) { 136 | gulp.start('default').once('stop', function() { 137 | mockGulpDest.assertDestContains('src/app/components/todo/todo.js'); 138 | done(); 139 | }); 140 | }); 141 | it('should add a Todo controller with a corresponding test file', function(done) { 142 | gulp.start('default').once('stop', function() { 143 | mockGulpDest.assertDestContains([ 144 | 'src/app/components/todo/todo-controller.js', 145 | 'src/app/components/todo/todo-controller.spec.js' 146 | ]); 147 | done(); 148 | }); 149 | }); 150 | }); 151 | }); 152 | describe('CSS files', function() { 153 | it('should add less stylesheets by default', function(done) { 154 | testingUtil.mockPrompt({ 155 | name: 'module', 156 | example: ['todo'] 157 | }); 158 | gulp.start('default').once('stop', function() { 159 | mockGulpDest.assertDestContains([ 160 | 'src/app/app.less', 161 | 'src/app/styles/_base.less', 162 | 'src/app/components/todo/todo.less' 163 | ]); 164 | done(); 165 | }); 166 | }); 167 | it('should add LESS stylesheets when LESS is chosen', function(done) { 168 | testingUtil.mockPrompt({ 169 | name: 'module', 170 | csstype: 'less', 171 | example: ['todo'] 172 | }); 173 | gulp.start('default').once('stop', function() { 174 | mockGulpDest.assertDestContains([ 175 | 'src/app/app.less', 176 | 'src/app/styles/_base.less', 177 | 'src/app/components/todo/todo.less' 178 | ]); 179 | done(); 180 | }); 181 | }); 182 | it('should add Sass stylesheets when Sass is chosen', function(done) { 183 | testingUtil.mockPrompt({ 184 | name: 'module', 185 | csstype: 'sass', 186 | example: ['todo'] 187 | }); 188 | gulp.start('default').once('stop', function() { 189 | mockGulpDest.assertDestContains([ 190 | 'src/app/app.scss', 191 | 'src/app/styles/_base.scss', 192 | 'src/app/components/todo/todo.scss' 193 | ]); 194 | done(); 195 | }); 196 | }); 197 | }); 198 | }); 199 | ///////////// Constants //////////// 200 | describe('constant generator', function() { 201 | beforeEach(function() { 202 | testingUtil.mockPrompt({ 203 | module: 'module1', 204 | fileName: 'myconstant' 205 | }); 206 | util.setRuntimeMode('TEST'); 207 | }); 208 | it('should put the constant file in the correct directory', function(done) { 209 | gulp.start('constant').once('stop', function() { 210 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/components/module1'); 211 | done(); 212 | }); 213 | }); 214 | it('should put the correct constant filename', function(done) { 215 | gulp.start('constant').once('stop', function() { 216 | mockGulpDest.assertDestContains('myconstant-constant.js') 217 | done(); 218 | }); 219 | }); 220 | }); 221 | ///////////// Controllers //////////// 222 | describe('controller generator with test', function() { 223 | beforeEach(function() { 224 | testingUtil.mockPrompt({ 225 | module: 'module1', 226 | fileName: 'mycontroller', 227 | test: true 228 | }); 229 | util.setRuntimeMode('TEST'); 230 | }); 231 | it('should put the controller file in the correct directory', function(done) { 232 | gulp.start('controller').once('stop', function() { 233 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/components/module1'); 234 | done(); 235 | }); 236 | }); 237 | it('should put the correct controller filename', function(done) { 238 | gulp.start('controller').once('stop', function() { 239 | mockGulpDest.assertDestContains('mycontroller-controller.js'); 240 | mockGulpDest.assertDestContains('mycontroller-controller.spec.js'); 241 | done(); 242 | }); 243 | }); 244 | 245 | }); // With test controller 246 | describe('controller generator without test', function() { 247 | beforeEach(function() { 248 | testingUtil.mockPrompt({ 249 | module: 'module1', 250 | fileName: 'mycontroller', 251 | test: false 252 | }); 253 | util.setRuntimeMode('TEST'); 254 | }); 255 | it('should put the controller file in the correct directory', function(done) { 256 | gulp.start('controller').once('stop', function() { 257 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/components/module1'); 258 | done(); 259 | }); 260 | }); 261 | it('should put the correct controller filename', function(done) { 262 | gulp.start('controller').once('stop', function() { 263 | mockGulpDest.assertDestContains('mycontroller-controller.js'); 264 | done(); 265 | }); 266 | }); 267 | 268 | }); // With out test controller 269 | describe('decorator generator test', function() { 270 | beforeEach(function() { 271 | testingUtil.mockPrompt({ 272 | module: 'module1', 273 | fileName: 'mydecorator' 274 | }); 275 | util.setRuntimeMode('TEST'); 276 | }); 277 | it('should put the decorator file in the correct directory', function(done) { 278 | gulp.start('decorator').once('stop', function() { 279 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/components/module1'); 280 | done(); 281 | }); 282 | }); 283 | it('should put the correct decorator filename', function(done) { 284 | gulp.start('decorator').once('stop', function() { 285 | mockGulpDest.assertDestContains('mydecorator-decorator.js'); 286 | done(); 287 | }); 288 | }); 289 | 290 | }); // decorator test 291 | describe('directive generator test', function() { 292 | beforeEach(function() { 293 | testingUtil.mockPrompt({ 294 | module: 'module1', 295 | fileName: 'mydirective' 296 | }); 297 | util.setRuntimeMode('TEST'); 298 | }); 299 | it('should put the directive file in the correct directory', function(done) { 300 | gulp.start('directive').once('stop', function() { 301 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/components/module1'); 302 | done(); 303 | }); 304 | }); 305 | it('should put the correct directive filename', function(done) { 306 | gulp.start('directive').once('stop', function() { 307 | mockGulpDest.assertDestContains('mydirective-directive.js'); 308 | done(); 309 | }); 310 | }); 311 | 312 | }); // directive test 313 | describe('factory generator test', function() { 314 | beforeEach(function() { 315 | testingUtil.mockPrompt({ 316 | module: 'module1', 317 | fileName: 'myfactory' 318 | }); 319 | util.setRuntimeMode('TEST'); 320 | }); 321 | it('should put the factory file in the correct directory', function(done) { 322 | gulp.start('factory').once('stop', function() { 323 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/components/module1'); 324 | done(); 325 | }); 326 | }); 327 | it('should put the correct factory filename', function(done) { 328 | gulp.start('factory').once('stop', function() { 329 | mockGulpDest.assertDestContains('myfactory-factory.js'); 330 | done(); 331 | }); 332 | }); 333 | 334 | }); // factory test 335 | describe('filter generator test', function() { 336 | beforeEach(function() { 337 | testingUtil.mockPrompt({ 338 | module: 'module1', 339 | fileName: 'myfilter' 340 | }); 341 | util.setRuntimeMode('TEST'); 342 | }); 343 | it('should put the filter file in the correct directory', function(done) { 344 | gulp.start('filter').once('stop', function() { 345 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/components/module1'); 346 | done(); 347 | }); 348 | }); 349 | it('should put the correct filter filename', function(done) { 350 | gulp.start('filter').once('stop', function() { 351 | mockGulpDest.assertDestContains('myfilter-filter.js'); 352 | done(); 353 | }); 354 | }); 355 | 356 | }); // filter test 357 | describe('module - config generator test', function() { 358 | beforeEach(function() { 359 | testingUtil.mockPrompt({ 360 | module: 'mymodule', 361 | config: 'config' 362 | }); 363 | util.setRuntimeMode('TEST'); 364 | }); 365 | it('should put the module file in the correct directory', function(done) { 366 | gulp.start('module').once('stop', function() { 367 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/components/mymodule'); 368 | done(); 369 | }); 370 | }); 371 | it('should put the correct module filename', function(done) { 372 | gulp.start('module').once('stop', function() { 373 | mockGulpDest.assertDestContains('mymodule-config.js'); 374 | done(); 375 | }); 376 | }); 377 | 378 | }); // module test 379 | describe('module - routes generator test', function() { 380 | beforeEach(function() { 381 | testingUtil.mockPrompt({ 382 | module: 'mymodule', 383 | config: 'routes' 384 | }); 385 | util.setRuntimeMode('TEST'); 386 | }); 387 | it('should put the module file in the correct directory', function(done) { 388 | gulp.start('module').once('stop', function() { 389 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/components/mymodule'); 390 | done(); 391 | }); 392 | }); 393 | it('should put the correct module filename', function(done) { 394 | gulp.start('module').once('stop', function() { 395 | mockGulpDest.assertDestContains('mymodule-routes.js'); 396 | done(); 397 | }); 398 | }); 399 | 400 | }); // module test 401 | describe('provider generator test', function() { 402 | beforeEach(function() { 403 | testingUtil.mockPrompt({ 404 | module: 'module1', 405 | fileName: 'myprovider' 406 | }); 407 | util.setRuntimeMode('TEST'); 408 | }); 409 | it('should put the provider file in the correct directory', function(done) { 410 | gulp.start('provider').once('stop', function() { 411 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/components/module1'); 412 | done(); 413 | }); 414 | }); 415 | it('should put the correct provider filename', function(done) { 416 | gulp.start('provider').once('stop', function() { 417 | mockGulpDest.assertDestContains('myprovider-provider.js'); 418 | done(); 419 | }); 420 | }); 421 | 422 | }); // provider test 423 | describe('route generator test', function() { 424 | beforeEach(function() { 425 | testingUtil.mockPrompt({ 426 | module: 'module1', 427 | fileName: 'myroute' 428 | }); 429 | util.setRuntimeMode('TEST'); 430 | }); 431 | it('should put the route file in the correct directory', function(done) { 432 | gulp.start('route').once('stop', function() { 433 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/components/module1'); 434 | done(); 435 | }); 436 | }); 437 | it('should put the correct route filename', function(done) { 438 | gulp.start('route').once('stop', function() { 439 | mockGulpDest.assertDestContains('myroute-route.js'); 440 | done(); 441 | }); 442 | }); 443 | 444 | }); // route test 445 | describe('service generator test', function() { 446 | beforeEach(function() { 447 | testingUtil.mockPrompt({ 448 | module: 'module1', 449 | fileName: 'myservice' 450 | }); 451 | util.setRuntimeMode('TEST'); 452 | }); 453 | it('should put the service file in the correct directory', function(done) { 454 | gulp.start('service').once('stop', function() { 455 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/components/module1'); 456 | done(); 457 | }); 458 | }); 459 | it('should put the correct service filename', function(done) { 460 | gulp.start('service').once('stop', function() { 461 | mockGulpDest.assertDestContains('myservice-service.js'); 462 | done(); 463 | }); 464 | }); 465 | 466 | }); // service test 467 | describe('value generator test', function() { 468 | beforeEach(function() { 469 | testingUtil.mockPrompt({ 470 | module: 'module1', 471 | fileName: 'myvalue' 472 | }); 473 | util.setRuntimeMode('TEST'); 474 | }); 475 | it('should put the value file in the correct directory', function(done) { 476 | gulp.start('value').once('stop', function() { 477 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/components/module1'); 478 | done(); 479 | }); 480 | }); 481 | it('should put the correct value filename', function(done) { 482 | gulp.start('value').once('stop', function() { 483 | mockGulpDest.assertDestContains('myvalue-value.js'); 484 | done(); 485 | }); 486 | }); 487 | 488 | }); // value test 489 | describe('view generator test', function() { 490 | beforeEach(function() { 491 | testingUtil.mockPrompt({ 492 | module: 'module1', 493 | fileName: 'myview' 494 | }); 495 | util.setRuntimeMode('TEST'); 496 | }); 497 | it('should put the view file in the correct directory', function(done) { 498 | gulp.start('view').once('stop', function() { 499 | assert.that(mockGulpDest.basePath()).is.endingWith('src/app/components/module1'); 500 | done(); 501 | }); 502 | }); 503 | it('should put the correct view filename', function(done) { 504 | gulp.start('view').once('stop', function() { 505 | mockGulpDest.assertDestContains('myview-view.html'); 506 | done(); 507 | }); 508 | }); 509 | 510 | }); // view test 511 | describe('Negative case testing:', function() { 512 | beforeEach(function() { 513 | testingUtil.mockPrompt({ 514 | module: 'module1', 515 | fileName: 'strangefilename', 516 | test : true 517 | }); 518 | util.setRuntimeMode('LIVE'); 519 | }); 520 | it('test for error constant', function(done) { 521 | assert.that(function() { 522 | done(); 523 | gulp.start('constant', ['test']); 524 | }).is.throwing(); 525 | }); 526 | it('test for error controller', function(done) { 527 | assert.that(function() { 528 | done(); 529 | gulp.start('controller'); 530 | }).is.throwing(); 531 | }); 532 | it('test for error service', function(done) { 533 | assert.that(function() { 534 | done(); 535 | gulp.start('service'); 536 | }).is.throwing(); 537 | }); 538 | it('test for error decorator', function(done) { 539 | assert.that(function() { 540 | done(); 541 | gulp.start('decorator'); 542 | }).is.throwing(); 543 | }); 544 | it('test for error directive', function(done) { 545 | assert.that(function() { 546 | done(); 547 | gulp.start('directive'); 548 | }).is.throwing(); 549 | }); 550 | it('test for error factory', function(done) { 551 | assert.that(function() { 552 | done(); 553 | gulp.start('factory'); 554 | }).is.throwing(); 555 | }); 556 | it('test for error filter', function(done) { 557 | assert.that(function() { 558 | done(); 559 | gulp.start('filter'); 560 | }).is.throwing(); 561 | }); 562 | it('test for error provider', function(done) { 563 | assert.that(function() { 564 | done(); 565 | gulp.start('provider'); 566 | }).is.throwing(); 567 | }); 568 | it('test for error route', function(done) { 569 | assert.that(function() { 570 | done(); 571 | gulp.start('route'); 572 | }).is.throwing(); 573 | }); 574 | it('test for error value', function(done) { 575 | assert.that(function() { 576 | done(); 577 | gulp.start('value'); 578 | }).is.throwing(); 579 | }); 580 | it('test for error view', function(done) { 581 | assert.that(function() { 582 | done(); 583 | gulp.start('view'); 584 | }).is.throwing(); 585 | }); 586 | 587 | }); // view negative 588 | 589 | }); 590 | 591 | })(); 592 | -------------------------------------------------------------------------------- /test/testing_util.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | var inquirer = require('inquirer'); 5 | 6 | /** 7 | * Mock inquirer prompt 8 | */ 9 | module.exports.mockPrompt = function(answers) { 10 | 11 | inquirer.prompt = function(prompts) { 12 | [].concat(prompts).forEach(function(prompt) { 13 | if (!(prompt.name in answers)) { 14 | if (_.isNumber(prompt) && prompt.choices && _.isArray(prompt.choices)) { 15 | answers[prompt.name] = prompt.choices[prompt.default]; 16 | } else { 17 | answers[prompt.name] = prompt.default; 18 | } 19 | } 20 | }); 21 | return new Promise(function(done, reject) { 22 | done(answers); 23 | }) 24 | }; 25 | inquirer.prompt.UI = {}; 26 | 27 | }; 28 | 29 | 30 | module.exports.promisedMap = function(array, transform) { 31 | return new Promise(function(resolve, reject) { 32 | setTimeout(function() { 33 | resolve(array.map(transform)); 34 | }, 100); 35 | }); 36 | } 37 | })(); 38 | -------------------------------------------------------------------------------- /test/top.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | function importTest(name, path) { 5 | describe(name, function() { 6 | require(path); 7 | }); 8 | } 9 | 10 | var common = require("./common"); 11 | var testingUtil = common.testingUtil; 12 | var util = common.util; 13 | var _ = common._; 14 | 15 | var testSuite = [{ 16 | description: 'Test the Application generator', 17 | testcase: './cases/app.spec' 18 | }, { 19 | description: 'Test the Constants generator', 20 | testcase: './cases/constant.spec' 21 | }, { 22 | description: 'Test controller generator with test', 23 | testcase: './cases/controller.test.spec' 24 | }, { 25 | description: 'Test controller generator without test', 26 | testcase: './cases/controller.spec' 27 | }, { 28 | description: 'Test decorator generator', 29 | testcase: './cases/decorator.spec' 30 | }, { 31 | description: 'Test directive generator', 32 | testcase: './cases/directive.spec' 33 | }, { 34 | description: 'Test factory generator', 35 | testcase: './cases/factory.spec' 36 | }, { 37 | description: 'Test filter generator', 38 | testcase: './cases/filter.spec' 39 | }, { 40 | description: 'Test module with config generator', 41 | testcase: './cases/module.config.spec' 42 | }, { 43 | description: 'Test module with route generator', 44 | testcase: './cases/module.route.spec' 45 | }, { 46 | description: 'Test provider generator', 47 | testcase: './cases/provider.spec' 48 | }, { 49 | description: 'Test route generator', 50 | testcase: './cases/route.spec' 51 | }, { 52 | description: 'Test service generator', 53 | testcase: './cases/service.spec' 54 | }, { 55 | description: 'Test value generator', 56 | testcase: './cases/value.spec' 57 | }, { 58 | description: 'Test view generator', 59 | testcase: './cases/view.spec' 60 | }, { 61 | description: 'Test Negative usecases for generator', 62 | testcase: './cases/negative.spec' 63 | }]; 64 | 65 | require('blanket')({ 66 | pattern: function(filename) { 67 | return !/node_modules/.test(filename); 68 | } 69 | }); 70 | 71 | //Load the main slush file for testing 72 | require('../slushfile'); 73 | 74 | describe('slush-angular-gulp', function() { 75 | before(function() { 76 | console.log('Starting...'); 77 | }); 78 | 79 | _.each(testSuite, function(tCase) { 80 | importTest(tCase.description, tCase.testcase); 81 | }); 82 | 83 | 84 | after(function() { 85 | console.log('Completed.'); 86 | }); 87 | }); 88 | 89 | })(); 90 | -------------------------------------------------------------------------------- /util.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | /** 4 | * cssTypeData configuration 5 | * @type {cssTypeData} 6 | */ 7 | var cssTypeData = { 8 | 'less': { 9 | plugin: 'gulp-less', 10 | pluginVersion: '^3.0.5', 11 | pipeCommand: 'g.less()', 12 | extension: 'less' 13 | }, 14 | 'sass': { 15 | plugin: 'gulp-sass', 16 | pluginVersion: '^2.2.0', 17 | pipeCommand: 'g.sass()', 18 | extension: 'scss' 19 | }, 20 | 'styl': { 21 | plugin: 'gulp-stylus', 22 | pluginVersion: '^2.3.1', 23 | pipeCommand: 'g.stylus({use: [require(\'nib\')()]})', 24 | extension: 'styl', 25 | extraDependencies: { 26 | 'nib': '^1.1.0' 27 | } 28 | } 29 | }; 30 | 31 | /** 32 | * Proposes the names based on the path/package.json file. 33 | * @return {String} name 34 | */ 35 | function getNameProposal() { 36 | var path = require('path'); 37 | try { 38 | return require(path.join(process.cwd(), 'package.json')).name; 39 | } catch (e) { 40 | return path.basename(process.cwd()); 41 | } 42 | }; 43 | 44 | /** 45 | * Organize quize. 46 | * @return {String} name 47 | */ 48 | function getDefaultOption(args, index) { 49 | if (args && args[index]) { 50 | return args[index]; 51 | } else { 52 | return null; 53 | } 54 | }; 55 | 56 | var runtimeMode = 'LIVE'; //Other option is 'TEST' 57 | function setRuntimeMode(mode) { 58 | runtimeMode = mode; 59 | }; 60 | 61 | function getRuntimeMode() { 62 | return runtimeMode; 63 | }; 64 | 65 | 66 | /** 67 | * Get Modules proposal 68 | * @return {list} dir 69 | */ 70 | function getModuleProposal(appDir) { 71 | if (getRuntimeMode() === 'TEST') { 72 | return ['module1', 'module2']; 73 | } 74 | var modules = []; 75 | var componentsDir = appDir;// + '/components'; 76 | var fs = require('fs'); 77 | 78 | var finalList = []; 79 | if (fs.existsSync(componentsDir)) { 80 | modules = fs.readdirSync(componentsDir); 81 | for (var i = 0; i < modules.length; i++) { 82 | var stats = fs.statSync(componentsDir + '/' + modules[i]); 83 | if (stats.isDirectory()) { 84 | finalList.push(modules[i]); 85 | } 86 | } 87 | } 88 | 89 | return finalList; 90 | }; 91 | 92 | /** 93 | * Get global Options 94 | * command line options 95 | * --appdir Default Application location 96 | * --base is the base for the application 97 | * Note: if both are padssed then it will search on base + appdir 98 | * @return {Object} name 99 | */ 100 | function getGlobalOptions() { 101 | var argv = require('yargs').argv; 102 | 103 | return { 104 | appDir: argv.appdir || 'src/app', 105 | base: argv.base || './' 106 | }; 107 | }; 108 | 109 | 110 | module.exports.cssTypeData = cssTypeData; 111 | module.exports.getNameProposal = getNameProposal; 112 | module.exports.getDefaultOption = getDefaultOption; 113 | module.exports.setRuntimeMode = setRuntimeMode; 114 | module.exports.getRuntimeMode = getRuntimeMode; 115 | module.exports.getModuleProposal = getModuleProposal; 116 | module.exports.getGlobalOptions = getGlobalOptions; 117 | 118 | })(); 119 | --------------------------------------------------------------------------------