diff --git a/.nodemonignore b/.nodemonignore index b368c0d00f..e384b68122 100644 --- a/.nodemonignore +++ b/.nodemonignore @@ -1,2 +1,3 @@ -/views/* -/public/build/* \ No newline at end of file +public/* +views/* +Gruntfile.js \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index a8f5a01d30..428d28c856 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -101,45 +101,44 @@ module.exports = function(grunt) { } }, - exec: { - start: { - cmd: function(mode){ - if(mode && mode == 'production'){ - return 'nodemon --exec "./start.sh" production' - }else{ - return 'nodemon --exec "./start.sh"' - } + nodemon: { + dev: { + ignoredFiles: ['public/*', 'Gruntfile.js', 'views/*'] // Do not work! + } + }, + + watch: { + dev: { + files: ['public/**/*.css'], // 'public/**/*.js' Not needed because not in production + tasks: [ 'build:dev' ], + options: { + nospawn: true } } - } + }, - /*hashres: { + concurrent: { + dev: ['nodemon', 'watch'], options: { - fileNameFormat: '${name}-${hash}.${ext}', - }, - build: { - src: [ - 'public/build/app.js', - 'public/build/static.js' - ], - dest: 'views/i-do-not-exist.jade' // Non existing file! + logConcurrentOutput: true } - }*/ + } }); // Register tasks. - grunt.registerTask('production', ['clean:build', 'uglify', 'stylus', 'cssmin']); - grunt.registerTask('development', ['clean:build', 'stylus', 'cssmin']); - grunt.registerTask('start:production', ['exec:start:production']); - grunt.registerTask('start', ['exec:start']); + grunt.registerTask('build:prod', ['clean:build', 'uglify', 'stylus', 'cssmin']); + grunt.registerTask('build:dev', ['clean:build', 'stylus', 'cssmin']); + + grunt.registerTask('run:dev', [ 'build:dev', 'concurrent' ]); // Load tasks grunt.loadNpmTasks('grunt-contrib-uglify'); - grunt.loadNpmTasks('grunt-hashres'); grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-stylus'); grunt.loadNpmTasks('grunt-contrib-cssmin'); - grunt.loadNpmTasks('grunt-exec'); + grunt.loadNpmTasks('grunt-nodemon'); + grunt.loadNpmTasks('grunt-concurrent'); + grunt.loadNpmTasks('grunt-contrib-watch'); }; diff --git a/README.md b/README.md index 74e0f3a427..ea36e22492 100644 --- a/README.md +++ b/README.md @@ -5,20 +5,30 @@ HabitRPG Rewrite under development. Built using Angular, Express, Mongoose, Jade **Note: This branch is under development, and these instructions may fall out of date. They were accurate as of August 5, 2013.** Should you encounter this, join #habitrpg on IRC (Freenode) and talk to litenull. +Before starting install [MongoDB](http://www.mongodb.org/) and [NodeJS](http://nodejs.org/) + The general steps are: 1. Clone the repo +1. Install the global dependencies 1. Install all dependencies 1. Run the client Or, expressed in commands on the command line: 1. `git clone --recursive -b angular_rewrite https://github.com/lefnire/habitrpg.git` +1. 'npm install -g grunt-cli' (you may need to add `sudo` in front of it) 1. `cd habitrpg && npm install` -1. `grunt start` (`grunt start:production` to concat & minify js) +1. `grunt run:dev` To access the site, open http://localhost:3000 in your browser. +There are a few other Grunt task avalaible: + +- `grunt build:dev` - Compile, concat and minify Stylus files +- `grunt build:prod` - Same as `grunt build:dev` but concat and minify Javascript files. +- `grunt nodemon` - Start the server with **nodemon**, restart when a file change but without compiling Stylus files + # Technologies 1. Angular, Express, Mongoose. Awesome, tried technologies. Read up on them. @@ -72,11 +82,11 @@ npm ERR! not ok code 0 Ignore this error and proceed with the following: -1. Run 'npm install -g nodemon' +1. Run 'npm install -g grunt-cli' 1. Run 'npm install -g bower' 1. Run 'bower install -f' 1. Run 'copy config.json.example config.json' -1. `grunt start` (`grunt start:production` to concat & minify js) +1. `grunt run:dev` Open a browser to URL http://localhost:3000 to test the application. diff --git a/package.json b/package.json index 1c24849da8..3c683eaa82 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "habitrpg", "description": "A habit tracker app which treats your goals like a Role Playing Game.", "version": "0.0.0-152", - "main": "./server.js", + "main": "./src/server.js", "dependencies": { "habitrpg-shared": "git://github.com/HabitRPG/habitrpg-shared#rewrite", "derby-auth": "git://github.com/lefnire/derby-auth#master", @@ -27,11 +27,12 @@ "stylus": "~0.37.0", "grunt": "~0.4.1", "grunt-contrib-uglify": "~0.2.4", - "grunt-hashres": "~0.3.2", "grunt-contrib-stylus": "~0.8.0", "grunt-contrib-clean": "~0.5.0", "grunt-contrib-cssmin": "~0.6.1", - "grunt-exec": "~0.4.x", + "grunt-contrib-watch": "~0.5.x", + "grunt-nodemon": "~0.1.1", + "grunt-concurrent": "~0.3.1", "bower": "~1.2.4", "nib": "~1.0.1", "jade": "~0.35.0", diff --git a/start.sh b/start.sh deleted file mode 100755 index 05885587fa..0000000000 --- a/start.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -if [ $1 = "production" ]; then - echo "Starting production server"; - grunt production; -else - echo "Starting development server"; - grunt development; -fi - -node ./src/server.js \ No newline at end of file