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

Commit

Permalink
Update grunt dev to run server.js, watch js app files, and launch a b…
Browse files Browse the repository at this point in the history
…rowser 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.
  • Loading branch information
dopry committed Aug 7, 2015
1 parent e0663ab commit b7dd761
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ src/img/icons/all.svg
test/*/index.js
**/*.browserified.js
**/*.js.map
.rebooted
63 changes: 61 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,10 @@ module.exports = function(grunt) {
},
jsApp: {
files: ['src/js/**/*.js', 'src/*.html', 'src/tpl/**/*.html'],
tasks: ['dist-js-app']
tasks: ['dist-js-app'],
options: {
livereload: true
}
},
jsUnitTest: {
files: ['test/unit/**/*-test.js', 'test/*.js'],
Expand All @@ -563,6 +566,13 @@ module.exports = function(grunt) {
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']
},
server: {
// watch for file written by nodemon on reboot to trigger live reload.
files: ['.rebooted'],
options: {
livereload: true
}
}
},

Expand Down Expand Up @@ -661,6 +671,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,
}
}
}

});
Expand Down Expand Up @@ -720,6 +776,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');
Expand All @@ -733,6 +790,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');
Expand Down Expand Up @@ -773,7 +832,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']);

Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -59,18 +59,22 @@
"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",
"grunt-svgstore": "~0.3.4",
"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",
Expand Down

0 comments on commit b7dd761

Please sign in to comment.