From aa4e2d9d6f1a87280c48887fe55e5a73e67521f1 Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Fri, 29 Jan 2016 13:42:25 +0100 Subject: [PATCH] Improve Grunt integration. Wiredep. --- .bowerrc | 3 +++ Gruntfile.js | 18 +++++++++++++++++- bower.json | 22 +++++++++++++++++++++- grunt-config/bgShell.js | 6 ++++++ grunt-config/jscs.js | 12 ++++++++++++ grunt-config/shell.js | 3 +++ grunt-config/watch.js | 9 ++++++++- grunt-config/wiredep.js | 6 ++++++ package.json | 21 ++++++++++++--------- 9 files changed, 88 insertions(+), 12 deletions(-) create mode 100644 .bowerrc create mode 100644 grunt-config/bgShell.js create mode 100644 grunt-config/jscs.js create mode 100644 grunt-config/wiredep.js diff --git a/.bowerrc b/.bowerrc new file mode 100644 index 0000000..d12db12 --- /dev/null +++ b/.bowerrc @@ -0,0 +1,3 @@ +{ + "directory": "accountant/frontend/static/bower_components" +} diff --git a/Gruntfile.js b/Gruntfile.js index 277b8bd..5aec04b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -2,8 +2,15 @@ module.exports = function(grunt) { require('load-grunt-tasks')(grunt); require('time-grunt')(grunt); + var appConfig = { + app: require('./bower.json'), + dist: 'dist' + }; + // Options var options = { + accountant: appConfig, + config: { src: "grunt-config/*.js" }, @@ -26,14 +33,23 @@ module.exports = function(grunt) { grunt.registerTask('generatestatic', [ 'shell:npm_install', + 'shell:bower_install', + 'wiredep:app', ]); grunt.registerTask('jsdev', [ - 'jshint', + 'newer:jshint', + 'newer:jscs' ]); grunt.registerTask('dev', [ 'generatestatic', 'jsdev' ]); + + grunt.registerTask('serve', [ + 'dev', + 'bgShell:runserver', + 'watch' + ]); }; diff --git a/bower.json b/bower.json index cc91303..7e48d44 100644 --- a/bower.json +++ b/bower.json @@ -5,6 +5,10 @@ "Alexis Lahouze " ], "license": "AGPL", + "main": [ + "accountant/frontend/templates/layout.html", + "accountant/frontend/static/js/app.js" + ], "ignore": [ "**/.*", "node_modules", @@ -28,6 +32,22 @@ "angular-http-auth": "~1.2.3", "meanie-angular-storage": "~1.1", "font-awesome": ">=4.5.0", - "bootbox": "~4.4.0" + "bootbox": "~4.4.0", + "angular-bootstrap": "^1.1.1" + }, + "overrides": { + "bootstrap": { + "main": [ + "less/bootstrap.less", + "dist/css/bootstrap.css", + "dist/js/bootstrap.js" + ] + }, + "font-awesome": { + "main": [ + "./css/font-awesome.css", + "./fonts/*" + ] + } } } diff --git a/grunt-config/bgShell.js b/grunt-config/bgShell.js new file mode 100644 index 0000000..e9f3644 --- /dev/null +++ b/grunt-config/bgShell.js @@ -0,0 +1,6 @@ +module.exports = { + runserver: { + cmd: 'python -m manage runserver', + bg: true + } +}; diff --git a/grunt-config/jscs.js b/grunt-config/jscs.js new file mode 100644 index 0000000..08d2411 --- /dev/null +++ b/grunt-config/jscs.js @@ -0,0 +1,12 @@ +module.exports = { + options: { + config: '.jscsrc', + verbose: true + }, + frontend_js: [ + '<%= paths.frontend_js %>' + ], + toolchain: [ + 'Gruntfile.js' + ] +}; diff --git a/grunt-config/shell.js b/grunt-config/shell.js index 51eb220..360934e 100644 --- a/grunt-config/shell.js +++ b/grunt-config/shell.js @@ -1,5 +1,8 @@ module.exports = { npm_install: { command: 'npm install' + }, + bower_install: { + command: 'bower install' } }; diff --git a/grunt-config/watch.js b/grunt-config/watch.js index fa6ff18..8f39eee 100644 --- a/grunt-config/watch.js +++ b/grunt-config/watch.js @@ -1,6 +1,13 @@ module.exports = { + bower: { + files: 'bower.json', + tasks: ['wiredep'] + }, js: { files: '<%= paths.frontend_js %>', - tasks: ['jshint:frontend_js', 'concat:frontend_js'] + tasks: ['devjs'] + }, + gruntfile: { + files: ['Gruntfile.js'] } }; diff --git a/grunt-config/wiredep.js b/grunt-config/wiredep.js new file mode 100644 index 0000000..18336a5 --- /dev/null +++ b/grunt-config/wiredep.js @@ -0,0 +1,6 @@ +module.exports = { + app: { + src: ['accountant/frontend/templates/layout.html'], + ignorePath: /\.\.\// + } +}; diff --git a/package.json b/package.json index 8eed781..459e3a6 100644 --- a/package.json +++ b/package.json @@ -3,18 +3,21 @@ "version": "0.1.0", "repository": "https://git.lahouze.org/xals/accountant", "license": "AGPL-1.0", - "dependencies": { + "devDependencies": { "grunt": "0.4.5", - "grunt-copy": "0.1.0", + "grunt-bg-shell": "^2.3.1", "grunt-contrib-clean": "0.6.0", - "grunt-contrib-watch": "0.6.1", "grunt-contrib-concat": "0.5.1", - "time-grunt": "1.2.1", + "grunt-contrib-jshint": "0.11.2", + "grunt-contrib-watch": "0.6.1", + "grunt-copy": "0.1.0", + "grunt-jscs": "^2.6.0", + "grunt-newer": "^1.1.1", + "grunt-shell": "1.1.2", + "grunt-wiredep": "^2.0.0", + "jshint-stylish": "2.0.0", "load-grunt-configs": "0.4.3", "load-grunt-tasks": "3.2.0", - "grunt-shell": "1.1.2", - "grunt-contrib-jshint": "0.11.2", - "jshint-stylish": "2.0.0" - }, - "devDependencies": {} + "time-grunt": "1.2.1" + } }