├── .gitattributes
├── templates
├── common
│ ├── root
│ │ ├── .yo-rc.json
│ │ ├── .gitattributes
│ │ ├── _bowerrc
│ │ ├── gitignore
│ │ ├── .jshintrc
│ │ ├── test
│ │ │ └── .jshintrc
│ │ ├── README.md
│ │ ├── .editorconfig
│ │ ├── _tsd.json
│ │ ├── _bower.json
│ │ ├── _package.json
│ │ └── _Gruntfile.js
│ └── app
│ │ ├── .buildignore
│ │ ├── views
│ │ ├── view.html
│ │ └── main.html
│ │ ├── robots.txt
│ │ ├── favicon.ico
│ │ ├── images
│ │ └── yeoman.png
│ │ ├── styles
│ │ ├── main.css
│ │ └── main.scss
│ │ ├── index.html
│ │ ├── 404.html
│ │ └── .htaccess
├── typescript
│ ├── service
│ │ ├── value.ts
│ │ ├── constant.ts
│ │ ├── service.ts
│ │ ├── factory.ts
│ │ └── provider.ts
│ ├── decorator.ts
│ ├── filter.ts
│ ├── controller.ts
│ ├── directive.ts
│ ├── spec
│ │ ├── service.ts
│ │ ├── filter.ts
│ │ ├── directive.ts
│ │ └── controller.ts
│ └── app.ts
├── javascript
│ ├── service
│ │ ├── value.js
│ │ ├── constant.js
│ │ ├── service.js
│ │ ├── factory.js
│ │ └── provider.js
│ ├── filter.js
│ ├── controller.js
│ ├── decorator.js
│ ├── spec
│ │ ├── service.js
│ │ ├── filter.js
│ │ ├── directive.js
│ │ └── controller.js
│ ├── directive.js
│ └── app.js
└── coffeescript
│ ├── service
│ ├── value.coffee
│ ├── constant.coffee
│ ├── service.coffee
│ ├── factory.coffee
│ └── provider.coffee
│ ├── filter.coffee
│ ├── decorator.coffee
│ ├── spec
│ ├── service.coffee
│ ├── filter.coffee
│ ├── directive.coffee
│ └── controller.coffee
│ ├── directive.coffee
│ ├── controller.coffee
│ └── app.coffee
├── .gitignore
├── .travis.yml
├── view
├── USAGE
└── index.js
├── filter
├── USAGE
└── index.js
├── directive
├── USAGE
└── index.js
├── controller
├── USAGE
└── index.js
├── decorator
├── USAGE
└── index.js
├── .editorconfig
├── value
├── USAGE
└── index.js
├── .jshintrc
├── constant
├── USAGE
└── index.js
├── factory
├── USAGE
└── index.js
├── provider
├── USAGE
└── index.js
├── service
├── USAGE
└── index.js
├── route
├── USAGE
└── index.js
├── app
├── USAGE
└── index.js
├── main
└── index.js
├── test
├── test-load.js
├── test-appname-substitution.js
├── test-route-creation.js
├── test-apppath.js
└── test-file-creation.js
├── common
└── index.js
├── package.json
├── util.js
├── Gruntfile.js
├── contributing.md
├── script-base.js
├── readme.md
└── CHANGELOG.md
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 |
--------------------------------------------------------------------------------
/templates/common/root/.yo-rc.json:
--------------------------------------------------------------------------------
1 | {}
2 |
--------------------------------------------------------------------------------
/templates/common/root/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
--------------------------------------------------------------------------------
/templates/common/app/.buildignore:
--------------------------------------------------------------------------------
1 | *.coffee
2 | *.ts
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | test/tmp
4 |
--------------------------------------------------------------------------------
/templates/common/app/views/view.html:
--------------------------------------------------------------------------------
1 |
This is the <%= name %> view.
2 |
--------------------------------------------------------------------------------
/templates/common/root/_bowerrc:
--------------------------------------------------------------------------------
1 | {
2 | "directory": "bower_components"
3 | }
4 |
--------------------------------------------------------------------------------
/templates/common/app/robots.txt:
--------------------------------------------------------------------------------
1 | # robotstxt.org
2 |
3 | User-agent: *
4 | Disallow:
5 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: node_js
3 | node_js:
4 | - 'iojs'
5 | - '0.12'
6 | - '0.10'
7 |
--------------------------------------------------------------------------------
/templates/common/root/gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | /dist
3 | /.tmp
4 | /.sass-cache
5 | /bower_components
6 |
--------------------------------------------------------------------------------
/templates/common/app/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onshape/generator-angular-typescript/HEAD/templates/common/app/favicon.ico
--------------------------------------------------------------------------------
/templates/common/app/images/yeoman.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onshape/generator-angular-typescript/HEAD/templates/common/app/images/yeoman.png
--------------------------------------------------------------------------------
/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/views/thing.html
9 |
--------------------------------------------------------------------------------
/templates/typescript/service/value.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | 'use strict';
4 |
5 | angular.module('<%= scriptAppName %>')
6 | .value('<%= cameledName %>', 42);
7 |
--------------------------------------------------------------------------------
/templates/typescript/service/constant.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | 'use strict';
4 |
5 | angular.module('<%= scriptAppName %>')
6 | .constant('<%= cameledName %>', 42);
7 |
--------------------------------------------------------------------------------
/filter/USAGE:
--------------------------------------------------------------------------------
1 | Description:
2 | Creates a new AngularJS filter
3 |
4 | Example:
5 | yo angular:filter thing [--coffee]
6 |
7 | This will create:
8 | app/scripts/filters/thing.js
9 |
--------------------------------------------------------------------------------
/directive/USAGE:
--------------------------------------------------------------------------------
1 | Description:
2 | Creates a new Angular directive
3 |
4 | Example:
5 | yo angular:directive thing [--coffee]
6 |
7 | This will create:
8 | app/scripts/directives/thing.js
9 |
--------------------------------------------------------------------------------
/controller/USAGE:
--------------------------------------------------------------------------------
1 | Description:
2 | Creates a new Angular controller
3 |
4 | Example:
5 | yo angular:controller Thing [--coffee]
6 |
7 | This will create:
8 | app/scripts/controllers/thing-ctrl.js
9 |
--------------------------------------------------------------------------------
/decorator/USAGE:
--------------------------------------------------------------------------------
1 | Description:
2 | Creates a new AngularJS decorator for a specified service
3 |
4 | Example:
5 | yo angular:decorator serviceName [--coffee]
6 |
7 | This will create:
8 | app/scripts/decorators/serviceNameDecorator.js
9 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/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]
7 |
8 | This will create:
9 | app/scripts/services/thing.js
10 |
--------------------------------------------------------------------------------
/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "bitwise": true,
3 | "curly": true,
4 | "eqeqeq": true,
5 | "eqnull": true,
6 | "esnext": true,
7 | "globalstrict": true,
8 | "latedef": true,
9 | "mocha" : true,
10 | "noarg": true,
11 | "node": true,
12 | "strict": true,
13 | "undef": true
14 | }
15 |
--------------------------------------------------------------------------------
/constant/USAGE:
--------------------------------------------------------------------------------
1 | Description:
2 | Creates a new AngularJS constant.
3 | Docs: http://docs.angularjs.org/guide/dev_guide.services.creating_services
4 |
5 | Example:
6 | yo angular:constant thing [--coffee]
7 |
8 | This will create:
9 | app/scripts/services/thing.js
10 |
--------------------------------------------------------------------------------
/factory/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:factory thing [--coffee]
7 |
8 | This will create:
9 | app/scripts/services/thing.js
10 |
--------------------------------------------------------------------------------
/provider/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:provider thing [--coffee]
7 |
8 | This will create:
9 | app/scripts/services/thing.js
10 |
--------------------------------------------------------------------------------
/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]
7 |
8 | This will create:
9 | app/scripts/services/thing.js
10 |
--------------------------------------------------------------------------------
/route/USAGE:
--------------------------------------------------------------------------------
1 | Description:
2 | Creates a new AngularJS route
3 |
4 | Example:
5 | yo angular:route thing [--coffee] [--uri=path_to/thing]
6 |
7 | This will create:
8 | app/scripts/controllers/thing.js
9 | app/views/thing.html
10 | And add routing to:
11 | app.js
12 |
--------------------------------------------------------------------------------
/templates/javascript/service/value.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * @ngdoc service
5 | * @name <%= scriptAppName %>.<%= cameledName %>
6 | * @description
7 | * # <%= cameledName %>
8 | * Value in the <%= scriptAppName %>.
9 | */
10 | angular.module('<%= scriptAppName %>')
11 | .value('<%= cameledName %>', 42);
12 |
--------------------------------------------------------------------------------
/templates/coffeescript/service/value.coffee:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | ###*
4 | # @ngdoc service
5 | # @name <%= scriptAppName %>.<%= cameledName %>
6 | # @description
7 | # # <%= cameledName %>
8 | # Value in the <%= scriptAppName %>.
9 | ###
10 | angular.module '<%= scriptAppName %>'
11 | .value '<%= cameledName %>', 42
12 |
--------------------------------------------------------------------------------
/templates/coffeescript/service/constant.coffee:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | ###*
4 | # @ngdoc service
5 | # @name <%= scriptAppName %>.<%= cameledName %>
6 | # @description
7 | # # <%= cameledName %>
8 | # Constant in the <%= scriptAppName %>.
9 | ###
10 | angular.module '<%= scriptAppName %>'
11 | .constant '<%= cameledName %>', 42
12 |
--------------------------------------------------------------------------------
/templates/javascript/service/constant.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * @ngdoc service
5 | * @name <%= scriptAppName %>.<%= cameledName %>
6 | * @description
7 | * # <%= cameledName %>
8 | * Constant in the <%= scriptAppName %>.
9 | */
10 | angular.module('<%= scriptAppName %>')
11 | .constant('<%= cameledName %>', 42);
12 |
--------------------------------------------------------------------------------
/templates/common/root/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "bitwise": true,
3 | "browser": true,
4 | "curly": true,
5 | "eqeqeq": true,
6 | "esnext": true,
7 | "latedef": true,
8 | "noarg": true,
9 | "node": true,
10 | "strict": true,
11 | "undef": true,
12 | "unused": true,
13 | "globals": {
14 | "angular": false
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/templates/common/root/test/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "bitwise": true,
3 | "browser": true,
4 | "curly": true,
5 | "eqeqeq": true,
6 | "esnext": true,
7 | "jasmine": true,
8 | "latedef": true,
9 | "noarg": true,
10 | "node": true,
11 | "strict": true,
12 | "undef": true,
13 | "unused": true,
14 | "globals": {
15 | "angular": false,
16 | "inject": false
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/templates/common/root/README.md:
--------------------------------------------------------------------------------
1 | # <%= _.slugify(_.humanize(appname)) %>
2 |
3 | This project is generated with [yo angular generator](https://github.com/yeoman/generator-angular)
4 | version <%= pkg.version %>.
5 |
6 | ## Build & development
7 |
8 | Run `grunt` for building and `grunt serve` for preview.
9 |
10 | ## Testing
11 |
12 | Running `grunt test` will run the unit tests with karma.
13 |
--------------------------------------------------------------------------------
/templates/coffeescript/filter.coffee:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | ###*
4 | # @ngdoc filter
5 | # @name <%= scriptAppName %>.filter:<%= cameledName %>
6 | # @function
7 | # @description
8 | # # <%= cameledName %>
9 | # Filter in the <%= scriptAppName %>.
10 | ###
11 | angular.module '<%= scriptAppName %>'
12 | .filter '<%= cameledName %>', ->
13 | (input) ->
14 | '<%= cameledName %> filter: ' + input
15 |
--------------------------------------------------------------------------------
/templates/coffeescript/service/service.coffee:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | ###*
4 | # @ngdoc service
5 | # @name <%= scriptAppName %>.<%= cameledName %>
6 | # @description
7 | # # <%= cameledName %>
8 | # Service in the <%= scriptAppName %>.
9 | ###
10 | angular.module '<%= scriptAppName %>'
11 | .service '<%= cameledName %>', ->
12 | # AngularJS will instantiate a singleton by calling "new" on this function
13 |
--------------------------------------------------------------------------------
/templates/javascript/service/service.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * @ngdoc service
5 | * @name <%= scriptAppName %>.<%= cameledName %>
6 | * @description
7 | * # <%= cameledName %>
8 | * Service in the <%= scriptAppName %>.
9 | */
10 | angular.module('<%= scriptAppName %>')
11 | .service('<%= cameledName %>', function () {
12 | // AngularJS will instantiate a singleton by calling "new" on this function
13 | });
14 |
--------------------------------------------------------------------------------
/templates/typescript/service/service.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | 'use strict';
4 |
5 | module <%= scriptAppName %> {
6 | export class <%= classedName %> {
7 | awesomeThings:any[] = [
8 | 'HTML5 Boilerplate',
9 | 'AngularJS',
10 | 'Karma'
11 | ];
12 | }
13 | }
14 |
15 | angular.module('<%= scriptAppName %>')
16 | .service('<%= cameledName %>', <%= scriptAppName %>.<%= classedName %>);
17 |
--------------------------------------------------------------------------------
/templates/coffeescript/decorator.coffee:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | ###*
4 | # @ngdoc function
5 | # @name <%= scriptAppName %>.decorator:<%= classedName %>
6 | # @description
7 | # # <%= classedName %>
8 | # Decorator of the <%= scriptAppName %>
9 | ###
10 | angular.module '<%= scriptAppName %>'
11 | .config ($provide) ->
12 | $provide.decorator '<%= cameledName %>', ($delegate) ->
13 | # decorate the $delegate
14 | $delegate
15 |
--------------------------------------------------------------------------------
/templates/coffeescript/spec/service.coffee:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | describe 'Service: <%= cameledName %>', ->
4 |
5 | # load the service's module
6 | beforeEach module '<%= scriptAppName %>'
7 |
8 | # instantiate service
9 | <%= cameledName %> = {}
10 | beforeEach inject (_<%= cameledName %>_) ->
11 | <%= cameledName %> = _<%= cameledName %>_
12 |
13 | it 'should do something', ->
14 | expect(!!<%= cameledName %>).toBe true
15 |
--------------------------------------------------------------------------------
/templates/coffeescript/directive.coffee:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | ###*
4 | # @ngdoc directive
5 | # @name <%= scriptAppName %>.directive:<%= cameledName %>
6 | # @description
7 | # # <%= cameledName %>
8 | ###
9 | angular.module '<%= scriptAppName %>'
10 | .directive '<%= cameledName %>', ->
11 | restrict: 'EA'
12 | template: ''
13 | link: (scope, element, attrs) ->
14 | element.text 'this is the <%= cameledName %> directive'
15 |
--------------------------------------------------------------------------------
/templates/javascript/filter.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * @ngdoc filter
5 | * @name <%= scriptAppName %>.filter:<%= cameledName %>
6 | * @function
7 | * @description
8 | * # <%= cameledName %>
9 | * Filter in the <%= scriptAppName %>.
10 | */
11 | angular.module('<%= scriptAppName %>')
12 | .filter('<%= cameledName %>', function () {
13 | return function (input) {
14 | return '<%= cameledName %> filter: ' + input;
15 | };
16 | });
17 |
--------------------------------------------------------------------------------
/templates/coffeescript/controller.coffee:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | ###*
4 | # @ngdoc function
5 | # @name <%= scriptAppName %>.controller:<%= classedName %>Ctrl
6 | # @description
7 | # # <%= classedName %>Ctrl
8 | # Controller of the <%= scriptAppName %>
9 | ###
10 | angular.module '<%= scriptAppName %>'
11 | .controller '<%= classedName %>Ctrl', ->
12 | @awesomeThings = [
13 | 'HTML5 Boilerplate'
14 | 'AngularJS'
15 | 'Karma'
16 | ]
17 | return
18 |
--------------------------------------------------------------------------------
/templates/coffeescript/service/factory.coffee:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | ###*
4 | # @ngdoc service
5 | # @name <%= scriptAppName %>.<%= cameledName %>
6 | # @description
7 | # # <%= cameledName %>
8 | # Factory in the <%= scriptAppName %>.
9 | ###
10 | angular.module '<%= scriptAppName %>'
11 | .factory '<%= cameledName %>', ->
12 | # Service logic
13 | # ...
14 |
15 | meaningOfLife = 42
16 |
17 | # Public API here
18 | someMethod: ->
19 | meaningOfLife
20 |
--------------------------------------------------------------------------------
/templates/javascript/controller.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * @ngdoc function
5 | * @name <%= scriptAppName %>.controller:<%= classedName %>Ctrl
6 | * @description
7 | * # <%= classedName %>Ctrl
8 | * Controller of the <%= scriptAppName %>
9 | */
10 | angular.module('<%= scriptAppName %>')
11 | .controller('<%= classedName %>Ctrl', function () {
12 | this.awesomeThings = [
13 | 'HTML5 Boilerplate',
14 | 'AngularJS',
15 | 'Karma'
16 | ];
17 | });
18 |
--------------------------------------------------------------------------------
/templates/javascript/decorator.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * @ngdoc function
5 | * @name <%= scriptAppName %>.decorator:<%= classedName %>
6 | * @description
7 | * # <%= classedName %>
8 | * Decorator of the <%= scriptAppName %>
9 | */
10 | angular.module('<%= scriptAppName %>')
11 | .config(function ($provide) {
12 | $provide.decorator('<%= cameledName %>', function ($delegate) {
13 | // decorate the $delegate
14 | return $delegate;
15 | });
16 | });
17 |
--------------------------------------------------------------------------------
/filter/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.createFilterFiles = function createFilterFiles() {
13 | this.generateSourceAndTest(
14 | 'filter',
15 | 'spec/filter',
16 | 'filters',
17 | this.options['skip-add'] || false
18 | );
19 | };
20 |
--------------------------------------------------------------------------------
/templates/javascript/spec/service.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Service: <%= cameledName %>', function () {
4 |
5 | // load the service's module
6 | beforeEach(module('<%= scriptAppName %>'));
7 |
8 | // instantiate service
9 | var <%= cameledName %>;
10 | beforeEach(inject(function (_<%= cameledName %>_) {
11 | <%= cameledName %> = _<%= cameledName %>_;
12 | }));
13 |
14 | it('should do something', function () {
15 | expect(!!<%= cameledName %>).toBe(true);
16 | });
17 |
18 | });
19 |
--------------------------------------------------------------------------------
/app/USAGE:
--------------------------------------------------------------------------------
1 | Description:
2 | Creates a default AngularJS app
3 |
4 | Example:
5 | yo angular [--coffee]
6 |
7 | This will create:
8 | Gruntfile.js
9 | bower.json
10 |
11 | app/index.html
12 | app/scripts/your-app-name-here.js
13 | app/scripts/controllers/main.js
14 | app/bower_components/angular/angular.js
15 | app/styles/main.css
16 | app/views/main.html
17 |
18 | test/lib/angular-mocks.js
19 | test/spec/controllers/main.js
20 |
--------------------------------------------------------------------------------
/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(
14 | 'service/value',
15 | 'spec/service',
16 | 'services',
17 | this.options['skip-add'] || false
18 | );
19 | };
20 |
--------------------------------------------------------------------------------
/factory/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(
14 | 'service/factory',
15 | 'spec/service',
16 | 'services',
17 | this.options['skip-add'] || false
18 | );
19 | };
20 |
--------------------------------------------------------------------------------
/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(
14 | 'service/service',
15 | 'spec/service',
16 | 'services',
17 | this.options['skip-add'] || false
18 | );
19 | };
20 |
--------------------------------------------------------------------------------
/constant/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(
14 | 'service/constant',
15 | 'spec/service',
16 | 'services',
17 | this.options['skip-add'] || false
18 | );
19 | };
20 |
--------------------------------------------------------------------------------
/directive/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.createDirectiveFiles = function createDirectiveFiles() {
13 | this.generateSourceAndTest(
14 | 'directive',
15 | 'spec/directive',
16 | 'directives',
17 | this.options['skip-add'] || false
18 | );
19 | };
20 |
--------------------------------------------------------------------------------
/provider/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(
14 | 'service/provider',
15 | 'spec/service',
16 | 'services',
17 | this.options['skip-add'] || false
18 | );
19 | };
20 |
--------------------------------------------------------------------------------
/templates/common/root/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig helps developers define and maintain consistent
2 | # coding styles between different editors and IDEs
3 | # editorconfig.org
4 |
5 | root = true
6 |
7 |
8 | [*]
9 |
10 | # Change these settings to your own preference
11 | indent_style = space
12 | indent_size = 2
13 |
14 | # We recommend you to keep these unchanged
15 | end_of_line = lf
16 | charset = utf-8
17 | trim_trailing_whitespace = true
18 | insert_final_newline = true
19 |
20 | [*.md]
21 | trim_trailing_whitespace = false
22 |
--------------------------------------------------------------------------------
/templates/javascript/directive.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * @ngdoc directive
5 | * @name <%= scriptAppName %>.directive:<%= cameledName %>
6 | * @description
7 | * # <%= cameledName %>
8 | */
9 | angular.module('<%= scriptAppName %>')
10 | .directive('<%= cameledName %>', function () {
11 | return {
12 | template: '',
13 | restrict: 'E',
14 | link: function postLink(scope, element, attrs) {
15 | element.text('this is the <%= cameledName %> directive');
16 | }
17 | };
18 | });
19 |
--------------------------------------------------------------------------------
/templates/coffeescript/app.coffee:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | ###*
4 | # @ngdoc overview
5 | # @name <%= scriptAppName %>
6 | # @description
7 | # # <%= scriptAppName %>
8 | #
9 | # Main module of the application.
10 | ###
11 | angular
12 | .module '<%= scriptAppName %>', [<%= angularModules %>]<% if (ngRoute) { %>
13 | .config ($routeProvider) ->
14 | $routeProvider
15 | .when '/',
16 | templateUrl: 'views/main.html'
17 | controller: 'MainCtrl'
18 | controllerAs: 'main'
19 | .otherwise
20 | redirectTo: '/'
21 | <% } %>
22 |
--------------------------------------------------------------------------------
/templates/javascript/service/factory.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * @ngdoc service
5 | * @name <%= scriptAppName %>.<%= cameledName %>
6 | * @description
7 | * # <%= cameledName %>
8 | * Factory in the <%= scriptAppName %>.
9 | */
10 | angular.module('<%= scriptAppName %>')
11 | .factory('<%= cameledName %>', function () {
12 | // Service logic
13 | // ...
14 |
15 | var meaningOfLife = 42;
16 |
17 | // Public API here
18 | return {
19 | someMethod: function () {
20 | return meaningOfLife;
21 | }
22 | };
23 | });
24 |
--------------------------------------------------------------------------------
/templates/coffeescript/spec/filter.coffee:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | describe 'Filter: <%= cameledName %>', ->
4 |
5 | # load the filter's module
6 | beforeEach module '<%= scriptAppName %>'
7 |
8 | # initialize a new instance of the filter before each test
9 | <%= cameledName %> = {}
10 | beforeEach inject ($filter) ->
11 | <%= cameledName %> = $filter '<%= cameledName %>'
12 |
13 | it 'should return the input prefixed with "<%= cameledName %> filter:"', ->
14 | text = 'angularjs'
15 | expect(<%= cameledName %> text).toBe ('<%= cameledName %> filter: ' + text)
16 |
--------------------------------------------------------------------------------
/templates/typescript/service/factory.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | 'use strict';
4 |
5 | module <%= scriptAppName %> {
6 | export function <%= cameledName %>Factory() {
7 | return new <%= classedName %>(42);
8 | }
9 |
10 | export class <%= classedName %> {
11 | // @ngInject
12 | constructor (private meaningOfLife) {
13 | }
14 |
15 | someMethod() {
16 | return this.meaningOfLife;
17 | }
18 | }
19 | }
20 |
21 | angular.module('<%= scriptAppName %>')
22 | .factory('<%= cameledName %>', <%= scriptAppName %>.<%= cameledName %>Factory);
23 |
--------------------------------------------------------------------------------
/templates/coffeescript/spec/directive.coffee:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | describe 'Directive: <%= cameledName %>', ->
4 |
5 | # load the directive's module
6 | beforeEach module '<%= scriptAppName %>'
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 <%= cameledName %> directive'
17 |
--------------------------------------------------------------------------------
/templates/typescript/service/provider.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | 'use strict';
4 |
5 | module <%= scriptAppName %> {
6 |
7 | var salutation: string;
8 |
9 | export class Greeter {
10 | greet = () => salutation;
11 | }
12 |
13 | export class <%= classedName %>Provider {
14 | $get = () => new Greeter();
15 |
16 | // Public API for configuration
17 | setSalutation = (s: string) => salutation = s;
18 | }
19 |
20 | }
21 |
22 |
23 | angular.module('<%= scriptAppName %>')
24 | .provider('<%= cameledName %>', <%= scriptAppName %>.<%= classedName %>Provider);
25 |
--------------------------------------------------------------------------------
/templates/javascript/app.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * @ngdoc overview
5 | * @name <%= scriptAppName %>
6 | * @description
7 | * # <%= scriptAppName %>
8 | *
9 | * Main module of the application.
10 | */
11 | angular
12 | .module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) { %>
13 | .config(function ($routeProvider) {
14 | $routeProvider
15 | .when('/', {
16 | templateUrl: 'views/main.html',
17 | controller: 'MainCtrl',
18 | controllerAs: 'main'
19 | })
20 | .otherwise({
21 | redirectTo: '/'
22 | });
23 | })<% } %>;
24 |
--------------------------------------------------------------------------------
/templates/coffeescript/spec/controller.coffee:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | describe 'Controller: <%= classedName %>Ctrl', ->
4 |
5 | # load the controller's module
6 | beforeEach module '<%= scriptAppName %>'
7 |
8 | <%= classedName %>Ctrl = {}
9 |
10 | # Initialize the controller and a mock scope
11 | beforeEach inject ($controller, $rootScope) ->
12 | <%= classedName %>Ctrl = $controller '<%= classedName %>Ctrl', {
13 | # place here mocked dependencies
14 | }
15 |
16 | it 'should attach a list of awesomeThings to the scope', ->
17 | expect(<%= classedName %>Ctrl.awesomeThings.length).toBe 3
18 |
--------------------------------------------------------------------------------
/templates/typescript/decorator.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | 'use strict';
4 |
5 | module <%= scriptAppName %> {
6 | export function <%= cameledName %>DecoratorProvider($provide: ng.auto.IProvideService): void {
7 | //decorate <%= cameledName %>
8 | $provide.decorator('<%= cameledName %>', <%= cameledName %>Decorator);
9 | }
10 |
11 | export function <%= cameledName %>Decorator($delegate: any) {
12 | // decorate the $delegate
13 | return $delegate;
14 | }
15 | }
16 |
17 | angular.module('<%= scriptAppName %>')
18 | .config(<%= scriptAppName %>.<%= cameledName %>DecoratorProvider);
19 |
--------------------------------------------------------------------------------
/templates/typescript/filter.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | 'use strict';
4 |
5 | module <%= scriptAppName %> {
6 | export function <%= cameledName %>FilterFactory(): Function {
7 | return <%= cameledName %>Filter;
8 | }
9 |
10 | function <%= cameledName %>Filter(input, param) {
11 | //usage {{"text" | <%= cameledName %>: "suffix"}}
12 | //returns '<%= cameledName %> filter: text suffix'
13 | return '<%= cameledName %> filter: ' + input + (param ? ' ' + param: '');
14 | }
15 | }
16 |
17 | angular.module('<%= scriptAppName %>')
18 | .filter('<%= cameledName %>', <%= scriptAppName %>.<%= cameledName %>FilterFactory);
--------------------------------------------------------------------------------
/templates/javascript/spec/filter.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Filter: <%= cameledName %>', function () {
4 |
5 | // load the filter's module
6 | beforeEach(module('<%= scriptAppName %>'));
7 |
8 | // initialize a new instance of the filter before each test
9 | var <%= cameledName %>;
10 | beforeEach(inject(function ($filter) {
11 | <%= cameledName %> = $filter('<%= cameledName %>');
12 | }));
13 |
14 | it('should return the input prefixed with "<%= cameledName %> filter:"', function () {
15 | var text = 'angularjs';
16 | expect(<%= cameledName %>(text)).toBe('<%= cameledName %> filter: ' + text);
17 | });
18 |
19 | });
20 |
--------------------------------------------------------------------------------
/templates/typescript/controller.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | 'use strict';
4 |
5 | module <%= scriptAppName %> {
6 | export interface I<%= classedName %>Scope extends ng.IScope {
7 | awesomeThings: any[];
8 | }
9 |
10 | export class <%= classedName %>Ctrl {
11 | // @ngInject
12 | constructor (private $scope: I<%= classedName %>Scope) {
13 | $scope.awesomeThings = [
14 | 'HTML5 Boilerplate',
15 | 'AngularJS',
16 | 'Karma'
17 | ];
18 | }
19 | }
20 | }
21 |
22 | angular.module('<%= scriptAppName %>')
23 | .controller('<%= classedName %>Ctrl', <%= scriptAppName %>.<%= classedName %>Ctrl);
24 |
--------------------------------------------------------------------------------
/templates/javascript/spec/directive.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Directive: <%= cameledName %>', function () {
4 |
5 | // load the directive's module
6 | beforeEach(module('<%= scriptAppName %>'));
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 <%= cameledName %> directive');
19 | }));
20 | });
21 |
--------------------------------------------------------------------------------
/templates/javascript/spec/controller.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Controller: <%= classedName %>Ctrl', function () {
4 |
5 | // load the controller's module
6 | beforeEach(module('<%= scriptAppName %>'));
7 |
8 | var <%= classedName %>Ctrl;
9 |
10 | // Initialize the controller and a mock scope
11 | beforeEach(inject(function ($controller, $rootScope) {
12 | <%= classedName %>Ctrl = $controller('<%= classedName %>Ctrl', {
13 | // place here mocked dependencies
14 | });
15 | }));
16 |
17 | it('should attach a list of awesomeThings to the scope', function () {
18 | expect(<%= classedName %>Ctrl.awesomeThings.length).toBe(3);
19 | });
20 | });
21 |
--------------------------------------------------------------------------------
/templates/coffeescript/service/provider.coffee:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | ###*
4 | # @ngdoc service
5 | # @name <%= scriptAppName %>.<%= cameledName %>
6 | # @description
7 | # # <%= cameledName %>
8 | # Provider in the <%= scriptAppName %>.
9 | ###
10 | angular.module '<%= scriptAppName %>'
11 | .provider '<%= cameledName %>', ->
12 |
13 | # Private variables
14 | salutation = 'Hello'
15 |
16 | # Private constructor
17 | class Greeter
18 | @greet = ->
19 | salutation
20 |
21 | # Public API for configuration
22 | @setSalutation = (s) ->
23 | salutation = s
24 |
25 | # Method for instantiating
26 | @$get = ->
27 | new Greeter()
28 |
29 | return
30 |
--------------------------------------------------------------------------------
/templates/typescript/directive.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | 'use strict';
4 |
5 | module <%= scriptAppName %> {
6 |
7 | export class <%= classedName %> implements ng.IDirective {
8 | template = '';
9 | restrict = 'E';
10 | link = (scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes): void => {
11 | element.text('this is the <%= cameledName %> directive');
12 | }
13 | }
14 |
15 | export function <%= cameledName %>Factory() {
16 | return new <%= scriptAppName %>.<%= classedName %>();
17 | }
18 |
19 | }
20 |
21 | angular.module('<%= scriptAppName %>')
22 | .directive('<%= cameledName %>', <%= scriptAppName %>.<%= cameledName %>Factory);
23 |
--------------------------------------------------------------------------------
/main/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | var path = require('path');
3 | var util = require('util');
4 | var yeoman = require('yeoman-generator');
5 | var ScriptBase = require('../script-base.js');
6 |
7 | var Generator = module.exports = function Generator() {
8 | ScriptBase.apply(this, arguments);
9 | };
10 |
11 | util.inherits(Generator, ScriptBase);
12 |
13 | Generator.prototype.createAppFile = function createAppFile() {
14 | this.angularModules = this.env.options.angularDeps;
15 | this.ngCookies = this.env.options.ngCookies;
16 | this.ngResource = this.env.options.ngResource;
17 | this.ngSanitize = this.env.options.ngSanitize;
18 | this.ngRoute = this.env.options.ngRoute;
19 | this.appTemplate('app', 'scripts/app');
20 | };
21 |
--------------------------------------------------------------------------------
/templates/typescript/spec/service.ts:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 | ///
4 |
5 | 'use strict';
6 |
7 | describe('Service: <%= cameledName %>', () => {
8 |
9 | // load the service's module
10 | beforeEach(module('<%= scriptAppName %>'));
11 |
12 | // instantiate service
13 | var <%= cameledName %>;
14 | beforeEach(inject(_<%= cameledName %>_ => {
15 | <%= cameledName %> = _<%= cameledName %>_;
16 | }));
17 |
18 | it('should do something', () => {
19 | expect(!!<%= cameledName %>).toBe(true);
20 | });
21 |
22 | });
23 |
--------------------------------------------------------------------------------
/templates/common/app/views/main.html:
--------------------------------------------------------------------------------
1 |
2 |
'Allo, 'Allo!
3 |
4 | 
5 | Always a pleasure scaffolding your apps.
6 |
7 |
Splendid!
8 |
9 |
10 |
11 |
HTML5 Boilerplate
12 |
13 | HTML5 Boilerplate is a professional front-end template for building fast, robust, and adaptable web apps or sites.
14 |
15 |
16 |
Angular
17 |
18 | AngularJS is a toolset for building the framework most suited to your application development.
19 |
20 |
21 |
Karma
22 |
Spectacular Test Runner for JavaScript.
23 |
24 |
--------------------------------------------------------------------------------
/templates/javascript/service/provider.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * @ngdoc service
5 | * @name <%= scriptAppName %>.<%= cameledName %>
6 | * @description
7 | * # <%= cameledName %>
8 | * Provider in the <%= scriptAppName %>.
9 | */
10 | angular.module('<%= scriptAppName %>')
11 | .provider('<%= cameledName %>', function () {
12 |
13 | // Private variables
14 | var salutation = 'Hello';
15 |
16 | // Private constructor
17 | function Greeter() {
18 | this.greet = function () {
19 | return salutation;
20 | };
21 | }
22 |
23 | // Public API for configuration
24 | this.setSalutation = function (s) {
25 | salutation = s;
26 | };
27 |
28 | // Method for instantiating
29 | this.$get = function () {
30 | return new Greeter();
31 | };
32 | });
33 |
--------------------------------------------------------------------------------
/controller/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 | // if the controller name is suffixed with ctrl, remove the suffix
10 | // if the controller name is just "ctrl," don't append/remove "ctrl"
11 | if (this.name && this.name.toLowerCase() !== 'ctrl' && this.name.substr(-4).toLowerCase() === 'ctrl') {
12 | this.name = this.name.slice(0, -4);
13 | }
14 | };
15 |
16 | util.inherits(Generator, ScriptBase);
17 |
18 | Generator.prototype.createControllerFiles = function createControllerFiles() {
19 | this.generateSourceAndTest(
20 | 'controller',
21 | 'spec/controller',
22 | 'controllers',
23 | this.options['skip-add'] || false
24 | );
25 | };
26 |
--------------------------------------------------------------------------------
/templates/typescript/spec/filter.ts:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 | ///
4 |
5 | 'use strict';
6 |
7 | describe('Filter: <%= cameledName %>', () => {
8 |
9 | // load the filter's module
10 | beforeEach(module('<%= scriptAppName %>'));
11 |
12 | // initialize a new instance of the filter before each test
13 | var <%= cameledName %>;
14 | beforeEach(inject($filter => {
15 | <%= cameledName %> = $filter('<%= cameledName %>');
16 | }));
17 |
18 | it('should return the input prefixed with "<%= cameledName %> filter:"', () => {
19 | var text = 'angularjs';
20 | expect(<%= cameledName %>(text)).toBe('<%= cameledName %> filter: ' + text);
21 | });
22 |
23 | });
24 |
--------------------------------------------------------------------------------
/templates/typescript/app.ts:
--------------------------------------------------------------------------------
1 | /// <% if (ngCookies) { %>
2 | /// <% } %><% if (ngResource) { %>
3 | /// <% } %><% if (ngSanitize) { %>
4 | /// <% } %><% if (ngRoute) { %>
5 | /// <% } %>
6 |
7 | 'use strict';
8 |
9 | angular.module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) { %>
10 | .config(($routeProvider:ng.route.IRouteProvider) => {
11 | $routeProvider
12 | .when('/', {
13 | templateUrl: 'views/main.html',
14 | controller: 'MainCtrl'
15 | })
16 | .otherwise({
17 | redirectTo: '/'
18 | });
19 | })<% } %>;
20 |
--------------------------------------------------------------------------------
/templates/typescript/spec/directive.ts:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 | ///
4 |
5 | 'use strict';
6 |
7 | describe('Directive: <%= cameledName %>', () => {
8 |
9 | // load the directive's module
10 | beforeEach(module('<%= scriptAppName %>'));
11 |
12 | var element: JQuery,
13 | scope: ng.IScope;
14 |
15 | beforeEach(inject(($rootScope: ng.IRootScopeService) => {
16 | scope = $rootScope.$new();
17 | }));
18 |
19 | it('should make hidden element visible', inject(($compile: ng.ICompileService) => {
20 | element = angular.element('<<%= _.dasherize(name) %>><%= _.dasherize(name) %>>');
21 | element = $compile(element)(scope);
22 | expect(element.text()).toBe('this is the <%= cameledName %> directive');
23 | }));
24 | });
25 |
--------------------------------------------------------------------------------
/test/test-load.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var assert = require('yeoman-generator').assert;
4 |
5 | describe('Angular-Module generator load test', function () {
6 | it('can be imported without blowing up', function () {
7 | assert(require('../app') !== undefined);
8 | assert(require('../common') !== undefined);
9 | assert(require('../constant') !== undefined);
10 | assert(require('../controller') !== undefined);
11 | assert(require('../decorator') !== undefined);
12 | assert(require('../directive') !== undefined);
13 | assert(require('../factory') !== undefined);
14 | assert(require('../filter') !== undefined);
15 | assert(require('../main') !== undefined);
16 | assert(require('../provider') !== undefined);
17 | assert(require('../route') !== undefined);
18 | assert(require('../service') !== undefined);
19 | assert(require('../value') !== undefined);
20 | assert(require('../view') !== undefined);
21 | });
22 | });
23 |
--------------------------------------------------------------------------------
/templates/typescript/spec/controller.ts:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 | ///
4 |
5 | 'use strict';
6 |
7 | describe('Controller: <%= classedName %>Ctrl', () => {
8 |
9 | // load the controller's module
10 | beforeEach(module('<%= scriptAppName %>'));
11 |
12 | var <%= classedName %>Ctrl: <%= scriptAppName %>.<%= classedName %>Ctrl,
13 | scope: <%= scriptAppName %>.I<%= classedName %>Scope;
14 |
15 | // Initialize the controller and a mock scope
16 | beforeEach(inject(($controller: ng.IControllerService, $rootScope: ng.IRootScopeService) => {
17 | scope = $rootScope.$new();
18 | <%= classedName %>Ctrl = $controller('<%= classedName %>Ctrl', {
19 | $scope: scope
20 | });
21 | }));
22 |
23 | it('should attach a list of awesomeThings to the scope', () => {
24 | expect(scope.awesomeThings.length).toBe(3);
25 | });
26 | });
27 |
--------------------------------------------------------------------------------
/view/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | var path = require('path');
3 | var util = require('util');
4 | var yeoman = require('yeoman-generator');
5 |
6 | var Generator = module.exports = function Generator() {
7 | yeoman.generators.NamedBase.apply(this, arguments);
8 |
9 | this.sourceRoot(path.join(__dirname, '../templates/common'));
10 |
11 | if (typeof this.env.options.appPath === 'undefined') {
12 | this.env.options.appPath = this.options.appPath;
13 |
14 | if (!this.env.options.appPath) {
15 | try {
16 | this.env.options.appPath = require(path.join(process.cwd(), 'bower.json')).appPath;
17 | } catch (e) {}
18 | }
19 | this.env.options.appPath = this.env.options.appPath || 'app';
20 | this.options.appPath = this.env.options.appPath;
21 | }
22 | };
23 |
24 | util.inherits(Generator, yeoman.generators.NamedBase);
25 |
26 | Generator.prototype.createViewFiles = function createViewFiles() {
27 | this.template(
28 | 'app/views/view.html',
29 | path.join(
30 | this.env.options.appPath,
31 | 'views',
32 | this.name.toLowerCase() + '.html'
33 | )
34 | );
35 | };
36 |
--------------------------------------------------------------------------------
/templates/common/root/_tsd.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "v4",
3 | "repo": "borisyankov/DefinitelyTyped",
4 | "ref": "master",
5 | "path": "typings",
6 | "bundle": "typings/tsd.d.ts",
7 | "installed": {
8 | "jquery/jquery.d.ts": {
9 | "commit": "f3244190e20af6901e865f4cc58127d19216baa1"
10 | },
11 | "angularjs/angular.d.ts": {
12 | "commit": "f3244190e20af6901e865f4cc58127d19216baa1"
13 | },
14 | "angularjs/angular-resource.d.ts": {
15 | "commit": "aadd63ecae3feb76ea2d4be80511e266b5c2c4a7"
16 | },
17 | "angularjs/angular-route.d.ts": {
18 | "commit": "f23cd55e319a0f67362ca0dbc4cf3e2ec1339f4e"
19 | },
20 | "angularjs/angular-mocks.d.ts": {
21 | "commit": "f23cd55e319a0f67362ca0dbc4cf3e2ec1339f4e"
22 | },
23 | "angularjs/angular-cookies.d.ts": {
24 | "commit": "f23cd55e319a0f67362ca0dbc4cf3e2ec1339f4e"
25 | },
26 | "angularjs/angular-sanitize.d.ts": {
27 | "commit": "f23cd55e319a0f67362ca0dbc4cf3e2ec1339f4e"
28 | },
29 | "jasmine/jasmine.d.ts": {
30 | "commit": "f23cd55e319a0f67362ca0dbc4cf3e2ec1339f4e"
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/templates/common/root/_bower.json:
--------------------------------------------------------------------------------
1 | {<% var ngVer = "1.3.0" %>
2 | "name": "<%= _.slugify(_.humanize(appname)) %>",
3 | "version": "0.0.0",
4 | "dependencies": {
5 | "angular": "^<%= ngVer %>"<% if (bootstrap) { %>,<% if (!compassBootstrap) { %>
6 | "bootstrap": "^3.2.0"<% } else { %>
7 | "bootstrap-sass-official": "^3.2.0"<% } } %><% if (animateModule) { %>,
8 | "angular-animate": "^<%= ngVer %>"<% } %><% if (ariaModule) { %>,
9 | "angular-aria": "^<%= ngVer %>"<% } %><% if (cookiesModule) { %>,
10 | "angular-cookies": "^<%= ngVer %>"<% } %><% if (messagesModule) { %>,
11 | "angular-messages": "^<%= ngVer %>"<% } %><% if (resourceModule) { %>,
12 | "angular-resource": "^<%= ngVer %>"<% } %><% if (routeModule) { %>,
13 | "angular-route": "^<%= ngVer %>"<% } %><% if (sanitizeModule) { %>,
14 | "angular-sanitize": "^<%= ngVer %>"<% } %><% if (touchModule) { %>,
15 | "angular-touch": "^<%= ngVer %>"<% } %>
16 | },
17 | "devDependencies": {
18 | "angular-mocks": "^<%= ngVer %>"
19 | }<% if (appPath) { %>,
20 | "appPath": "<%= appPath %>"<% } %>,
21 | "moduleName": "<%= scriptAppName %>"
22 | }
23 |
--------------------------------------------------------------------------------
/common/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.Base.apply(this, arguments);
9 | };
10 |
11 | util.inherits(Generator, yeoman.generators.Base);
12 |
13 | Generator.prototype.setupEnv = function setupEnv() {
14 | var join = path.join;
15 |
16 | this.sourceRoot(join(__dirname, '../templates/common/root'));
17 | this.copy('.editorconfig');
18 | this.copy('.gitattributes');
19 | this.copy('.jshintrc');
20 | this.copy('.yo-rc.json');
21 | this.copy('gitignore', '.gitignore');
22 | this.directory('test');
23 |
24 | this.sourceRoot(join(__dirname, '../templates/common'));
25 | var appPath = this.options.appPath;
26 | var copy = function (dest) {
27 | this.copy(join('app', dest), join(appPath, dest));
28 | }.bind(this);
29 |
30 | copy('.buildignore');
31 | copy('.htaccess');
32 | copy('404.html');
33 | copy('favicon.ico');
34 | copy('robots.txt');
35 | copy('views/main.html');
36 | this.directory(join('app', 'images'), join(appPath, 'images'));
37 | };
38 |
--------------------------------------------------------------------------------
/templates/common/root/_package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "<%= _.slugify(appname) %>",
3 | "private": true,
4 | "devDependencies": {
5 | "grunt": "^0.4.5",
6 | "grunt-angular-templates": "^0.5.7",
7 | "grunt-autoprefixer": "^2.0.0",
8 | "grunt-concurrent": "^1.0.0",
9 | "grunt-contrib-clean": "^0.6.0",<% if (coffee) { %>
10 | "grunt-contrib-coffee": "^0.12.0",<% } %><% if (compass) { %>
11 | "grunt-contrib-compass": "^1.0.0",<% } %>
12 | "grunt-contrib-concat": "^0.5.0",
13 | "grunt-contrib-connect": "^0.9.0",
14 | "grunt-contrib-copy": "^0.7.0",
15 | "grunt-contrib-cssmin": "^0.12.0",
16 | "grunt-contrib-htmlmin": "^0.4.0",
17 | "grunt-contrib-imagemin": "^1.0.0",
18 | "grunt-contrib-jshint": "^0.11.0",
19 | "grunt-contrib-uglify": "^0.7.0",
20 | "grunt-contrib-watch": "^0.6.1",
21 | "grunt-filerev": "^2.1.2",
22 | "grunt-google-cdn": "^0.4.3",
23 | "grunt-karma": "^0.12.1",
24 | "grunt-newer": "^1.1.0",
25 | "grunt-ng-annotate": "^0.9.2",
26 | "grunt-svgmin": "^2.0.0",<% if (typescript) { %>
27 | "grunt-tsd": "^0.1.0",
28 | "grunt-typescript": "^0.6.2",<% } %>
29 | "grunt-usemin": "^3.0.0",
30 | "grunt-wiredep": "^2.0.0",
31 | "jshint-stylish": "^1.0.0",
32 | "load-grunt-tasks": "^3.1.0",
33 | "time-grunt": "^1.0.0"
34 | },
35 | "engines": {
36 | "node": ">=0.10.0"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "generator-angular-typescript",
3 | "version": "0.11.2",
4 | "description": "Yeoman generator for AngularJS with TypeScript",
5 | "keywords": [
6 | "yeoman-generator",
7 | "scaffold",
8 | "framework",
9 | "component",
10 | "front-end",
11 | "app",
12 | "angular",
13 | "TypeScript"
14 | ],
15 | "author": ["The Yeoman Team", "awk@onshape.com"],
16 | "main": "app/index.js",
17 | "files": [
18 | "app",
19 | "common",
20 | "constant",
21 | "controller",
22 | "decorator",
23 | "directive",
24 | "factory",
25 | "filter",
26 | "main",
27 | "provider",
28 | "route",
29 | "service",
30 | "templates",
31 | "value",
32 | "view",
33 | "script-base.js",
34 | "util.js"
35 | ],
36 | "repository": "onshape/generator-angular-typescript",
37 | "scripts": {
38 | "test": "mocha"
39 | },
40 | "dependencies": {
41 | "chalk": "^1.0.0",
42 | "wiredep": "^2.2.0",
43 | "yeoman-generator": "^0.16.0",
44 | "yosay": "^1.0.2"
45 | },
46 | "peerDependencies": {
47 | "generator-karma-typescript": ">=0.9.0"
48 | },
49 | "devDependencies": {
50 | "grunt": "^0.4.5",
51 | "grunt-contrib-jshint": "^0.11.0",
52 | "grunt-conventional-changelog": "^1.1.0",
53 | "grunt-release": "^0.11.0",
54 | "load-grunt-tasks": "^3.1.0",
55 | "mocha": "*",
56 | "semver": "^4.3.0",
57 | "underscore.string": "^3.0.3"
58 | },
59 | "engines": {
60 | "node": ">=0.10.0"
61 | },
62 | "licenses": [
63 | {
64 | "type": "BSD"
65 | }
66 | ]
67 | }
68 |
--------------------------------------------------------------------------------
/templates/common/app/styles/main.css:
--------------------------------------------------------------------------------
1 | .browsehappy {
2 | margin: 0.2em 0;
3 | background: #ccc;
4 | color: #000;
5 | padding: 0.2em 0;
6 | }
7 |
8 | body {
9 | padding: 0;
10 | }
11 |
12 | /* Everything but the jumbotron gets side spacing for mobile first views */
13 | .header,
14 | .marketing,
15 | .footer {
16 | padding-left: 15px;
17 | padding-right: 15px;
18 | }
19 |
20 | /* Custom page header */
21 | .header {
22 | border-bottom: 1px solid #e5e5e5;
23 | margin-bottom: 10px;
24 | }
25 | /* Make the masthead heading the same height as the navigation */
26 | .header h3 {
27 | margin-top: 0;
28 | margin-bottom: 0;
29 | line-height: 40px;
30 | padding-bottom: 19px;
31 | }
32 |
33 | /* Custom page footer */
34 | .footer {
35 | padding-top: 19px;
36 | color: #777;
37 | border-top: 1px solid #e5e5e5;
38 | }
39 |
40 | .container-narrow > hr {
41 | margin: 30px 0;
42 | }
43 |
44 | /* Main marketing message and sign up button */
45 | .jumbotron {
46 | text-align: center;
47 | border-bottom: 1px solid #e5e5e5;
48 | }
49 | .jumbotron .btn {
50 | font-size: 21px;
51 | padding: 14px 24px;
52 | }
53 |
54 | /* Supporting marketing content */
55 | .marketing {
56 | margin: 40px 0;
57 | }
58 | .marketing p + h4 {
59 | margin-top: 28px;
60 | }
61 |
62 | /* Responsive: Portrait tablets and up */
63 | @media screen and (min-width: 768px) {
64 | .container {
65 | max-width: 730px;
66 | }
67 |
68 | /* Remove the padding we set earlier */
69 | .header,
70 | .marketing,
71 | .footer {
72 | padding-left: 0;
73 | padding-right: 0;
74 | }
75 | /* Space out the masthead */
76 | .header {
77 | margin-bottom: 30px;
78 | }
79 | /* Remove the bottom border on the jumbotron for visual effect */
80 | .jumbotron {
81 | border-bottom: 0;
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/templates/common/app/styles/main.scss:
--------------------------------------------------------------------------------
1 | <% if (compassBootstrap) { %>$icon-font-path: "../bower_components/bootstrap-sass-official/assets/fonts/bootstrap/";
2 | <% } %>// bower:scss
3 | // endbower
4 |
5 | .browsehappy {
6 | margin: 0.2em 0;
7 | background: #ccc;
8 | color: #000;
9 | padding: 0.2em 0;
10 | }
11 |
12 | body {
13 | padding: 0;
14 | }
15 |
16 | /* Everything but the jumbotron gets side spacing for mobile first views */
17 | .header,
18 | .marketing,
19 | .footer {
20 | padding-left: 15px;
21 | padding-right: 15px;
22 | }
23 |
24 | /* Custom page header */
25 | .header {
26 | border-bottom: 1px solid #e5e5e5;
27 | margin-bottom: 10px;
28 |
29 | /* Make the masthead heading the same height as the navigation */
30 | h3 {
31 | margin-top: 0;
32 | margin-bottom: 0;
33 | line-height: 40px;
34 | padding-bottom: 19px;
35 | }
36 | }
37 |
38 | /* Custom page footer */
39 | .footer {
40 | padding-top: 19px;
41 | color: #777;
42 | border-top: 1px solid #e5e5e5;
43 | }
44 |
45 | .container-narrow > hr {
46 | margin: 30px 0;
47 | }
48 |
49 | /* Main marketing message and sign up button */
50 | .jumbotron {
51 | text-align: center;
52 | border-bottom: 1px solid #e5e5e5;
53 |
54 | .btn {
55 | font-size: 21px;
56 | padding: 14px 24px;
57 | }
58 | }
59 |
60 | /* Supporting marketing content */
61 | .marketing {
62 | margin: 40px 0;
63 |
64 | p + h4 {
65 | margin-top: 28px;
66 | }
67 | }
68 |
69 | /* Responsive: Portrait tablets and up */
70 | @media screen and (min-width: 768px) {
71 | .container {
72 | max-width: 730px;
73 | }
74 |
75 | /* Remove the padding we set earlier */
76 | .header,
77 | .marketing,
78 | .footer {
79 | padding-left: 0;
80 | padding-right: 0;
81 | }
82 | /* Space out the masthead */
83 | .header {
84 | margin-bottom: 30px;
85 | }
86 | /* Remove the bottom border on the jumbotron for visual effect */
87 | .jumbotron {
88 | border-bottom: 0;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/util.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | var path = require('path');
3 | var fs = require('fs');
4 |
5 | function escapeRegExp (str) {
6 | return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
7 | }
8 |
9 | function rewrite (args) {
10 | /* jshint -W044 */
11 | // check if splicable is already in the body text
12 | var re = new RegExp(args.splicable.map(function (line) {
13 | return '\s*' + escapeRegExp(line);
14 | }).join('\n'));
15 |
16 | if (re.test(args.haystack)) {
17 | return args.haystack;
18 | }
19 |
20 | var lines = args.haystack.split('\n');
21 |
22 | var otherwiseLineIndex = 0;
23 | lines.forEach(function (line, i) {
24 | if (line.indexOf(args.needle) !== -1) {
25 | otherwiseLineIndex = i;
26 | }
27 | });
28 |
29 | var spaces = 0;
30 | while (lines[otherwiseLineIndex].charAt(spaces) === ' ') {
31 | spaces += 1;
32 | }
33 |
34 | var spaceStr = '';
35 | while ((spaces -= 1) >= 0) {
36 | spaceStr += ' ';
37 | }
38 |
39 | lines.splice(otherwiseLineIndex, 0, args.splicable.map(function (line) {
40 | return spaceStr + line;
41 | }).join('\n'));
42 |
43 | return lines.join('\n');
44 | }
45 |
46 | function rewriteFile (args) {
47 | args.path = args.path || process.cwd();
48 | var fullPath = path.join(args.path, args.file);
49 |
50 | args.haystack = fs.readFileSync(fullPath, 'utf8');
51 | var body = rewrite(args);
52 |
53 | fs.writeFileSync(fullPath, body);
54 | }
55 |
56 | function appName (self) {
57 | var counter = 0, suffix = self.options['app-suffix'];
58 | // Have to check this because of generator bug #386
59 | process.argv.forEach(function(val) {
60 | if (val.indexOf('--app-suffix') > -1) {
61 | counter++;
62 | }
63 | });
64 | if (counter === 0 || (typeof suffix === 'boolean' && suffix)) {
65 | suffix = 'App';
66 | }
67 | return suffix ? self._.classify(suffix) : '';
68 | }
69 |
70 |
71 | module.exports = {
72 | rewrite: rewrite,
73 | rewriteFile: rewriteFile,
74 | appName: appName
75 | };
76 |
--------------------------------------------------------------------------------
/test/test-appname-substitution.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var helpers = require('yeoman-generator').test;
5 |
6 | describe('Angular generator template', function () {
7 | var angular;
8 | var appName = 'upperCaseBug';
9 |
10 | beforeEach(function (done) {
11 | var deps = [
12 | '../../../app',
13 | '../../../common',
14 | '../../../controller',
15 | '../../../main',
16 | [ helpers.createDummyGenerator(), 'karma:app' ]
17 | ];
18 | helpers.testDirectory(path.join(__dirname, 'tmp', appName), function (err) {
19 | if (err) {
20 | done(err);
21 | }
22 |
23 | angular = helpers.createGenerator('angular-typescript:app', deps, [appName], {
24 | 'appPath': 'app',
25 | 'skip-welcome-message': true,
26 | 'skip-install': true,
27 | 'skip-message': true
28 | });
29 |
30 | helpers.mockPrompt(angular, {
31 | compass: true,
32 | bootstrap: true,
33 | compassBootstrap: true,
34 | modules: []
35 | });
36 |
37 | done();
38 | });
39 | });
40 |
41 | it('should generate the same appName in every file', function (done) {
42 | angular.run({}, function () {
43 | helpers.assertFile([
44 | 'app/scripts/app.js',
45 | 'app/scripts/controllers/main.js',
46 | 'app/index.html',
47 | 'test/spec/controllers/main.js'
48 | ]);
49 |
50 | helpers.assertFileContent(
51 | 'app/scripts/app.js',
52 | new RegExp('module\\(\'' + appName + 'App\'')
53 | );
54 | helpers.assertFileContent(
55 | 'app/scripts/controllers/main.js',
56 | new RegExp('module\\(\'' + appName + 'App\'')
57 | );
58 | helpers.assertFileContent(
59 | 'test/spec/controllers/main.js',
60 | new RegExp('module\\(\'' + appName + 'App\'')
61 | );
62 |
63 | helpers.assertFileContent(
64 | 'app/index.html',
65 | new RegExp('ng-app=\"' + appName + 'App\"')
66 | );
67 | done();
68 | });
69 | });
70 | });
71 |
--------------------------------------------------------------------------------
/route/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | var path = require('path');
3 | var chalk = require('chalk');
4 | var util = require('util');
5 | var ScriptBase = require('../script-base.js');
6 | var angularUtils = require('../util.js');
7 |
8 |
9 | var Generator = module.exports = function Generator() {
10 | ScriptBase.apply(this, arguments);
11 | this.option('uri', {
12 | desc: 'Allow a custom uri for routing',
13 | type: String,
14 | required: false
15 | });
16 |
17 | var coffee = this.env.options.coffee;
18 | var typescript = this.env.options.typescript;
19 | var bower = require(path.join(process.cwd(), 'bower.json'));
20 | var match = require('fs').readFileSync(path.join(
21 | this.env.options.appPath,
22 | 'scripts/app.' + (coffee ? 'coffee' : typescript ? 'ts': 'js')
23 | ), 'utf-8').match(/\.when/);
24 |
25 | if (
26 | bower.dependencies['angular-route'] ||
27 | bower.devDependencies['angular-route'] ||
28 | match !== null
29 | ) {
30 | this.foundWhenForRoute = true;
31 | }
32 |
33 | this.hookFor('angular-typescript:controller');
34 | this.hookFor('angular-typescript:view');
35 | };
36 |
37 | util.inherits(Generator, ScriptBase);
38 |
39 | Generator.prototype.rewriteAppJs = function () {
40 | var coffee = this.env.options.coffee;
41 |
42 | if (!this.foundWhenForRoute) {
43 | this.on('end', function () {
44 | this.log(chalk.yellow(
45 | '\nangular-route is not installed. Skipping adding the route to ' +
46 | 'scripts/app.' + (coffee ? 'coffee' : 'js')
47 | ));
48 | });
49 | return;
50 | }
51 |
52 | this.uri = this.name;
53 | if (this.options.uri) {
54 | this.uri = this.options.uri;
55 | }
56 |
57 | var typescript = this.env.options.typescript;
58 | var config = {
59 | file: path.join(
60 | this.env.options.appPath,
61 | 'scripts/app.' + (coffee ? 'coffee' : typescript ? 'ts': 'js')
62 | ),
63 | needle: '.otherwise',
64 | splicable: [
65 | " templateUrl: 'views/" + this.name.toLowerCase() + ".html'" + (coffee ? "" : "," ),
66 | " controller: '" + this.classedName + "Ctrl'" + (coffee ? "" : ","),
67 | " controllerAs: '" + this.cameledName + "'"
68 | ]
69 | };
70 |
71 | if (coffee) {
72 | config.splicable.unshift(".when '/" + this.uri + "',");
73 | }
74 | else {
75 | config.splicable.unshift(".when('/" + this.uri + "', {");
76 | config.splicable.push("})");
77 | }
78 |
79 | angularUtils.rewriteFile(config);
80 | };
81 |
--------------------------------------------------------------------------------
/decorator/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | var util = require('util');
3 | var ScriptBase = require('../script-base.js');
4 | var fs = require('fs');
5 | var path = require('path');
6 |
7 | function buildRelativePath(fileName){
8 | return path.join('decorators', fileName + "Decorator");
9 | }
10 |
11 | var Generator = module.exports = function Generator(args, options) {
12 | ScriptBase.apply(this, arguments);
13 | this.fileName = this.name;
14 |
15 | if (typeof this.env.options.appPath === 'undefined') {
16 | this.env.options.appPath = this.options.appPath;
17 |
18 | if (!this.env.options.appPath) {
19 | try {
20 | this.env.options.appPath = require(path.join(process.cwd(), 'bower.json')).appPath;
21 | } catch (e) {}
22 | }
23 | this.env.options.appPath = this.env.options.appPath || 'app';
24 | this.options.appPath = this.env.options.appPath;
25 | }
26 | };
27 |
28 | util.inherits(Generator, ScriptBase);
29 |
30 | Generator.prototype.askForOverwrite = function askForOverwrite() {
31 | var cb = this.async();
32 |
33 | // TODO: Any yeoman.util function to handle this?
34 | if (fs.existsSync(path.join(
35 | this.env.cwd, this.env.options.appPath,
36 | 'scripts', buildRelativePath(this.fileName) + ".js"
37 | ))) {
38 | var prompts = [{
39 | type: 'confirm',
40 | name: 'overwriteDecorator',
41 | message: 'Would you like to overwrite existing decorator?',
42 | default: false
43 | }];
44 |
45 | this.prompt(prompts, function (props) {
46 | this.overwriteDecorator = props.overwriteDecorator;
47 |
48 | cb();
49 | }.bind(this));
50 | }
51 | else{
52 | cb();
53 | return;
54 | }
55 | };
56 |
57 | Generator.prototype.askForNewName = function askForNewName() {
58 | var cb = this.async();
59 |
60 | if (this.overwriteDecorator === undefined || this.overwriteDecorator === true) {
61 | cb();
62 | return;
63 | }
64 | else {
65 | var prompts = [];
66 | prompts.push({
67 | name: 'decoratorName',
68 | message: 'Alternative name for the decorator'
69 | });
70 |
71 | this.prompt(prompts, function (props) {
72 | this.fileName = props.decoratorName;
73 |
74 | cb();
75 | }.bind(this));
76 | }
77 | };
78 |
79 | Generator.prototype.createDecoratorFiles = function createDecoratorFiles() {
80 | this.appTemplate(
81 | 'decorator',
82 | path.join('scripts', buildRelativePath(this.fileName))
83 | );
84 | this.addScriptToIndex(buildRelativePath(this.fileName));
85 | };
86 |
--------------------------------------------------------------------------------
/test/test-route-creation.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var helpers = require('yeoman-generator').test;
5 |
6 | describe('Angular generator route', function () {
7 | var angular;
8 | var route = 'simpleroute';
9 | var expected = [
10 | 'app/scripts/controllers/' + route + '.js',
11 | 'test/spec/controllers/' + route + '.js',
12 | 'app/views/' + route + '.html'
13 | ];
14 | var genOptions = {
15 | 'appPath': 'app',
16 | 'skip-install': true,
17 | 'skip-welcome-message': true,
18 | 'skip-message': true
19 | };
20 | var mockPrompts = {
21 | compass: true,
22 | bootstrap: true,
23 | compassBootstrap: true,
24 | modules: ['routeModule']
25 | };
26 |
27 | beforeEach(function (done) {
28 | helpers.testDirectory(path.join(__dirname, 'tmp', route), function (err) {
29 | if (err) {
30 | done(err);
31 | }
32 | angular = helpers.createGenerator(
33 | 'angular-typescript:app',
34 | [
35 | '../../../app',
36 | '../../../common',
37 | '../../../controller',
38 | '../../../main',
39 | '../../../route',
40 | '../../../view',
41 | [ helpers.createDummyGenerator(), 'karma:app']
42 | ],
43 | false,
44 | genOptions
45 | );
46 | helpers.mockPrompt(angular, mockPrompts);
47 | angular.run({}, function () {
48 | angular = helpers.createGenerator(
49 | 'angular-typescript:route',
50 | [
51 | '../../../controller',
52 | '../../../route',
53 | '../../../view'
54 | ],
55 | [route],
56 | genOptions
57 | );
58 | helpers.mockPrompt(angular, mockPrompts);
59 | done();
60 | });
61 | });
62 | });
63 |
64 | describe('create routes', function () {
65 | it('should generate default route items', function(done){
66 | angular.run({}, function(e) {
67 | helpers.assertFile(expected);
68 | helpers.assertFileContent(
69 | 'app/scripts/app.js',
70 | new RegExp('when\\(\'/' + route + '\'')
71 | );
72 |
73 | done();
74 | });
75 | });
76 |
77 | // Test with URI specified explicitly
78 | it('should generate route items with the route uri given', function(done){
79 | var uri = 'segment1/segment2/:parameter';
80 |
81 | angular.options.uri = uri;
82 | angular.run({}, function() {
83 | helpers.assertFile(expected);
84 | helpers.assertFileContent(
85 | 'app/scripts/app.js',
86 | new RegExp('when\\(\'/' + uri + '\'')
87 | );
88 |
89 | done();
90 | });
91 | });
92 | });
93 | });
94 |
--------------------------------------------------------------------------------
/Gruntfile.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | var semver = require('semver');
3 |
4 | module.exports = function (grunt) {
5 | require('load-grunt-tasks')(grunt);
6 |
7 | grunt.initConfig({
8 | pkg: require('./package.json'),
9 | jshint: {
10 | all: {
11 | options: {
12 | jshintrc: './.jshintrc'
13 | },
14 | src: [
15 | '**/index.js',
16 | '*.js',
17 | '!test/**/*.js',
18 | '!node_modules/**/*.js'
19 | ]
20 | }
21 | },
22 | changelog: {
23 | options: {
24 | dest: 'CHANGELOG.md',
25 | versionFile: 'package.json'
26 | }
27 | },
28 | release: {
29 | options: {
30 | bump: false, // we have our own bump
31 | file: 'package.json',
32 | commitMessage: 'chore(release): Release version <%= version %>',
33 | tagName: 'v<%= version %>',
34 | github: {
35 | repo: 'yeoman/generator-angular',
36 | usernameVar: 'GITHUB_USERNAME',
37 | passwordVar: 'GITHUB_AUTHTOKEN'
38 | }
39 | }
40 | },
41 | stage: {
42 | options: {
43 | files: ['CHANGELOG.md']
44 | }
45 | }
46 | });
47 |
48 | grunt.registerTask('default', ['jshint']);
49 |
50 | grunt.registerTask('bump', 'Bump manifest version', function (type) {
51 | var options = this.options({
52 | file: grunt.config('pkgFile') || 'package.json'
53 | });
54 |
55 | function setup(file, type) {
56 | var pkg = grunt.file.readJSON(file);
57 | var newVersion = pkg.version = semver.inc(pkg.version, type || 'patch');
58 | return {
59 | file: file,
60 | pkg: pkg,
61 | newVersion: newVersion
62 | };
63 | }
64 |
65 | var config = setup(options.file, type);
66 | grunt.file.write(
67 | config.file,
68 | JSON.stringify(config.pkg, null, ' ') + '\n'
69 | );
70 | grunt.config('pkg', config.pkg);
71 | grunt.log.ok('Version bumped to ' + config.newVersion);
72 | });
73 |
74 | grunt.registerTask('stage', 'Git adds files', function () {
75 | var files = this.options().files;
76 | grunt.util.spawn({
77 | cmd: process.platform === 'win32' ? 'git.cmd' : 'git',
78 | args: ['add'].concat(files)
79 | }, grunt.task.current.async());
80 | });
81 |
82 | // grunt-release will only commit the package.json file by default. Until
83 | // https://github.com/geddski/grunt-release/pull/43/files lands, it should
84 | // be patched to do the same so it commits the changelog as well.
85 | grunt.registerTask('publish', function (type) {
86 | grunt.task.run([
87 | 'default',
88 | 'bump' + (type ? ':' + type : ''),
89 | 'changelog',
90 | 'stage',
91 | 'release'
92 | ]);
93 | });
94 | };
95 |
--------------------------------------------------------------------------------
/contributing.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | See the [contributing docs](https://github.com/yeoman/yeoman/blob/master/contributing.md)
4 |
5 | Additionally for this generator:
6 |
7 | * When submitting an issue, please follow the [guidelines](https://github.com/yeoman/yeoman/blob/master/contributing.md#issue-submission). Especially important is to make sure Yeoman is up-to-date, and providing the command or commands that cause the issue.
8 | * When submitting a PR, make sure that the commit messages match the [AngularJS conventions][commit-message-format] (see below).
9 | * When submitting a bugfix, write a test that exposes the bug and fails before applying your fix. Submit the test alongside the fix.
10 | * When submitting a new feature, add tests that cover the feature.
11 |
12 | ## Git Commit Guidelines
13 |
14 | These rules are adopted from the AngularJS project.
15 |
16 | ### Commit Message Format
17 | Each commit message consists of a **header**, a **body** and a **footer**. The header has a special
18 | format that includes a **type**, a **scope** and a **subject**:
19 |
20 | ```
21 | ():
22 |
23 |
24 |
25 |