From 8cad18d5eae5a2304b437c8870f773ae82a5d9c2 Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Sat, 15 Oct 2016 11:45:39 +0200 Subject: [PATCH] Review toolchain. --- Gruntfile.js | 95 ++++++++++++++++++++++++++++++++++-------- grunt-config/flake8.js | 3 ++ 2 files changed, 80 insertions(+), 18 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 7999719..01da7dc 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,57 +1,115 @@ +// vim: set tw=80 ts=4 sw=4 sts=4: + 'use strict'; module.exports = function(grunt) { + // Grunt plugin initialization. + // ============================ + + // Automagically load grunt tasks. require('load-grunt-tasks')(grunt); + + // Display duration for each task. require('time-grunt')(grunt); // Options var options = { + // Application related configuration. accountant: { + // Frontend related frontend: { + // Application dependencies by bower. app: require('./bower.json'), + // Source path src: 'accountant-ui', + // Distribution path dist: 'accountant-ui_dist' } }, + // Grunt configurationi files. config: { src: 'grunt-config/*.js' }, - 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' + // Package description for NPM. + 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' }; + // Load configuration from Grunt configuration directory. var configs = require('load-grunt-configs')(grunt, options); + + // Initialize Grunt configuration. grunt.initConfig(configs); - grunt.registerTask('dependencies', [ + // Toolchain tasks. + // ================ + + // Manage toolchain + grunt.registerTask('toolchain', [ + // NodeJS dependencies for toolchain. 'shell:npmInstall', - 'shell:bowerInstall', - 'shell:pipInstall', - 'wiredep:app' + // Configuration file linting. + 'newer:eslint:toolchain', + 'newer:jsonlint:toolchain' ]); - grunt.registerTask('pydev', [ + // Backend tasks. + // ============== + grunt.registerTask('beDeps', [ + // Python dependencies. Does not work in virtualenv. + // 'shell:pipInstall' + ]); + + // Linting + grunt.registerTask('beLint', [ + // Use flake8 for python linting. 'newer:flake8' ]); - grunt.registerTask('jsdev', [ - 'wiredep', - 'newer:eslint' + // Backend dev task. + grunt.registerTask('beDev', [ + 'beDeps', + 'beLint' ]); - grunt.registerTask('htmldev', [ + // Frontend tasks. + // =============== + + // Front dependency management. + grunt.registerTask('feDeps', [ + // Web assets using bower + 'shell:bowerInstall', + // Inject dependencies into application. + 'wiredep:app' + ]); + + // Linting + grunt.registerTask('feLint', [ + // ECMAScript + 'newer:eslint:frontend', + // HTML. 'newer:htmllint' ]); - grunt.registerTask('dev', [ - 'dependencies', - 'pydev', - 'jsdev', - 'htmldev' + // Frontend dev task. + grunt.registerTask('feDev', [ + 'feDeps', + 'feLint' ]); + // Global tasks. + // ============= + + // Dev. + grunt.registerTask('dev', [ + 'toolchain', + 'beDev', + 'feDev' + ]); + + // Serve application. grunt.registerTask('serve', [ 'dev', 'bgShell:runserver', @@ -59,8 +117,9 @@ module.exports = function(grunt) { 'watch' ]); + // Make distribution. grunt.registerTask('dist', [ - 'wiredep', + 'dev', 'clean:dist', 'useminPrepare', 'copy:dist', diff --git a/grunt-config/flake8.js b/grunt-config/flake8.js index 01a8e77..45bdc7d 100644 --- a/grunt-config/flake8.js +++ b/grunt-config/flake8.js @@ -1,6 +1,9 @@ 'use strict'; module.exports = { + options: { + maxComplexity: 4 + }, src: [ 'accountant/**/*.py' ]