├── .gitattributes
├── templates
├── common
│ ├── root
│ │ ├── .gitattributes
│ │ ├── _bowerrc
│ │ ├── gitignore
│ │ ├── .jscsrc
│ │ ├── .jshintrc
│ │ ├── README.md
│ │ ├── .editorconfig
│ │ ├── _bower.json
│ │ ├── _package.json
│ │ └── _Gruntfile.js
│ ├── app
│ │ ├── views
│ │ │ ├── view.html
│ │ │ └── main.html
│ │ ├── robots.txt
│ │ ├── favicon.ico
│ │ ├── images
│ │ │ └── yeoman.png
│ │ ├── styles
│ │ │ ├── main.css
│ │ │ └── main.scss
│ │ ├── index.html
│ │ └── 404.html
│ ├── test
│ │ └── .jshintrc
│ └── scripts
│ │ ├── test-main.js
│ │ └── main.js
└── javascript
│ ├── service
│ ├── value.js
│ ├── constant.js
│ ├── service.js
│ ├── factory.js
│ └── provider.js
│ ├── filter.js
│ ├── decorator.js
│ ├── controller.js
│ ├── directive.js
│ ├── spec
│ ├── service.js
│ ├── filter.js
│ ├── directive.js
│ ├── provider.js
│ └── controller.js
│ └── app.js
├── .gitignore
├── 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
├── factory
├── USAGE
└── index.js
├── provider
├── USAGE
└── index.js
├── service
├── USAGE
└── index.js
├── constant
├── USAGE
└── index.js
├── .travis.yml
├── route
├── USAGE
└── index.js
├── .jshintrc
├── app
├── USAGE
└── index.js
├── test
├── utils.js
├── view.js
├── value.js
├── filter.js
├── factory.js
├── service.js
├── constant.js
├── provider.js
├── directive.js
├── controller.js
├── route.js
└── app.js
├── Gruntfile.js
├── package.json
├── contributing.md
├── util.js
├── script-base.js
└── README.md
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 |
--------------------------------------------------------------------------------
/templates/common/root/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | test/tmp
4 | npm-debug.log
5 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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/aaronallport/generator-angular-require/HEAD/templates/common/app/favicon.ico
--------------------------------------------------------------------------------
/templates/common/app/images/yeoman.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aaronallport/generator-angular-require/HEAD/templates/common/app/images/yeoman.png
--------------------------------------------------------------------------------
/view/USAGE:
--------------------------------------------------------------------------------
1 | Description:
2 | Creates a new AngularJS view
3 |
4 | Example:
5 | yo angular-require:view thing
6 |
7 | This will create:
8 | app/views/thing.html
9 |
--------------------------------------------------------------------------------
/filter/USAGE:
--------------------------------------------------------------------------------
1 | Description:
2 | Creates a new AngularJS filter
3 |
4 | Example:
5 | yo angular-require:filter thing
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-require:directive thing
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-require:controller Thing
6 |
7 | This will create:
8 | app/scripts/controllers/thing-ctrl.js
9 |
--------------------------------------------------------------------------------
/templates/common/root/.jscsrc:
--------------------------------------------------------------------------------
1 | {
2 | "requireCamelCaseOrUpperCaseIdentifiers": true,
3 | "requireCapitalizedConstructors": true,
4 | "requireParenthesesAroundIIFE": true,
5 | "validateQuoteMarks": "'"
6 | }
7 |
--------------------------------------------------------------------------------
/decorator/USAGE:
--------------------------------------------------------------------------------
1 | Description:
2 | Creates a new AngularJS decorator for a specified service
3 |
4 | Example:
5 | yo angular-require:decorator serviceName
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-require:value thing
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-require:factory thing
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-require:provider thing
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-require:service thing
7 |
8 | This will create:
9 | app/scripts/services/thing.js
10 |
--------------------------------------------------------------------------------
/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-require:constant thing
7 |
8 | This will create:
9 | app/scripts/services/thing.js
10 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: node_js
3 | node_js:
4 | - 'iojs'
5 | - '0.12'
6 | before_install:
7 | - currentfolder=${PWD##*/}
8 | - if [ "$currentfolder" != 'generator-angular-require' ]; then cd .. && eval "mv $currentfolder generator-angular-require" && cd generator-angular-require; fi
9 |
--------------------------------------------------------------------------------
/route/USAGE:
--------------------------------------------------------------------------------
1 | Description:
2 | Creates a new AngularJS route
3 |
4 | Example:
5 | yo angular-require:route thing [--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 |
--------------------------------------------------------------------------------
/.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": false,
13 | "undef": true,
14 | "globals": {
15 | /* AMD */
16 | "define" : false
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/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 | /* AMD */
16 | "define": false
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/templates/javascript/service/value.js:
--------------------------------------------------------------------------------
1 | define(['angular'], function (angular) {
2 | 'use strict';
3 |
4 | /**
5 | * @ngdoc service
6 | * @name <%= scriptAppName %>.<%= cameledName %>
7 | * @description
8 | * # <%= cameledName %>
9 | * Value in the <%= scriptAppName %>.
10 | */
11 | angular.module('<%= scriptAppName %>.services.<%= classedName %>', [])
12 | .value('<%= cameledName %>', 42);
13 | });
14 |
--------------------------------------------------------------------------------
/templates/common/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 | /* AMD */
17 | "define": false,
18 | "inject": false
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/templates/javascript/service/constant.js:
--------------------------------------------------------------------------------
1 | define(['angular'], function (angular) {
2 | 'use strict';
3 |
4 | /**
5 | * @ngdoc service
6 | * @name <%= scriptAppName %>.<%= cameledName %>
7 | * @description
8 | * # <%= cameledName %>
9 | * Constant in the <%= scriptAppName %>.
10 | */
11 | angular.module('<%= scriptAppName %>.services.<%= classedName %>', [])
12 | .constant('<%= cameledName %>', 42);
13 | });
14 |
--------------------------------------------------------------------------------
/templates/common/root/README.md:
--------------------------------------------------------------------------------
1 | # <%= appSlugName %>
2 |
3 | This project is generated with [yo angular-require generator](https://github.com/aaronallport/generator-angular-require)
4 | version <%= pkg.version %>.
5 |
6 | ## Development & building
7 |
8 | Run `grunt serve` for development preview.
9 |
10 | Run `grunt` for building.
11 |
12 | Run `grunt serve:dist` for building and previewing.
13 |
14 | ## Testing
15 |
16 | Running `grunt test` will run the unit tests.
17 |
--------------------------------------------------------------------------------
/app/USAGE:
--------------------------------------------------------------------------------
1 | Description:
2 | Creates a default AngularJS app
3 |
4 | Example:
5 | yo angular
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 |
--------------------------------------------------------------------------------
/templates/javascript/service/service.js:
--------------------------------------------------------------------------------
1 | define(['angular'], function (angular) {
2 | 'use strict';
3 |
4 | /**
5 | * @ngdoc service
6 | * @name <%= scriptAppName %>.<%= cameledName %>
7 | * @description
8 | * # <%= cameledName %>
9 | * Service in the <%= scriptAppName %>.
10 | */
11 | angular.module('<%= scriptAppName %>.services.<%= classedName %>', [])
12 | .service('<%= cameledName %>', function () {
13 | // AngularJS will instantiate a singleton by calling "new" on this function
14 | });
15 | });
16 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/view/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var util = require('util');
5 | var ScriptBase = require('../script-base.js');
6 |
7 | var ViewGenerator = ScriptBase.extend({
8 | constructor: function() {
9 | ScriptBase.apply(this, arguments);
10 | },
11 |
12 | createViewFile: function() {
13 | this.htmlTemplate(
14 | '../common/app/views/view.html',
15 | path.join(
16 | 'views',
17 | this.name.toLowerCase() + '.html'
18 | )
19 | );
20 | }
21 | });
22 |
23 | module.exports = ViewGenerator;
24 |
--------------------------------------------------------------------------------
/templates/javascript/filter.js:
--------------------------------------------------------------------------------
1 | define(['angular'], function (angular) {
2 | 'use strict';
3 |
4 | /**
5 | * @ngdoc filter
6 | * @name <%= scriptAppName %>.filter:<%= cameledName %>
7 | * @function
8 | * @description
9 | * # <%= cameledName %>
10 | * Filter in the <%= scriptAppName %>.
11 | */
12 | angular.module('<%= scriptAppName %>.filters.<%= classedName %>', [])
13 | .filter('<%= cameledName %>', function () {
14 | return function (input) {
15 | return '<%= cameledName %> filter: ' + input;
16 | };
17 | });
18 | });
19 |
--------------------------------------------------------------------------------
/templates/javascript/decorator.js:
--------------------------------------------------------------------------------
1 | define(['angular'], function (angular) {
2 | 'use strict';
3 |
4 | /**
5 | * @ngdoc function
6 | * @name <%= scriptAppName %>.decorator:<%= classedName %>
7 | * @description
8 | * # <%= classedName %>
9 | * Decorator of the <%= scriptAppName %>
10 | */
11 | angular.module('<%= scriptAppName %>.decorators.<%= classedName %>', [])
12 | .config(function ($provide) {
13 | $provide.decorator('<%= cameledName %>', function ($delegate) {
14 | // decorate the $delegate
15 | return $delegate;
16 | });
17 | });
18 | });
19 |
--------------------------------------------------------------------------------
/templates/javascript/controller.js:
--------------------------------------------------------------------------------
1 | define(['angular'], function (angular) {
2 | 'use strict';
3 |
4 | /**
5 | * @ngdoc function
6 | * @name <%= scriptAppName %>.controller:<%= classedName %>Ctrl
7 | * @description
8 | * # <%= classedName %>Ctrl
9 | * Controller of the <%= scriptAppName %>
10 | */
11 | angular.module('<%= scriptAppName %>.controllers.<%= classedName %>Ctrl', [])
12 | .controller('<%= classedName %>Ctrl', function () {
13 | this.awesomeThings = [
14 | 'HTML5 Boilerplate',
15 | 'AngularJS',
16 | 'Karma'
17 | ];
18 | });
19 | });
20 |
--------------------------------------------------------------------------------
/templates/javascript/directive.js:
--------------------------------------------------------------------------------
1 | define(['angular'], function (angular) {
2 | 'use strict';
3 |
4 | /**
5 | * @ngdoc directive
6 | * @name <%= scriptAppName %>.directive:<%= cameledName %>
7 | * @description
8 | * # <%= cameledName %>
9 | */
10 | angular.module('<%= scriptAppName %>.directives.<%= classedName %>', [])
11 | .directive('<%= cameledName %>', function () {
12 | return {
13 | template: '',
14 | restrict: 'E',
15 | link: function postLink(scope, element, attrs) {
16 | element.text('this is the <%= cameledName %> directive');
17 | }
18 | };
19 | });
20 | });
21 |
--------------------------------------------------------------------------------
/templates/javascript/spec/service.js:
--------------------------------------------------------------------------------
1 | /*jshint unused: vars */
2 | define(['angular', 'angular-mocks', 'app'], function(angular, mocks, app) {
3 | 'use strict';
4 |
5 | describe('Service: <%= cameledName %>', function () {
6 |
7 | // load the service's module
8 | beforeEach(module('<%= scriptAppName %>.services.<%= classedName %>'));
9 |
10 | // instantiate service
11 | var <%= cameledName %>;
12 | beforeEach(inject(function (_<%= cameledName %>_) {
13 | <%= cameledName %> = _<%= cameledName %>_;
14 | }));
15 |
16 | it('should do something', function () {
17 | expect(!!<%= cameledName %>).toBe(true);
18 | });
19 |
20 | });
21 | });
22 |
--------------------------------------------------------------------------------
/test/utils.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var helpers = require('yeoman-test');
4 |
5 | exports.generateFullProject = function (cb) {
6 | return helpers.run(require.resolve('../app'))
7 | .withGenerators([
8 | require.resolve('../controller'),
9 | require.resolve('../route'),
10 | require.resolve('../view'),
11 | [helpers.createDummyGenerator(), 'karma-require:app']
12 | ])
13 | .withOptions({
14 | 'appPath': 'app',
15 | 'skip-welcome-message': true,
16 | 'skip-message': true
17 | })
18 | .withPrompts({
19 | compass: true,
20 | bootstrap: true,
21 | compassBootstrap: true,
22 | modules: []
23 | });
24 | }
25 |
--------------------------------------------------------------------------------
/templates/javascript/service/factory.js:
--------------------------------------------------------------------------------
1 | define(['angular'], function (angular) {
2 | 'use strict';
3 |
4 | /**
5 | * @ngdoc service
6 | * @name <%= scriptAppName %>.<%= cameledName %>
7 | * @description
8 | * # <%= cameledName %>
9 | * Factory in the <%= scriptAppName %>.
10 | */
11 | angular.module('<%= scriptAppName %>.services.<%= classedName %>', [])
12 | .factory('<%= cameledName %>', function () {
13 | // Service logic
14 | // ...
15 |
16 | var meaningOfLife = 42;
17 |
18 | // Public API here
19 | return {
20 | someMethod: function () {
21 | return meaningOfLife;
22 | }
23 | };
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/templates/javascript/app.js:
--------------------------------------------------------------------------------
1 | /*jshint unused: vars */
2 | define(['angular']/*deps*/, function (angular)/*invoke*/ {
3 | 'use strict';
4 |
5 | /**
6 | * @ngdoc overview
7 | * @name <%= scriptAppName %>
8 | * @description
9 | * # <%= scriptAppName %>
10 | *
11 | * Main module of the application.
12 | */
13 | return angular
14 | .module('<%= scriptAppName %>', [/*angJSDeps*/<%- angularModules %>])<% if (ngRoute) { %>
15 | .config(function ($routeProvider) {
16 | $routeProvider
17 | .when('/', {
18 | templateUrl: 'views/main.html',
19 | controller: 'MainCtrl',
20 | controllerAs: 'main'
21 | })
22 | .otherwise({
23 | redirectTo: '/'
24 | });
25 | })<% } %>;
26 | });
27 |
--------------------------------------------------------------------------------
/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/spec/filter.js:
--------------------------------------------------------------------------------
1 | /*jshint unused: vars */
2 | define(['angular', 'angular-mocks', 'app'], function(angular, mocks, app) {
3 | 'use strict';
4 |
5 | describe('Filter: <%= cameledName %>', function () {
6 |
7 | // load the filter's module
8 | beforeEach(module('<%= scriptAppName %>.filters.<%= classedName %>'));
9 |
10 | // initialize a new instance of the filter before each test
11 | var <%= cameledName %>;
12 | beforeEach(inject(function ($filter) {
13 | <%= cameledName %> = $filter('<%= cameledName %>');
14 | }));
15 |
16 | it('should return the input prefixed with "<%= cameledName %> filter:"', function () {
17 | var text = 'angularjs';
18 | expect(<%= cameledName %>(text)).toBe('<%= cameledName %> filter: ' + text);
19 | });
20 |
21 | });
22 | });
23 |
--------------------------------------------------------------------------------
/templates/javascript/spec/directive.js:
--------------------------------------------------------------------------------
1 | /*jshint unused: vars */
2 | define(['angular', 'angular-mocks', 'app'], function(angular, mocks, app) {
3 | 'use strict';
4 |
5 | describe('Directive: <%= cameledName %>', function () {
6 |
7 | // load the directive's module
8 | beforeEach(module('<%= scriptAppName %>.directives.<%= classedName %>'));
9 |
10 | var element,
11 | scope;
12 |
13 | beforeEach(inject(function ($rootScope) {
14 | scope = $rootScope.$new();
15 | }));
16 |
17 | it('should make hidden element visible', inject(function ($compile) {
18 | element = angular.element('<<%= dasherizedName %>><%= dasherizedName %>>');
19 | element = $compile(element)(scope);
20 | expect(element.text()).toBe('this is the <%= cameledName %> directive');
21 | }));
22 | });
23 | });
24 |
--------------------------------------------------------------------------------
/templates/javascript/spec/provider.js:
--------------------------------------------------------------------------------
1 | describe('Service: <%= cameledName %>', function () {
2 | 'use strict';
3 |
4 | // instantiate service
5 | var <%= cameledName %>,
6 | init = function () {
7 | inject(function (_<%= cameledName %>_) {
8 | <%= cameledName %> = _<%= cameledName %>_;
9 | });
10 | };
11 |
12 | // load the service's module
13 | beforeEach(module('<%= scriptAppName %>'));
14 |
15 | it('should do something', function () {
16 | init();
17 |
18 | expect(!!<%= cameledName %>).toBe(true);
19 | });
20 |
21 | it('should be configurable', function () {
22 | module(function (<%= cameledName %>Provider) {
23 | <%= cameledName %>Provider.setSalutation('Lorem ipsum');
24 | });
25 |
26 | init();
27 |
28 | expect(<%= cameledName %>.greet()).toEqual('Lorem ipsum');
29 | });
30 |
31 | });
32 |
--------------------------------------------------------------------------------
/templates/javascript/spec/controller.js:
--------------------------------------------------------------------------------
1 | /*jshint unused: vars */
2 | define(['angular', 'angular-mocks', 'app'], function(angular, mocks, app) {
3 | 'use strict';
4 |
5 | describe('Controller: <%= classedName %>Ctrl', function () {
6 |
7 | // load the controller's module
8 | beforeEach(module('<%= scriptAppName %>.controllers.<%= classedName %>Ctrl'));
9 |
10 | var <%= classedName %>Ctrl;
11 | var scope;
12 |
13 | // Initialize the controller and a mock scope
14 | beforeEach(inject(function ($controller, $rootScope) {
15 | scope = $rootScope.$new();
16 | <%= classedName %>Ctrl = $controller('<%= classedName %>Ctrl', {
17 | $scope: scope
18 | // place here mocked dependencies
19 | });
20 | }));
21 |
22 | it('should attach a list of awesomeThings to the scope', function () {
23 | expect(<%= classedName %>Ctrl.awesomeThings.length).toBe(3);
24 | });
25 | });
26 | });
27 |
--------------------------------------------------------------------------------
/templates/javascript/service/provider.js:
--------------------------------------------------------------------------------
1 | define(['angular'], function (angular) {
2 | 'use strict';
3 |
4 | /**
5 | * @ngdoc service
6 | * @name <%= scriptAppName %>.<%= cameledName %>
7 | * @description
8 | * # <%= cameledName %>
9 | * Provider in the <%= scriptAppName %>.
10 | */
11 | angular.module('<%= scriptAppName %>.services.<%= classedName %>', [])
12 | .provider('<%= cameledName %>', function () {
13 |
14 | // Private variables
15 | var salutation = 'Hello';
16 |
17 | // Private constructor
18 | function Greeter() {
19 | this.greet = function () {
20 | return salutation;
21 | };
22 | }
23 |
24 | // Public API for configuration
25 | this.setSalutation = function (s) {
26 | salutation = s;
27 | };
28 |
29 | // Method for instantiating
30 | this.$get = function () {
31 | return new Greeter();
32 | };
33 | });
34 | });
35 |
--------------------------------------------------------------------------------
/test/view.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var fs = require('fs');
4 | var path = require('path');
5 | var helpers = require('yeoman-test');
6 | var assert = require('yeoman-assert');
7 |
8 | describe('angular-require:view', function () {
9 | beforeEach(function () {
10 | this.angularView = helpers
11 | .run(require.resolve('../view'))
12 | .withArguments('foo/bar');
13 | });
14 |
15 | describe('default settings', function () {
16 | beforeEach(function (done) {
17 | this.angularView.on('end', done);
18 | });
19 |
20 | it('generates a new view', function () {
21 | assert.file('app/views/foo/bar.html');
22 | });
23 | });
24 |
25 | describe('--appPath', function () {
26 | beforeEach(function (done) {
27 | this.angularView
28 | .withOptions({
29 | appPath: 'alternative'
30 | })
31 | .on('end', done);
32 | });
33 |
34 | it('generates a new view', function () {
35 | assert.file('alternative/views/foo/bar.html');
36 | });
37 | });
38 | });
39 |
--------------------------------------------------------------------------------
/test/value.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var fs = require('fs');
4 | var path = require('path');
5 | var helpers = require('yeoman-test');
6 | var assert = require('yeoman-assert');
7 | var generateFullProject = require('./utils').generateFullProject;
8 |
9 | describe('angular-require:value', function () {
10 | beforeEach(function (done) {
11 | generateFullProject()
12 | .on('end', function () {
13 | this.angularRequireValue = helpers.run(require.resolve('../value'))
14 | .withOptions({
15 | appPath: 'app'
16 | })
17 | .withArguments(['foo']);
18 |
19 | // Hack to not clear the directory
20 | this.angularRequireValue.inDirSet = true;
21 |
22 | done();
23 | }.bind(this));
24 | });
25 |
26 | it('generates a new value', function (done) {
27 | this.angularRequireValue.on('end', function () {
28 | assert.file('test/spec/services/fooSpec.js');
29 | assert.fileContent(
30 | path.join(process.cwd() + '/app/scripts/services/foo.js'),
31 | /value\('foo'/
32 | );
33 |
34 | done();
35 | });
36 | });
37 | });
38 |
--------------------------------------------------------------------------------
/test/filter.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var fs = require('fs');
4 | var path = require('path');
5 | var helpers = require('yeoman-test');
6 | var assert = require('yeoman-assert');
7 | var generateFullProject = require('./utils').generateFullProject;
8 |
9 | describe('angular-require:filter', function () {
10 | beforeEach(function (done) {
11 | generateFullProject()
12 | .on('end', function () {
13 | this.angularRequireFilter = helpers.run(require.resolve('../filter'))
14 | .withOptions({
15 | appPath: 'app'
16 | })
17 | .withArguments(['foo']);
18 |
19 | // Hack to not clear the directory
20 | this.angularRequireFilter.inDirSet = true;
21 |
22 | done();
23 | }.bind(this));
24 | });
25 |
26 | it('generates a new filter', function (done) {
27 | this.angularRequireFilter.on('end', function () {
28 | assert.file('test/spec/filters/fooSpec.js');
29 | assert.fileContent(
30 | path.join(process.cwd() + '/app/scripts/filters/foo.js'),
31 | /filter\('foo'/
32 | );
33 |
34 | done();
35 | });
36 | });
37 | });
38 |
--------------------------------------------------------------------------------
/test/factory.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var fs = require('fs');
4 | var path = require('path');
5 | var helpers = require('yeoman-test');
6 | var assert = require('yeoman-assert');
7 | var generateFullProject = require('./utils').generateFullProject;
8 |
9 | describe('angular-require:factory', function () {
10 | beforeEach(function (done) {
11 | generateFullProject()
12 | .on('end', function () {
13 | this.angularRequireFactory = helpers.run(require.resolve('../factory'))
14 | .withOptions({
15 | appPath: 'app'
16 | })
17 | .withArguments(['foo']);
18 |
19 | // Hack to not clear the directory
20 | this.angularRequireFactory.inDirSet = true;
21 |
22 | done();
23 | }.bind(this));
24 | });
25 |
26 | it('generates a new factory', function (done) {
27 | this.angularRequireFactory.on('end', function () {
28 | assert.file('test/spec/services/fooSpec.js');
29 | assert.fileContent(
30 | path.join(process.cwd() + '/app/scripts/services/foo.js'),
31 | /factory\('foo'/
32 | );
33 |
34 | done();
35 | });
36 | });
37 | });
38 |
--------------------------------------------------------------------------------
/test/service.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var fs = require('fs');
4 | var path = require('path');
5 | var helpers = require('yeoman-test');
6 | var assert = require('yeoman-assert');
7 | var generateFullProject = require('./utils').generateFullProject;
8 |
9 | describe('angular-require:service', function () {
10 | beforeEach(function (done) {
11 | generateFullProject()
12 | .on('end', function () {
13 | this.angularRequireService = helpers.run(require.resolve('../service'))
14 | .withOptions({
15 | appPath: 'app'
16 | })
17 | .withArguments(['foo']);
18 |
19 | // Hack to not clear the directory
20 | this.angularRequireService.inDirSet = true;
21 |
22 | done();
23 | }.bind(this));
24 | });
25 |
26 | it('generates a new service', function (done) {
27 | this.angularRequireService.on('end', function () {
28 | assert.file('test/spec/services/fooSpec.js');
29 | assert.fileContent(
30 | path.join(process.cwd() + '/app/scripts/services/foo.js'),
31 | /service\('Foo'/
32 | );
33 |
34 | done();
35 | });
36 | });
37 | });
38 |
--------------------------------------------------------------------------------
/test/constant.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var fs = require('fs');
4 | var path = require('path');
5 | var helpers = require('yeoman-test');
6 | var assert = require('yeoman-assert');
7 | var generateFullProject = require('./utils').generateFullProject;
8 |
9 | describe('angular-require:constant', function () {
10 | beforeEach(function (done) {
11 | generateFullProject()
12 | .on('end', function () {
13 | this.angularRequireConstant = helpers.run(require.resolve('../constant'))
14 | .withOptions({
15 | appPath: 'app'
16 | })
17 | .withArguments(['foo']);
18 |
19 | // Hack to not clear the directory
20 | this.angularRequireConstant.inDirSet = true;
21 |
22 | done();
23 | }.bind(this));
24 | });
25 |
26 | it('generates a new constant', function (done) {
27 | this.angularRequireConstant.on('end', function () {
28 | assert.file('test/spec/services/fooSpec.js');
29 | assert.fileContent(
30 | path.join(process.cwd() + '/app/scripts/services/foo.js'),
31 | /constant\('foo'/
32 | );
33 |
34 | done();
35 | });
36 | });
37 | });
38 |
--------------------------------------------------------------------------------
/test/provider.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var fs = require('fs');
4 | var path = require('path');
5 | var helpers = require('yeoman-test');
6 | var assert = require('yeoman-assert');
7 | var generateFullProject = require('./utils').generateFullProject;
8 |
9 | describe('angular-require:provider', function () {
10 | beforeEach(function (done) {
11 | generateFullProject()
12 | .on('end', function () {
13 | this.angularRequireProvider = helpers.run(require.resolve('../provider'))
14 | .withOptions({
15 | appPath: 'app'
16 | })
17 | .withArguments(['foo']);
18 |
19 | // Hack to not clear the directory
20 | this.angularRequireProvider.inDirSet = true;
21 |
22 | done();
23 | }.bind(this));
24 | });
25 |
26 | it('generates a new provider', function (done) {
27 | this.angularRequireProvider.on('end', function () {
28 | assert.file('test/spec/services/fooSpec.js');
29 | assert.fileContent(
30 | path.join(process.cwd() + '/app/scripts/services/foo.js'),
31 | /provider\('foo'/
32 | );
33 |
34 | done();
35 | });
36 | });
37 | });
38 |
--------------------------------------------------------------------------------
/value/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var util = require('util');
5 | var ScriptBase = require('../script-base.js');
6 | var angularUtils = require('../util.js');
7 |
8 | var ValueGenerator = ScriptBase.extend({
9 | constructor: function() {
10 | ScriptBase.apply(this, arguments);
11 | },
12 |
13 | createServiceFiles: function() {
14 | this.generateSourceAndTest(
15 | 'service/value',
16 | 'spec/service',
17 | 'services',
18 | true // Skip adding the script to the index.html file of the application
19 | );
20 | },
21 |
22 | // Re-write the main app module to account for our new dependency
23 | injectDependenciesToApp: function() {
24 | var appPath = this.config.get('appPath');
25 |
26 | if (typeof appPath === "undefined") {
27 | appPath = this.env.options.appPath;
28 | }
29 |
30 | angularUtils.injectIntoFile(
31 | appPath,
32 | 'services/' + this.name.toLowerCase(),
33 | this.classedName + 'Value',
34 | this.scriptAppName + '.services.' + this.classedName
35 | );
36 | }
37 | });
38 |
39 | module.exports = ValueGenerator;
40 |
--------------------------------------------------------------------------------
/filter/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var util = require('util');
5 | var ScriptBase = require('../script-base.js');
6 | var angularUtils = require('../util.js');
7 |
8 | var FilterGenerator = ScriptBase.extend({
9 | constructor: function() {
10 | ScriptBase.apply(this, arguments);
11 | },
12 |
13 | createFilterFiles: function() {
14 | this.generateSourceAndTest(
15 | 'filter',
16 | 'spec/filter',
17 | 'filters',
18 | true // Skip adding the script to the index.html file of the application
19 | );
20 | },
21 |
22 | // Re-write the main app module to account for our new dependency
23 | injectDependenciesToApp: function () {
24 | var appPath = this.config.get('appPath');
25 |
26 | if (typeof appPath === "undefined") {
27 | appPath = this.env.options.appPath;
28 | }
29 |
30 | angularUtils.injectIntoFile(
31 | appPath,
32 | 'filters/' + this.name.toLowerCase(),
33 | this.classedName + 'Filter',
34 | this.scriptAppName + '.filters.' + this.classedName
35 | );
36 | }
37 | });
38 |
39 | module.exports = FilterGenerator;
40 |
--------------------------------------------------------------------------------
/factory/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var util = require('util');
5 | var ScriptBase = require('../script-base.js');
6 | var angularUtils = require('../util.js');
7 |
8 | var FactoryGenerator = ScriptBase.extend({
9 | constructor: function() {
10 | ScriptBase.apply(this, arguments);
11 | },
12 |
13 | createServiceFiles: function() {
14 | this.generateSourceAndTest(
15 | 'service/factory',
16 | 'spec/service',
17 | 'services',
18 | true // Skip adding the script to the index.html file of the application
19 | );
20 | },
21 |
22 | // Re-write the main app module to account for our new dependency
23 | injectDependenciesToApp: function() {
24 | var appPath = this.config.get('appPath');
25 |
26 | if (typeof appPath === "undefined") {
27 | appPath = this.env.options.appPath;
28 | }
29 |
30 | angularUtils.injectIntoFile(
31 | appPath,
32 | 'services/' + this.name.toLowerCase(),
33 | this.classedName + 'Factory',
34 | this.scriptAppName + '.services.' + this.classedName
35 | );
36 | }
37 | });
38 |
39 | module.exports = FactoryGenerator;
40 |
--------------------------------------------------------------------------------
/test/directive.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var fs = require('fs');
4 | var path = require('path');
5 | var helpers = require('yeoman-test');
6 | var assert = require('yeoman-assert');
7 | var generateFullProject = require('./utils').generateFullProject;
8 |
9 | describe('angular-require:directive', function () {
10 | beforeEach(function (done) {
11 | generateFullProject()
12 | .on('end', function () {
13 | this.angularRequireDirective = helpers.run(require.resolve('../directive'))
14 | .withOptions({
15 | appPath: 'app'
16 | })
17 | .withArguments(['foo']);
18 |
19 | // Hack to not clear the directory
20 | this.angularRequireDirective.inDirSet = true;
21 |
22 | done();
23 | }.bind(this));
24 | });
25 |
26 | it('generates a new directive', function (done) {
27 | this.angularRequireDirective.on('end', function () {
28 | assert.file('test/spec/directives/fooSpec.js');
29 | assert.fileContent(
30 | path.join(process.cwd() + '/app/scripts/directives/foo.js'),
31 | /directive\('foo'/
32 | );
33 |
34 | done();
35 | });
36 | });
37 | });
38 |
--------------------------------------------------------------------------------
/constant/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var util = require('util');
5 | var ScriptBase = require('../script-base.js');
6 | var angularUtils = require('../util.js');
7 |
8 | var ConstantGenerator = ScriptBase.extend({
9 | constructor: function(name) {
10 | ScriptBase.apply(this, arguments);
11 | },
12 |
13 | createServiceFiles: function() {
14 | this.generateSourceAndTest(
15 | 'service/constant',
16 | 'spec/service',
17 | 'services',
18 | true // Skip adding the script to the index.html file of the application
19 | );
20 | },
21 |
22 | // Re-write the main app module to account for our new dependency
23 | injectDependenciesToApp: function () {
24 | var appPath = this.config.get('appPath');
25 |
26 | if (typeof appPath === "undefined") {
27 | appPath = this.env.options.appPath;
28 | }
29 |
30 | angularUtils.injectIntoFile(
31 | appPath,
32 | 'services/' + this.name.toLowerCase(),
33 | this.classedName + 'Constant',
34 | this.scriptAppName + '.services.' + this.classedName
35 | );
36 | }
37 | });
38 |
39 | module.exports = ConstantGenerator;
40 |
--------------------------------------------------------------------------------
/provider/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var util = require('util');
5 | var ScriptBase = require('../script-base.js');
6 | var angularUtils = require('../util.js');
7 |
8 | var ProviderGenerator = ScriptBase.extend({
9 | constructor: function() {
10 | ScriptBase.apply(this, arguments);
11 | },
12 |
13 | createServiceFiles: function() {
14 | this.generateSourceAndTest(
15 | 'service/provider',
16 | 'spec/provider',
17 | 'services',
18 | true // Skip adding the script to the index.html file of the application
19 | );
20 | },
21 |
22 | // Re-write the main app module to account for our new dependency
23 | injectDependenciesToApp: function() {
24 | var appPath = this.config.get('appPath');
25 |
26 | if (typeof appPath === "undefined") {
27 | appPath = this.env.options.appPath;
28 | }
29 |
30 | angularUtils.injectIntoFile(
31 | appPath,
32 | 'services/' + this.name.toLowerCase(),
33 | this.classedName + 'Provider',
34 | this.scriptAppName + '.services.' + this.classedName
35 | );
36 | }
37 | });
38 |
39 | module.exports = ProviderGenerator;
40 |
--------------------------------------------------------------------------------
/directive/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var util = require('util');
5 | var ScriptBase = require('../script-base.js');
6 | var angularUtils = require('../util.js');
7 |
8 | var DirectiveGenerator = ScriptBase.extend({
9 | constructor: function(name) {
10 | ScriptBase.apply(this, arguments);
11 | },
12 |
13 | createDirectiveFiles: function() {
14 | this.generateSourceAndTest(
15 | 'directive',
16 | 'spec/directive',
17 | 'directives',
18 | true // Skip adding the script to the index.html file of the application
19 | );
20 | },
21 |
22 | // Re-write the main app module to account for our new dependency
23 | injectDependenciesToApp: function() {
24 | var appPath = this.config.get('appPath');
25 |
26 | if (typeof appPath === "undefined") {
27 | appPath = this.env.options.appPath;
28 | }
29 |
30 | angularUtils.injectIntoFile(
31 | appPath,
32 | 'directives/' + this.name.toLowerCase(),
33 | this.classedName + 'Directive',
34 | this.scriptAppName + '.directives.' + this.classedName
35 | );
36 | }
37 | });
38 |
39 | module.exports = DirectiveGenerator;
40 |
--------------------------------------------------------------------------------
/test/controller.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var fs = require('fs');
4 | var path = require('path');
5 | var helpers = require('yeoman-test');
6 | var assert = require('yeoman-assert');
7 | var generateFullProject = require('./utils').generateFullProject;
8 |
9 | describe('angular-require:controller', function () {
10 | beforeEach(function (done) {
11 | generateFullProject()
12 | .on('end', function () {
13 | this.angularRequireController = helpers.run(require.resolve('../controller'))
14 | .withOptions({
15 | appPath: 'app'
16 | })
17 | .withArguments(['foo']);
18 |
19 | // Hack to not clear the directory
20 | this.angularRequireController.inDirSet = true;
21 |
22 | done();
23 | }.bind(this));
24 | });
25 |
26 | it('generates a new controller', function (done) {
27 | this.angularRequireController.on('end', function () {
28 | assert.file('test/spec/controllers/fooSpec.js');
29 | assert.fileContent(
30 | path.join(process.cwd() + '/app/scripts/controllers/foo.js'),
31 | /controller\('FooCtrl'/
32 | );
33 |
34 | done();
35 | });
36 | });
37 | });
38 |
--------------------------------------------------------------------------------
/service/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var util = require('util');
5 | var ScriptBase = require('../script-base.js');
6 | var angularUtils = require('../util.js');
7 |
8 | var ServiceGenerator = ScriptBase.extend({
9 | constructor: function() {
10 | ScriptBase.apply(this, arguments);
11 | },
12 |
13 | writing: {
14 | createServiceFiles: function() {
15 | this.generateSourceAndTest(
16 | 'service/service',
17 | 'spec/service',
18 | 'services',
19 | true // Skip adding the script to the index.html file of the application
20 | );
21 | }
22 | },
23 |
24 | install: {
25 | // Re-write the main app module to account for our new dependency
26 | injectDependenciesToApp: function() {
27 | var appPath = this.config.get('appPath');
28 |
29 | if (typeof appPath === "undefined") {
30 | appPath = this.env.options.appPath;
31 | }
32 |
33 | angularUtils.injectIntoFile(
34 | appPath,
35 | 'services/' + this.name.toLowerCase(),
36 | this.classedName + 'Service',
37 | this.scriptAppName + '.services.' + this.classedName
38 | );
39 | }
40 | }
41 | });
42 |
43 | module.exports = ServiceGenerator;
44 |
--------------------------------------------------------------------------------
/templates/common/scripts/test-main.js:
--------------------------------------------------------------------------------
1 | var tests = [];
2 | for (var file in window.__karma__.files) {
3 | if (window.__karma__.files.hasOwnProperty(file)) {
4 | // Removed "Spec" naming from files
5 | if (/Spec\.js$/.test(file)) {
6 | tests.push(file);
7 | }
8 | }
9 | }
10 |
11 | requirejs.config({
12 | // Karma serves files from '/base'
13 | baseUrl: '/base/app/scripts',
14 |
15 | paths: {
16 |
17 | },
18 |
19 | shim: {
20 | 'angular' : {'exports' : 'angular'}<% if (routeModule) { %>,
21 | 'angular-route': ['angular']<% } %><% if (cookiesModule) { %>,
22 | 'angular-cookies': ['angular']<% } %><% if (sanitizeModule) { %>,
23 | 'angular-sanitize': ['angular']<% } %><% if (resourceModule) { %>,
24 | 'angular-resource': ['angular']<% } %><% if (animateModule) { %>,
25 | 'angular-animate': ['angular']<% } %><% if (touchModule) { %>,
26 | 'angular-touch': ['angular']<% } %>,
27 | 'angular-mocks': {
28 | deps:['angular'],
29 | 'exports':'angular.mock'
30 | }
31 | },
32 |
33 | // ask Require.js to load these files (all our tests)
34 | deps: tests,
35 |
36 | // start test run, once Require.js is done
37 | callback: window.__karma__.start
38 | });
39 |
--------------------------------------------------------------------------------
/Gruntfile.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = function (grunt) {
4 | require('load-grunt-tasks')(grunt);
5 |
6 | grunt.initConfig({
7 | conventionalGithubReleaser: {
8 | release: {
9 | options: {
10 | auth: {
11 | type: 'oauth',
12 | token: process.env.GITHUB_AUTHTOKEN
13 | },
14 | changelogOpts: {
15 | preset: 'angular-require',
16 | releaseCount: 1
17 | }
18 | }
19 | }
20 | },
21 | bump: {
22 | options: {
23 | commitMessage: 'chore(release): Release version <%= version %>'
24 | }
25 | }
26 | });
27 |
28 | grunt.registerTask('npmPublish', 'Publish to npm', function () {
29 | grunt.util.spawn({
30 | cmd: 'npm',
31 | args: ['publish']
32 | }, grunt.task.current.async());
33 | });
34 |
35 | // grunt-release will only commit the package.json file by default. Until
36 | // https://github.com/geddski/grunt-release/pull/43/files lands, it should
37 | // be patched to do the same so it commits the changelog as well.
38 | grunt.registerTask('publish', function (type) {
39 | grunt.task.run([
40 | 'bump' + (type ? ':' + type : ''),
41 | 'npmPublish',
42 | 'conventionalGithubReleaser'
43 | ]);
44 | });
45 | };
46 |
--------------------------------------------------------------------------------
/templates/common/root/_bower.json:
--------------------------------------------------------------------------------
1 | {<% var ngVer = "1.4.0" %>
2 | "name": "<%= appSlugName %>",
3 | "version": "0.0.0",
4 | "dependencies": {
5 | "angular": "^<%= ngVer %>"<% if (animateModule) { %>,
6 | "angular-animate": "^<%= ngVer %>"<% } %><% if (ariaModule) { %>,
7 | "angular-aria": "^<%= ngVer %>"<% } %><% if (cookiesModule) { %>,
8 | "angular-cookies": "^<%= ngVer %>"<% } %><% if (messagesModule) { %>,
9 | "angular-messages": "^<%= ngVer %>"<% } %><% if (resourceModule) { %>,
10 | "angular-resource": "^<%= ngVer %>"<% } %><% if (routeModule) { %>,
11 | "angular-route": "^<%= ngVer %>"<% } %><% if (sanitizeModule) { %>,
12 | "angular-sanitize": "^<%= ngVer %>"<% } %><% if (touchModule) { %>,
13 | "angular-touch": "^<%= ngVer %>"<% } %><% if (bootstrap) { %>,<% if (!compassBootstrap) { %>
14 | "bootstrap": "^3.2.0"<% } else { %>
15 | "bootstrap-sass-official": "^3.2.0"<% } } %>,
16 | "requirejs": "^2.1.0"
17 | },
18 | "devDependencies": {
19 | "angular-mocks": "^<%= ngVer %>"
20 | }<% if (appPath) { %>,
21 | "appPath": "<%= appPath %>"<% } %>,
22 | "moduleName": "<%= scriptAppName %>"<% if (bootstrap) { %>,
23 | "overrides": {
24 | "bootstrap": {
25 | "main": [
26 | "less/bootstrap.less",
27 | "dist/css/bootstrap.css",
28 | "dist/js/bootstrap.js"
29 | ]
30 | }
31 | }<% } %>
32 | }
33 |
--------------------------------------------------------------------------------
/templates/common/root/_package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "<%= appSlugName %>",
3 | "private": true,
4 | "devDependencies": {
5 | "autoprefixer-core": "^5.2.1",
6 | "generator-karma-require": "^1.1.0",
7 | "grunt": "^0.4.5",
8 | "grunt-autoprefixer": "^2.0.0",
9 | "grunt-bower-requirejs": "^2.0.0",
10 | "grunt-concurrent": "^1.0.0",
11 | "grunt-contrib-clean": "^0.6.0",<% if (compass) { %>
12 | "grunt-contrib-compass": "^1.0.0",<% } %>
13 | "grunt-contrib-concat": "^0.5.0",
14 | "grunt-contrib-connect": "^0.9.0",
15 | "grunt-contrib-copy": "^0.7.0",
16 | "grunt-contrib-cssmin": "^0.12.0",
17 | "grunt-contrib-htmlmin": "^0.4.0",
18 | "grunt-contrib-imagemin": "^1.0.0",
19 | "grunt-contrib-jshint": "^0.11.0",
20 | "grunt-contrib-uglify": "^0.7.0",
21 | "grunt-contrib-watch": "^0.6.1",
22 | "grunt-filerev": "^2.1.2",
23 | "grunt-google-cdn": "^0.4.3",
24 | "grunt-jscs": "^1.8.0",
25 | "grunt-karma": "^0.10.1",
26 | "grunt-newer": "^1.1.0",
27 | "grunt-ng-annotate": "^0.9.2",
28 | "grunt-postcss": "^0.5.5",
29 | "grunt-requirejs": "^0.4.2",
30 | "grunt-svgmin": "^2.0.0",
31 | "grunt-text-replace": "^0.4.0",
32 | "grunt-usemin": "^3.0.0",
33 | "grunt-wiredep": "^2.0.0",
34 | "jit-grunt": "^0.9.1",
35 | "jshint-stylish": "^1.0.0",
36 | "time-grunt": "^1.0.0"
37 | },
38 | "engines": {
39 | "node": ">=0.10.0"
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/controller/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var util = require('util');
5 | var ScriptBase = require('../script-base.js');
6 | var angularUtils = require('../util.js');
7 |
8 | var ControllerGenerator = ScriptBase.extend({
9 | constructor: function(name) {
10 | ScriptBase.apply(this, arguments);
11 |
12 | // if the controller name is suffixed with ctrl, remove the suffix
13 | // if the controller name is just "ctrl," don't append/remove "ctrl"
14 | if (this.name && this.name.toLowerCase() !== 'ctrl' && this.name.substr(-4).toLowerCase() === 'ctrl') {
15 | this.name = this.name.slice(0, -4);
16 | }
17 | },
18 |
19 | createControllerFiles: function() {
20 | this.generateSourceAndTest(
21 | 'controller',
22 | 'spec/controller',
23 | 'controllers',
24 | true // Skip adding the script to the index.html file of the application
25 | );
26 | },
27 |
28 | // Re-write the main app module to account for our new dependency
29 | injectDependenciesToApp: function () {
30 | var appPath = this.config.get('appPath')
31 |
32 | if (typeof appPath === "undefined") {
33 | appPath = this.env.options.appPath;
34 | }
35 |
36 | angularUtils.injectIntoFile(
37 | appPath,
38 | 'controllers/' + this.name.toLowerCase(),
39 | this.classedName + 'Ctrl',
40 | this.scriptAppName + '.controllers.' + this.classedName + 'Ctrl'
41 | );
42 | }
43 | });
44 |
45 | module.exports = ControllerGenerator;
46 |
--------------------------------------------------------------------------------
/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/scripts/main.js:
--------------------------------------------------------------------------------
1 | /*jshint unused: vars */
2 | require.config({
3 | paths: {},
4 | shim: {
5 | 'angular' : {'exports' : 'angular'}<% if (routeModule) { %>,
6 | 'angular-route': ['angular']<% } %><% if (cookiesModule) { %>,
7 | 'angular-cookies': ['angular']<% } %><% if (sanitizeModule) { %>,
8 | 'angular-sanitize': ['angular']<% } %><% if (resourceModule) { %>,
9 | 'angular-resource': ['angular']<% } %><% if (animateModule) { %>,
10 | 'angular-animate': ['angular']<% } %><% if (touchModule) { %>,
11 | 'angular-touch': ['angular']<% } %>,
12 | 'angular-mocks': {
13 | deps:['angular'],
14 | 'exports':'angular.mock'
15 | }
16 | },
17 | priority: [
18 | 'angular'
19 | ]
20 | });
21 |
22 | //http://code.angularjs.org/1.2.1/docs/guide/bootstrap#overview_deferred-bootstrap
23 | window.name = 'NG_DEFER_BOOTSTRAP!';
24 |
25 | require([
26 | 'angular',
27 | 'app'<% if (routeModule) { %>,
28 | 'angular-route'<% } %><% if (cookiesModule) { %>,
29 | 'angular-cookies'<% } %><% if (sanitizeModule) { %>,
30 | 'angular-sanitize'<% } %><% if (resourceModule) { %>,
31 | 'angular-resource'<% } %><% if (animateModule) { %>,
32 | 'angular-animate'<% } %><% if (touchModule) { %>,
33 | 'angular-touch'<% } %>
34 | ], function(angular, app<% if (routeModule) { %>, ngRoutes<% } %><% if (cookiesModule) { %>, ngCookies<% } %><% if (sanitizeModule) { %>, ngSanitize<% } %><% if (resourceModule) { %>, ngResource<% } %><% if (animateModule) { %>, ngAnimate<% } %><% if (touchModule) { %>, ngTouch<% } %>) {
35 | 'use strict';
36 | /* jshint ignore:start */
37 | var $html = angular.element(document.getElementsByTagName('html')[0]);
38 | /* jshint ignore:end */
39 | angular.element().ready(function() {
40 | angular.resumeBootstrap([app.name]);
41 | });
42 | });
43 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "generator-angular-require",
3 | "version": "3.5.0",
4 | "description": "Yeoman generator for AngularJS using RequireJS",
5 | "keywords": [
6 | "yeoman-generator",
7 | "scaffold",
8 | "framework",
9 | "component",
10 | "front-end",
11 | "app",
12 | "angular",
13 | "requirejs"
14 | ],
15 | "author": "Aaron Allport",
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": {
37 | "type": "git",
38 | "url": "https://github.com/aaronallport/generator-angular-require.git"
39 | },
40 | "bugs": "http://github.com/aaronallport/generator-angular-require/issues",
41 | "scripts": {
42 | "test": "mocha"
43 | },
44 | "dependencies": {
45 | "yeoman-generator": "^0.22.0",
46 | "bower-requirejs": "^1.1.2",
47 | "lodash": "^4.0.0",
48 | "underscore.string": "^3.2.0",
49 | "yosay": "^1.0.2",
50 | "chalk": "^1.0.0",
51 | "wiredep": "^3.0.0"
52 | },
53 | "peerDependencies": {
54 | "yo": ">=1.0.0"
55 | },
56 | "devDependencies": {
57 | "ejs": "^2.3.4",
58 | "grunt": "^0.4.5",
59 | "grunt-bump": "^0.7.0",
60 | "grunt-contrib-jshint": "^0.12.0",
61 | "grunt-conventional-github-releaser": "^0.5.0",
62 | "load-grunt-tasks": "^3.1.0",
63 | "mocha": "*",
64 | "yeoman-assert": "^2.1.1",
65 | "yeoman-test": "^1.0.0"
66 | },
67 | "engines": {
68 | "node": ">=0.10.0",
69 | "npm": ">=1.2.10"
70 | },
71 | "license": "BSD-2-Clause"
72 | }
73 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/test/route.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var helpers = require('yeoman-test');
5 | var assert = require('yeoman-assert');
6 | var generateFullProject = require('./utils').generateFullProject;
7 |
8 | describe('angular-require:route', function () {
9 | beforeEach(function (done) {
10 | generateFullProject()
11 | .withPrompts({
12 | modules: ['routeModule']
13 | })
14 | .on('end', function () {
15 | this.angularRequireRoute = helpers.run(require.resolve('../route'))
16 | .withGenerators([
17 | require.resolve('../controller'),
18 | require.resolve('../view')
19 | ])
20 | .withOptions({
21 | appPath: 'app'
22 | })
23 | .withArguments(['simpleroute']);
24 |
25 | // Hack to not clear the directory
26 | this.angularRequireRoute.inDirSet = true;
27 |
28 | done();
29 | }.bind(this));
30 | });
31 |
32 | it('generates default route items', function (done) {
33 | this.angularRequireRoute.on('end', function () {
34 | assert.file([
35 | 'app/scripts/controllers/simpleroute.js',
36 | 'test/spec/controllers/simplerouteSpec.js',
37 | 'app/views/simpleroute.html'
38 | ]);
39 | assert.fileContent(
40 | 'app/scripts/app.js',
41 | /when\('\/simpleroute'/
42 | );
43 | done();
44 | });
45 | });
46 |
47 | it('generates route items with the route uri given', function (done) {
48 | this.angularRequireRoute
49 | .withOptions({
50 | uri: 'segment1/segment2/:parameter'
51 | })
52 | .on('end', function () {
53 | assert.file([
54 | 'app/scripts/controllers/simpleroute.js',
55 | 'test/spec/controllers/simplerouteSpec.js',
56 | 'app/views/simpleroute.html'
57 | ]);
58 | assert.fileContent(
59 | 'app/scripts/app.js',
60 | /when\('\/segment1\/segment2\/\:parameter'/
61 | );
62 | done();
63 | });
64 | });
65 | });
66 |
--------------------------------------------------------------------------------
/route/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var chalk = require('chalk');
5 | var util = require('util');
6 | var ScriptBase = require('../script-base.js');
7 | var angularUtils = require('../util.js');
8 |
9 | var RouteGenerator = ScriptBase.extend({
10 | constructor: function() {
11 | ScriptBase.apply(this, arguments);
12 |
13 | this.option('uri', {
14 | desc: 'Allow a custom uri for routing',
15 | type: String,
16 | required: false
17 | });
18 |
19 | var appPath = this.config.get('appPath')
20 |
21 | if (typeof appPath === "undefined") {
22 | appPath = this.env.options.appPath;
23 | }
24 |
25 | var bower = require(path.join(process.cwd(), 'bower.json'));
26 | var match = require('fs').readFileSync(
27 | path.join(appPath, 'scripts/app.js'), 'utf-8'
28 | ).match(/\.when/);
29 |
30 | if (
31 | bower.dependencies['angular-route'] ||
32 | bower.devDependencies['angular-route'] ||
33 | match !== null
34 | ) {
35 | this.foundWhenForRoute = true;
36 | }
37 | },
38 |
39 | writing: {
40 | rewriteAppJs: function() {
41 | if (!this.foundWhenForRoute) {
42 | this.on('end', function () {
43 | this.log(chalk.yellow(
44 | '\nangular-route is not installed. Skipping adding the route to scripts/app.js'
45 | ));
46 | });
47 |
48 | return;
49 | }
50 |
51 | this.uri = this.name;
52 | if (this.options.uri) {
53 | this.uri = this.options.uri;
54 | }
55 |
56 | var config = {
57 | file: path.join(
58 | this.config.get('appPath'),
59 | 'scripts/app.js'),
60 | needle: '.otherwise',
61 | splicable: [
62 | " templateUrl: 'views/" + this.name.toLowerCase() + ".html',",
63 | " controller: '" + this.classedName + "Ctrl',",
64 | " controllerAs: '" + this.cameledName + "'"
65 | ]
66 | };
67 |
68 | config.splicable.unshift(".when('/" + this.uri + "', {");
69 | config.splicable.push("})");
70 |
71 | angularUtils.rewriteFile(config);
72 |
73 | this.composeWith('controller', { arguments: [this.name] }, {
74 | local: require.resolve('../controller/index.js')
75 | });
76 |
77 | this.composeWith('view', { arguments: [this.name.toLowerCase()] }, {
78 | local: require.resolve('../view/index.js')
79 | });
80 | }
81 | }
82 | });
83 |
84 | module.exports = RouteGenerator;
85 |
--------------------------------------------------------------------------------
/decorator/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var util = require('util');
5 | var ScriptBase = require('../script-base.js');
6 | var angularUtils = require('../util.js');
7 | var fs = require('fs');
8 |
9 | var buildRelativePath = function(fileName){
10 | return path.join('decorators', fileName + "Decorator");
11 | };
12 |
13 | var DecoratorGenerator = ScriptBase.extend({
14 | constructor: function(name) {
15 | ScriptBase.apply(this, arguments);
16 | this.fileName = this.name;
17 |
18 | util.inherits(DecoratorGenerator, ScriptBase);
19 | },
20 |
21 | askForOverwrite: function() {
22 | var cb = this.async();
23 |
24 | if (fs.existsSync(path.join(
25 | this.env.cwd, this.env.options.appPath,
26 | 'scripts', buildRelativePath(this.fileName) + ".js"
27 | ))) {
28 | var prompts = [{
29 | type: 'confirm',
30 | name: 'overwriteDecorator',
31 | message: 'Would you like to overwrite existing decorator?',
32 | default: false
33 | }];
34 |
35 | this.prompt(prompts, function (props) {
36 | this.overwriteDecorator = props.overwriteDecorator;
37 |
38 | cb();
39 | }.bind(this));
40 | }
41 | else{
42 | cb();
43 | return;
44 | }
45 | },
46 |
47 | askForNewName: function() {
48 | var cb = this.async();
49 |
50 | if (this.overwriteDecorator === undefined || this.overwriteDecorator === true) {
51 | cb();
52 | return;
53 | }
54 | else {
55 | var prompts = [];
56 | prompts.push({
57 | name: 'decoratorName',
58 | message: 'Alternative name for the decorator'
59 | });
60 |
61 | this.prompt(prompts, function (props) {
62 | this.fileName = props.decoratorName;
63 |
64 | cb();
65 | }.bind(this));
66 | }
67 | },
68 |
69 | createDecoratorFiles: function() {
70 | this.appTemplate(
71 | 'decorator',
72 | path.join('scripts', buildRelativePath(this.fileName))
73 | );
74 | this.addScriptToIndex(buildRelativePath(this.fileName));
75 | },
76 |
77 | // Re-write the main app module to account for our new dependency
78 | injectDependenciesToApp: function () {
79 | var appPath = this.config.get('appPath');
80 |
81 | if (typeof appPath === "undefined") {
82 | appPath = this.env.options.appPath;
83 | }
84 |
85 | angularUtils.injectIntoFile(
86 | appPath,
87 | 'decorators/' + this.name.toLowerCase() + "Decorator",
88 | this.classedName + 'Decorator',
89 | this.scriptAppName + '.decorators.' + this.classedName
90 | );
91 | }
92 | });
93 |
94 | module.exports = DecoratorGenerator;
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 |