├── .editorconfig ├── .gitattributes ├── .gitignore ├── .jshintrc ├── .travis.yml ├── CHANGELOG.md ├── Gruntfile.js ├── README.MD ├── README.md ├── app ├── USAGE ├── index.js └── templates │ ├── bootstrap.css │ ├── images │ ├── glyphicons-halflings-white.png │ └── glyphicons-halflings.png │ └── styles │ ├── css │ ├── bootstrap.css │ └── main.css │ └── 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 ├── 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 │ ├── Procfile │ ├── _bower.json │ ├── _package.json │ ├── app.js │ ├── bower.json │ ├── gitignore │ ├── index.html │ ├── package.json │ ├── root │ │ ├── .bowerrc │ │ ├── .editorconfig │ │ ├── .gitattributes │ │ ├── .jshintrc │ │ ├── app │ │ │ ├── .buildignore │ │ │ ├── .htaccess │ │ │ ├── 404.html │ │ │ ├── favicon.ico │ │ │ ├── robots.txt │ │ │ ├── styles │ │ │ │ └── main.css │ │ │ └── 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 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '0.10' 4 | - '0.8' 5 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | ## v0.3.1 (2013-07-24) 3 | 4 | 5 | #* **Bug Fixes:** 6 | 7 | * **app:** 8 | * order of script inclusions ([9919b2d0](http://github.com/yeoman/generator-angular/commit/9919b2d0bb749cbe5e795608c2b93c3504e3298b), closes [#278](http://github.com/yeoman/generator-angular/issues/278)) 9 | * copy glyphicons for sass ([2c458009](http://github.com/yeoman/generator-angular/commit/2c4580096572678de6212c8592fb553c10b3a4c0), closes [#269](http://github.com/yeoman/generator-angular/issues/269)) 10 | * add jQuery \' 118 | ] 119 | }); 120 | } catch (e) { 121 | console.log('\nUnable to find '.yellow + fullPath + '. Reference to '.yellow + this._dest(src) + '.js ' + 'not added.\n'.yellow); 122 | } 123 | }; 124 | -------------------------------------------------------------------------------- /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:service thing [--coffee] [--minsafe] 7 | 8 | This will create: 9 | app/scripts/services/thing.js 10 | -------------------------------------------------------------------------------- /service/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var path = require('path'); 3 | var util = require('util'); 4 | var ScriptBase = require('../script-base.js'); 5 | var angularUtils = require('../util.js'); 6 | 7 | 8 | module.exports = Generator; 9 | 10 | function Generator() { 11 | ScriptBase.apply(this, arguments); 12 | } 13 | 14 | util.inherits(Generator, ScriptBase); 15 | 16 | Generator.prototype.createServiceFiles = function createServiceFiles() { 17 | this.appTemplate('service/service'); 18 | this.testTemplate('spec/service'); 19 | }; 20 | -------------------------------------------------------------------------------- /templates/coffeescript-min/app.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | angular.module('<%= moduleName %>', []) 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('<%= moduleName %>') 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('<%= moduleName %>').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('<%= moduleName %>') 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('<%= moduleName %>') 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('<%= moduleName %>') 4 | .constant '<%= _.camelize(name) %>', 42 5 | -------------------------------------------------------------------------------- /templates/coffeescript-min/service/factory.coffee: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('<%= moduleName %>') 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('<%= moduleName %>') 4 | .provider '<%= _.camelize(name) %>', [() -> 5 | 6 | # Private variables 7 | salutation = 'Hello' 8 | 9 | # Private constructor 10 | Greeter () -> 11 | this.greet = () { 12 | salutation 13 | 14 | # Public API for configuration 15 | this.setSalutation = (s) -> 16 | salutation = s 17 | 18 | # Method for instantiating 19 | this.$get = () -> 20 | new Greeter() 21 | ] 22 | -------------------------------------------------------------------------------- /templates/coffeescript-min/service/service.coffee: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('<%= moduleName %>') 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('<%= moduleName %>') 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 '<%= moduleName %>' 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 '<%= moduleName %>' 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 '<%= moduleName %>' 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: <%= _.camelize(name) %>', () -> 4 | 5 | # load the service's module 6 | beforeEach module '<%= moduleName %>' 7 | 8 | # instantiate service 9 | <%= _.camelize(name) %> = {} 10 | beforeEach inject (_<%= _.camelize(name) %>_) -> 11 | <%= _.camelize(name) %> = _<%= _.camelize(name) %>_ 12 | 13 | it 'should do something', () -> 14 | expect(!!<%= _.camelize(name) %>).toBe true 15 | -------------------------------------------------------------------------------- /templates/coffeescript/app.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | angular.module('<%= moduleName %>', []) 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('<%= moduleName %>') 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('<%= moduleName %>').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('<%= moduleName %>') 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('<%= moduleName %>') 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('<%= moduleName %>') 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 | Greeter () -> 11 | this.greet = () { 12 | salutation 13 | 14 | # Public API for configuration 15 | this.setSalutation = (s) -> 16 | salutation = s 17 | 18 | # Method for instantiating 19 | this.$get = () -> 20 | new Greeter() 21 | -------------------------------------------------------------------------------- /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 '<%= moduleName %>' 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 '<%= moduleName %>' 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 '<%= moduleName %>' 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: <%= _.camelize(name) %>', () -> 4 | 5 | # load the service's module 6 | beforeEach module '<%= moduleName %>' 7 | 8 | # instantiate service 9 | <%= _.camelize(name) %> = {} 10 | beforeEach inject (_<%= _.camelize(name) %>_) -> 11 | <%= _.camelize(name) %> = _<%= _.camelize(name) %>_ 12 | 13 | it 'should do something', () -> 14 | expect(!!<%= _.camelize(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 | var LIVERELOAD_PORT = 35729; 4 | var lrSnippet = require('connect-livereload')({ port: LIVERELOAD_PORT }); 5 | var mountFolder = function (connect, dir) { 6 | return connect.static(require('path').resolve(dir)); 7 | }; 8 | 9 | // # Globbing 10 | // for performance reasons we're only matching one level down: 11 | // 'test/spec/{,*/}*.js' 12 | // use this if you want to recursively match all subfolders: 13 | // 'test/spec/**/*.js' 14 | 15 | module.exports = function (grunt) { 16 | // load all grunt tasks 17 | require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); 18 | 19 | // configurable paths 20 | var yeomanConfig = { 21 | app: 'app', 22 | dist: 'dist' 23 | }; 24 | 25 | try { 26 | yeomanConfig.app = require('./bower.json').appPath || yeomanConfig.app; 27 | } catch (e) {} 28 | 29 | grunt.initConfig({ 30 | yeoman: yeomanConfig, 31 | watch: { 32 | coffee: { 33 | files: ['<%%= yeoman.app %>/scripts/{,*/}*.coffee'], 34 | tasks: ['coffee:dist'] 35 | }, 36 | coffeeTest: { 37 | files: ['test/spec/{,*/}*.coffee'], 38 | tasks: ['coffee:test'] 39 | },<% if (compassBootstrap) { %> 40 | compass: { 41 | files: ['<%%= yeoman.app %>/styles/{,*/}*.{scss,sass}'], 42 | tasks: ['compass:server'] 43 | },<% } %> 44 | livereload: { 45 | options: { 46 | livereload: LIVERELOAD_PORT 47 | }, 48 | files: [ 49 | '<%%= yeoman.app %>/{,*/}*.html', 50 | '{.tmp,<%%= yeoman.app %>}/styles/{,*/}*.css', 51 | '{.tmp,<%%= yeoman.app %>}/scripts/{,*/}*.js', 52 | '<%%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}' 53 | ] 54 | } 55 | }, 56 | connect: { 57 | options: { 58 | port: 9000, 59 | // Change this to '0.0.0.0' to access the server from outside. 60 | hostname: 'localhost' 61 | }, 62 | livereload: { 63 | options: { 64 | middleware: function (connect) { 65 | return [ 66 | lrSnippet, 67 | mountFolder(connect, '.tmp'), 68 | mountFolder(connect, yeomanConfig.app) 69 | ]; 70 | } 71 | } 72 | }, 73 | test: { 74 | options: { 75 | middleware: function (connect) { 76 | return [ 77 | mountFolder(connect, '.tmp'), 78 | mountFolder(connect, 'test') 79 | ]; 80 | } 81 | } 82 | }, 83 | dist: { 84 | options: { 85 | middleware: function (connect) { 86 | return [ 87 | mountFolder(connect, yeomanConfig.dist) 88 | ]; 89 | } 90 | } 91 | } 92 | }, 93 | open: { 94 | server: { 95 | url: 'http://localhost:<%%= connect.options.port %>' 96 | } 97 | }, 98 | clean: { 99 | dist: { 100 | files: [{ 101 | dot: true, 102 | src: [ 103 | '.tmp', 104 | '<%%= yeoman.dist %>/*', 105 | '!<%%= yeoman.dist %>/.git*' 106 | ] 107 | }] 108 | }, 109 | server: '.tmp' 110 | }, 111 | jshint: { 112 | options: { 113 | jshintrc: '.jshintrc' 114 | }, 115 | all: [ 116 | 'Gruntfile.js', 117 | '<%%= yeoman.app %>/scripts/{,*/}*.js' 118 | ] 119 | }, 120 | coffee: { 121 | dist: { 122 | files: [{ 123 | expand: true, 124 | cwd: '<%%= yeoman.app %>/scripts', 125 | src: '{,*/}*.coffee', 126 | dest: '.tmp/scripts', 127 | ext: '.js' 128 | }] 129 | }, 130 | test: { 131 | files: [{ 132 | expand: true, 133 | cwd: 'test/spec', 134 | src: '{,*/}*.coffee', 135 | dest: '.tmp/spec', 136 | ext: '.js' 137 | }] 138 | } 139 | },<% if (compassBootstrap) { %> 140 | compass: { 141 | options: { 142 | sassDir: '<%%= yeoman.app %>/styles', 143 | cssDir: '.tmp/styles', 144 | generatedImagesDir: '.tmp/images/generated', 145 | imagesDir: '<%%= yeoman.app %>/images', 146 | javascriptsDir: '<%%= yeoman.app %>/scripts', 147 | fontsDir: '<%%= yeoman.app %>/styles/fonts', 148 | importPath: '<%%= yeoman.app %>/bower_components', 149 | httpImagesPath: '/images', 150 | httpGeneratedImagesPath: '/images/generated', 151 | httpFontsPath: '/styles/fonts', 152 | relativeAssets: false 153 | }, 154 | dist: {}, 155 | server: { 156 | options: { 157 | debugInfo: true 158 | } 159 | } 160 | },<% } %> 161 | // not used since Uglify task does concat, 162 | // but still available if needed 163 | /*concat: { 164 | dist: {} 165 | },*/ 166 | rev: { 167 | dist: { 168 | files: { 169 | src: [ 170 | '<%%= yeoman.dist %>/scripts/{,*/}*.js', 171 | '<%%= yeoman.dist %>/styles/{,*/}*.css', 172 | '<%%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}', 173 | '<%%= yeoman.dist %>/styles/fonts/*' 174 | ] 175 | } 176 | } 177 | }, 178 | useminPrepare: { 179 | html: '<%%= yeoman.app %>/index.html', 180 | options: { 181 | dest: '<%%= yeoman.dist %>' 182 | } 183 | }, 184 | usemin: { 185 | html: ['<%%= yeoman.dist %>/{,*/}*.html'], 186 | css: ['<%%= yeoman.dist %>/styles/{,*/}*.css'], 187 | options: { 188 | dirs: ['<%%= yeoman.dist %>'] 189 | } 190 | }, 191 | imagemin: { 192 | dist: { 193 | files: [{ 194 | expand: true, 195 | cwd: '<%%= yeoman.app %>/images', 196 | src: '{,*/}*.{png,jpg,jpeg}', 197 | dest: '<%%= yeoman.dist %>/images' 198 | }] 199 | } 200 | }, 201 | svgmin: { 202 | dist: { 203 | files: [{ 204 | expand: true, 205 | cwd: '<%%= yeoman.app %>/images', 206 | src: '{,*/}*.svg', 207 | dest: '<%%= yeoman.dist %>/images' 208 | }] 209 | } 210 | }, 211 | cssmin: { 212 | // By default, your `index.html` will take care of 213 | // minification. This option is pre-configured if you do not wish to use 214 | // Usemin blocks. 215 | // dist: { 216 | // files: { 217 | // '<%%= yeoman.dist %>/styles/main.css': [ 218 | // '.tmp/styles/{,*/}*.css', 219 | // '<%%= yeoman.app %>/styles/{,*/}*.css' 220 | // ] 221 | // } 222 | // } 223 | }, 224 | htmlmin: { 225 | dist: { 226 | options: { 227 | /*removeCommentsFromCDATA: true, 228 | // https://github.com/yeoman/grunt-usemin/issues/44 229 | //collapseWhitespace: true, 230 | collapseBooleanAttributes: true, 231 | removeAttributeQuotes: true, 232 | removeRedundantAttributes: true, 233 | useShortDoctype: true, 234 | removeEmptyAttributes: true, 235 | removeOptionalTags: true*/ 236 | }, 237 | files: [{ 238 | expand: true, 239 | cwd: '<%%= yeoman.app %>', 240 | src: ['*.html', 'views/*.html'], 241 | dest: '<%%= yeoman.dist %>' 242 | }] 243 | } 244 | }, 245 | // Put files not handled in other tasks here 246 | copy: { 247 | dist: { 248 | files: [{ 249 | expand: true, 250 | dot: true, 251 | cwd: '<%%= yeoman.app %>', 252 | dest: '<%%= yeoman.dist %>', 253 | src: [ 254 | '*.{ico,png,txt}', 255 | '.htaccess', 256 | 'bower_components/**/*', 257 | 'images/{,*/}*.{gif,webp}', 258 | 'styles/fonts/*' 259 | ] 260 | }, { 261 | expand: true, 262 | cwd: '.tmp/images', 263 | dest: '<%%= yeoman.dist %>/images', 264 | src: [ 265 | 'generated/*' 266 | ] 267 | }] 268 | } 269 | }, 270 | concurrent: { 271 | server: [ 272 | 'coffee:dist'<% if (compassBootstrap) { %>, 273 | 'compass:server'<% } %> 274 | ], 275 | test: [ 276 | 'coffee'<% if (compassBootstrap) { %>, 277 | 'compass'<% } %> 278 | ], 279 | dist: [ 280 | 'coffee',<% if (compassBootstrap) { %> 281 | 'compass:dist',<% } %> 282 | 'imagemin', 283 | 'svgmin', 284 | 'htmlmin' 285 | ] 286 | }, 287 | karma: { 288 | unit: { 289 | configFile: 'karma.conf.js', 290 | singleRun: true 291 | } 292 | }, 293 | cdnify: { 294 | dist: { 295 | html: ['<%%= yeoman.dist %>/*.html'] 296 | } 297 | }, 298 | ngmin: { 299 | dist: { 300 | files: [{ 301 | expand: true, 302 | cwd: '<%%= yeoman.dist %>/scripts', 303 | src: '*.js', 304 | dest: '<%%= yeoman.dist %>/scripts' 305 | }] 306 | } 307 | }, 308 | uglify: { 309 | dist: { 310 | files: { 311 | '<%%= yeoman.dist %>/scripts/scripts.js': [ 312 | '<%%= yeoman.dist %>/scripts/scripts.js' 313 | ] 314 | } 315 | } 316 | } 317 | }); 318 | 319 | grunt.registerTask('server', function (target) { 320 | if (target === 'dist') { 321 | return grunt.task.run(['build', 'open', 'connect:dist:keepalive']); 322 | } 323 | 324 | grunt.task.run([ 325 | 'clean:server', 326 | 'concurrent:server', 327 | 'connect:livereload', 328 | 'open', 329 | 'watch' 330 | ]); 331 | }); 332 | 333 | grunt.registerTask('test', [ 334 | 'clean:server', 335 | 'concurrent:test', 336 | 'connect:test', 337 | 'karma' 338 | ]); 339 | 340 | grunt.registerTask('build', [ 341 | 'clean:dist', 342 | 'useminPrepare', 343 | 'concurrent:dist', 344 | 'concat', 345 | 'copy', 346 | 'cdnify', 347 | 'ngmin', 348 | 'cssmin', 349 | 'uglify', 350 | 'rev', 351 | 'usemin' 352 | ]); 353 | 354 | grunt.registerTask('default', [ 355 | 'jshint', 356 | 'test', 357 | 'build' 358 | ]); 359 | }; 360 | -------------------------------------------------------------------------------- /templates/common/Procfile: -------------------------------------------------------------------------------- 1 | web: node app.js 2 | -------------------------------------------------------------------------------- /templates/common/_bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= _.camelize(appname) %>", 3 | "version": "0.0.0", 4 | "dependencies": { 5 | "angular": "~1.0.7", 6 | "json3": "~3.2.4",<% if (bootstrap) { %> 7 | "jquery": "~1.9.1", 8 | "bootstrap-sass": "~2.3.1", 9 | <% } %>"es5-shim": "~2.0.8"<% if (resourceModule) { %>, 10 | "angular-resource": "~1.0.7"<% } %><% if (cookiesModule) { %>, 11 | "angular-cookies": "~1.0.7"<% } %><% if (sanitizeModule) { %>, 12 | "angular-sanitize": "~1.0.7"<% } %> 13 | }, 14 | "devDependencies": { 15 | "angular-mocks": "~1.0.7", 16 | "angular-scenario": "~1.0.7" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /templates/common/_package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= _.slugify(appname) %>", 3 | "version": "0.0.0", 4 | "dependencies": { 5 | "express": "~3.0.0", 6 | "ejs": "~0.8.4" 7 | }, 8 | "devDependencies": { 9 | "grunt": "~0.4.1", 10 | "grunt-contrib-copy": "~0.4.1", 11 | "grunt-contrib-concat": "~0.3.0", 12 | "grunt-contrib-coffee": "~0.7.0", 13 | "grunt-contrib-uglify": "~0.2.0", 14 | "grunt-contrib-compass": "~0.3.0", 15 | "grunt-contrib-jshint": "~0.6.0", 16 | "grunt-contrib-cssmin": "~0.6.0", 17 | "grunt-contrib-connect": "~0.3.0", 18 | "grunt-contrib-clean": "~0.4.1", 19 | "grunt-contrib-htmlmin": "~0.1.3", 20 | "grunt-contrib-imagemin": "~0.1.4", 21 | "grunt-contrib-watch": "~0.4.0", 22 | "grunt-usemin": "~0.1.11", 23 | "grunt-svgmin": "~0.2.0", 24 | "grunt-rev": "~0.1.0", 25 | "grunt-karma": "~0.4.3", 26 | "grunt-open": "~0.2.0", 27 | "grunt-concurrent": "~0.3.0", 28 | "matchdep": "~0.1.2", 29 | "connect-livereload": "~0.2.0", 30 | "grunt-google-cdn": "~0.2.0", 31 | "grunt-ngmin": "~0.0.2" 32 | }, 33 | "engines": { 34 | "node": ">=0.8.0" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /templates/common/app.js: -------------------------------------------------------------------------------- 1 | var express = require("express"); 2 | 3 | var app = express(); 4 | app.use(express.logger()); 5 | 6 | // Configuration 7 | 8 | app.configure(function(){ 9 | app.set('views', __dirname + '/app'); 10 | //app.set('view engine', 'jade'); 11 | app.use(express.bodyParser()); 12 | app.use(express.methodOverride()); 13 | app.use(express.static(__dirname + '/app')); 14 | app.use(app.router); 15 | app.engine('html', require('ejs').renderFile); 16 | }); 17 | 18 | app.get('/', function(request, response) { 19 | response.render('index.html') 20 | }); 21 | 22 | var port = process.env.PORT || 5000; 23 | app.listen(port, function() { 24 | console.log("Listening on " + port); 25 | }); 26 | -------------------------------------------------------------------------------- /templates/common/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= _.camelize(appname) %>", 3 | "version": "0.0.0", 4 | "dependencies": { 5 | "angular": "~1.0.5", 6 | "json3": "~3.2.4", 7 | "es5-shim": "~2.0.8"<% if (resourceModule) { %>, 8 | "angular-resource": "~1.0.5"<% } %><% if (cookiesModule) { %>, 9 | "angular-cookies": "~1.0.5"<% } %><% if (sanitizeModule) { %>, 10 | "angular-sanitize": "~1.0.5"<% } %> 11 | }, 12 | "devDependencies": { 13 | "angular-mocks": "~1.0.5", 14 | "angular-scenario": "~1.0.5" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /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 | angular.module('<%= moduleName %>', []) 4 | .config(['$routeProvider', function ($routeProvider) { 5 | $routeProvider 6 | .when('/', { 7 | templateUrl: 'views/main.html', 8 | controller: 'MainCtrl' 9 | }) 10 | .otherwise({ 11 | redirectTo: '/' 12 | }); 13 | }]); 14 | -------------------------------------------------------------------------------- /templates/javascript-min/controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('<%= moduleName %>') 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('<%= moduleName %>') 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('<%= moduleName %>') 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('<%= moduleName %>') 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('<%= moduleName %>') 4 | .constant('<%= _.camelize(name) %>', 42); 5 | -------------------------------------------------------------------------------- /templates/javascript-min/service/factory.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('<%= moduleName %>') 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('<%= moduleName %>') 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('<%= moduleName %>') 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('<%= moduleName %>') 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('<%= moduleName %>')); 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('<%= moduleName %>')); 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('<%= moduleName %>')); 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: <%= _.camelize(name) %>', function () { 4 | 5 | // load the service's module 6 | beforeEach(module('<%= moduleName %>')); 7 | 8 | // instantiate service 9 | var <%= _.camelize(name) %>; 10 | beforeEach(inject(function(_<%= _.camelize(name) %>_) { 11 | <%= _.camelize(name) %> = _<%= _.camelize(name) %>_; 12 | })); 13 | 14 | it('should do something', function () { 15 | expect(!!<%= _.camelize(name) %>).toBe(true); 16 | }); 17 | 18 | }); 19 | -------------------------------------------------------------------------------- /templates/javascript/app.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('<%= moduleName %>', []) 4 | .config(function ($routeProvider) { 5 | $routeProvider 6 | .when('/', { 7 | templateUrl: 'views/main.html', 8 | controller: 'MainCtrl' 9 | }) 10 | .otherwise({ 11 | redirectTo: '/' 12 | }); 13 | }); 14 | -------------------------------------------------------------------------------- /templates/javascript/controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('<%= moduleName %>') 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('<%= moduleName %>') 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('<%= moduleName %>') 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('<%= moduleName %>') 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('<%= moduleName %>') 4 | .constant('<%= _.camelize(name) %>', 42); 5 | -------------------------------------------------------------------------------- /templates/javascript/service/factory.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('<%= moduleName %>') 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('<%= moduleName %>') 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('<%= moduleName %>') 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('<%= moduleName %>') 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('<%= moduleName %>')); 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('<%= moduleName %>')); 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('<%= moduleName %>')); 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: <%= _.camelize(name) %>', function () { 4 | 5 | // load the service's module 6 | beforeEach(module('<%= moduleName %>')); 7 | 8 | // instantiate service 9 | var <%= _.camelize(name) %>; 10 | beforeEach(inject(function (_<%= _.camelize(name) %>_) { 11 | <%= _.camelize(name) %> = _<%= _.camelize(name) %>_; 12 | })); 13 | 14 | it('should do something', function () { 15 | expect(!!<%= _.camelize(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: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 | 10 | 11 | describe('Angular 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: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 | describe('Controller', function () { 105 | it('should generate a new controller', function (done) { 106 | var angularCtrl; 107 | var deps = ['../../controller']; 108 | angularCtrl = helpers.createGenerator('angular:controller', deps, ['foo']); 109 | 110 | helpers.mockPrompt(angular, { 111 | bootstrap: true, 112 | compassBoostrap: true, 113 | modules: [] 114 | }); 115 | angular.run([], function () { 116 | angularCtrl.run([], function () { 117 | helpers.assertFiles([ 118 | ['app/scripts/controllers/foo.js', /controller\('FooCtrl'/], 119 | ['test/spec/controllers/foo.js', /describe\('Controller: FooCtrl'/] 120 | ]); 121 | done(); 122 | }); 123 | }); 124 | }); 125 | }); 126 | 127 | describe('View', function () { 128 | it('should generate a new view', function (done) { 129 | var angularView; 130 | var deps = ['../../view']; 131 | angularView = helpers.createGenerator('angular:view', deps, ['foo']); 132 | 133 | helpers.mockPrompt(angular, { 134 | bootstrap: true, 135 | compassBoostrap: true, 136 | modules: [] 137 | }); 138 | angular.run([], function (){ 139 | angularView.run([], function () { 140 | helpers.assertFiles([ 141 | ['app/views/foo.html'] 142 | ]); 143 | done(); 144 | }); 145 | }); 146 | }); 147 | }); 148 | }); 149 | -------------------------------------------------------------------------------- /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:value thing [--coffee] [--minsafe] 7 | 8 | This will create: 9 | app/scripts/services/thing.js 10 | -------------------------------------------------------------------------------- /value/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var path = require('path'); 3 | var util = require('util'); 4 | var ScriptBase = require('../script-base.js'); 5 | var angularUtils = require('../util.js'); 6 | 7 | 8 | module.exports = Generator; 9 | 10 | function Generator() { 11 | ScriptBase.apply(this, arguments); 12 | } 13 | 14 | util.inherits(Generator, ScriptBase); 15 | 16 | Generator.prototype.createServiceFiles = function createServiceFiles() { 17 | this.appTemplate('service/value'); 18 | this.testTemplate('spec/service'); 19 | }; 20 | -------------------------------------------------------------------------------- /view/USAGE: -------------------------------------------------------------------------------- 1 | Description: 2 | Creates a new AngularJS view 3 | 4 | Example: 5 | yo angular:view thing 6 | 7 | This will create: 8 | app/scripts/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 | module.exports = Generator; 8 | 9 | function Generator() { 10 | yeoman.generators.NamedBase.apply(this, arguments); 11 | this.sourceRoot(path.join(__dirname, '../templates')); 12 | 13 | if (typeof this.env.options.appPath === 'undefined') { 14 | try { 15 | this.env.options.appPath = require(path.join(process.cwd(), 'bower.json')).appPath; 16 | } catch (e) {} 17 | this.env.options.appPath = this.env.options.appPath || 'app'; 18 | } 19 | } 20 | 21 | util.inherits(Generator, yeoman.generators.NamedBase); 22 | 23 | Generator.prototype.createViewFiles = function createViewFiles() { 24 | var targetPath = this.name; 25 | if (this.name.indexOf('/') === -1) { 26 | targetPath = 'views/' + targetPath; 27 | } 28 | this.template('common/view.html', path.join(this.env.options.appPath, this.name + '.html')); 29 | }; 30 | --------------------------------------------------------------------------------