diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..8a80734 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + + +[*] + +# Change these settings to your own preference +indent_style = space +indent_size = 4 + +# We recommend you to keep these unchanged +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitignore b/.gitignore index c4a7a0b..7d495b8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ bower_components node_modules /.tmp /.ssh +/coverage diff --git a/Gruntfile.js b/Gruntfile.js index 2f8da5a..c2f8839 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -9,8 +9,12 @@ module.exports = function (grunt) { - // Load grunt tasks automatically - require('load-grunt-tasks')(grunt); + // Lazy-load grunt tasks automatically + require('jit-grunt')(grunt, { + useminPrepare: 'grunt-usemin', + sshexec: 'grunt-ssh', + sftp: 'grunt-ssh' + }); // Time how long tasks take. Can help when optimizing build times require('time-grunt')(grunt); @@ -86,18 +90,26 @@ module.exports = function (grunt) { } }, test: { - options: { - port: 9001, - middleware: function (connect) { - return [ - connect().use( - '/bower_components', - connect.static('./bower_components') - ), - connect.static(appConfig.app) - ]; + options: { + port: 9001, + middleware: function (connect) { + return [ + connect().use( + '/bower_components', + connect.static('./bower_components') + ), + connect.static(appConfig.app) + ]; + } + } + }, + coverage: { + options: { + open: true, + port: 9003, + keepalive: true, + base: './coverage/' } - } }, dist: { options: { @@ -115,12 +127,14 @@ module.exports = function (grunt) { }, unit: { singleRun: true, - browsers: ['Chrome'] + browsers: ['Chrome'], + reporters: ['notify', 'coverage'] }, continuous: { singleRun: false, background: true, - browsers: ['PhantomJS'] + browsers: ['Chrome'], + reporters: ['progress', 'notify'] } }, @@ -346,11 +360,19 @@ module.exports = function (grunt) { createDirectories: true } } - } + }, + // Display notfifications when builds complete using Growl + notify: { + deploy: { + options: { + message: 'Jamstash deployed to test server' + } + } + } }); - grunt.registerTask('serve', 'Compile then start a connect web server', function (target) { + grunt.registerTask('serve', 'Compile then start a connect web server', function(target) { if (target === 'dist') { return grunt.task.run(['build', 'connect:dist:keepalive']); } @@ -363,31 +385,43 @@ module.exports = function (grunt) { ]); }); - grunt.registerTask('test', [ - 'karma:unit', - 'jshint' - ]); + grunt.registerTask('test', 'Run unit tests and jshint', function() { + return grunt.task.run([ + 'karma:unit', + 'jshint' + ]); + }); - grunt.registerTask('build', [ - 'clean:dist', - 'wiredep:app', - 'useminPrepare', - 'concat:generated', - 'copy:dist', - 'imagemin', - //'ngAnnotate', - 'cssmin', - 'uglify:generated', - 'filerev', - 'usemin', - 'htmlmin' - ]); + grunt.registerTask('coverage', 'Run unit tests and display test coverage results on browser', function() { + return grunt.task.run([ + 'karma:unit', + 'connect:coverage' + ]); + }); + + grunt.registerTask('build', 'Concatenate all JS files, minify all JS, CSS, HTML and image files and version all static assets', function() { + return grunt.task.run([ + 'clean:dist', + 'wiredep:app', + 'useminPrepare', + 'concat:generated', + 'copy:dist', + 'imagemin', + //'ngAnnotate', + 'cssmin', + 'uglify:generated', + 'filerev', + 'usemin', + 'htmlmin' + ]); + }); grunt.registerTask('deploy', 'Build and deploy to test server', function() { return grunt.task.run([ 'build', 'sshexec:cleanTest', - 'sftp:test' + 'sftp:test', + 'notify:deploy' ]); }); diff --git a/karma.conf.js b/karma.conf.js index 8ca8d80..85c3f11 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -42,6 +42,10 @@ module.exports = function(config) { // list of files / patterns to exclude exclude: ['app/vendor/**/*.js'], + preprocessors: { + 'app/**/!(*_test).js': ['coverage'] + }, + // web server port port: 8080, @@ -54,14 +58,16 @@ module.exports = function(config) { // - PhantomJS // - IE (only Windows) browsers: [ - 'Chrome' + 'PhantomJS' ], // Which plugins to enable plugins: [ 'karma-chrome-launcher', 'karma-phantomjs-launcher', - 'karma-jasmine' + 'karma-jasmine', + 'karma-coverage', + 'karma-notify-reporter' ], // Continuous Integration mode diff --git a/package.json b/package.json index 7becdee..98e7dd6 100644 --- a/package.json +++ b/package.json @@ -42,16 +42,18 @@ "grunt-filerev": "^2.1.1", "grunt-karma": "^0.9.0", "grunt-ng-annotate": "^0.5.0", + "grunt-notify": "^0.4.1", "grunt-ssh": "^0.12.0", "grunt-usemin": "^2.6.0", "grunt-wiredep": "^1.9.0", + "jit-grunt": "^0.9.0", "jshint-stylish": "^1.0.0", "karma": "^0.12.25", "karma-chrome-launcher": "^0.1.5", + "karma-coverage": "^0.2.6", "karma-jasmine": "^0.3.0", + "karma-notify-reporter": "^0.1.1", "karma-phantomjs-launcher": "^0.1.4", - "load-grunt-tasks": "^1.0.0", - "sellout": "0.0.1", "time-grunt": "^1.0.0" }, "engines": {