From 8ef26895adcf896c96c4ff549cdfec6f807cdb79 Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Sat, 13 Jun 2015 17:37:35 +0200 Subject: [PATCH] Manage project with Grunt and Bower. --- Gruntfile.js | 46 ++++++++++++++++++++++++++++++++++++ bower.json | 27 +++++++++++++++++++++ grunt-config/bower.js | 16 +++++++++++++ grunt-config/bower_concat.js | 9 +++++++ grunt-config/clean.js | 5 ++++ grunt-config/concat.js | 15 ++++++++++++ grunt-config/copy.js | 14 +++++++++++ grunt-config/jshint.js | 9 +++++++ grunt-config/shell.js | 5 ++++ grunt-config/watch.js | 6 +++++ package.json | 23 ++++++++++++++++++ 11 files changed, 175 insertions(+) create mode 100644 Gruntfile.js create mode 100644 bower.json create mode 100644 grunt-config/bower.js create mode 100644 grunt-config/bower_concat.js create mode 100644 grunt-config/clean.js create mode 100644 grunt-config/concat.js create mode 100644 grunt-config/copy.js create mode 100644 grunt-config/jshint.js create mode 100644 grunt-config/shell.js create mode 100644 grunt-config/watch.js create mode 100644 package.json diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..ac2c71d --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,46 @@ +module.exports = function(grunt) { + require('load-grunt-tasks')(grunt); + require('time-grunt')(grunt); + + // Options + var options = { + config: { + src: "grunt-config/*.js" + }, + paths: { + frontend_js: [ + 'accountant/frontend/static/js/app.js', + 'accountant/frontend/static/js/accounts.js', + 'accountant/frontend/static/js/months.js', + 'accountant/frontend/static/js/entries.js', + 'accountant/frontend/static/js/scheduler.js' + ], + frontend_build: 'accountant/frontend/static/build' + }, + pkg: grunt.file.readJSON('package.json'), + banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %>\n'+ + '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %> */\n', + }; + + var configs = require('load-grunt-configs')(grunt, options); + grunt.initConfig(configs); + + grunt.registerTask('generatestatic', [ + 'shell:npm_install', + 'bower:install', + 'bower_concat', + 'copy:bootstrap-select.css.map', + 'copy:fontawesome-webfont.woff', + 'copy:fontawesome-webfont.ttf' + ]); + + grunt.registerTask('jsdev', [ + 'jshint', + 'concat' + ]); + + grunt.registerTask('dev', [ + 'generatestatic', + 'jsdev' + ]); +}; diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..fdb084a --- /dev/null +++ b/bower.json @@ -0,0 +1,27 @@ +{ + "name": "accountant", + "version": "0.1.0", + "authors": [ + "Alexis Lahouze " + ], + "license": "AGPL", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ], + "dependencies": { + "jquery": "2.1.4", + "moment": "2.10.3", + "bootstrap": "3.3.4", + "bootstrap-datepicker": "1.4.0", + "font-awesome": "4.3.0", + "pines-notify": "1.2.0", + "angular": "1.4.0", + "angular-strap": "2.2.4", + "d3": "3.5.5", + "nvd3": "1.8.1-alpha" + } +} diff --git a/grunt-config/bower.js b/grunt-config/bower.js new file mode 100644 index 0000000..b4ce4ac --- /dev/null +++ b/grunt-config/bower.js @@ -0,0 +1,16 @@ +module.exports = { + install: { + options: { + copy: false + } + }, + frontend: { + dest: 'accountant/frontend/static/third-party', + + options: { + expand: true, + stripAffix: true, + keepExpandedHierarchy: false + } + } +}; diff --git a/grunt-config/bower_concat.js b/grunt-config/bower_concat.js new file mode 100644 index 0000000..09b4ed3 --- /dev/null +++ b/grunt-config/bower_concat.js @@ -0,0 +1,9 @@ +module.exports = { + main: { + dest: 'accountant/frontend/static/build/js/vendor.js', + cssDest: 'accountant/frontend/static/build/css/vendor.css', + dependencies: { + 'autotype': 'jquery' + } + }, +}; diff --git a/grunt-config/clean.js b/grunt-config/clean.js new file mode 100644 index 0000000..7383930 --- /dev/null +++ b/grunt-config/clean.js @@ -0,0 +1,5 @@ +module.exports = { + libs: [ + "accountant/frontend/static/build" + ] +}; diff --git a/grunt-config/concat.js b/grunt-config/concat.js new file mode 100644 index 0000000..ddc9385 --- /dev/null +++ b/grunt-config/concat.js @@ -0,0 +1,15 @@ +module.exports = { + options: { + stripBanners: false, + banner: '<%= banner %>\n', + process: function(src, filepath) { + // Add comments with original filename. + return '// ### Begin: ' + filepath + ' ### //\n' + src + + '// ### End: ' + filepath + ' ### //\n'; + } + }, + frontend_js: { + src: '<%= paths.frontend_js %>', + dest: '<%= paths.frontend_build %>/js/app.js' + } +}; diff --git a/grunt-config/copy.js b/grunt-config/copy.js new file mode 100644 index 0000000..d3ffb9a --- /dev/null +++ b/grunt-config/copy.js @@ -0,0 +1,14 @@ +module.exports = { + "bootstrap-select.css.map": { + src: 'bower_components/bootstrap-select/dist/css/bootstrap-select.css.map', + dest: '<%= paths.frontend_build %>/css/bootstrap-select.css.map' + }, + "fontawesome-webfont.woff": { + src: 'bower_components/font-awesome/fonts/fontawesome-webfont.woff', + dest: '<%= paths.frontend_build %>/fonts/fontawesome-webfont.woff' + }, + "fontawesome-webfont.ttf": { + src: 'bower_components/font-awesome/fonts/fontawesome-webfont.ttf', + dest: '<%= paths.frontend_build %>/fonts/fontawesome-webfont.ttf' + } +}; diff --git a/grunt-config/jshint.js b/grunt-config/jshint.js new file mode 100644 index 0000000..561a2e2 --- /dev/null +++ b/grunt-config/jshint.js @@ -0,0 +1,9 @@ +module.exports = { + options: { + reporter: require('jshint-stylish') + }, + work: [ + '<%= paths.frontend_js %>/*.js', + 'Gruntfile.js' + ] +}; diff --git a/grunt-config/shell.js b/grunt-config/shell.js new file mode 100644 index 0000000..51eb220 --- /dev/null +++ b/grunt-config/shell.js @@ -0,0 +1,5 @@ +module.exports = { + npm_install: { + command: 'npm install' + } +}; diff --git a/grunt-config/watch.js b/grunt-config/watch.js new file mode 100644 index 0000000..be0d0d1 --- /dev/null +++ b/grunt-config/watch.js @@ -0,0 +1,6 @@ +module.exports = { + js: { + files: '<%= paths.frontend_js %>', + tasks: ['concat:frontend_js'] + } +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..79f767a --- /dev/null +++ b/package.json @@ -0,0 +1,23 @@ +{ + "name": "accountant", + "version": "0.1.0", + "repository": "https://git.lahouze.org/xals/accountant", + "license": "AGPL-1.0", + "dependencies": { + "grunt": "0.4.5", + "grunt-copy": "0.1.0", + "grunt-contrib-clean": "0.6.0", + "grunt-contrib-watch": "0.6.1", + "grunt-contrib-concat": "0.5.1", + "time-grunt": "1.2.1", + "load-grunt-configs": "0.4.3", + "load-grunt-tasks": "3.2.0", + "grunt-bowercopy": "0.4.1", + "grunt-shell": "1.1.2", + "grunt-bower-task": "0.4.0", + "grunt-bower-concat": "0.5.0", + "grunt-contrib-jshint": "0.11.2", + "jshint-stylish": "2.0.0" + }, + "devDependencies": {} +}