Skip to content
This repository was archived by the owner on Jul 10, 2019. It is now read-only.

Commit b7dd761

Browse files
committed
Update grunt dev to run server.js, watch js app files, and launch a browser windows.
* use nodemon to run server.js so we have socket.io when developing locally. * very basic watches on app.js, the watch should be steamlined, current it takes about 30s to build changes to the js app files.
1 parent e0663ab commit b7dd761

File tree

4 files changed

+80
-6
lines changed

4 files changed

+80
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ src/img/icons/all.svg
1212
test/*/index.js
1313
**/*.browserified.js
1414
**/*.js.map
15+
.rebooted

Gruntfile.js

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,10 @@ module.exports = function(grunt) {
542542
},
543543
jsApp: {
544544
files: ['src/js/**/*.js', 'src/*.html', 'src/tpl/**/*.html'],
545-
tasks: ['dist-js-app']
545+
tasks: ['dist-js-app'],
546+
options: {
547+
livereload: true
548+
}
546549
},
547550
jsUnitTest: {
548551
files: ['test/unit/**/*-test.js', 'test/*.js'],
@@ -563,6 +566,13 @@ module.exports = function(grunt) {
563566
app: {
564567
files: ['src/*.js', 'src/*.html', 'src/tpl/**/*.html', 'src/**/*.json', 'src/manifest.*', 'src/img/**/*', 'src/font/**/*'],
565568
tasks: ['copy:app', 'copy:tpl', 'copy:img', 'copy:font', 'manifest-dev', 'offline-cache']
569+
},
570+
server: {
571+
// watch for file written by nodemon on reboot to trigger live reload.
572+
files: ['.rebooted'],
573+
options: {
574+
livereload: true
575+
}
566576
}
567577
},
568578

@@ -661,6 +671,52 @@ module.exports = function(grunt) {
661671
src: ['**/*.*'],
662672
dest: 'dist/appcache.manifest'
663673
}
674+
},
675+
nodemon: {
676+
dev: {
677+
script: 'server.js',
678+
options: {
679+
// tell server not to redirect to https
680+
args: ['--dev'],
681+
// node inspector support.
682+
nodeArgs: ['--debug'],
683+
env: { PORT: 8859 },
684+
watch: ['server.js'],
685+
callback: function(nodemon) {
686+
nodemon.on('log', function (event) {
687+
console.log(event.colour);
688+
});
689+
690+
// opens browser on initial server start
691+
nodemon.on('config:update', function () {
692+
// Delay before server listens on port
693+
setTimeout(function() {
694+
require('open')('http://localhost:8859');
695+
}, 1000);
696+
});
697+
698+
// refreshes browser when server reboots
699+
nodemon.on('restart', function () {
700+
// Delay before server listens on port
701+
setTimeout(function() {
702+
require('fs').writeFileSync('.rebooted', 'rebooted');
703+
}, 1000);
704+
});
705+
}
706+
}
707+
}
708+
},
709+
'node-inspector': {
710+
dev: {}
711+
},
712+
713+
concurrent: {
714+
'dev': {
715+
tasks: ['nodemon', 'node-inspector', 'watch'],
716+
options: {
717+
logConcurrentOutput: true,
718+
}
719+
}
664720
}
665721

666722
});
@@ -720,6 +776,7 @@ module.exports = function(grunt) {
720776

721777
// Load the plugin(s)
722778
grunt.loadNpmTasks('grunt-browserify');
779+
grunt.loadNpmTasks('grunt-concurrent');
723780
grunt.loadNpmTasks('grunt-contrib-concat');
724781
grunt.loadNpmTasks('grunt-contrib-uglify');
725782
grunt.loadNpmTasks('grunt-contrib-connect');
@@ -733,6 +790,8 @@ module.exports = function(grunt) {
733790
grunt.loadNpmTasks('grunt-contrib-compress');
734791
grunt.loadNpmTasks('grunt-manifest');
735792
grunt.loadNpmTasks('grunt-mocha-phantomjs');
793+
grunt.loadNpmTasks('grunt-node-inspector');
794+
grunt.loadNpmTasks('grunt-nodemon');
736795
grunt.loadNpmTasks('grunt-exorcise');
737796
grunt.loadNpmTasks('grunt-string-replace');
738797
grunt.loadNpmTasks('grunt-svgmin');
@@ -773,7 +832,7 @@ module.exports = function(grunt) {
773832
grunt.registerTask('offline-cache', ['manifest', 'swPrecache:prod']);
774833

775834
// Test/Dev tasks
776-
grunt.registerTask('dev', ['connect:dev']);
835+
grunt.registerTask('dev', ['concurrent:dev', 'watch']);
777836
grunt.registerTask('test', ['jshint', 'connect:test', 'mocha_phantomjs']);
778837
grunt.registerTask('prod', ['connect:prod']);
779838

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,23 @@ You can download a prebuilt bundle under [releases](https://github.com/whiteout-
5050
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.
5151

5252
### Development
53-
For development you can start a connect dev server:
5453

54+
For development you should begin by ensuring you have build a complete distribution.
55+
56+
*windows users may may need to comment out the shell task on line 823 of Gruntfile.js*
57+
58+
```bash
59+
grunt dist
60+
```
61+
62+
Then you can start a local instance with watchers and [live reload](http://livereload.com/) for the application js files.
63+
64+
```bash
5565
grunt dev
66+
```
5667

57-
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:
68+
If a browser window does not open to the local development instance automatically, you can goto [http://localhost:8859](http://localhost:8859) manually.
5869

59-
grunt watch
6070

6171
## Releasing Chrome App
6272

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"grunt-angular-templates": "~0.5.7",
4646
"grunt-autoprefixer": "~0.7.2",
4747
"grunt-browserify": "3.7.0",
48-
"insert-module-globals": "6.5.0",
48+
"grunt-concurrent": "^2.0.1",
4949
"grunt-contrib-clean": "~0.5.0",
5050
"grunt-contrib-compress": "~0.5.2",
5151
"grunt-contrib-concat": "^0.5.0",
@@ -59,18 +59,22 @@
5959
"grunt-exorcise": "^0.2.0",
6060
"grunt-manifest": "^0.4.0",
6161
"grunt-mocha-phantomjs": "^0.7.0",
62+
"grunt-node-inspector": "^0.2.0",
63+
"grunt-nodemon": "^0.4.0",
6264
"grunt-shell": "~1.1.1",
6365
"grunt-string-replace": "~1.0.0",
6466
"grunt-svgmin": "~1.0.0",
6567
"grunt-svgstore": "~0.3.4",
6668
"handlebars-helper-compose": "~0.2.12",
6769
"iframe-resizer": "^2.8.3",
6870
"imap-client": "~0.14.2",
71+
"insert-module-globals": "6.5.0",
6972
"jquery": "~2.1.1",
7073
"mailbuild": "^0.3.7",
7174
"mailreader": "~0.4.0",
7275
"mocha": "^1.21.4",
7376
"ng-infinite-scroll": "~1.1.2",
77+
"open": "0.0.5",
7478
"openpgp": "^1.0.0",
7579
"pgpbuilder": "~0.6.0",
7680
"pgpmailer": "~0.9.1",

0 commit comments

Comments
 (0)