Review toolchain.

This commit is contained in:
Alexis Lahouze 2016-10-15 11:45:39 +02:00
parent 96a553c130
commit 8cad18d5ea
2 changed files with 80 additions and 18 deletions

View File

@ -1,57 +1,115 @@
// vim: set tw=80 ts=4 sw=4 sts=4:
'use strict'; 'use strict';
module.exports = function(grunt) { module.exports = function(grunt) {
// Grunt plugin initialization.
// ============================
// Automagically load grunt tasks.
require('load-grunt-tasks')(grunt); require('load-grunt-tasks')(grunt);
// Display duration for each task.
require('time-grunt')(grunt); require('time-grunt')(grunt);
// Options // Options
var options = { var options = {
// Application related configuration.
accountant: { accountant: {
// Frontend related
frontend: { frontend: {
// Application dependencies by bower.
app: require('./bower.json'), app: require('./bower.json'),
// Source path
src: 'accountant-ui', src: 'accountant-ui',
// Distribution path
dist: 'accountant-ui_dist' dist: 'accountant-ui_dist'
} }
}, },
// Grunt configurationi files.
config: { config: {
src: 'grunt-config/*.js' src: 'grunt-config/*.js'
}, },
pkg: grunt.file.readJSON('package.json'), // Package description for NPM.
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %>\n' + pkg: grunt.file.readJSON('package.json')
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %> */\n' // 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); var configs = require('load-grunt-configs')(grunt, options);
// Initialize Grunt configuration.
grunt.initConfig(configs); grunt.initConfig(configs);
grunt.registerTask('dependencies', [ // Toolchain tasks.
// ================
// Manage toolchain
grunt.registerTask('toolchain', [
// NodeJS dependencies for toolchain.
'shell:npmInstall', 'shell:npmInstall',
'shell:bowerInstall', // Configuration file linting.
'shell:pipInstall', 'newer:eslint:toolchain',
'wiredep:app' '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' 'newer:flake8'
]); ]);
grunt.registerTask('jsdev', [ // Backend dev task.
'wiredep', grunt.registerTask('beDev', [
'newer:eslint' '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' 'newer:htmllint'
]); ]);
grunt.registerTask('dev', [ // Frontend dev task.
'dependencies', grunt.registerTask('feDev', [
'pydev', 'feDeps',
'jsdev', 'feLint'
'htmldev'
]); ]);
// Global tasks.
// =============
// Dev.
grunt.registerTask('dev', [
'toolchain',
'beDev',
'feDev'
]);
// Serve application.
grunt.registerTask('serve', [ grunt.registerTask('serve', [
'dev', 'dev',
'bgShell:runserver', 'bgShell:runserver',
@ -59,8 +117,9 @@ module.exports = function(grunt) {
'watch' 'watch'
]); ]);
// Make distribution.
grunt.registerTask('dist', [ grunt.registerTask('dist', [
'wiredep', 'dev',
'clean:dist', 'clean:dist',
'useminPrepare', 'useminPrepare',
'copy:dist', 'copy:dist',

View File

@ -1,6 +1,9 @@
'use strict'; 'use strict';
module.exports = { module.exports = {
options: {
maxComplexity: 4
},
src: [ src: [
'accountant/**/*.py' 'accountant/**/*.py'
] ]