From d595d7bfab5bff3d19e2b94536aac7e59f2f7f3c Mon Sep 17 00:00:00 2001 From: Nurahmadie Date: Sun, 4 Aug 2013 16:13:52 +0700 Subject: [PATCH 1/4] JSHint files under aura_components and extensions. --- templates/common/Gruntfile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/common/Gruntfile.js b/templates/common/Gruntfile.js index 4772c90..567babe 100644 --- a/templates/common/Gruntfile.js +++ b/templates/common/Gruntfile.js @@ -92,8 +92,8 @@ module.exports = function (grunt) { }, files: { src: [ - 'app/aura_components/**.js', - 'app/extensions/**.js', + 'app/aura_components/**/*.js', + 'app/extensions/*.js', 'app/main.js', ] } From f0fbd4cd4bb97e07604943b5ead7915b6b45b802 Mon Sep 17 00:00:00 2001 From: Nurahmadie Date: Sun, 4 Aug 2013 16:15:59 +0700 Subject: [PATCH 2/4] Refactor templates to pass JSHint. Underscore dependency at extensions were removed, I think the one at components should be good enough as an example. --- templates/aura_components/main.js | 9 +++++---- templates/extensions/main.js | 6 ++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/templates/aura_components/main.js b/templates/aura_components/main.js index f0039e6..2251be3 100644 --- a/templates/aura_components/main.js +++ b/templates/aura_components/main.js @@ -1,9 +1,10 @@ define(['underscore'], function (_) { + 'use strict'; return { initialize: function () { - this.$el.on('click', this.someCoolFeature.bind(this)); + this.$el.on('click', _.bind(this.someCoolFeature, this)); this.render(); }, @@ -12,13 +13,13 @@ define(['underscore'], function (_) { this.$el.html('Click me: ' + this.$el.html()); }, - someCoolFeature: function(){ + someCoolFeature: function () { //Awesome code var element = this.$el; - element.fadeOut(200, function(){ + element.fadeOut(200, function () { element.fadeIn(200); }); } }; -}); \ No newline at end of file +}); diff --git a/templates/extensions/main.js b/templates/extensions/main.js index 9db6890..4d6e41f 100644 --- a/templates/extensions/main.js +++ b/templates/extensions/main.js @@ -1,10 +1,12 @@ -define(['underscore'], function (_) { +define(function () { + 'use strict'; return { name: '<%= _.slugify(name) %>', initialize: function (application) { // Your brilliant code here! + application.logger.log('Initializing extension: <%= _.slugify(name) %>'); } }; -}); \ No newline at end of file +}); From 3b5cf1387d89e460b3951d15987b55e0de2f621e Mon Sep 17 00:00:00 2001 From: Nurahmadie Date: Sun, 4 Aug 2013 16:19:35 +0700 Subject: [PATCH 3/4] Basic optimization with requirejs. Apparently requirejs may automatically copy files between app and dist. So I remove `copy' from build task. May need some review on this. --- templates/app/main.js | 1 + templates/common/Gruntfile.js | 18 +++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/templates/app/main.js b/templates/app/main.js index aebdbcc..85b05d8 100644 --- a/templates/app/main.js +++ b/templates/app/main.js @@ -1,5 +1,6 @@ require.config({ paths: { + eventemitter: 'bower_components/eventemitter2/lib/eventemitter2', aura: 'bower_components/aura/lib', jquery: 'bower_components/jquery/jquery', underscore: 'bower_components/underscore/underscore' diff --git a/templates/common/Gruntfile.js b/templates/common/Gruntfile.js index 567babe..dd7c0f9 100644 --- a/templates/common/Gruntfile.js +++ b/templates/common/Gruntfile.js @@ -45,24 +45,24 @@ module.exports = function (grunt) { requirejs: { compile: { options: { - baseUrl: '.', - optimize: 'none', + baseUrl: '<%= yeoman.app %>', paths: { - aura: 'app/bower_components/aura/lib', + aura: 'bower_components/aura/lib', jquery: 'empty:', underscore: 'empty:', - eventemitter: 'app/bower_components/eventemitter2/lib/eventemitter2' + eventemitter: 'bower_components/eventemitter2/lib/eventemitter2' }, shim: { underscore: { exports: '_' } }, - include: [ - 'app/main' + modules: [ + {name: 'main'} ], - exclude: ['jquery', 'aura/aura'], - out: '<%= yeoman.dist %>/main.js' + dir: '<%= yeoman.dist %>', + fileExclusionRegExp: /^(tests?|spec|Gruntfile\.js)$/, + removeCombined: true } } }, @@ -155,6 +155,6 @@ module.exports = function (grunt) { // watch-spec allows us to use the spec task within a watch without having // connect try to launch a server on each cycle (which throws a Fatal error); grunt.registerTask('watch-spec', ['jshint', 'mocha']); - grunt.registerTask('build', ['clean', 'compass', 'spec', 'copy', 'requirejs']); + grunt.registerTask('build', ['clean', 'compass', 'spec', 'requirejs']); grunt.registerTask('default', ['compass', 'spec', 'watch']); }; From 69a6a8e74e73eb67d466deee55787a3f08da38b3 Mon Sep 17 00:00:00 2001 From: Nurahmadie Date: Sun, 4 Aug 2013 16:44:39 +0700 Subject: [PATCH 4/4] Fix link to MIT license. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 328a34a..919deae 100644 --- a/README.md +++ b/README.md @@ -87,4 +87,4 @@ See the [contributing docs](https://github.com/yeoman/yeoman/blob/master/contrib ## License -[BSD license](http://opensource.org/licenses/bsd-license.php) +[MIT license](http://opensource.org/licenses/mit-license.php)