diff --git a/.gitignore b/.gitignore index bd631faa..c5f113e8 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ src/img/icons/all.svg test/*/index.js **/*.browserified.js **/*.js.map +.rebooted diff --git a/Gruntfile.js b/Gruntfile.js index 86c2cd94..926de38f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -281,6 +281,16 @@ module.exports = function(grunt) { sourceMap: true }, app: { + src: [ + 'dist/js/app.browserified.js', + '<%= ngtemplates.mail.dest %>' + ], + dest: 'dist/js/app.min.js', + options: { + sourceMapName: 'dist/js/app.js.map' + } + }, + vendor: { src: [ 'src/lib/underscore/underscore.js', 'node_modules/jquery/dist/jquery.min.js', @@ -296,13 +306,11 @@ module.exports = function(grunt) { 'src/lib/lawnchair/lawnchair-adapter-indexed-db-git.js', 'src/lib/phonenumber/PhoneNumberMetadata.js', 'src/lib/phonenumber/PhoneNumberNormalizer.js', - 'src/lib/phonenumber/PhoneNumber.js', - 'dist/js/app.browserified.js', - '<%= ngtemplates.mail.dest %>' + 'src/lib/phonenumber/PhoneNumber.js' ], - dest: 'dist/js/app.min.js', + dest: 'dist/js/vendor.min.js', options: { - sourceMapName: 'dist/js/app.js.map' + sourceMapName: 'dist/js/vendor.js.map' } }, readSandbox: { @@ -534,15 +542,42 @@ module.exports = function(grunt) { watch: { css: { files: ['src/sass/**/*.scss'], - tasks: ['dist-css', 'offline-cache', 'dist-styleguide'] + tasks: ['dist-css', 'dist-styleguide'], + options: { + livereload: true + } }, styleguide: { files: ['src/styleguide/**/*.hbs', 'src/styleguide/**/*.js'], tasks: ['dist-styleguide'] }, jsApp: { - files: ['src/js/**/*.js', 'src/*.html', 'src/tpl/**/*.html'], - tasks: ['dist-js-app'] + files: ['src/js/**/*.js', 'src/*.html', ], + tasks: ['browserify:app', 'exorcise:app', 'concat:app'], + options: { + livereload: true + } + }, + pbkdf2Worker: { + files: [], + tasks: [ 'browserify:pbkdf2Worker', 'concat:pbkdf2Worker'], + options: { + livereload: true + } + }, + readSandbox: { + files: ['src/js/controller/app/read-sandbox.js'], + tasks: ['concat:readSandbox'], + options: { + livereload: true + } + }, + templates: { + files: ['src/tpl/**/*.html'], + tasks: ['ngtemplates', 'concat:app'], + options: { + livereload: true + } }, jsUnitTest: { files: ['test/unit/**/*-test.js', 'test/*.js'], @@ -554,15 +589,57 @@ module.exports = function(grunt) { }, icons: { files: ['src/index.html', 'src/img/icons/*.svg', '!src/img/icons/all.svg'], - tasks: ['svgmin', 'svgstore', 'string-replace', 'dist-styleguide', 'offline-cache'] + tasks: ['svgmin', 'svgstore', 'string-replace', 'dist-styleguide'] }, lib: { files: ['src/lib/**/*.js'], - tasks: ['copy:lib', 'offline-cache'] + tasks: ['copy:lib'], + options: { + livereload: true + } + }, + readSandboxTpl: { + files: ['src/js/controller/app/read-sandbox.js'], + tasks: ['copy:tpl'], + options: { + livereload: true, + } }, app: { - files: ['src/*.js', 'src/*.html', 'src/tpl/**/*.html', 'src/**/*.json', 'src/manifest.*', 'src/img/**/*', 'src/font/**/*'], - tasks: ['copy:app', 'copy:tpl', 'copy:img', 'copy:font', 'manifest-dev', 'offline-cache'] + files: ['src/*.js', 'src/**/*.json', 'src/manifest.*'], + tasks: ['copy:app'], + options: { + livereload: true + } + }, + images: { + files: ['src/img/**/*'], + tasks: ['copy:img'], + options: { + livereload: true + } + }, + font: { + files:['src/font/**/*'], + tasks: ['copy:font'], + options: { + livereload: true + } + }, + index: { + // insert csvg icons in index. + files: ['src/index.html'], + tasks: ['string-replace'], + options: { + livereload: true + } + }, + server: { + // watch for file written by nodemon on reboot to trigger live reload. + files: ['.rebooted'], + options: { + livereload: true + } } }, @@ -661,6 +738,52 @@ module.exports = function(grunt) { src: ['**/*.*'], dest: 'dist/appcache.manifest' } + }, + nodemon: { + dev: { + script: 'server.js', + options: { + // tell server not to redirect to https + args: ['--dev'], + // node inspector support. + nodeArgs: ['--debug'], + env: { PORT: 8859 }, + watch: ['server.js'], + callback: function(nodemon) { + nodemon.on('log', function (event) { + console.log(event.colour); + }); + + // opens browser on initial server start + nodemon.on('config:update', function () { + // Delay before server listens on port + setTimeout(function() { + require('open')('http://localhost:8859'); + }, 1000); + }); + + // refreshes browser when server reboots + nodemon.on('restart', function () { + // Delay before server listens on port + setTimeout(function() { + require('fs').writeFileSync('.rebooted', 'rebooted'); + }, 1000); + }); + } + } + } + }, + 'node-inspector': { + dev: {} + }, + + concurrent: { + 'dev': { + tasks: ['nodemon', 'node-inspector', 'watch'], + options: { + logConcurrentOutput: true, + } + } } }); @@ -720,6 +843,7 @@ module.exports = function(grunt) { // Load the plugin(s) grunt.loadNpmTasks('grunt-browserify'); + grunt.loadNpmTasks('grunt-concurrent'); grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-connect'); @@ -733,6 +857,8 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-compress'); grunt.loadNpmTasks('grunt-manifest'); grunt.loadNpmTasks('grunt-mocha-phantomjs'); + grunt.loadNpmTasks('grunt-node-inspector'); + grunt.loadNpmTasks('grunt-nodemon'); grunt.loadNpmTasks('grunt-exorcise'); grunt.loadNpmTasks('grunt-string-replace'); grunt.loadNpmTasks('grunt-svgmin'); @@ -773,7 +899,7 @@ module.exports = function(grunt) { grunt.registerTask('offline-cache', ['manifest', 'swPrecache:prod']); // Test/Dev tasks - grunt.registerTask('dev', ['connect:dev']); + grunt.registerTask('dev', ['concurrent:dev', 'watch']); grunt.registerTask('test', ['jshint', 'connect:test', 'mocha_phantomjs']); grunt.registerTask('prod', ['connect:prod']); diff --git a/README.md b/README.md index f665c1f0..9463999f 100644 --- a/README.md +++ b/README.md @@ -50,13 +50,23 @@ You can download a prebuilt bundle under [releases](https://github.com/whiteout- This will download all dependencies, run the tests and build the Chrome Packaged App bundle **release/whiteout-mail_DEV.zip** which can be installed under [chrome://extensions](chrome://extensions) in developer mode. ### Development -For development you can start a connect dev server: +For development you should begin by ensuring you have build a complete distribution. + +*windows users may may need to comment out the shell task on line 823 of Gruntfile.js* + +```bash + grunt dist +``` + +Then you can start a local instance with watchers and [live reload](http://livereload.com/) for the application js files. + +```bash grunt dev +``` -Then visit [http://localhost:8580/dist/#/account?dev=true](http://localhost:8580/dist/#/account?dev=true) for front-end code or [http://localhost:8580/test/unit/](http://localhost:8580/test/unit/) to test JavaScript changes. You can also start a watch task so you don't have rebuild everytime you make a change: +If a browser window does not open to the local development instance automatically, you can goto [http://localhost:8859](http://localhost:8859) manually. - grunt watch ## Releasing Chrome App diff --git a/package.json b/package.json index 65aba8f0..c62ffed8 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "grunt-angular-templates": "~0.5.7", "grunt-autoprefixer": "~0.7.2", "grunt-browserify": "3.7.0", - "insert-module-globals": "6.5.0", + "grunt-concurrent": "^2.0.1", "grunt-contrib-clean": "~0.5.0", "grunt-contrib-compress": "~0.5.2", "grunt-contrib-concat": "^0.5.0", @@ -59,6 +59,8 @@ "grunt-exorcise": "^0.2.0", "grunt-manifest": "^0.4.0", "grunt-mocha-phantomjs": "^0.7.0", + "grunt-node-inspector": "^0.2.0", + "grunt-nodemon": "^0.4.0", "grunt-shell": "~1.1.1", "grunt-string-replace": "~1.0.0", "grunt-svgmin": "~1.0.0", @@ -66,11 +68,13 @@ "handlebars-helper-compose": "~0.2.12", "iframe-resizer": "^2.8.3", "imap-client": "~0.14.2", + "insert-module-globals": "6.5.0", "jquery": "~2.1.1", "mailbuild": "^0.3.7", "mailreader": "~0.4.0", "mocha": "^1.21.4", "ng-infinite-scroll": "~1.1.2", + "open": "0.0.5", "openpgp": "^1.0.0", "pgpbuilder": "~0.6.0", "pgpmailer": "~0.9.1", diff --git a/src/index.html b/src/index.html index 8704c33f..77dfb714 100644 --- a/src/index.html +++ b/src/index.html @@ -37,6 +37,7 @@ +