From 17a31ef9850b63e14cf0fb8a020cba6a7ed13302 Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Tue, 20 Aug 2013 16:41:16 +0200 Subject: [PATCH] chore(gen): revert modular project structure Reverted until more fleshed out. Revert "feat(gen): generate a more modular project stucture" This reverts commit 84d2e4e8e60d297d60882fa84b6542c7279b5a39. Conflicts: view/index.js --- app/index.js | 4 +- constant/index.js | 6 ++- controller/index.js | 5 +- decorator/index.js | 29 ++++++----- directive/index.js | 5 +- factory/index.js | 5 +- provider/index.js | 5 +- route/index.js | 49 ++++++++----------- script-base.js | 39 ++++----------- service/index.js | 5 +- templates/coffeescript-min/app.coffee | 2 +- templates/coffeescript-min/controller.coffee | 2 +- templates/coffeescript-min/decorator.coffee | 4 +- templates/coffeescript-min/directive.coffee | 2 +- templates/coffeescript-min/filter.coffee | 2 +- .../coffeescript-min/service/constant.coffee | 2 +- .../coffeescript-min/service/factory.coffee | 2 +- .../coffeescript-min/service/provider.coffee | 2 +- .../coffeescript-min/service/service.coffee | 2 +- .../coffeescript-min/service/value.coffee | 2 +- .../coffeescript-min/spec/controller.coffee | 2 +- .../coffeescript-min/spec/directive.coffee | 2 +- templates/coffeescript-min/spec/filter.coffee | 2 +- .../coffeescript-min/spec/service.coffee | 2 +- templates/coffeescript/app.coffee | 2 +- templates/coffeescript/controller.coffee | 2 +- templates/coffeescript/decorator.coffee | 4 +- templates/coffeescript/directive.coffee | 2 +- templates/coffeescript/filter.coffee | 2 +- templates/coffeescript/service/factory.coffee | 2 +- templates/coffeescript/spec/controller.coffee | 2 +- templates/coffeescript/spec/directive.coffee | 2 +- templates/coffeescript/spec/filter.coffee | 2 +- templates/coffeescript/spec/service.coffee | 2 +- templates/javascript-min/app.js | 2 +- templates/javascript-min/controller.js | 2 +- templates/javascript-min/decorator.js | 2 +- templates/javascript-min/directive.js | 2 +- templates/javascript-min/filter.js | 2 +- templates/javascript-min/service/constant.js | 2 +- templates/javascript-min/service/factory.js | 2 +- templates/javascript-min/service/provider.js | 2 +- templates/javascript-min/service/service.js | 2 +- templates/javascript-min/service/value.js | 2 +- templates/javascript-min/spec/controller.js | 2 +- templates/javascript-min/spec/directive.js | 2 +- templates/javascript-min/spec/filter.js | 2 +- templates/javascript-min/spec/service.js | 2 +- templates/javascript/app.js | 2 +- templates/javascript/controller.js | 2 +- templates/javascript/decorator.js | 12 ++--- templates/javascript/directive.js | 2 +- templates/javascript/filter.js | 2 +- templates/javascript/service/constant.js | 2 +- templates/javascript/service/factory.js | 2 +- templates/javascript/service/provider.js | 2 +- templates/javascript/service/service.js | 2 +- templates/javascript/service/value.js | 2 +- templates/javascript/spec/controller.js | 2 +- templates/javascript/spec/directive.js | 2 +- templates/javascript/spec/filter.js | 2 +- templates/javascript/spec/service.js | 2 +- value/index.js | 5 +- 63 files changed, 129 insertions(+), 146 deletions(-) diff --git a/app/index.js b/app/index.js index 6ea478b76..6e74b36fd 100644 --- a/app/index.js +++ b/app/index.js @@ -61,7 +61,7 @@ var Generator = module.exports = function Generator(args, options) { coffee: this.options.coffee, travis: true, 'skip-install': this.options['skip-install'] - } + } } }); @@ -162,7 +162,7 @@ Generator.prototype.bootstrapFiles = function bootstrapFiles() { }); }; -Generator.prototype.bootstrapJs = function bootstrapJs() { +Generator.prototype.bootstrapJS = function bootstrapJS() { if (!this.bootstrap) { return; // Skip if disabled. } diff --git a/constant/index.js b/constant/index.js index 0d5296240..44abcd031 100644 --- a/constant/index.js +++ b/constant/index.js @@ -2,6 +2,7 @@ var path = require('path'); var util = require('util'); var ScriptBase = require('../script-base.js'); +var angularUtils = require('../util.js'); module.exports = Generator; @@ -13,6 +14,7 @@ function Generator() { util.inherits(Generator, ScriptBase); Generator.prototype.createServiceFiles = function createServiceFiles() { - this.appTemplate('service/constant'); - this.testTemplate('spec/service'); + this.appTemplate('service/constant', 'scripts/services/' + this.name); + this.testTemplate('spec/service', 'services/' + this.name); + this.addScriptToIndex('services/' + this.name); }; diff --git a/controller/index.js b/controller/index.js index bceb3bf4f..6a49111d6 100644 --- a/controller/index.js +++ b/controller/index.js @@ -19,6 +19,7 @@ function Generator() { util.inherits(Generator, ScriptBase); Generator.prototype.createControllerFiles = function createControllerFiles() { - this.appTemplate('controller'); - this.testTemplate('spec/controller'); + this.appTemplate('controller', 'scripts/controllers/' + this.name); + this.testTemplate('spec/controller', 'controllers/' + this.name); + this.addScriptToIndex('controllers/' + this.name); }; diff --git a/decorator/index.js b/decorator/index.js index 99aacffd6..56fb2115f 100644 --- a/decorator/index.js +++ b/decorator/index.js @@ -14,7 +14,7 @@ Generator.prototype.askForOverwrite = function askForOverwrite() { var cb = this.async(); // TODO: Any yeoman.util function to handle this? - var fileExists = fs.existsSync(this.env.cwd + '/app/scripts/' + buildRelativePath(this.fileName) + '.js'); + var fileExists = fs.existsSync(this.env.cwd + '/app/scripts/' + buildRelativePath(this.fileName) + ".js"); if (fileExists) { var prompts = [{ type: 'confirm', @@ -28,8 +28,10 @@ Generator.prototype.askForOverwrite = function askForOverwrite() { cb(); }.bind(this)); - } else { + } + else{ cb(); + return; } }; @@ -40,18 +42,19 @@ Generator.prototype.askForNewName = function askForNewName() { cb(); return; } + else { + var prompts = []; + prompts.push({ + name: 'decoratorName', + message: 'Alternative name for the decorator' + }); - var prompts = []; - prompts.push({ - name: 'decoratorName', - message: 'Alternative name for the decorator' - }); - - this.prompt(prompts, function (props) { - this.fileName = props.decoratorName; + this.prompt(prompts, function (props) { + this.fileName = props.decoratorName; - cb(); - }.bind(this)); + cb(); + }.bind(this)); + } }; Generator.prototype.createDecoratorFiles = function createDecoratorFiles() { @@ -60,5 +63,5 @@ Generator.prototype.createDecoratorFiles = function createDecoratorFiles() { }; function buildRelativePath(fileName){ - return 'decorators/' + fileName + 'Decorator'; + return 'decorators/' + fileName + "Decorator"; } diff --git a/directive/index.js b/directive/index.js index 1f982aff0..be5f999b9 100644 --- a/directive/index.js +++ b/directive/index.js @@ -14,6 +14,7 @@ function Generator() { util.inherits(Generator, ScriptBase); Generator.prototype.createDirectiveFiles = function createDirectiveFiles() { - this.appTemplate('directive'); - this.testTemplate('spec/directive'); + this.appTemplate('directive', 'scripts/directives/' + this.name); + this.testTemplate('spec/directive', 'directives/' + this.name); + this.addScriptToIndex('directives/' + this.name); }; diff --git a/factory/index.js b/factory/index.js index 4218e7406..959ace579 100644 --- a/factory/index.js +++ b/factory/index.js @@ -14,6 +14,7 @@ function Generator() { util.inherits(Generator, ScriptBase); Generator.prototype.createServiceFiles = function createServiceFiles() { - this.appTemplate('service/factory'); - this.testTemplate('spec/service'); + this.appTemplate('service/factory', 'scripts/services/' + this.name); + this.testTemplate('spec/service', 'services/' + this.name); + this.addScriptToIndex('services/' + this.name); }; diff --git a/provider/index.js b/provider/index.js index 14c77a237..5deb351ed 100644 --- a/provider/index.js +++ b/provider/index.js @@ -14,6 +14,7 @@ function Generator() { util.inherits(Generator, ScriptBase); Generator.prototype.createServiceFiles = function createServiceFiles() { - this.appTemplate('service/provider'); - this.testTemplate('spec/service'); + this.appTemplate('service/provider', 'scripts/services/' + this.name); + this.testTemplate('spec/service', 'services/' + this.name); + this.addScriptToIndex('services/' + this.name); }; diff --git a/route/index.js b/route/index.js index b0be1e2a1..55a7cf0b5 100644 --- a/route/index.js +++ b/route/index.js @@ -15,34 +15,27 @@ function Generator() { util.inherits(Generator, ScriptBase); Generator.prototype.rewriteAppJs = function () { - var htmlTemplatePath = this.name + '.html', - splicable, - filePath = path.join(this.env.options.appPath, 'scripts/app.'); - - if (htmlTemplatePath.indexOf('/') === -1) { - htmlTemplatePath = 'views/' + htmlTemplatePath; - } - if (this.env.options.coffee) { - splicable = [ - '.when \'/' + this.name + '\',', - ' templateUrl: \'' + htmlTemplatePath + '\',', - ' controller: \'' + this._.classify(this.name) + 'Ctrl\'' - ]; - filePath += 'coffee'; - } else { - splicable = [ - '.when(\'/' + this.name + '\', {', - ' templateUrl: \'' + htmlTemplatePath + '\',', - ' controller: \'' + this._.classify(this.name) + 'Ctrl\'', - '})' - ]; - filePath += 'js'; + angularUtils.rewriteFile({ + file: path.join(this.env.options.appPath, 'scripts/app.coffee'), + needle: '.otherwise', + splicable: [ + '.when \'/' + this.name + '\',', + ' templateUrl: \'views/' + this.name + '.html\',', + ' controller: \'' + this._.classify(this.name) + 'Ctrl\'' + ] + }); + } + else { + angularUtils.rewriteFile({ + file: path.join(this.env.options.appPath, 'scripts/app.js'), + needle: '.otherwise', + splicable: [ + '.when(\'/' + this.name + '\', {', + ' templateUrl: \'views/' + this.name + '.html\',', + ' controller: \'' + this._.classify(this.name) + 'Ctrl\'', + '})' + ] + }); } - - angularUtils.rewriteFile({ - file: filePath, - needle: '.otherwise', - splicable: splicable - }); }; diff --git a/script-base.js b/script-base.js index e4c6ae130..cd090c9ed 100644 --- a/script-base.js +++ b/script-base.js @@ -60,53 +60,32 @@ function Generator() { } this.sourceRoot(path.join(__dirname, sourceRoot)); - - this.moduleName = this._.camelize(this.appname) + 'App'; - - this.namespace = []; - if (this.name.indexOf('/') !== -1) { - this.namespace = this.name.split('/'); - this.name = this.namespace.pop(); - - this.moduleName += '.' + this.namespace.join('.'); // add to parent ? - } - } util.inherits(Generator, yeoman.generators.NamedBase); -Generator.prototype._dest = function (src) { - if (src.indexOf('spec/') === 0) { - src = src.substr(5); - } else if (src.indexOf('service/') === 0) { - src = src.substr(8); - } - return path.join((this.namespace.join('/') || src), this.name); -}; - -Generator.prototype.appTemplate = function (src) { +Generator.prototype.appTemplate = function (src, dest) { yeoman.generators.Base.prototype.template.apply(this, [ src + this.scriptSuffix, - path.join(this.env.options.appPath, this._dest(src)) + this.scriptSuffix + path.join(this.env.options.appPath, dest) + this.scriptSuffix ]); - this.addScriptToIndex(src); }; -Generator.prototype.testTemplate = function (src) { +Generator.prototype.testTemplate = function (src, dest) { yeoman.generators.Base.prototype.template.apply(this, [ src + this.scriptSuffix, - path.join(this.env.options.testPath, this._dest(src)) + this.scriptSuffix + path.join(this.env.options.testPath, dest) + this.scriptSuffix ]); }; -Generator.prototype.htmlTemplate = function (src) { +Generator.prototype.htmlTemplate = function (src, dest) { yeoman.generators.Base.prototype.template.apply(this, [ src, - path.join(this.env.options.appPath, this._dest(src)) + path.join(this.env.options.appPath, dest) ]); }; -Generator.prototype.addScriptToIndex = function (src) { +Generator.prototype.addScriptToIndex = function (script) { try { var appPath = this.env.options.appPath; var fullPath = path.join(appPath, 'index.html'); @@ -114,10 +93,10 @@ Generator.prototype.addScriptToIndex = function (src) { file: fullPath, needle: '', splicable: [ - '' + '' ] }); } catch (e) { - console.log('\nUnable to find '.yellow + fullPath + '. Reference to '.yellow + this._dest(src) + '.js ' + 'not added.\n'.yellow); + console.log('\nUnable to find '.yellow + fullPath + '. Reference to '.yellow + script + '.js ' + 'not added.\n'.yellow); } }; diff --git a/service/index.js b/service/index.js index 1afe0cf46..a539329fb 100644 --- a/service/index.js +++ b/service/index.js @@ -14,6 +14,7 @@ function Generator() { util.inherits(Generator, ScriptBase); Generator.prototype.createServiceFiles = function createServiceFiles() { - this.appTemplate('service/service'); - this.testTemplate('spec/service'); + this.appTemplate('service/service', 'scripts/services/' + this.name); + this.testTemplate('spec/service', 'services/' + this.name); + this.addScriptToIndex('services/' + this.name); }; diff --git a/templates/coffeescript-min/app.coffee b/templates/coffeescript-min/app.coffee index 50ab4f1f7..366db0619 100644 --- a/templates/coffeescript-min/app.coffee +++ b/templates/coffeescript-min/app.coffee @@ -1,6 +1,6 @@ 'use strict' -angular.module('<%= moduleName %>', []) +angular.module('<%= _.camelize(appname) %>App', []) .config ['$routeProvider', ($routeProvider) -> $routeProvider .when '/', diff --git a/templates/coffeescript-min/controller.coffee b/templates/coffeescript-min/controller.coffee index bc9380544..0a4e6f4d2 100644 --- a/templates/coffeescript-min/controller.coffee +++ b/templates/coffeescript-min/controller.coffee @@ -1,6 +1,6 @@ 'use strict' -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .controller '<%= _.classify(name) %>Ctrl', ['$scope', ($scope) -> $scope.awesomeThings = [ 'HTML5 Boilerplate' diff --git a/templates/coffeescript-min/decorator.coffee b/templates/coffeescript-min/decorator.coffee index 2266d3148..713877991 100644 --- a/templates/coffeescript-min/decorator.coffee +++ b/templates/coffeescript-min/decorator.coffee @@ -1,7 +1,7 @@ 'use strict'; -angular.module('<%= moduleName %>').config ['$provide', ($provide) -> - $provide.decorator '<%= _.camelize(name) %>', ($delegate) -> +angular.module("<%= _.camelize(appname) %>App").config ["$provide", ($provide) -> + $provide.decorator "<%= _.camelize(name) %>", ($delegate) -> # decorate the $delegate $delegate ] diff --git a/templates/coffeescript-min/directive.coffee b/templates/coffeescript-min/directive.coffee index d556331d7..71ff61c53 100644 --- a/templates/coffeescript-min/directive.coffee +++ b/templates/coffeescript-min/directive.coffee @@ -1,6 +1,6 @@ 'use strict'; -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .directive '<%= _.camelize(name) %>', [-> template: '
' restrict: 'E' diff --git a/templates/coffeescript-min/filter.coffee b/templates/coffeescript-min/filter.coffee index 36d0f3dca..e5e99eb8f 100644 --- a/templates/coffeescript-min/filter.coffee +++ b/templates/coffeescript-min/filter.coffee @@ -1,6 +1,6 @@ 'use strict'; -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .filter '<%= _.camelize(name) %>', [() -> (input) -> '<%= _.camelize(name) %> filter: ' + input diff --git a/templates/coffeescript-min/service/constant.coffee b/templates/coffeescript-min/service/constant.coffee index bbb3c8e73..e998f483b 100644 --- a/templates/coffeescript-min/service/constant.coffee +++ b/templates/coffeescript-min/service/constant.coffee @@ -1,4 +1,4 @@ 'use strict' -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .constant '<%= _.camelize(name) %>', 42 diff --git a/templates/coffeescript-min/service/factory.coffee b/templates/coffeescript-min/service/factory.coffee index cfb16bc15..35a2a415b 100644 --- a/templates/coffeescript-min/service/factory.coffee +++ b/templates/coffeescript-min/service/factory.coffee @@ -1,6 +1,6 @@ 'use strict'; -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .factory '<%= _.camelize(name) %>', [() -> # Service logic # ... diff --git a/templates/coffeescript-min/service/provider.coffee b/templates/coffeescript-min/service/provider.coffee index 30550aea8..a1364694b 100644 --- a/templates/coffeescript-min/service/provider.coffee +++ b/templates/coffeescript-min/service/provider.coffee @@ -1,6 +1,6 @@ 'use strict' -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .provider '<%= _.camelize(name) %>', [() -> # Private variables diff --git a/templates/coffeescript-min/service/service.coffee b/templates/coffeescript-min/service/service.coffee index 4f2c5f223..aa66b4ed8 100644 --- a/templates/coffeescript-min/service/service.coffee +++ b/templates/coffeescript-min/service/service.coffee @@ -1,5 +1,5 @@ 'use strict'; -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .service '<%= _.classify(name) %>', () -> # AngularJS will instantiate a singleton by calling "new" on this function diff --git a/templates/coffeescript-min/service/value.coffee b/templates/coffeescript-min/service/value.coffee index 320547836..0bd6d0ad2 100644 --- a/templates/coffeescript-min/service/value.coffee +++ b/templates/coffeescript-min/service/value.coffee @@ -1,4 +1,4 @@ 'use strict'; -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .value '<%= _.camelize(name) %>', 42 diff --git a/templates/coffeescript-min/spec/controller.coffee b/templates/coffeescript-min/spec/controller.coffee index 97461fa16..787c6924e 100644 --- a/templates/coffeescript-min/spec/controller.coffee +++ b/templates/coffeescript-min/spec/controller.coffee @@ -3,7 +3,7 @@ describe 'Controller: <%= _.classify(name) %>Ctrl', () -> # load the controller's module - beforeEach module '<%= moduleName %>' + beforeEach module '<%= _.camelize(appname) %>App' <%= _.classify(name) %>Ctrl = {} scope = {} diff --git a/templates/coffeescript-min/spec/directive.coffee b/templates/coffeescript-min/spec/directive.coffee index c0856a3ad..3c3cdd214 100644 --- a/templates/coffeescript-min/spec/directive.coffee +++ b/templates/coffeescript-min/spec/directive.coffee @@ -3,7 +3,7 @@ describe 'Directive: <%= _.camelize(name) %>', () -> # load the directive's module - beforeEach module '<%= moduleName %>' + beforeEach module '<%= _.camelize(appname) %>App' scope = {} diff --git a/templates/coffeescript-min/spec/filter.coffee b/templates/coffeescript-min/spec/filter.coffee index 83960147f..765e2fca0 100644 --- a/templates/coffeescript-min/spec/filter.coffee +++ b/templates/coffeescript-min/spec/filter.coffee @@ -3,7 +3,7 @@ describe 'Filter: <%= _.camelize(name) %>', () -> # load the filter's module - beforeEach module '<%= moduleName %>' + beforeEach module '<%= _.camelize(appname) %>App' # initialize a new instance of the filter before each test <%= _.camelize(name) %> = {} diff --git a/templates/coffeescript-min/spec/service.coffee b/templates/coffeescript-min/spec/service.coffee index 708ebe872..2610aeb10 100644 --- a/templates/coffeescript-min/spec/service.coffee +++ b/templates/coffeescript-min/spec/service.coffee @@ -3,7 +3,7 @@ describe 'Service: <%= _.camelize(name) %>', () -> # load the service's module - beforeEach module '<%= moduleName %>' + beforeEach module '<%= _.camelize(appname) %>App' # instantiate service <%= _.camelize(name) %> = {} diff --git a/templates/coffeescript/app.coffee b/templates/coffeescript/app.coffee index cca5a4582..46a677171 100644 --- a/templates/coffeescript/app.coffee +++ b/templates/coffeescript/app.coffee @@ -1,6 +1,6 @@ 'use strict' -angular.module('<%= moduleName %>', []) +angular.module('<%= _.camelize(appname) %>App', []) .config ($routeProvider) -> $routeProvider .when '/', diff --git a/templates/coffeescript/controller.coffee b/templates/coffeescript/controller.coffee index 5646635a9..e429e86f9 100644 --- a/templates/coffeescript/controller.coffee +++ b/templates/coffeescript/controller.coffee @@ -1,6 +1,6 @@ 'use strict' -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .controller '<%= _.classify(name) %>Ctrl', ($scope) -> $scope.awesomeThings = [ 'HTML5 Boilerplate' diff --git a/templates/coffeescript/decorator.coffee b/templates/coffeescript/decorator.coffee index cd5f76fe7..d34411c85 100644 --- a/templates/coffeescript/decorator.coffee +++ b/templates/coffeescript/decorator.coffee @@ -1,6 +1,6 @@ 'use strict'; -angular.module('<%= moduleName %>').config ($provide) -> - $provide.decorator '<%= _.camelize(name) %>', ($delegate) -> +angular.module("<%= _.camelize(appname) %>App").config ($provide) -> + $provide.decorator "<%= _.camelize(name) %>", ($delegate) -> # decorate the $delegate $delegate diff --git a/templates/coffeescript/directive.coffee b/templates/coffeescript/directive.coffee index 9de30fcf7..595e3a380 100644 --- a/templates/coffeescript/directive.coffee +++ b/templates/coffeescript/directive.coffee @@ -1,6 +1,6 @@ 'use strict'; -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .directive('<%= _.camelize(name) %>', () -> template: '
' restrict: 'E' diff --git a/templates/coffeescript/filter.coffee b/templates/coffeescript/filter.coffee index 7753507c3..978d4d262 100644 --- a/templates/coffeescript/filter.coffee +++ b/templates/coffeescript/filter.coffee @@ -1,6 +1,6 @@ 'use strict'; -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .filter '<%= _.camelize(name) %>', () -> (input) -> '<%= _.camelize(name) %> filter: ' + input diff --git a/templates/coffeescript/service/factory.coffee b/templates/coffeescript/service/factory.coffee index 31702b763..2fb53396d 100644 --- a/templates/coffeescript/service/factory.coffee +++ b/templates/coffeescript/service/factory.coffee @@ -1,6 +1,6 @@ 'use strict'; -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .factory '<%= _.camelize(name) %>', () -> # Service logic # ... diff --git a/templates/coffeescript/spec/controller.coffee b/templates/coffeescript/spec/controller.coffee index 97461fa16..787c6924e 100644 --- a/templates/coffeescript/spec/controller.coffee +++ b/templates/coffeescript/spec/controller.coffee @@ -3,7 +3,7 @@ describe 'Controller: <%= _.classify(name) %>Ctrl', () -> # load the controller's module - beforeEach module '<%= moduleName %>' + beforeEach module '<%= _.camelize(appname) %>App' <%= _.classify(name) %>Ctrl = {} scope = {} diff --git a/templates/coffeescript/spec/directive.coffee b/templates/coffeescript/spec/directive.coffee index c0856a3ad..3c3cdd214 100644 --- a/templates/coffeescript/spec/directive.coffee +++ b/templates/coffeescript/spec/directive.coffee @@ -3,7 +3,7 @@ describe 'Directive: <%= _.camelize(name) %>', () -> # load the directive's module - beforeEach module '<%= moduleName %>' + beforeEach module '<%= _.camelize(appname) %>App' scope = {} diff --git a/templates/coffeescript/spec/filter.coffee b/templates/coffeescript/spec/filter.coffee index 83960147f..765e2fca0 100644 --- a/templates/coffeescript/spec/filter.coffee +++ b/templates/coffeescript/spec/filter.coffee @@ -3,7 +3,7 @@ describe 'Filter: <%= _.camelize(name) %>', () -> # load the filter's module - beforeEach module '<%= moduleName %>' + beforeEach module '<%= _.camelize(appname) %>App' # initialize a new instance of the filter before each test <%= _.camelize(name) %> = {} diff --git a/templates/coffeescript/spec/service.coffee b/templates/coffeescript/spec/service.coffee index 708ebe872..2610aeb10 100644 --- a/templates/coffeescript/spec/service.coffee +++ b/templates/coffeescript/spec/service.coffee @@ -3,7 +3,7 @@ describe 'Service: <%= _.camelize(name) %>', () -> # load the service's module - beforeEach module '<%= moduleName %>' + beforeEach module '<%= _.camelize(appname) %>App' # instantiate service <%= _.camelize(name) %> = {} diff --git a/templates/javascript-min/app.js b/templates/javascript-min/app.js index 7295039d6..67a66dee9 100644 --- a/templates/javascript-min/app.js +++ b/templates/javascript-min/app.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('<%= moduleName %>', []) +angular.module('<%= _.camelize(appname) %>App', []) .config(['$routeProvider', function ($routeProvider) { $routeProvider .when('/', { diff --git a/templates/javascript-min/controller.js b/templates/javascript-min/controller.js index 660c101e3..f0385729a 100644 --- a/templates/javascript-min/controller.js +++ b/templates/javascript-min/controller.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .controller('<%= _.classify(name) %>Ctrl', ['$scope', function ($scope) { $scope.awesomeThings = [ 'HTML5 Boilerplate', diff --git a/templates/javascript-min/decorator.js b/templates/javascript-min/decorator.js index 28f03566f..7a0bcefd6 100644 --- a/templates/javascript-min/decorator.js +++ b/templates/javascript-min/decorator.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .config(['$provide', function ($provide) { $provide.decorator('<%= _.camelize(name) %>', function ($delegate) { // decorate the $delegate diff --git a/templates/javascript-min/directive.js b/templates/javascript-min/directive.js index 5af7bbab9..524231bd2 100644 --- a/templates/javascript-min/directive.js +++ b/templates/javascript-min/directive.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .directive('<%= _.camelize(name) %>', [function () { return { template: '
', diff --git a/templates/javascript-min/filter.js b/templates/javascript-min/filter.js index 465daf734..bc25b4c1c 100644 --- a/templates/javascript-min/filter.js +++ b/templates/javascript-min/filter.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .filter('<%= _.camelize(name) %>', [function () { return function (input) { return '<%= _.camelize(name) %> filter: ' + input; diff --git a/templates/javascript-min/service/constant.js b/templates/javascript-min/service/constant.js index f3b7e526e..62686827c 100644 --- a/templates/javascript-min/service/constant.js +++ b/templates/javascript-min/service/constant.js @@ -1,4 +1,4 @@ 'use strict'; -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .constant('<%= _.camelize(name) %>', 42); diff --git a/templates/javascript-min/service/factory.js b/templates/javascript-min/service/factory.js index 0131a9850..9529c7325 100644 --- a/templates/javascript-min/service/factory.js +++ b/templates/javascript-min/service/factory.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .factory('<%= _.camelize(name) %>', [function() { // Service logic // ... diff --git a/templates/javascript-min/service/provider.js b/templates/javascript-min/service/provider.js index c85d561b0..49789a81c 100644 --- a/templates/javascript-min/service/provider.js +++ b/templates/javascript-min/service/provider.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .provider('<%= _.camelize(name) %>', [function() { // Private variables diff --git a/templates/javascript-min/service/service.js b/templates/javascript-min/service/service.js index 1e3e0cd66..829dbd6e9 100644 --- a/templates/javascript-min/service/service.js +++ b/templates/javascript-min/service/service.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .service('<%= _.classify(name) %>', function <%= _.classify(name) %>() { // AngularJS will instantiate a singleton by calling "new" on this function }); diff --git a/templates/javascript-min/service/value.js b/templates/javascript-min/service/value.js index 861f5c3a8..90f219727 100644 --- a/templates/javascript-min/service/value.js +++ b/templates/javascript-min/service/value.js @@ -1,4 +1,4 @@ 'use strict'; -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .value('<%= _.camelize(name) %>', 42); diff --git a/templates/javascript-min/spec/controller.js b/templates/javascript-min/spec/controller.js index 30389187b..6545c70f2 100644 --- a/templates/javascript-min/spec/controller.js +++ b/templates/javascript-min/spec/controller.js @@ -3,7 +3,7 @@ describe('Controller: <%= _.classify(name) %>Ctrl', function () { // load the controller's module - beforeEach(module('<%= moduleName %>')); + beforeEach(module('<%= _.camelize(appname) %>App')); var <%= _.classify(name) %>Ctrl, scope; diff --git a/templates/javascript-min/spec/directive.js b/templates/javascript-min/spec/directive.js index ae919d648..f0e12fb13 100644 --- a/templates/javascript-min/spec/directive.js +++ b/templates/javascript-min/spec/directive.js @@ -3,7 +3,7 @@ describe('Directive: <%= _.camelize(name) %>', function () { // load the directive's module - beforeEach(module('<%= moduleName %>')); + beforeEach(module('<%= _.camelize(appname) %>App')); var element, scope; diff --git a/templates/javascript-min/spec/filter.js b/templates/javascript-min/spec/filter.js index 380a65dd1..7aa6a7695 100644 --- a/templates/javascript-min/spec/filter.js +++ b/templates/javascript-min/spec/filter.js @@ -3,7 +3,7 @@ describe('Filter: <%= _.camelize(name) %>', function () { // load the filter's module - beforeEach(module('<%= moduleName %>')); + beforeEach(module('<%= _.camelize(appname) %>App')); // initialize a new instance of the filter before each test var <%= _.camelize(name) %>; diff --git a/templates/javascript-min/spec/service.js b/templates/javascript-min/spec/service.js index 947241ab0..32ccb2d0c 100644 --- a/templates/javascript-min/spec/service.js +++ b/templates/javascript-min/spec/service.js @@ -3,7 +3,7 @@ describe('Service: <%= _.camelize(name) %>', function () { // load the service's module - beforeEach(module('<%= moduleName %>')); + beforeEach(module('<%= _.camelize(appname) %>App')); // instantiate service var <%= _.camelize(name) %>; diff --git a/templates/javascript/app.js b/templates/javascript/app.js index 8e108ef58..e88ea7922 100644 --- a/templates/javascript/app.js +++ b/templates/javascript/app.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('<%= moduleName %>', []) +angular.module('<%= _.camelize(appname) %>App', []) .config(function ($routeProvider) { $routeProvider .when('/', { diff --git a/templates/javascript/controller.js b/templates/javascript/controller.js index 8d8a8e619..dcebb0a00 100644 --- a/templates/javascript/controller.js +++ b/templates/javascript/controller.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .controller('<%= _.classify(name) %>Ctrl', function ($scope) { $scope.awesomeThings = [ 'HTML5 Boilerplate', diff --git a/templates/javascript/decorator.js b/templates/javascript/decorator.js index c2e0b9719..d5fb60087 100644 --- a/templates/javascript/decorator.js +++ b/templates/javascript/decorator.js @@ -1,9 +1,9 @@ 'use strict'; -angular.module('<%= moduleName %>') - .config(function ($provide) { - $provide.decorator('<%= _.camelize(name) %>', function ($delegate) { - // decorate the $delegate - return $delegate; +angular.module('<%= _.camelize(appname) %>App') + .config(function ($provide) { + $provide.decorator('<%= _.camelize(name) %>', function ($delegate) { + // decorate the $delegate + return $delegate; + }); }); - }); diff --git a/templates/javascript/directive.js b/templates/javascript/directive.js index 4e054ebcb..bec7df2d2 100644 --- a/templates/javascript/directive.js +++ b/templates/javascript/directive.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .directive('<%= _.camelize(name) %>', function () { return { template: '
', diff --git a/templates/javascript/filter.js b/templates/javascript/filter.js index a264925e8..7866f55f1 100644 --- a/templates/javascript/filter.js +++ b/templates/javascript/filter.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .filter('<%= _.camelize(name) %>', function () { return function (input) { return '<%= _.camelize(name) %> filter: ' + input; diff --git a/templates/javascript/service/constant.js b/templates/javascript/service/constant.js index f3b7e526e..62686827c 100644 --- a/templates/javascript/service/constant.js +++ b/templates/javascript/service/constant.js @@ -1,4 +1,4 @@ 'use strict'; -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .constant('<%= _.camelize(name) %>', 42); diff --git a/templates/javascript/service/factory.js b/templates/javascript/service/factory.js index 8fe075f36..821fa9173 100644 --- a/templates/javascript/service/factory.js +++ b/templates/javascript/service/factory.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .factory('<%= _.camelize(name) %>', function () { // Service logic // ... diff --git a/templates/javascript/service/provider.js b/templates/javascript/service/provider.js index f9c33d9dd..812e8f6a3 100644 --- a/templates/javascript/service/provider.js +++ b/templates/javascript/service/provider.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .provider('<%= _.camelize(name) %>', function () { // Private variables diff --git a/templates/javascript/service/service.js b/templates/javascript/service/service.js index 1e3e0cd66..829dbd6e9 100644 --- a/templates/javascript/service/service.js +++ b/templates/javascript/service/service.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .service('<%= _.classify(name) %>', function <%= _.classify(name) %>() { // AngularJS will instantiate a singleton by calling "new" on this function }); diff --git a/templates/javascript/service/value.js b/templates/javascript/service/value.js index 861f5c3a8..90f219727 100644 --- a/templates/javascript/service/value.js +++ b/templates/javascript/service/value.js @@ -1,4 +1,4 @@ 'use strict'; -angular.module('<%= moduleName %>') +angular.module('<%= _.camelize(appname) %>App') .value('<%= _.camelize(name) %>', 42); diff --git a/templates/javascript/spec/controller.js b/templates/javascript/spec/controller.js index 30389187b..6545c70f2 100644 --- a/templates/javascript/spec/controller.js +++ b/templates/javascript/spec/controller.js @@ -3,7 +3,7 @@ describe('Controller: <%= _.classify(name) %>Ctrl', function () { // load the controller's module - beforeEach(module('<%= moduleName %>')); + beforeEach(module('<%= _.camelize(appname) %>App')); var <%= _.classify(name) %>Ctrl, scope; diff --git a/templates/javascript/spec/directive.js b/templates/javascript/spec/directive.js index ae919d648..f0e12fb13 100644 --- a/templates/javascript/spec/directive.js +++ b/templates/javascript/spec/directive.js @@ -3,7 +3,7 @@ describe('Directive: <%= _.camelize(name) %>', function () { // load the directive's module - beforeEach(module('<%= moduleName %>')); + beforeEach(module('<%= _.camelize(appname) %>App')); var element, scope; diff --git a/templates/javascript/spec/filter.js b/templates/javascript/spec/filter.js index d6af16044..4344127de 100644 --- a/templates/javascript/spec/filter.js +++ b/templates/javascript/spec/filter.js @@ -3,7 +3,7 @@ describe('Filter: <%= _.camelize(name) %>', function () { // load the filter's module - beforeEach(module('<%= moduleName %>')); + beforeEach(module('<%= _.camelize(appname) %>App')); // initialize a new instance of the filter before each test var <%= _.camelize(name) %>; diff --git a/templates/javascript/spec/service.js b/templates/javascript/spec/service.js index aaf0e5913..d23867d44 100644 --- a/templates/javascript/spec/service.js +++ b/templates/javascript/spec/service.js @@ -3,7 +3,7 @@ describe('Service: <%= _.camelize(name) %>', function () { // load the service's module - beforeEach(module('<%= moduleName %>')); + beforeEach(module('<%= _.camelize(appname) %>App')); // instantiate service var <%= _.camelize(name) %>; diff --git a/value/index.js b/value/index.js index e8171966c..44abcd031 100644 --- a/value/index.js +++ b/value/index.js @@ -14,6 +14,7 @@ function Generator() { util.inherits(Generator, ScriptBase); Generator.prototype.createServiceFiles = function createServiceFiles() { - this.appTemplate('service/value'); - this.testTemplate('spec/service'); + this.appTemplate('service/constant', 'scripts/services/' + this.name); + this.testTemplate('spec/service', 'services/' + this.name); + this.addScriptToIndex('services/' + this.name); };