├── .editorconfig ├── .gitattributes ├── .gitignore ├── .jshintrc ├── .npmignore ├── .travis.yml ├── CHANGELOG.md ├── Gruntfile.js ├── app ├── USAGE ├── index.js └── templates │ └── styles │ ├── css │ ├── bootstrap.css │ └── main.css │ ├── sass │ ├── main.sass │ └── main.scss │ └── scss │ └── main.scss ├── common └── index.js ├── constant ├── USAGE └── index.js ├── contributing.md ├── controller ├── USAGE └── index.js ├── decorator ├── USAGE └── index.js ├── directive ├── USAGE └── index.js ├── factory ├── USAGE └── index.js ├── filter ├── USAGE └── index.js ├── main └── index.js ├── package.json ├── provider ├── USAGE └── index.js ├── readme.md ├── route ├── USAGE └── index.js ├── script-base.js ├── service ├── USAGE └── index.js ├── templates ├── coffeescript-min │ ├── app.coffee │ ├── controller.coffee │ ├── decorator.coffee │ ├── directive.coffee │ ├── filter.coffee │ ├── service │ │ ├── constant.coffee │ │ ├── factory.coffee │ │ ├── provider.coffee │ │ ├── service.coffee │ │ └── value.coffee │ └── spec │ │ ├── controller.coffee │ │ ├── directive.coffee │ │ ├── filter.coffee │ │ └── service.coffee ├── coffeescript │ ├── app.coffee │ ├── controller.coffee │ ├── decorator.coffee │ ├── directive.coffee │ ├── filter.coffee │ ├── service │ │ ├── constant.coffee │ │ ├── factory.coffee │ │ ├── provider.coffee │ │ ├── service.coffee │ │ └── value.coffee │ └── spec │ │ ├── controller.coffee │ │ ├── directive.coffee │ │ ├── filter.coffee │ │ └── service.coffee ├── common │ ├── Gruntfile.js │ ├── _bower.json │ ├── _package.json │ ├── gitignore │ ├── index.html │ ├── root │ │ ├── .bowerrc │ │ ├── .editorconfig │ │ ├── .gitattributes │ │ ├── .jshintrc │ │ ├── app │ │ │ ├── .buildignore │ │ │ ├── .htaccess │ │ │ ├── 404.html │ │ │ ├── favicon.ico │ │ │ ├── robots.txt │ │ │ └── views │ │ │ │ └── main.html │ │ └── test │ │ │ ├── .jshintrc │ │ │ └── runner.html │ └── view.html ├── javascript-min │ ├── app.js │ ├── controller.js │ ├── decorator.js │ ├── directive.js │ ├── filter.js │ ├── service │ │ ├── constant.js │ │ ├── factory.js │ │ ├── provider.js │ │ ├── service.js │ │ └── value.js │ └── spec │ │ ├── controller.js │ │ ├── directive.js │ │ ├── filter.js │ │ └── service.js └── javascript │ ├── app.js │ ├── controller.js │ ├── decorator.js │ ├── directive.js │ ├── filter.js │ ├── service │ ├── constant.js │ ├── factory.js │ ├── provider.js │ ├── service.js │ └── value.js │ └── spec │ ├── controller.js │ ├── directive.js │ ├── filter.js │ └── service.js ├── test ├── test-appname-substitution.js └── test-file-creation.js ├── util.js ├── value ├── USAGE └── index.js └── view ├── USAGE └── index.js /.editorconfig: -------------------------------------------------------------------------------- 1 | # 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 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | test/temp 3 | test/UpperCaseBug 4 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "esnext": true, 4 | "bitwise": false, 5 | "curly": false, 6 | "eqeqeq": true, 7 | "eqnull": true, 8 | "immed": true, 9 | "latedef": true, 10 | "newcap": true, 11 | "noarg": true, 12 | "undef": true, 13 | "strict": false, 14 | "trailing": true, 15 | "smarttabs": true 16 | } 17 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '0.10' 4 | - '0.8' 5 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | ### v0.5.3 (2015-02-27) 3 | 4 | 5 | ## v0.5.0 (2013-10-17) 6 | 7 | 8 | #### Bug Fixes 9 | 10 | * **app:** 11 | * serve files from correct place ([fe2bad04](http://github.com/yeoman/generator-angular/commit/fe2bad0417b3138fa2788c17abcf7eb5be5f3e91)) 12 | * include bootstrap images for css/scss ([e88dba43](http://github.com/yeoman/generator-angular/commit/e88dba43f2e714d69bca366cade453f49a24b62c), closes [#196](http://github.com/yeoman/generator-angular/issues/196)) 13 | * allow normal javascript to be created ([c8190b55](http://github.com/yeoman/generator-angular/commit/c8190b55284e8c1570cc8fafdc8723250f43829b), closes [#329](http://github.com/yeoman/generator-angular/issues/329), [#316](http://github.com/yeoman/generator-angular/issues/316)) 14 | * conditional include of jquery ([bc1e68e3](http://github.com/yeoman/generator-angular/commit/bc1e68e30450edc16145b934487f6df5eaaddcd8), closes [#362](http://github.com/yeoman/generator-angular/issues/362)) 15 | * **build:** 16 | * remove references to global yeomanConfig ([a0f16e26](http://github.com/yeoman/generator-angular/commit/a0f16e265729586802121c0fe3111f974e5145ec)) 17 | * update to grunt-contrib-connect 0.5.0 ([67c0ebf0](http://github.com/yeoman/generator-angular/commit/67c0ebf081889658a33bc690c530c3c8bc8a2c12)) 18 | * update to grunt-contrib-connect 0.4.0 ([368ad7f9](http://github.com/yeoman/generator-angular/commit/368ad7f9a16be0ee67e5182be581669017788f16)) 19 | * **docs:** fixed typo in readme ([a967907c](http://github.com/yeoman/generator-angular/commit/a967907cf523bac752b3fa9ea6363767d8855162)) 20 | * **generator:** add app modules dependency to app ([a45b71c9](http://github.com/yeoman/generator-angular/commit/a45b71c95c18deb85ff7a1538c0b0744e4faa508), closes [#230](http://github.com/yeoman/generator-angular/issues/230)) 21 | * **templates:** 22 | * Gruntfile indentation ([6f7d17e2](http://github.com/yeoman/generator-angular/commit/6f7d17e2a0f1f7f9f8cac3157beb07b82e8cf400)) 23 | * take out semicolons in coffeescript ([e38124ee](http://github.com/yeoman/generator-angular/commit/e38124eeb369b7741adc263f1763c618a918ee65)) 24 | * correct coffee provider template ([86aefe5d](http://github.com/yeoman/generator-angular/commit/86aefe5da49abe82e054666641f8ee4bdc8d555e)) 25 | * value generator should use value template ([67d0c5ad](http://github.com/yeoman/generator-angular/commit/67d0c5ad5cbc58a2dfcfd8f3db1f45be21afe357)) 26 | * **test:** update tests to match service files ([c30464c3](http://github.com/yeoman/generator-angular/commit/c30464c3a5216169026c23a6fea23d273bd0b948), closes [#338](http://github.com/yeoman/generator-angular/issues/338), [#354](http://github.com/yeoman/generator-angular/issues/354)) 27 | * **views:** correct path for sub views ([0568e744](http://github.com/yeoman/generator-angular/commit/0568e74446c5a8e28d2cea1a9a9a5886be190d7d), closes [#359](http://github.com/yeoman/generator-angular/issues/359)) 28 | 29 | 30 | ## v0.4.0 (2013-08-21) 31 | 32 | 33 | #### Bug Fixes 34 | 35 | * **cli:** fix typo in angular:view generator usage ([d62c2e34](http://github.com/yeoman/generator-angular/commit/d62c2e348bcc61a6794ca23df02b6cce3c79d993)) 36 | * **coffee:** 37 | * remove extraneous commas and returns ([6df875cd](http://github.com/yeoman/generator-angular/commit/6df875cd7167aa4a4e9f98a82d2f7fba98a20b0b)) 38 | * remove the semi-colon from the coffee script templates ([cd46aa88](http://github.com/yeoman/generator-angular/commit/cd46aa88953e60d81dfef64b999f751dc4468ab7)) 39 | * **docs:** 40 | * add decorator generator description ([85f07648](http://github.com/yeoman/generator-angular/commit/85f076485ffabf790fe0b7d55b7e3def3a041a6d)) 41 | * add contributing info to contributing file ([2461aad0](http://github.com/yeoman/generator-angular/commit/2461aad08afe186995d737a1d3dd595c20ec3fb3)) 42 | * **readme:** Remove `yo` installation step ([21f00e50](http://github.com/yeoman/generator-angular/commit/21f00e50571d272d19aea1431177f2d7157ee7be)) 43 | * **templates:** 44 | * removed grunt-karma from deps ([19a796f7](http://github.com/yeoman/generator-angular/commit/19a796f71925b6b33232d8a9a8b4f712de80ec40)) 45 | * classify services registered with .service ([8e1d6fdf](http://github.com/yeoman/generator-angular/commit/8e1d6fdf0d3ef23cf0670512295e03cc0f4516d6)) 46 | * new scope for directive spec ([2753c990](http://github.com/yeoman/generator-angular/commit/2753c990dbdc8efc7a5f245868cd10f15080c140)) 47 | * **test:** Add correct paths to generated files ([1d6f3fbf](http://github.com/yeoman/generator-angular/commit/1d6f3fbfcc315316a44b468418918afaad871f57)) 48 | * **wording:** clarify compass/scss feature prompt ([5521fd73](http://github.com/yeoman/generator-angular/commit/5521fd73d396763568b5e7c08043a82a4e8864a9)) 49 | 50 | 51 | #### Features 52 | 53 | * **build:** 54 | * generate karma 0.10 config ([e1cb2067](http://github.com/yeoman/generator-angular/commit/e1cb206710f54c8bea6ed8870566ac4c3e248b40)) 55 | * add autoprefixer support ([c4dfd61d](http://github.com/yeoman/generator-angular/commit/c4dfd61d860f86a97026d1e5188ab78a87f4e6a1), closes [#317](http://github.com/yeoman/generator-angular/issues/317)) 56 | * switch to use load-grunt-tasks ([4e030c78](http://github.com/yeoman/generator-angular/commit/4e030c78387ec2a60581ff6346b707c98ddb2508)) 57 | * show elapsed time for grunt tasks ([cacdd0fb](http://github.com/yeoman/generator-angular/commit/cacdd0fb5815355f6e35343c53e876352e622180)) 58 | * **coffee:** generate source maps for coffeescript ([38a872b3](http://github.com/yeoman/generator-angular/commit/38a872b31e9ccef1aac76bec330c3490303abdac)) 59 | * **gen:** Change ga.js to analytics.js ([17ae9e63](http://github.com/yeoman/generator-angular/commit/17ae9e63b2d11d271b36282bb34567b716099cb9)) 60 | 61 | 62 | ## v0.3.1 (2013-07-24) 63 | 64 | 65 | #* **Bug Fixes:** 66 | 67 | * **app:** 68 | * order of script inclusions ([9919b2d0](http://github.com/yeoman/generator-angular/commit/9919b2d0bb749cbe5e795608c2b93c3504e3298b), closes [#278](http://github.com/yeoman/generator-angular/issues/278)) 69 | * copy glyphicons for sass ([2c458009](http://github.com/yeoman/generator-angular/commit/2c4580096572678de6212c8592fb553c10b3a4c0), closes [#269](http://github.com/yeoman/generator-angular/issues/269)) 70 | * add jQuery \' 99 | ] 100 | }); 101 | } catch (e) { 102 | console.log('\nUnable to find '.yellow + fullPath + '. Reference to '.yellow + script + '.js ' + 'not added.\n'.yellow); 103 | } 104 | }; 105 | 106 | Generator.prototype.generateSourceAndTest = function (appTemplate, testTemplate, targetDirectory) { 107 | this.appTemplate(appTemplate, path.join('scripts', targetDirectory, this.name)); 108 | this.testTemplate(testTemplate, path.join(targetDirectory, this.name)); 109 | this.addScriptToIndex(path.join(targetDirectory, this.name)); 110 | }; 111 | -------------------------------------------------------------------------------- /service/USAGE: -------------------------------------------------------------------------------- 1 | Description: 2 | Creates a new AngularJS service. 3 | Docs: http://docs.angularjs.org/guide/dev_guide.services.creating_services 4 | 5 | Example: 6 | yo angular-ui-router:service thing [--coffee] [--minsafe] 7 | 8 | This will create: 9 | app/scripts/services/thing.js 10 | -------------------------------------------------------------------------------- /service/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var util = require('util'); 3 | var ScriptBase = require('../script-base.js'); 4 | 5 | 6 | var Generator = module.exports = function Generator() { 7 | ScriptBase.apply(this, arguments); 8 | }; 9 | 10 | util.inherits(Generator, ScriptBase); 11 | 12 | Generator.prototype.createServiceFiles = function createServiceFiles() { 13 | this.generateSourceAndTest('service/service', 'spec/service', 'services'); 14 | }; 15 | -------------------------------------------------------------------------------- /templates/coffeescript-min/app.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | angular.module('<%= _.camelize(appname) %>App', [<%= angularModules %>]) 4 | .config ['$routeProvider', ($routeProvider) -> 5 | $routeProvider 6 | .when '/', 7 | templateUrl: 'views/main.html' 8 | controller: 'MainCtrl' 9 | .otherwise 10 | redirectTo: '/' 11 | ] 12 | -------------------------------------------------------------------------------- /templates/coffeescript-min/controller.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .controller '<%= _.classify(name) %>Ctrl', ['$scope', ($scope) -> 5 | $scope.awesomeThings = [ 6 | 'HTML5 Boilerplate' 7 | 'AngularJS' 8 | 'Karma' 9 | ] 10 | ] 11 | -------------------------------------------------------------------------------- /templates/coffeescript-min/decorator.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | angular.module("<%= _.camelize(appname) %>App").config ["$provide", ($provide) -> 4 | $provide.decorator "<%= _.camelize(name) %>", ($delegate) -> 5 | # decorate the $delegate 6 | $delegate 7 | ] 8 | -------------------------------------------------------------------------------- /templates/coffeescript-min/directive.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .directive '<%= _.camelize(name) %>', [-> 5 | template: '
' 6 | restrict: 'E' 7 | link: (scope, element, attrs) -> 8 | element.text 'this is the <%= _.camelize(name) %> directive' 9 | ] 10 | -------------------------------------------------------------------------------- /templates/coffeescript-min/filter.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .filter '<%= _.camelize(name) %>', [() -> 5 | (input) -> 6 | '<%= _.camelize(name) %> filter: ' + input 7 | ] 8 | -------------------------------------------------------------------------------- /templates/coffeescript-min/service/constant.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .constant '<%= _.camelize(name) %>', 42 5 | -------------------------------------------------------------------------------- /templates/coffeescript-min/service/factory.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .factory '<%= _.camelize(name) %>', [() -> 5 | # Service logic 6 | # ... 7 | 8 | meaningOfLife = 42 9 | 10 | # Public API here 11 | { 12 | someMethod: () -> 13 | meaningOfLife 14 | } 15 | ] 16 | -------------------------------------------------------------------------------- /templates/coffeescript-min/service/provider.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .provider '<%= _.camelize(name) %>', [-> 5 | 6 | # Private variables 7 | salutation = 'Hello' 8 | 9 | # Private constructor 10 | class Greeter 11 | @greet = -> 12 | salutation 13 | 14 | # Public API for configuration 15 | @setSalutation = (s) -> 16 | salutation = s 17 | 18 | # Method for instantiating 19 | @$get = -> 20 | new Greeter() 21 | ] 22 | -------------------------------------------------------------------------------- /templates/coffeescript-min/service/service.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .service '<%= _.classify(name) %>', () -> 5 | # AngularJS will instantiate a singleton by calling "new" on this function 6 | -------------------------------------------------------------------------------- /templates/coffeescript-min/service/value.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .value '<%= _.camelize(name) %>', 42 5 | -------------------------------------------------------------------------------- /templates/coffeescript-min/spec/controller.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | describe 'Controller: <%= _.classify(name) %>Ctrl', () -> 4 | 5 | # load the controller's module 6 | beforeEach module '<%= _.camelize(appname) %>App' 7 | 8 | <%= _.classify(name) %>Ctrl = {} 9 | scope = {} 10 | 11 | # Initialize the controller and a mock scope 12 | beforeEach inject ($controller, $rootScope) -> 13 | scope = $rootScope.$new() 14 | <%= _.classify(name) %>Ctrl = $controller '<%= _.classify(name) %>Ctrl', { 15 | $scope: scope 16 | } 17 | 18 | it 'should attach a list of awesomeThings to the scope', () -> 19 | expect(scope.awesomeThings.length).toBe 3 20 | -------------------------------------------------------------------------------- /templates/coffeescript-min/spec/directive.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | describe 'Directive: <%= _.camelize(name) %>', () -> 4 | 5 | # load the directive's module 6 | beforeEach module '<%= _.camelize(appname) %>App' 7 | 8 | scope = {} 9 | 10 | beforeEach inject ($controller, $rootScope) -> 11 | scope = $rootScope.$new() 12 | 13 | it 'should make hidden element visible', inject ($compile) -> 14 | element = angular.element '<<%= _.dasherize(name) %>><%= _.dasherize(name) %>>' 15 | element = $compile(element) scope 16 | expect(element.text()).toBe 'this is the <%= _.camelize(name) %> directive' 17 | -------------------------------------------------------------------------------- /templates/coffeescript-min/spec/filter.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | describe 'Filter: <%= _.camelize(name) %>', () -> 4 | 5 | # load the filter's module 6 | beforeEach module '<%= _.camelize(appname) %>App' 7 | 8 | # initialize a new instance of the filter before each test 9 | <%= _.camelize(name) %> = {} 10 | beforeEach inject ($filter) -> 11 | <%= _.camelize(name) %> = $filter '<%= _.camelize(name) %>' 12 | 13 | it 'should return the input prefixed with "<%= _.camelize(name) %> filter:"', () -> 14 | text = 'angularjs' 15 | expect(<%= _.camelize(name) %> text).toBe ('<%= _.camelize(name) %> filter: ' + text) 16 | -------------------------------------------------------------------------------- /templates/coffeescript-min/spec/service.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | describe 'Service: <%= _.classify(name) %>', () -> 4 | 5 | # load the service's module 6 | beforeEach module '<%= _.classify(appname) %>App' 7 | 8 | # instantiate service 9 | <%= _.classify(name) %> = {} 10 | beforeEach inject (_<%= _.classify(name) %>_) -> 11 | <%= _.classify(name) %> = _<%= _.classify(name) %>_ 12 | 13 | it 'should do something', () -> 14 | expect(!!<%= _.classify(name) %>).toBe true 15 | -------------------------------------------------------------------------------- /templates/coffeescript/app.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | angular.module('<%= _.camelize(appname) %>App', [<%= angularModules %>]) 4 | .config ($routeProvider) -> 5 | $routeProvider 6 | .when '/', 7 | templateUrl: 'views/main.html' 8 | controller: 'MainCtrl' 9 | .otherwise 10 | redirectTo: '/' 11 | -------------------------------------------------------------------------------- /templates/coffeescript/controller.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .controller '<%= _.classify(name) %>Ctrl', ($scope) -> 5 | $scope.awesomeThings = [ 6 | 'HTML5 Boilerplate' 7 | 'AngularJS' 8 | 'Karma' 9 | ] 10 | -------------------------------------------------------------------------------- /templates/coffeescript/decorator.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | angular.module("<%= _.camelize(appname) %>App").config ($provide) -> 4 | $provide.decorator "<%= _.camelize(name) %>", ($delegate) -> 5 | # decorate the $delegate 6 | $delegate 7 | -------------------------------------------------------------------------------- /templates/coffeescript/directive.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .directive('<%= _.camelize(name) %>', () -> 5 | template: '' 6 | restrict: 'E' 7 | link: (scope, element, attrs) -> 8 | element.text 'this is the <%= _.camelize(name) %> directive' 9 | ) 10 | -------------------------------------------------------------------------------- /templates/coffeescript/filter.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .filter '<%= _.camelize(name) %>', () -> 5 | (input) -> 6 | '<%= _.camelize(name) %> filter: ' + input 7 | -------------------------------------------------------------------------------- /templates/coffeescript/service/constant.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .constant '<%= _.camelize(name) %>', 42 5 | -------------------------------------------------------------------------------- /templates/coffeescript/service/factory.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .factory '<%= _.camelize(name) %>', () -> 5 | # Service logic 6 | # ... 7 | 8 | meaningOfLife = 42 9 | 10 | # Public API here 11 | { 12 | someMethod: () -> 13 | meaningOfLife 14 | } 15 | -------------------------------------------------------------------------------- /templates/coffeescript/service/provider.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .provider '<%= _.camelize(name) %>', [-> 5 | 6 | # Private variables 7 | salutation = 'Hello' 8 | 9 | # Private constructor 10 | class Greeter 11 | @greet = -> 12 | salutation 13 | 14 | # Public API for configuration 15 | @setSalutation = (s) -> 16 | salutation = s 17 | 18 | # Method for instantiating 19 | @$get = -> 20 | new Greeter() 21 | ] 22 | -------------------------------------------------------------------------------- /templates/coffeescript/service/service.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .service '<%= _.classify(name) %>', () -> 5 | # AngularJS will instantiate a singleton by calling "new" on this function 6 | -------------------------------------------------------------------------------- /templates/coffeescript/service/value.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .value '<%= _.camelize(name) %>', 42 5 | -------------------------------------------------------------------------------- /templates/coffeescript/spec/controller.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | describe 'Controller: <%= _.classify(name) %>Ctrl', () -> 4 | 5 | # load the controller's module 6 | beforeEach module '<%= _.camelize(appname) %>App' 7 | 8 | <%= _.classify(name) %>Ctrl = {} 9 | scope = {} 10 | 11 | # Initialize the controller and a mock scope 12 | beforeEach inject ($controller, $rootScope) -> 13 | scope = $rootScope.$new() 14 | <%= _.classify(name) %>Ctrl = $controller '<%= _.classify(name) %>Ctrl', { 15 | $scope: scope 16 | } 17 | 18 | it 'should attach a list of awesomeThings to the scope', () -> 19 | expect(scope.awesomeThings.length).toBe 3 20 | -------------------------------------------------------------------------------- /templates/coffeescript/spec/directive.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | describe 'Directive: <%= _.camelize(name) %>', () -> 4 | 5 | # load the directive's module 6 | beforeEach module '<%= _.camelize(appname) %>App' 7 | 8 | scope = {} 9 | 10 | beforeEach inject ($controller, $rootScope) -> 11 | scope = $rootScope.$new() 12 | 13 | it 'should make hidden element visible', inject ($compile) -> 14 | element = angular.element '<<%= _.dasherize(name) %>><%= _.dasherize(name) %>>' 15 | element = $compile(element) scope 16 | expect(element.text()).toBe 'this is the <%= _.camelize(name) %> directive' 17 | -------------------------------------------------------------------------------- /templates/coffeescript/spec/filter.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | describe 'Filter: <%= _.camelize(name) %>', () -> 4 | 5 | # load the filter's module 6 | beforeEach module '<%= _.camelize(appname) %>App' 7 | 8 | # initialize a new instance of the filter before each test 9 | <%= _.camelize(name) %> = {} 10 | beforeEach inject ($filter) -> 11 | <%= _.camelize(name) %> = $filter '<%= _.camelize(name) %>' 12 | 13 | it 'should return the input prefixed with "<%= _.camelize(name) %> filter:"', () -> 14 | text = 'angularjs' 15 | expect(<%= _.camelize(name) %> text).toBe ('<%= _.camelize(name) %> filter: ' + text) 16 | -------------------------------------------------------------------------------- /templates/coffeescript/spec/service.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | describe 'Service: <%= _.classify(name) %>', () -> 4 | 5 | # load the service's module 6 | beforeEach module '<%= _.classify(appname) %>App' 7 | 8 | # instantiate service 9 | <%= _.classify(name) %> = {} 10 | beforeEach inject (_<%= _.classify(name) %>_) -> 11 | <%= _.classify(name) %> = _<%= _.classify(name) %>_ 12 | 13 | it 'should do something', () -> 14 | expect(!!<%= _.classify(name) %>).toBe true 15 | -------------------------------------------------------------------------------- /templates/common/Gruntfile.js: -------------------------------------------------------------------------------- 1 | // Generated on <%= (new Date).toISOString().split('T')[0] %> using <%= pkg.name %> <%= pkg.version %> 2 | 'use strict'; 3 | 4 | // # Globbing 5 | // for performance reasons we're only matching one level down: 6 | // 'test/spec/**/**/*.js' 7 | // use this if you want to recursively match all subfolders: 8 | // 'test/spec/**/*.js' 9 | 10 | module.exports = function (grunt) { 11 | require('load-grunt-tasks')(grunt); 12 | require('time-grunt')(grunt); 13 | 14 | grunt.initConfig({ 15 | yeoman: { 16 | // configurable paths 17 | app: require('./bower.json').appPath || 'app', 18 | dist: 'dist' 19 | }, 20 | watch: { 21 | coffee: { 22 | files: ['<%%= yeoman.app %>/scripts/**/**/*.coffee'], 23 | tasks: ['coffee:dist'] 24 | }, 25 | coffeeTest: { 26 | files: ['test/spec/**/**/*.coffee'], 27 | tasks: ['coffee:test'] 28 | },<% if (compassBootstrap || usingSass) { %> 29 | compass: { 30 | files: ['<%%= yeoman.app %>/styles/**/**/*.{scss,sass}'], 31 | tasks: ['compass:server', 'autoprefixer'] 32 | },<% } %> 33 | styles: { 34 | files: ['<%%= yeoman.app %>/styles/**/**/*.css'], 35 | tasks: ['copy:styles', 'autoprefixer'] 36 | }, 37 | livereload: { 38 | options: { 39 | livereload: '<%%= connect.options.livereload %>' 40 | }, 41 | files: [ 42 | '<%%= yeoman.app %>/**/**/*.html', 43 | '.tmp/styles/**/**/*.css', 44 | '{.tmp,<%%= yeoman.app %>}/scripts/**/**/*.js', 45 | '<%%= yeoman.app %>/images/**/**/*.{png,jpg,jpeg,gif,webp,svg}' 46 | ] 47 | } 48 | }, 49 | autoprefixer: { 50 | options: ['last 1 version'], 51 | dist: { 52 | files: [{ 53 | expand: true, 54 | cwd: '.tmp/styles/', 55 | src: '**/**/*.css', 56 | dest: '.tmp/styles/' 57 | }] 58 | } 59 | }, 60 | connect: { 61 | options: { 62 | port: 9000, 63 | // Change this to '0.0.0.0' to access the server from outside. 64 | hostname: 'localhost', 65 | livereload: 35729 66 | }, 67 | livereload: { 68 | options: { 69 | open: true, 70 | base: [ 71 | '.tmp', 72 | '<%%= yeoman.app %>' 73 | ] 74 | } 75 | }, 76 | test: { 77 | options: { 78 | port: 9001, 79 | base: [ 80 | '.tmp', 81 | 'test', 82 | '<%%= yeoman.app %>' 83 | ] 84 | } 85 | }, 86 | dist: { 87 | options: { 88 | base: '<%%= yeoman.dist %>' 89 | } 90 | } 91 | }, 92 | clean: { 93 | dist: { 94 | files: [{ 95 | dot: true, 96 | src: [ 97 | '.tmp', 98 | '<%%= yeoman.dist %>/*', 99 | '!<%%= yeoman.dist %>/.git*' 100 | ] 101 | }] 102 | }, 103 | server: '.tmp' 104 | }, 105 | jshint: { 106 | options: { 107 | jshintrc: '.jshintrc' 108 | }, 109 | all: [ 110 | 'Gruntfile.js', 111 | '<%%= yeoman.app %>/scripts/**/**/*.js' 112 | ] 113 | }, 114 | coffee: { 115 | options: { 116 | sourceMap: true, 117 | sourceRoot: '' 118 | }, 119 | dist: { 120 | files: [{ 121 | expand: true, 122 | cwd: '<%%= yeoman.app %>/scripts', 123 | src: '**/**/*.coffee', 124 | dest: '.tmp/scripts', 125 | ext: '.js' 126 | }] 127 | }, 128 | test: { 129 | files: [{ 130 | expand: true, 131 | cwd: 'test/spec', 132 | src: '**/**/*.coffee', 133 | dest: '.tmp/spec', 134 | ext: '.js' 135 | }] 136 | } 137 | },<% if (compassBootstrap || usingSass) { %> 138 | compass: { 139 | options: { 140 | sassDir: '<%%= yeoman.app %>/styles', 141 | cssDir: '.tmp/styles', 142 | generatedImagesDir: '.tmp/images/generated', 143 | imagesDir: '<%%= yeoman.app %>/images', 144 | javascriptsDir: '<%%= yeoman.app %>/scripts', 145 | fontsDir: '<%%= yeoman.app %>/styles/fonts', 146 | importPath: '<%%= yeoman.app %>/bower_components', 147 | httpImagesPath: '/images', 148 | httpGeneratedImagesPath: '/images/generated', 149 | httpFontsPath: '/styles/fonts', 150 | relativeAssets: false 151 | }, 152 | dist: {}, 153 | server: { 154 | options: { 155 | debugInfo: true 156 | } 157 | } 158 | },<% } %> 159 | // not used since Uglify task does concat, 160 | // but still available if needed 161 | /*concat: { 162 | dist: {} 163 | },*/ 164 | rev: { 165 | dist: { 166 | files: { 167 | src: [ 168 | '<%%= yeoman.dist %>/scripts/**/**/*.js', 169 | '<%%= yeoman.dist %>/styles/**/**/*.css', 170 | '<%%= yeoman.dist %>/images/**/**/*.{png,jpg,jpeg,gif,webp,svg}', 171 | '<%%= yeoman.dist %>/styles/fonts/*' 172 | ] 173 | } 174 | } 175 | }, 176 | useminPrepare: { 177 | html: '<%%= yeoman.app %>/index.html', 178 | options: { 179 | dest: '<%%= yeoman.dist %>' 180 | } 181 | }, 182 | usemin: { 183 | html: ['<%%= yeoman.dist %>/**/**/*.html'], 184 | css: ['<%%= yeoman.dist %>/styles/**/**/*.css'], 185 | options: { 186 | dirs: ['<%%= yeoman.dist %>'] 187 | } 188 | }, 189 | imagemin: { 190 | dist: { 191 | files: [{ 192 | expand: true, 193 | cwd: '<%%= yeoman.app %>/images', 194 | src: '**/**/*.{png,jpg,jpeg}', 195 | dest: '<%%= yeoman.dist %>/images' 196 | }] 197 | } 198 | }, 199 | svgmin: { 200 | dist: { 201 | files: [{ 202 | expand: true, 203 | cwd: '<%%= yeoman.app %>/images', 204 | src: '**/**/*.svg', 205 | dest: '<%%= yeoman.dist %>/images' 206 | }] 207 | } 208 | }, 209 | cssmin: { 210 | // By default, your `index.html` will take care of 211 | // minification. This option is pre-configured if you do not wish to use 212 | // Usemin blocks. 213 | // dist: { 214 | // files: { 215 | // '<%%= yeoman.dist %>/styles/main.css': [ 216 | // '.tmp/styles/**/**/*.css', 217 | // '<%%= yeoman.app %>/styles/**/**/*.css' 218 | // ] 219 | // } 220 | // } 221 | }, 222 | htmlmin: { 223 | dist: { 224 | options: { 225 | /*removeCommentsFromCDATA: true, 226 | // https://github.com/yeoman/grunt-usemin/issues/44 227 | //collapseWhitespace: true, 228 | collapseBooleanAttributes: true, 229 | removeAttributeQuotes: true, 230 | removeRedundantAttributes: true, 231 | useShortDoctype: true, 232 | removeEmptyAttributes: true, 233 | removeOptionalTags: true*/ 234 | }, 235 | files: [{ 236 | expand: true, 237 | cwd: '<%%= yeoman.app %>', 238 | src: ['*.html', 'views/*.html'], 239 | dest: '<%%= yeoman.dist %>' 240 | }] 241 | } 242 | }, 243 | // Put files not handled in other tasks here 244 | copy: { 245 | dist: { 246 | files: [{ 247 | expand: true, 248 | dot: true, 249 | cwd: '<%%= yeoman.app %>', 250 | dest: '<%%= yeoman.dist %>', 251 | src: [ 252 | '*.{ico,png,txt}', 253 | '.htaccess', 254 | 'bower_components/**/*', 255 | 'images/**/**/*.{gif,webp}', 256 | 'styles/fonts/*' 257 | ] 258 | }, { 259 | expand: true, 260 | cwd: '.tmp/images', 261 | dest: '<%%= yeoman.dist %>/images', 262 | src: [ 263 | 'generated/*' 264 | ] 265 | }] 266 | }, 267 | styles: { 268 | expand: true, 269 | cwd: '<%%= yeoman.app %>/styles', 270 | dest: '.tmp/styles/', 271 | src: '**/**/*.css' 272 | } 273 | }, 274 | concurrent: { 275 | server: [ 276 | 'coffee:dist',<% if (compassBootstrap || usingSass) { %> 277 | 'compass:server',<% } %> 278 | 'copy:styles' 279 | ], 280 | test: [ 281 | 'coffee',<% if (compassBootstrap || usingSass) { %> 282 | 'compass',<% } %> 283 | 'copy:styles' 284 | ], 285 | dist: [ 286 | 'coffee',<% if (compassBootstrap || usingSass) { %> 287 | 'compass:dist',<% } %> 288 | 'copy:styles', 289 | 'imagemin', 290 | 'svgmin', 291 | 'htmlmin' 292 | ] 293 | }, 294 | karma: { 295 | unit: { 296 | configFile: 'karma.conf.js', 297 | singleRun: true 298 | } 299 | }, 300 | cdnify: { 301 | dist: { 302 | html: ['<%%= yeoman.dist %>/*.html'] 303 | } 304 | }, 305 | ngmin: { 306 | dist: { 307 | files: [{ 308 | expand: true, 309 | cwd: '<%%= yeoman.dist %>/scripts', 310 | src: '*.js', 311 | dest: '<%%= yeoman.dist %>/scripts' 312 | }] 313 | } 314 | }, 315 | uglify: { 316 | dist: { 317 | files: { 318 | '<%%= yeoman.dist %>/scripts/scripts.js': [ 319 | '<%%= yeoman.dist %>/scripts/scripts.js' 320 | ] 321 | } 322 | } 323 | } 324 | }); 325 | 326 | grunt.registerTask('server', function (target) { 327 | if (target === 'dist') { 328 | return grunt.task.run(['build', 'connect:dist:keepalive']); 329 | } 330 | 331 | grunt.task.run([ 332 | 'clean:server', 333 | 'concurrent:server', 334 | 'autoprefixer', 335 | 'connect:livereload', 336 | 'watch' 337 | ]); 338 | }); 339 | 340 | grunt.registerTask('test', [ 341 | 'clean:server', 342 | 'concurrent:test', 343 | 'autoprefixer', 344 | 'connect:test', 345 | 'karma' 346 | ]); 347 | 348 | grunt.registerTask('build', [ 349 | 'clean:dist', 350 | 'useminPrepare', 351 | 'concurrent:dist', 352 | 'autoprefixer', 353 | 'concat', 354 | 'copy:dist', 355 | 'cdnify', 356 | 'ngmin', 357 | 'cssmin', 358 | 'uglify', 359 | 'rev', 360 | 'usemin' 361 | ]); 362 | 363 | grunt.registerTask('default', [ 364 | 'jshint', 365 | 'test', 366 | 'build' 367 | ]); 368 | }; 369 | -------------------------------------------------------------------------------- /templates/common/_bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= _.camelize(appname) %>", 3 | "version": "0.0.0", 4 | "dependencies": { 5 | "angular": ">=1.3.14", 6 | "json3": ">=3.2.4",<% if (bootstrap) { %> 7 | "jquery": ">=2.1.3", 8 | "twitter-bootstrap-sass": ">=3.3.3", 9 | <% } %>"es5-shim": "~2.0.8"<% if (resourceModule) { %>, 10 | "angular-resource": ">=1.3.14" <% } %><% if (cookiesModule) { %>, 11 | "angular-cookies": ">=1.3.14" <% } %><% if (sanitizeModule) { %>, 12 | "angular-sanitize": ">=1.3.14" <% } %><% if (uirouterModule) { %>, 13 | "angular-ui-router": "*"<% } %> 14 | }, 15 | "devDependencies": { 16 | "angular-mocks": ">=1.3.14", 17 | "angular-scenario": ">=1.3.14" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /templates/common/_package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= _.slugify(appname) %>", 3 | "version": "0.0.0", 4 | "dependencies": {}, 5 | "devDependencies": { 6 | "grunt": "~0.4.5", 7 | "grunt-contrib-copy": "~0.8.0", 8 | "grunt-contrib-concat": "~0.5.1", 9 | "grunt-contrib-coffee": "~0.13.0", 10 | "grunt-contrib-uglify": "~0.8.0", 11 | "grunt-contrib-compass": "~1.0.1", 12 | "grunt-contrib-jshint": "~0.11.0", 13 | "grunt-contrib-cssmin": "~0.12.2", 14 | "grunt-contrib-connect": "~0.9.0", 15 | "grunt-contrib-clean": "~0.6.0", 16 | "grunt-contrib-htmlmin": "~0.4.0", 17 | "grunt-contrib-imagemin": "~1.0.1", 18 | "grunt-contrib-watch": "~0.6.1", 19 | "grunt-autoprefixer": "~2.2.0", 20 | "grunt-usemin": "~3.0.0", 21 | "grunt-svgmin": "~2.0.1", 22 | "grunt-rev": "~0.1.0", 23 | "grunt-concurrent": "~1.0.0", 24 | "load-grunt-tasks": "~3.1.0", 25 | "grunt-google-cdn": "~0.4.3", 26 | "grunt-ngmin": "~0.0.3", 27 | "time-grunt": "~1.1.0" 28 | }, 29 | "engines": { 30 | "node": ">=0.10.0" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /templates/common/gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | .tmp 4 | .sass-cache 5 | app/bower_components 6 | -------------------------------------------------------------------------------- /templates/common/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |Sorry, but the page you were trying to view does not exist.
146 |It looks like this was the result of either:
147 |You now have
4 |installed.
8 |This is the <%= name %> view.
2 | -------------------------------------------------------------------------------- /templates/javascript-min/app.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | <% if(uirouterModules){ %> 4 | angular.module('<%= _.camelize(appname) %>App', [<%= angularModules %>]) 5 | .config(function ($stateProvider, $urlRouterProvider) { 6 | //delete $httpProvider.defaults.headers.common['X-Requested-With']; 7 | $stateProvider 8 | .state('index', { 9 | url: '/', 10 | templateUrl: 'views/main.html', 11 | controller:'MainCtrl' 12 | }) 13 | $urlRouterProvider.otherwise('/'); 14 | }) 15 | <% }else{ %> 16 | angular.module('<%= _.camelize(appname) %>App', [<%= angularModules %>]) 17 | .config(function ($routeProvider) { 18 | $routeProvider 19 | .when('/', { 20 | templateUrl: 'views/main.html', 21 | controller: 'MainCtrl' 22 | }) 23 | .otherwise({ 24 | redirectTo: '/' 25 | }); 26 | }); 27 | <% } %> 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /templates/javascript-min/controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .controller('<%= _.classify(name) %>Ctrl', ['$scope', function ($scope) { 5 | $scope.awesomeThings = [ 6 | 'HTML5 Boilerplate', 7 | 'AngularJS', 8 | 'Karma' 9 | ]; 10 | }]); 11 | -------------------------------------------------------------------------------- /templates/javascript-min/decorator.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .config(['$provide', function ($provide) { 5 | $provide.decorator('<%= _.camelize(name) %>', function ($delegate) { 6 | // decorate the $delegate 7 | return $delegate; 8 | }); 9 | }]); 10 | -------------------------------------------------------------------------------- /templates/javascript-min/directive.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .directive('<%= _.camelize(name) %>', [function () { 5 | return { 6 | template: '', 7 | restrict: 'E', 8 | link: function postLink(scope, element, attrs) { 9 | element.text('this is the <%= _.camelize(name) %> directive'); 10 | } 11 | }; 12 | }]); 13 | -------------------------------------------------------------------------------- /templates/javascript-min/filter.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .filter('<%= _.camelize(name) %>', [function () { 5 | return function (input) { 6 | return '<%= _.camelize(name) %> filter: ' + input; 7 | }; 8 | }]); 9 | -------------------------------------------------------------------------------- /templates/javascript-min/service/constant.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .constant('<%= _.camelize(name) %>', 42); 5 | -------------------------------------------------------------------------------- /templates/javascript-min/service/factory.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .factory('<%= _.camelize(name) %>', [function() { 5 | // Service logic 6 | // ... 7 | 8 | var meaningOfLife = 42; 9 | 10 | // Public API here 11 | return { 12 | someMethod: function() { 13 | return meaningOfLife; 14 | } 15 | }; 16 | }]); 17 | -------------------------------------------------------------------------------- /templates/javascript-min/service/provider.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .provider('<%= _.camelize(name) %>', [function() { 5 | 6 | // Private variables 7 | var salutation = 'Hello'; 8 | 9 | // Private constructor 10 | function Greeter() { 11 | this.greet = function() { 12 | return salutation; 13 | }; 14 | } 15 | 16 | // Public API for configuration 17 | this.setSalutation = function(s) { 18 | salutation = s; 19 | }; 20 | 21 | // Method for instantiating 22 | this.$get = function() { 23 | return new Greeter(); 24 | }; 25 | }]); 26 | -------------------------------------------------------------------------------- /templates/javascript-min/service/service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .service('<%= _.classify(name) %>', function <%= _.classify(name) %>() { 5 | // AngularJS will instantiate a singleton by calling "new" on this function 6 | }); 7 | -------------------------------------------------------------------------------- /templates/javascript-min/service/value.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .value('<%= _.camelize(name) %>', 42); 5 | -------------------------------------------------------------------------------- /templates/javascript-min/spec/controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | describe('Controller: <%= _.classify(name) %>Ctrl', function () { 4 | 5 | // load the controller's module 6 | beforeEach(module('<%= _.camelize(appname) %>App')); 7 | 8 | var <%= _.classify(name) %>Ctrl, 9 | scope; 10 | 11 | // Initialize the controller and a mock scope 12 | beforeEach(inject(function ($controller, $rootScope) { 13 | scope = $rootScope.$new(); 14 | <%= _.classify(name) %>Ctrl = $controller('<%= _.classify(name) %>Ctrl', { 15 | $scope: scope 16 | }); 17 | })); 18 | 19 | it('should attach a list of awesomeThings to the scope', function () { 20 | expect(scope.awesomeThings.length).toBe(3); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /templates/javascript-min/spec/directive.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | describe('Directive: <%= _.camelize(name) %>', function () { 4 | 5 | // load the directive's module 6 | beforeEach(module('<%= _.camelize(appname) %>App')); 7 | 8 | var element, 9 | scope; 10 | 11 | beforeEach(inject(function ($rootScope) { 12 | scope = $rootScope.$new(); 13 | })); 14 | 15 | it('should make hidden element visible', inject(function ($compile) { 16 | element = angular.element('<<%= _.dasherize(name) %>><%= _.dasherize(name) %>>'); 17 | element = $compile(element)(scope); 18 | expect(element.text()).toBe('this is the <%= _.camelize(name) %> directive'); 19 | })); 20 | }); 21 | -------------------------------------------------------------------------------- /templates/javascript-min/spec/filter.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | describe('Filter: <%= _.camelize(name) %>', function () { 4 | 5 | // load the filter's module 6 | beforeEach(module('<%= _.camelize(appname) %>App')); 7 | 8 | // initialize a new instance of the filter before each test 9 | var <%= _.camelize(name) %>; 10 | beforeEach(inject(function($filter) { 11 | <%= _.camelize(name) %> = $filter('<%= _.camelize(name) %>'); 12 | })); 13 | 14 | it('should return the input prefixed with "<%= _.camelize(name) %> filter:"', function () { 15 | var text = 'angularjs'; 16 | expect(<%= _.camelize(name) %>(text)).toBe('<%= _.camelize(name) %> filter: ' + text); 17 | }); 18 | 19 | }); 20 | -------------------------------------------------------------------------------- /templates/javascript-min/spec/service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | describe('Service: <%= _.classify(name) %>', function () { 4 | 5 | // load the service's module 6 | beforeEach(module('<%= _.classify(appname) %>App')); 7 | 8 | // instantiate service 9 | var <%= _.classify(name) %>; 10 | beforeEach(inject(function(_<%= _.classify(name) %>_) { 11 | <%= _.classify(name) %> = _<%= _.classify(name) %>_; 12 | })); 13 | 14 | it('should do something', function () { 15 | expect(!!<%= _.classify(name) %>).toBe(true); 16 | }); 17 | 18 | }); 19 | -------------------------------------------------------------------------------- /templates/javascript/app.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | <% if(uirouterModules){ %> 4 | angular.module('<%= _.camelize(appname) %>App', [<%= angularModules %>]) 5 | .config(function ($stateProvider, $urlRouterProvider) { 6 | //delete $httpProvider.defaults.headers.common['X-Requested-With']; 7 | $urlRouterProvider.otherwise('/'); 8 | $stateProvider 9 | .state('index', { 10 | url: '/', 11 | templateUrl: 'views/main.html', 12 | controller:'MainCtrl' 13 | }) 14 | }) 15 | <% }else{ %> 16 | angular.module('<%= _.camelize(appname) %>App', [<%= angularModules %>]) 17 | .config(function ($routeProvider) { 18 | $routeProvider 19 | .when('/', { 20 | templateUrl: 'views/main.html', 21 | controller: 'MainCtrl' 22 | }) 23 | .otherwise({ 24 | redirectTo: '/' 25 | }); 26 | }); 27 | <% } %> 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /templates/javascript/controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .controller('<%= _.classify(name) %>Ctrl', function ($scope) { 5 | $scope.awesomeThings = [ 6 | 'HTML5 Boilerplate', 7 | 'AngularJS', 8 | 'Karma' 9 | ]; 10 | }); 11 | -------------------------------------------------------------------------------- /templates/javascript/decorator.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .config(function ($provide) { 5 | $provide.decorator('<%= _.camelize(name) %>', function ($delegate) { 6 | // decorate the $delegate 7 | return $delegate; 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /templates/javascript/directive.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .directive('<%= _.camelize(name) %>', function () { 5 | return { 6 | template: '', 7 | restrict: 'E', 8 | link: function postLink(scope, element, attrs) { 9 | element.text('this is the <%= _.camelize(name) %> directive'); 10 | } 11 | }; 12 | }); 13 | -------------------------------------------------------------------------------- /templates/javascript/filter.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .filter('<%= _.camelize(name) %>', function () { 5 | return function (input) { 6 | return '<%= _.camelize(name) %> filter: ' + input; 7 | }; 8 | }); 9 | -------------------------------------------------------------------------------- /templates/javascript/service/constant.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .constant('<%= _.camelize(name) %>', 42); 5 | -------------------------------------------------------------------------------- /templates/javascript/service/factory.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .factory('<%= _.camelize(name) %>', function () { 5 | // Service logic 6 | // ... 7 | 8 | var meaningOfLife = 42; 9 | 10 | // Public API here 11 | return { 12 | someMethod: function () { 13 | return meaningOfLife; 14 | } 15 | }; 16 | }); 17 | -------------------------------------------------------------------------------- /templates/javascript/service/provider.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .provider('<%= _.camelize(name) %>', function () { 5 | 6 | // Private variables 7 | var salutation = 'Hello'; 8 | 9 | // Private constructor 10 | function Greeter() { 11 | this.greet = function () { 12 | return salutation; 13 | }; 14 | } 15 | 16 | // Public API for configuration 17 | this.setSalutation = function (s) { 18 | salutation = s; 19 | }; 20 | 21 | // Method for instantiating 22 | this.$get = function () { 23 | return new Greeter(); 24 | }; 25 | }); 26 | -------------------------------------------------------------------------------- /templates/javascript/service/service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .service('<%= _.classify(name) %>', function <%= _.classify(name) %>() { 5 | // AngularJS will instantiate a singleton by calling "new" on this function 6 | }); 7 | -------------------------------------------------------------------------------- /templates/javascript/service/value.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('<%= _.camelize(appname) %>App') 4 | .value('<%= _.camelize(name) %>', 42); 5 | -------------------------------------------------------------------------------- /templates/javascript/spec/controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | describe('Controller: <%= _.classify(name) %>Ctrl', function () { 4 | 5 | // load the controller's module 6 | beforeEach(module('<%= _.camelize(appname) %>App')); 7 | 8 | var <%= _.classify(name) %>Ctrl, 9 | scope; 10 | 11 | // Initialize the controller and a mock scope 12 | beforeEach(inject(function ($controller, $rootScope) { 13 | scope = $rootScope.$new(); 14 | <%= _.classify(name) %>Ctrl = $controller('<%= _.classify(name) %>Ctrl', { 15 | $scope: scope 16 | }); 17 | })); 18 | 19 | it('should attach a list of awesomeThings to the scope', function () { 20 | expect(scope.awesomeThings.length).toBe(3); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /templates/javascript/spec/directive.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | describe('Directive: <%= _.camelize(name) %>', function () { 4 | 5 | // load the directive's module 6 | beforeEach(module('<%= _.camelize(appname) %>App')); 7 | 8 | var element, 9 | scope; 10 | 11 | beforeEach(inject(function ($rootScope) { 12 | scope = $rootScope.$new(); 13 | })); 14 | 15 | it('should make hidden element visible', inject(function ($compile) { 16 | element = angular.element('<<%= _.dasherize(name) %>><%= _.dasherize(name) %>>'); 17 | element = $compile(element)(scope); 18 | expect(element.text()).toBe('this is the <%= _.camelize(name) %> directive'); 19 | })); 20 | }); 21 | -------------------------------------------------------------------------------- /templates/javascript/spec/filter.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | describe('Filter: <%= _.camelize(name) %>', function () { 4 | 5 | // load the filter's module 6 | beforeEach(module('<%= _.camelize(appname) %>App')); 7 | 8 | // initialize a new instance of the filter before each test 9 | var <%= _.camelize(name) %>; 10 | beforeEach(inject(function ($filter) { 11 | <%= _.camelize(name) %> = $filter('<%= _.camelize(name) %>'); 12 | })); 13 | 14 | it('should return the input prefixed with "<%= _.camelize(name) %> filter:"', function () { 15 | var text = 'angularjs'; 16 | expect(<%= _.camelize(name) %>(text)).toBe('<%= _.camelize(name) %> filter: ' + text); 17 | }); 18 | 19 | }); 20 | -------------------------------------------------------------------------------- /templates/javascript/spec/service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | describe('Service: <%= _.classify(name) %>', function () { 4 | 5 | // load the service's module 6 | beforeEach(module('<%= _.classify(appname) %>App')); 7 | 8 | // instantiate service 9 | var <%= _.classify(name) %>; 10 | beforeEach(inject(function (_<%= _.classify(name) %>_) { 11 | <%= _.classify(name) %> = _<%= _.classify(name) %>_; 12 | })); 13 | 14 | it('should do something', function () { 15 | expect(!!<%= _.classify(name) %>).toBe(true); 16 | }); 17 | 18 | }); 19 | -------------------------------------------------------------------------------- /test/test-appname-substitution.js: -------------------------------------------------------------------------------- 1 | /*global describe, before, it, beforeEach */ 2 | 'use strict'; 3 | var fs = require('fs'); 4 | var assert = require('assert'); 5 | var path = require('path'); 6 | var util = require('util'); 7 | var generators = require('yeoman-generator'); 8 | var helpers = require('yeoman-generator').test; 9 | 10 | 11 | describe('Angular generator template mechanism', function () { 12 | //TODO: Add underscore dependency and test with _.camelize(folderName); 13 | var folderName = 'UpperCaseBug'; 14 | var angular; 15 | 16 | beforeEach(function (done) { 17 | var deps = [ 18 | '../../app', 19 | '../../common', 20 | '../../controller', 21 | '../../main', [ 22 | helpers.createDummyGenerator(), 23 | 'karma:app' 24 | ] 25 | ]; 26 | helpers.testDirectory(path.join(__dirname, folderName), function (err) { 27 | if (err) { 28 | done(err); 29 | } 30 | angular = helpers.createGenerator('angular-ui-router:app', deps); 31 | angular.options['skip-install'] = true; 32 | done(); 33 | }); 34 | }); 35 | 36 | it('should generate the same appName in every file', function (done) { 37 | var expectedAppName = folderName + 'App'; 38 | var expected = [ 39 | 'app/scripts/app.js', 40 | 'app/scripts/controllers/main.js', 41 | 'app/index.html', 42 | 'test/spec/controllers/main.js' 43 | ]; 44 | helpers.mockPrompt(angular, { 45 | bootstrap: true, 46 | compassBoostrap: true, 47 | modules: [] 48 | }); 49 | 50 | angular.run({}, function () { 51 | // Check if all files are created for the test 52 | helpers.assertFiles(expected); 53 | 54 | // read JS Files 55 | var app_js = fs.readFileSync('app/scripts/app.js', 'utf8'); 56 | var main_js = fs.readFileSync('app/scripts/controllers/main.js', 'utf8'); 57 | var main_test_js = fs.readFileSync('test/spec/controllers/main.js', 'utf8'); 58 | 59 | // Test JS Files 60 | var regex_js = new RegExp('module\\(\'' + expectedAppName + '\''); 61 | assert.ok(regex_js.test(app_js), 'app.js template using a wrong appName'); 62 | assert.ok(regex_js.test(main_js), 'main.js template using a wrong appName'); 63 | assert.ok(regex_js.test(main_test_js), 'controller spec template using a wrong appName'); 64 | 65 | // read HTML file 66 | var index_html = fs.readFileSync('app/index.html', 'utf8'); 67 | 68 | // Test HTML File 69 | var regex_html = new RegExp('ng-app=\"' + expectedAppName + '\"'); 70 | assert.ok(regex_html.test(index_html), 'index.html template using a wrong appName'); 71 | done(); 72 | }); 73 | }); 74 | }); 75 | -------------------------------------------------------------------------------- /test/test-file-creation.js: -------------------------------------------------------------------------------- 1 | /*global describe, before, it, beforeEach */ 2 | 'use strict'; 3 | var fs = require('fs'); 4 | var assert = require('assert'); 5 | var path = require('path'); 6 | var util = require('util'); 7 | var generators = require('yeoman-generator'); 8 | var helpers = require('yeoman-generator').test; 9 | var _ = require('underscore.string'); 10 | 11 | describe('angular-ui-router generator', function () { 12 | var angular; 13 | 14 | beforeEach(function (done) { 15 | var deps = [ 16 | '../../app', 17 | '../../common', 18 | '../../controller', 19 | '../../main', [ 20 | helpers.createDummyGenerator(), 21 | 'karma:app' 22 | ] 23 | ]; 24 | helpers.testDirectory(path.join(__dirname, 'temp'), function (err) { 25 | if (err) { 26 | done(err); 27 | } 28 | angular = helpers.createGenerator('angular-ui-router:app', deps); 29 | angular.options['skip-install'] = true; 30 | done(); 31 | }); 32 | }); 33 | 34 | it('should generate dotfiles', function (done) { 35 | helpers.mockPrompt(angular, { 36 | bootstrap: true, 37 | compassBoostrap: true, 38 | modules: [] 39 | }); 40 | 41 | angular.run({}, function () { 42 | helpers.assertFiles(['.bowerrc', '.gitignore', '.editorconfig', '.jshintrc']); 43 | done(); 44 | }); 45 | }); 46 | 47 | it('creates expected files', function (done) { 48 | var expected = ['app/.htaccess', 49 | 'app/404.html', 50 | 'app/favicon.ico', 51 | 'app/robots.txt', 52 | 'app/styles/main.css', 53 | 'app/views/main.html', 54 | ['.bowerrc', /"directory": "app\/bower_components"/], 55 | 'Gruntfile.js', 56 | 'package.json', 57 | ['bower.json', /"name":\s+"temp"/], 58 | 'app/scripts/app.js', 59 | 'app/index.html', 60 | 'app/scripts/controllers/main.js', 61 | 'test/spec/controllers/main.js' 62 | ]; 63 | helpers.mockPrompt(angular, { 64 | bootstrap: true, 65 | compassBoostrap: true, 66 | modules: [] 67 | }); 68 | 69 | angular.run({}, function() { 70 | helpers.assertFiles(expected); 71 | done(); 72 | }); 73 | }); 74 | 75 | it('creates coffeescript files', function (done) { 76 | var expected = ['app/.htaccess', 77 | 'app/404.html', 78 | 'app/favicon.ico', 79 | 'app/robots.txt', 80 | 'app/styles/main.css', 81 | 'app/views/main.html', 82 | ['.bowerrc', /"directory": "app\/bower_components"/], 83 | 'Gruntfile.js', 84 | 'package.json', 85 | ['bower.json', /"name":\s+"temp"/], 86 | 'app/scripts/app.coffee', 87 | 'app/index.html', 88 | 'app/scripts/controllers/main.coffee', 89 | 'test/spec/controllers/main.coffee' 90 | ]; 91 | helpers.mockPrompt(angular, { 92 | bootstrap: true, 93 | compassBoostrap: true, 94 | modules: [] 95 | }); 96 | 97 | angular.env.options.coffee = true; 98 | angular.run([], function () { 99 | helpers.assertFiles(expected); 100 | done(); 101 | }); 102 | }); 103 | 104 | /** 105 | * Generic test function that can be used to cover the scenarios where a generator is creating both a source file 106 | * and a test file. The function will run the respective generator, and then check for the existence of the two 107 | * generated files. A RegExp check is done on each file, checking for the generated content with a pattern. 108 | * 109 | * The number of parameters is quite huge due to the many options in which the generated files differ, 110 | * e.g. Services start with an upper case letter, whereas filters, directives or constants start with a lower case 111 | * letter. 112 | * 113 | * The generated items all use the dummy name 'foo'. 114 | * 115 | * @param generatorType The type of generator to run, e.g. 'filter'. 116 | * @param specType The type of the generated spec file, e.g. 'service' - all service types (constant, value, ...) 117 | * use the same Service spec template. 118 | * @param targetDirectory The directory into which the files are generated, e.g. 'directives' - this will be 119 | * located under 'app/scripts' for the sources and 'test/spec' for the tests. 120 | * @param scriptNameFn The function used to create the name of the created item, e.g. _.classify to generate 'Foo', 121 | * or _.camelize to generate 'foo'. 122 | * @param specNameFn Same as scriptNameFn, but for the describe text used in the Spec file. Some generators use 123 | * _.classify, others use _.camelize. 124 | * @param suffix An optional suffix to be appended to the generated item name, e.g. 'Ctrl' for controllers, which 125 | * will generate 'FooCtrl'. 126 | * @param done The done function. 127 | */ 128 | function generatorTest(generatorType, specType, targetDirectory, scriptNameFn, specNameFn, suffix, done) { 129 | var angularGenerator; 130 | var name = 'foo'; 131 | var deps = [path.join('../..', generatorType)]; 132 | angularGenerator = helpers.createGenerator('angular-ui-router:' + generatorType, deps, [name]); 133 | 134 | helpers.mockPrompt(angular, { 135 | bootstrap: true, 136 | compassBoostrap: true, 137 | modules: [] 138 | }); 139 | angular.run([], function (){ 140 | angularGenerator.run([], function () { 141 | helpers.assertFiles([ 142 | [path.join('app/scripts', targetDirectory, name + '.js'), new RegExp(generatorType + '\\(\'' + scriptNameFn(name) + suffix + '\'', 'g')], 143 | [path.join('test/spec', targetDirectory, name + '.js'), new RegExp('describe\\(\'' + _.classify(specType) + ': ' + specNameFn(name) + suffix + '\'', 'g')] 144 | ]); 145 | done(); 146 | }); 147 | }); 148 | } 149 | 150 | describe('Controller', function () { 151 | it('should generate a new controller', function (done) { 152 | generatorTest('controller', 'controller', 'controllers', _.classify, _.classify, 'Ctrl', done); 153 | }); 154 | }); 155 | 156 | describe('Directive', function () { 157 | it('should generate a new directive', function (done) { 158 | generatorTest('directive', 'directive', 'directives', _.camelize, _.camelize, '', done); 159 | }); 160 | }); 161 | 162 | describe('Filter', function () { 163 | it('should generate a new filter', function (done) { 164 | generatorTest('filter', 'filter', 'filters', _.camelize, _.camelize, '', done); 165 | }); 166 | }); 167 | 168 | describe('Service', function () { 169 | function serviceTest (generatorType, nameFn, done) { 170 | generatorTest(generatorType, 'service', 'services', nameFn, _.classify, '', done); 171 | }; 172 | 173 | it('should generate a new constant', function (done) { 174 | serviceTest('constant', _.camelize, done); 175 | }); 176 | 177 | it('should generate a new service', function (done) { 178 | serviceTest('service', _.classify, done); 179 | }); 180 | 181 | it('should generate a new factory', function (done) { 182 | serviceTest('factory', _.camelize, done); 183 | }); 184 | 185 | it('should generate a new provider', function (done) { 186 | serviceTest('provider', _.camelize, done); 187 | }); 188 | 189 | it('should generate a new value', function (done) { 190 | serviceTest('value', _.camelize, done); 191 | }); 192 | }); 193 | 194 | describe('View', function () { 195 | it('should generate a new view', function (done) { 196 | var angularView; 197 | var deps = ['../../view']; 198 | angularView = helpers.createGenerator('angular-ui-router:view', deps, ['foo']); 199 | 200 | helpers.mockPrompt(angular, { 201 | bootstrap: true, 202 | compassBoostrap: true, 203 | modules: [] 204 | }); 205 | angular.run([], function (){ 206 | angularView.run([], function () { 207 | helpers.assertFiles([ 208 | ['app/views/foo.html'] 209 | ]); 210 | done(); 211 | }); 212 | }); 213 | }); 214 | 215 | it('should generate a new view in subdirectories', function (done) { 216 | var angularView; 217 | var deps = ['../../view']; 218 | angularView = helpers.createGenerator('angular-ui-router:view', deps, ['foo/bar']); 219 | 220 | helpers.mockPrompt(angular, { 221 | bootstrap: true, 222 | compassBoostrap: true, 223 | modules: [] 224 | }); 225 | angular.run([], function (){ 226 | angularView.run([], function () { 227 | helpers.assertFiles([ 228 | ['app/views/foo/bar.html'] 229 | ]); 230 | done(); 231 | }); 232 | }); 233 | }); 234 | }); 235 | }); 236 | -------------------------------------------------------------------------------- /util.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var path = require('path'); 3 | var fs = require('fs'); 4 | 5 | 6 | module.exports = { 7 | rewrite: rewrite, 8 | rewriteFile: rewriteFile 9 | }; 10 | 11 | function rewriteFile (args) { 12 | args.path = args.path || process.cwd(); 13 | var fullPath = path.join(args.path, args.file); 14 | 15 | args.haystack = fs.readFileSync(fullPath, 'utf8'); 16 | var body = rewrite(args); 17 | 18 | fs.writeFileSync(fullPath, body); 19 | } 20 | 21 | function escapeRegExp (str) { 22 | return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); 23 | } 24 | 25 | function rewrite (args) { 26 | // check if splicable is already in the body text 27 | var re = new RegExp(args.splicable.map(function (line) { 28 | return '\s*' + escapeRegExp(line); 29 | }).join('\n')); 30 | 31 | if (re.test(args.haystack)) { 32 | return args.haystack; 33 | } 34 | 35 | var lines = args.haystack.split('\n'); 36 | 37 | var otherwiseLineIndex = 0; 38 | lines.forEach(function (line, i) { 39 | if (line.indexOf(args.needle) !== -1) { 40 | otherwiseLineIndex = i; 41 | } 42 | }); 43 | 44 | var spaces = 0; 45 | while (lines[otherwiseLineIndex].charAt(spaces) === ' ') { 46 | spaces += 1; 47 | } 48 | 49 | var spaceStr = ''; 50 | while ((spaces -= 1) >= 0) { 51 | spaceStr += ' '; 52 | } 53 | 54 | lines.splice(otherwiseLineIndex, 0, args.splicable.map(function (line) { 55 | return spaceStr + line; 56 | }).join('\n')); 57 | 58 | return lines.join('\n'); 59 | } 60 | -------------------------------------------------------------------------------- /value/USAGE: -------------------------------------------------------------------------------- 1 | Description: 2 | Creates a new AngularJS service. 3 | Docs: http://docs.angularjs.org/guide/dev_guide.services.creating_services 4 | 5 | Example: 6 | yo angular-ui-router:value thing [--coffee] [--minsafe] 7 | 8 | This will create: 9 | app/scripts/services/thing.js 10 | -------------------------------------------------------------------------------- /value/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var util = require('util'); 3 | var ScriptBase = require('../script-base.js'); 4 | 5 | 6 | var Generator = module.exports = function Generator() { 7 | ScriptBase.apply(this, arguments); 8 | }; 9 | 10 | util.inherits(Generator, ScriptBase); 11 | 12 | Generator.prototype.createServiceFiles = function createServiceFiles() { 13 | this.generateSourceAndTest('service/value', 'spec/service', 'services'); 14 | }; 15 | -------------------------------------------------------------------------------- /view/USAGE: -------------------------------------------------------------------------------- 1 | Description: 2 | Creates a new AngularJS view 3 | 4 | Example: 5 | yo angular-ui-router:view thing 6 | 7 | This will create: 8 | app/views/thing.html 9 | -------------------------------------------------------------------------------- /view/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var path = require('path'); 3 | var util = require('util'); 4 | var yeoman = require('yeoman-generator'); 5 | 6 | 7 | var Generator = module.exports = function Generator() { 8 | yeoman.generators.NamedBase.apply(this, arguments); 9 | this.sourceRoot(path.join(__dirname, '../templates')); 10 | 11 | if (typeof this.env.options.appPath === 'undefined') { 12 | try { 13 | this.env.options.appPath = require(path.join(process.cwd(), 'bower.json')).appPath; 14 | } catch (e) {} 15 | this.env.options.appPath = this.env.options.appPath || 'app'; 16 | } 17 | }; 18 | 19 | util.inherits(Generator, yeoman.generators.NamedBase); 20 | 21 | Generator.prototype.createViewFiles = function createViewFiles() { 22 | this.template('common/view.html', path.join(this.env.options.appPath, 'views', this.name + '.html')); 23 | }; 24 | --------------------------------------------------------------------------------