Permalink
Browse files

feat(app): remove minsafe options

Remove the minsafe templates, documentation and options from the
generator.

Closes #452

BREAKING CHANGE: Removes the --minsafe from the generator. See the
readme for more information about this change
  • Loading branch information...
1 parent 51e4645 commit c24e25097acb109240f687ace7c214b095d3ee77 @eddiemonge eddiemonge committed Jan 27, 2014
Showing with 19 additions and 411 deletions.
  1. +1 −1 app/USAGE
  2. +2 −11 app/index.js
  3. +1 −1 constant/USAGE
  4. +1 −1 controller/USAGE
  5. +1 −1 directive/USAGE
  6. +1 −1 factory/USAGE
  7. +1 −1 filter/USAGE
  8. +1 −1 provider/USAGE
  9. +4 −35 readme.md
  10. +1 −1 route/USAGE
  11. +0 −9 script-base.js
  12. +1 −1 service/USAGE
  13. +0 −12 templates/coffeescript-min/app.coffee
  14. +0 −10 templates/coffeescript-min/controller.coffee
  15. +0 −7 templates/coffeescript-min/decorator.coffee
  16. +0 −9 templates/coffeescript-min/directive.coffee
  17. +0 −7 templates/coffeescript-min/filter.coffee
  18. +0 −4 templates/coffeescript-min/service/constant.coffee
  19. +0 −15 templates/coffeescript-min/service/factory.coffee
  20. +0 −21 templates/coffeescript-min/service/provider.coffee
  21. +0 −5 templates/coffeescript-min/service/service.coffee
  22. +0 −4 templates/coffeescript-min/service/value.coffee
  23. +0 −19 templates/coffeescript-min/spec/controller.coffee
  24. +0 −16 templates/coffeescript-min/spec/directive.coffee
  25. +0 −15 templates/coffeescript-min/spec/filter.coffee
  26. +0 −14 templates/coffeescript-min/spec/service.coffee
  27. +3 −2 templates/common/Gruntfile.js
  28. +0 −13 templates/javascript-min/app.js
  29. +0 −10 templates/javascript-min/controller.js
  30. +0 −9 templates/javascript-min/decorator.js
  31. +0 −12 templates/javascript-min/directive.js
  32. +0 −8 templates/javascript-min/filter.js
  33. +0 −4 templates/javascript-min/service/constant.js
  34. +0 −16 templates/javascript-min/service/factory.js
  35. +0 −25 templates/javascript-min/service/provider.js
  36. +0 −6 templates/javascript-min/service/service.js
  37. +0 −4 templates/javascript-min/service/value.js
  38. +0 −22 templates/javascript-min/spec/controller.js
  39. +0 −20 templates/javascript-min/spec/directive.js
  40. +0 −19 templates/javascript-min/spec/filter.js
  41. +0 −18 templates/javascript-min/spec/service.js
  42. +1 −1 value/USAGE
View
@@ -2,7 +2,7 @@ Description:
Creates a default AngularJS app
Example:
- yo angular [--coffee] [--minsafe]
+ yo angular [--coffee]
This will create:
Gruntfile.js
View
@@ -47,14 +47,6 @@ var Generator = module.exports = function Generator(args, options) {
this.env.options.coffee = this.options.coffee;
}
- if (typeof this.env.options.minsafe === 'undefined') {
- this.option('minsafe', {
- desc: 'Generate AngularJS minification safe code'
- });
- this.env.options.minsafe = this.options.minsafe;
- args.push('--minsafe');
- }
-
this.hookFor('angular:common', {
args: args
});
@@ -118,11 +110,10 @@ Generator.prototype.welcome = function welcome() {
'Out of the box I include Bootstrap and some AngularJS recommended modules.\n'
);
- // Deprecation notice for minsafe
+ // Removed notice for minsafe
if (this.options.minsafe) {
console.warn(
- '\n** The --minsafe flag is being deprecated in 0.7.0 and removed in ' +
- '0.8.0. For more information, see ' +
+ '\n** The --minsafe flag has been removed. For more information, see ' +
'https://github.com/yeoman/generator-angular#minification-safe. **\n'
);
}
View
@@ -3,7 +3,7 @@ Description:
Docs: http://docs.angularjs.org/guide/dev_guide.services.creating_services
Example:
- yo angular:constant thing [--coffee] [--minsafe]
+ yo angular:constant thing [--coffee]
This will create:
app/scripts/services/thing.js
View
@@ -2,7 +2,7 @@ Description:
Creates a new Angular controller
Example:
- yo angular:controller Thing [--coffee] [--minsafe]
+ yo angular:controller Thing [--coffee]
This will create:
app/scripts/controllers/thing-ctrl.js
View
@@ -2,7 +2,7 @@ Description:
Creates a new Angular directive
Example:
- yo angular:directive thing [--coffee] [--minsafe]
+ yo angular:directive thing [--coffee]
This will create:
app/scripts/directives/thing.js
View
@@ -3,7 +3,7 @@ Description:
Docs: http://docs.angularjs.org/guide/dev_guide.services.creating_services
Example:
- yo angular:factory thing [--coffee] [--minsafe]
+ yo angular:factory thing [--coffee]
This will create:
app/scripts/services/thing.js
View
@@ -2,7 +2,7 @@ Description:
Creates a new AngularJS filter
Example:
- yo angular:filter thing [--coffee] [--minsafe]
+ yo angular:filter thing [--coffee]
This will create:
app/scripts/filters/thing.js
View
@@ -3,7 +3,7 @@ Description:
Docs: http://docs.angularjs.org/guide/dev_guide.services.creating_services
Example:
- yo angular:provider thing [--coffee] [--minsafe]
+ yo angular:provider thing [--coffee]
This will create:
app/scripts/services/thing.js
View
@@ -193,45 +193,14 @@ To output JavaScript files, even if CoffeeScript files exist (the default is to
### Minification Safe
-**Deprecated**
+**Removed**
-[Related Issue #452](https://github.com/yeoman/generator-angular/issues/452): This option is being removed in future versions of the generator. Initially it was needed as ngMin was not entirely stable. As it has matured, the need to keep separate versions of the script templates has led to extra complexity and maintenance of the generator. By removing these extra burdens, new features and bug fixes should be easier to implement. If you are dependent on this option, please take a look at ngMin and seriously consider implementing it in your own code. It will help reduce the amount of typing you have to do (and look through) as well as make your code cleaner to look at.
+[Related Issue #452](https://github.com/yeoman/generator-angular/issues/452): This option has been removed from the generator. Initially it was needed as ngMin was not entirely stable. As it has matured, the need to keep separate versions of the script templates has led to extra complexity and maintenance of the generator. By removing these extra burdens, new features and bug fixes should be easier to implement. If you are dependent on this option, please take a look at ngMin and seriously consider implementing it in your own code. It will help reduce the amount of typing you have to do (and look through) as well as make your code cleaner to look at.
-
-By default, generators produce unannotated code. Without annotations, AngularJS's DI system will break when minified. Typically, these annotations that make minification safe are added automatically at build-time, after application files are concatenated, but before they are minified. By providing the `--minsafe` option, the code generated will out-of-the-box be ready for minification. The trade-off is between amount of boilerplate, and build process complexity.
-
-#### Example
-```bash
-yo angular:controller user --minsafe
-```
-
-Produces `app/controller/user.js`:
-```javascript
-angular.module('myMod').controller('UserCtrl', ['$scope', function ($scope) {
- // ...
-}]);
-```
-
-#### Background
-Unannotated:
-```javascript
-angular.module('myMod').controller('MyCtrl', function ($scope, $http, myService) {
- // ...
-});
-```
-
-Annotated:
-```javascript
-angular.module('myMod').controller('MyCtrl',
- ['$scope', '$http', 'myService', function ($scope, $http, myService) {
-
- // ...
- }]);
-```
-
-The annotations are important because minified code will rename variables, making it impossible for AngularJS to infer module names based solely on function parameters.
+By default, generators produce unannotated code. Without annotations, AngularJS's DI system will break when minified. Typically, these annotations that make minification safe are added automatically at build-time, after application files are concatenated, but before they are minified. The annotations are important because minified code will rename variables, making it impossible for AngularJS to infer module names based solely on function parameters.
The recommended build process uses `ngmin`, a tool that automatically adds these annotations. However, if you'd rather not use `ngmin`, you have to add these annotations manually yourself. **One thing to note is that `ngmin` does not produce minsafe code for things that are not main level elements like controller, services, providers, etc.:
+
```javascript
resolve: {
User: function(myService) {
View
@@ -2,7 +2,7 @@ Description:
Creates a new AngularJS route
Example:
- yo angular:route thing [--coffee] [--minsafe]
+ yo angular:route thing [--coffee]
This will create:
app/scripts/controllers/thing.js
View
@@ -46,11 +46,6 @@ var Generator = module.exports = function Generator() {
this.env.options.coffee = this.options.coffee;
}
- if (typeof this.env.options.minsafe === 'undefined') {
- this.option('minsafe');
- this.env.options.minsafe = this.options.minsafe;
- }
-
var sourceRoot = '/templates/javascript';
this.scriptSuffix = '.js';
@@ -59,10 +54,6 @@ var Generator = module.exports = function Generator() {
this.scriptSuffix = '.coffee';
}
- if (this.env.options.minsafe) {
- sourceRoot += '-min';
- }
-
this.sourceRoot(path.join(__dirname, sourceRoot));
};
View
@@ -3,7 +3,7 @@ Description:
Docs: http://docs.angularjs.org/guide/dev_guide.services.creating_services
Example:
- yo angular:service thing [--coffee] [--minsafe]
+ yo angular:service thing [--coffee]
This will create:
app/scripts/services/thing.js
@@ -1,12 +0,0 @@
-'use strict'
-
-angular.module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) { %>
- .config ['$routeProvider', ($routeProvider) ->
- $routeProvider
- .when '/',
- templateUrl: 'views/main.html'
- controller: 'MainCtrl'
- .otherwise
- redirectTo: '/'
- ]
-<% } %>
@@ -1,10 +0,0 @@
-'use strict'
-
-angular.module('<%= scriptAppName %>')
- .controller '<%= classedName %>Ctrl', ['$scope', ($scope) ->
- $scope.awesomeThings = [
- 'HTML5 Boilerplate'
- 'AngularJS'
- 'Karma'
- ]
- ]
@@ -1,7 +0,0 @@
-'use strict'
-
-angular.module("<%= scriptAppName %>").config ["$provide", ($provide) ->
- $provide.decorator "<%= cameledName %>", ($delegate) ->
- # decorate the $delegate
- $delegate
-]
@@ -1,9 +0,0 @@
-'use strict'
-
-angular.module('<%= scriptAppName %>')
- .directive '<%= cameledName %>', [->
- template: '<div></div>'
- restrict: 'E'
- link: (scope, element, attrs) ->
- element.text 'this is the <%= cameledName %> directive'
- ]
@@ -1,7 +0,0 @@
-'use strict'
-
-angular.module('<%= scriptAppName %>')
- .filter '<%= cameledName %>', [->
- (input) ->
- '<%= cameledName %> filter: ' + input
- ]
@@ -1,4 +0,0 @@
-'use strict'
-
-angular.module('<%= scriptAppName %>')
- .constant '<%= cameledName %>', 42
@@ -1,15 +0,0 @@
-'use strict'
-
-angular.module('<%= scriptAppName %>')
- .factory '<%= cameledName %>', [->
- # Service logic
- # ...
-
- meaningOfLife = 42
-
- # Public API here
- {
- someMethod: ->
- meaningOfLife
- }
- ]
@@ -1,21 +0,0 @@
-'use strict'
-
-angular.module('<%= scriptAppName %>')
- .provider '<%= cameledName %>', [->
-
- # Private variables
- salutation = 'Hello'
-
- # Private constructor
- class Greeter
- @greet = ->
- salutation
-
- # Public API for configuration
- @setSalutation = (s) ->
- salutation = s
-
- # Method for instantiating
- @$get = ->
- new Greeter()
- ]
@@ -1,5 +0,0 @@
-'use strict'
-
-angular.module('<%= scriptAppName %>')
- .service '<%= classedName %>', ->
- # AngularJS will instantiate a singleton by calling "new" on this function
@@ -1,4 +0,0 @@
-'use strict'
-
-angular.module('<%= scriptAppName %>')
- .value '<%= cameledName %>', 42
@@ -1,19 +0,0 @@
-'use strict'
-
-describe 'Controller: <%= classedName %>Ctrl', ->
-
- # load the controller's module
- beforeEach module '<%= scriptAppName %>'
-
- <%= classedName %>Ctrl = {}
- scope = {}
-
- # Initialize the controller and a mock scope
- beforeEach inject ($controller, $rootScope) ->
- scope = $rootScope.$new()
- <%= classedName %>Ctrl = $controller '<%= classedName %>Ctrl', {
- $scope: scope
- }
-
- it 'should attach a list of awesomeThings to the scope', ->
- expect(scope.awesomeThings.length).toBe 3
@@ -1,16 +0,0 @@
-'use strict'
-
-describe 'Directive: <%= cameledName %>', ->
-
- # load the directive's module
- beforeEach module '<%= scriptAppName %>'
-
- scope = {}
-
- beforeEach inject ($controller, $rootScope) ->
- scope = $rootScope.$new()
-
- it 'should make hidden element visible', inject ($compile) ->
- element = angular.element '<<%= _.dasherize(name) %>></<%= _.dasherize(name) %>>'
- element = $compile(element) scope
- expect(element.text()).toBe 'this is the <%= cameledName %> directive'
@@ -1,15 +0,0 @@
-'use strict'
-
-describe 'Filter: <%= cameledName %>', ->
-
- # load the filter's module
- beforeEach module '<%= scriptAppName %>'
-
- # initialize a new instance of the filter before each test
- <%= cameledName %> = {}
- beforeEach inject ($filter) ->
- <%= cameledName %> = $filter '<%= cameledName %>'
-
- it 'should return the input prefixed with "<%= cameledName %> filter:"', ->
- text = 'angularjs'
- expect(<%= cameledName %> text).toBe ('<%= cameledName %> filter: ' + text)
@@ -1,14 +0,0 @@
-'use strict'
-
-describe 'Service: <%= cameledName %>', ->
-
- # load the service's module
- beforeEach module '<%= scriptAppName %>'
-
- # instantiate service
- <%= cameledName %> = {}
- beforeEach inject (_<%= cameledName %>_) ->
- <%= cameledName %> = _<%= cameledName %>_
-
- it 'should do something', ->
- expect(!!<%= cameledName %>).toBe true
@@ -288,8 +288,9 @@ module.exports = function (grunt) {
}
},
- // Allow the use of non-minsafe AngularJS files. Automatically makes it
- // minsafe compatible so Uglify does not destroy the ng references
+ // ngmin tries to make the code safe for minification automatically by
+ // using the Angular long form for dependency injection. It doesn't work on
+ // things like resolve or inject so those have to be done manually.
ngmin: {
dist: {
files: [{
@@ -1,13 +0,0 @@
-'use strict';
-
-angular.module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) { %>
- .config(['$routeProvider', function ($routeProvider) {
- $routeProvider
- .when('/', {
- templateUrl: 'views/main.html',
- controller: 'MainCtrl'
- })
- .otherwise({
- redirectTo: '/'
- });
- }])<% } %>;
@@ -1,10 +0,0 @@
-'use strict';
-
-angular.module('<%= scriptAppName %>')
- .controller('<%= classedName %>Ctrl', ['$scope', function ($scope) {
- $scope.awesomeThings = [
- 'HTML5 Boilerplate',
- 'AngularJS',
- 'Karma'
- ];
- }]);
Oops, something went wrong.

0 comments on commit c24e250

Please sign in to comment.