Skip to content

Commit

Permalink
Add grunt license checker (opensourcepos#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
daN4cat committed Aug 8, 2016
1 parent 4a54dc7 commit dd07b9f
Show file tree
Hide file tree
Showing 4 changed files with 336 additions and 174 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ git-svn-diff.py
*.~
*.log
application/sessions/*
.licenses
369 changes: 195 additions & 174 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
module.exports = function(grunt) {

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
wiredep: {
task: {
ignorePath: '../../../',
src: ['application/views/partial/header_debug.php']
}
},
bower_concat: {
all: {
mainFiles: {
'bootswatch-dist': ['bootstrap/dist/js/bootstrap.js'],
'bootstrap-table': [ "src/bootstrap-table.js", "src/bootstrap-table.css", "dist/extensions/export/bootstrap-table-export.js", "dist/extensions/mobile/bootstrap-table-mobile.js"]
},
dest: {
'js': 'tmp/opensourcepos_bower.js',
'css': 'tmp/opensourcepos_bower.css'
}
}
},
bowercopy: {
pkg: grunt.file.readJSON('package.json'),
wiredep: {
task: {
ignorePath: '../../../',
src: ['application/views/partial/header_debug.php']
}
},
bower_concat: {
all: {
mainFiles: {
'bootswatch-dist': ['bootstrap/dist/js/bootstrap.js'],
'bootstrap-table': [ "src/bootstrap-table.js", "src/bootstrap-table.css", "dist/extensions/export/bootstrap-table-export.js", "dist/extensions/mobile/bootstrap-table-mobile.js"]
},
dest: {
'js': 'tmp/opensourcepos_bower.js',
'css': 'tmp/opensourcepos_bower.css'
}
}
},
bowercopy: {
options: {
// Bower components folder will be removed afterwards
// clean: true
Expand All @@ -42,164 +42,185 @@ module.exports = function(grunt) {
// add here anything that should be copied in a tmp directory
}
}*/
},
cssmin: {
target: {
files: {
'dist/<%= pkg.name %>.min.css': ['tmp/opensourcepos_bower.css', 'css/*.css', '!css/login.css', '!css/invoice_email.css']
}
}
},
concat: {
js: {
options: {
separator: ';'
},
files: {
'dist/<%= pkg.name %>.js': ['tmp/opensourcepos_bower.js', 'js/jquery*', 'js/*.js']
}
},
sql: {
options: {
banner: '-- >> This file is autogenerated from tables.sql and constraints.sql. Do not modify directly << --'
},
files: {
'database/database.sql': ['database/tables.sql', 'database/constraints.sql'],
'database/migrate_phppos_dist.sql': ['database/tables.sql', 'database/phppos_migrate.sql', 'database/constraints.sql']
}
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
},
dist: {
files: {
'dist/<%= pkg.name %>.min.js': ['dist/<%= pkg.name %>.js']
}
}
},
jshint: {
files: ['Gruntfile.js', 'js/*.js'],
options: {
// options here to override JSHint defaults
globals: {
jQuery: true,
console: true,
module: true,
document: true
}
}
},
tags: {
css_header: {
options: {
scriptTemplate: '<rel type="text/css" src="{{ path }}"></rel>',
openTag: '<!-- start css template tags -->',
closeTag: '<!-- end css template tags -->',
absolutePath: true
},
src: ['css/*.css', '!css/login.css', '!css/invoice_email.css'],
dest: 'application/views/partial/header_debug.php',
},
mincss_header: {
options: {
scriptTemplate: '<rel type="text/css" src="{{ path }}"></rel>',
openTag: '<!-- start mincss template tags -->',
closeTag: '<!-- end mincss template tags -->',
absolutePath: true
},
src: ['dist/*.css'],
dest: 'application/views/partial/header.php',
},
mincss_header_templates: {
options: {
scriptTemplate: '<rel type="text/css" src="{{ path }}"></rel>',
openTag: '<!-- start mincss template tags -->',
closeTag: '<!-- end mincss template tags -->',
absolutePath: true
},
src: ['dist/*.css', '!dist/bootstrap.min.css'],
dest: 'templates/spacelab/views/partial/header.php'
},
css_login: {
options: {
scriptTemplate: '<rel type="text/css" src="{{ path }}"></rel>',
openTag: '<!-- start css template tags -->',
closeTag: '<!-- end css template tags -->',
absolutePath: true
},
src: ['dist/bootstrap.min.css', 'css/login.css'],
dest: 'application/views/login.php'
},
js: {
options: {
scriptTemplate: '<script type="text/javascript" src="{{ path }}"></script>',
openTag: '<!-- start js template tags -->',
closeTag: '<!-- end js template tags -->',
absolutePath: true
},
src: ['js/jquery*', 'js/*.js'],
dest: 'application/views/partial/header_debug.php'
},
minjs: {
options: {
scriptTemplate: '<script type="text/javascript" src="{{ path }}"></script>',
openTag: '<!-- start minjs template tags -->',
closeTag: '<!-- end minjs template tags -->',
absolutePath: true
},
src: ['dist/*min.js'],
dest: 'application/views/partial/header.php'
}
},
mochaWebdriver: {
options: {
timeout: 1000 * 60 * 3
},
test : {
options: {
usePhantom: true,
usePromises: true
},
src: ['test/**/*.js']
}
},
watch: {
files: ['<%= jshint.files %>'],
tasks: ['jshint']
},
cachebreaker: {
dev: {
options: {
match: [ {
'opensourcepos.min.js': 'dist/opensourcepos.min.js',
'opensourcepos.min.css': 'dist/opensourcepos.min.css',
'bootstrap.min.css': 'dist/bootstrap.min.css'
} ],
replacement: 'md5'
},
files: {
src: ['**/header.php', '**/login.php']
}
}
},
license: {
all: {
// Target-specific file lists and/or options go here.
options: {
// Target-specific options go here.
directory: 'bower_components',
output: 'license/LICENSES'
}
}
}
},
cssmin: {
target: {
files: {
'dist/<%= pkg.name %>.min.css': ['tmp/opensourcepos_bower.css', 'css/*.css', '!css/login.css', '!css/invoice_email.css']
}
}
},
concat: {
js: {
options: {
separator: ';'
},
files: {
'dist/<%= pkg.name %>.js': ['tmp/opensourcepos_bower.js', 'js/jquery*', 'js/*.js']
}
},
sql: {
options: {
banner: '-- >> This file is autogenerated from tables.sql and constraints.sql. Do not modify directly << --'
},
files: {
'database/database.sql': ['database/tables.sql', 'database/constraints.sql'],
'database/migrate_phppos_dist.sql': ['database/tables.sql', 'database/phppos_migrate.sql', 'database/constraints.sql']
}
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
},
dist: {
files: {
'dist/<%= pkg.name %>.min.js': ['dist/<%= pkg.name %>.js']
}
}
},
jshint: {
files: ['Gruntfile.js', 'js/*.js'],
options: {
// options here to override JSHint defaults
globals: {
jQuery: true,
console: true,
module: true,
document: true
}
}
},
tags: {
css_header: {
options: {
scriptTemplate: '<rel type="text/css" src="{{ path }}"></rel>',
openTag: '<!-- start css template tags -->',
closeTag: '<!-- end css template tags -->',
absolutePath: true
},
src: ['css/*.css', '!css/login.css', '!css/invoice_email.css'],
dest: 'application/views/partial/header_debug.php',
},
mincss_header: {
options: {
scriptTemplate: '<rel type="text/css" src="{{ path }}"></rel>',
openTag: '<!-- start mincss template tags -->',
closeTag: '<!-- end mincss template tags -->',
absolutePath: true
},
src: ['dist/*.css'],
dest: 'application/views/partial/header.php',
},
mincss_header_templates: {
options: {
scriptTemplate: '<rel type="text/css" src="{{ path }}"></rel>',
openTag: '<!-- start mincss template tags -->',
closeTag: '<!-- end mincss template tags -->',
absolutePath: true
},
src: ['dist/*.css', '!dist/bootstrap.min.css'],
dest: 'templates/spacelab/views/partial/header.php'
},
css_login: {
options: {
scriptTemplate: '<rel type="text/css" src="{{ path }}"></rel>',
openTag: '<!-- start css template tags -->',
closeTag: '<!-- end css template tags -->',
absolutePath: true
},
src: ['dist/bootstrap.min.css', 'css/login.css'],
dest: 'application/views/login.php'
},
js: {
options: {
scriptTemplate: '<script type="text/javascript" src="{{ path }}"></script>',
openTag: '<!-- start js template tags -->',
closeTag: '<!-- end js template tags -->',
absolutePath: true
},
src: ['js/jquery*', 'js/*.js'],
dest: 'application/views/partial/header_debug.php'
},
minjs: {
options: {
scriptTemplate: '<script type="text/javascript" src="{{ path }}"></script>',
openTag: '<!-- start minjs template tags -->',
closeTag: '<!-- end minjs template tags -->',
absolutePath: true
},
src: ['dist/*min.js'],
dest: 'application/views/partial/header.php'
}
},
mochaWebdriver: {
options: {
timeout: 1000 * 60 * 3
},
test : {
options: {
usePhantom: true,
usePromises: true
},
src: ['test/**/*.js']
}
},
watch: {
files: ['<%= jshint.files %>'],
tasks: ['jshint']
},
cachebreaker: {
dev: {
options: {
match: [ {
'opensourcepos.min.js': 'dist/opensourcepos.min.js',
'opensourcepos.min.css': 'dist/opensourcepos.min.css',
'bootstrap.min.css': 'dist/bootstrap.min.css'
} ],
replacement: 'md5'
},
files: {
src: ['**/header.php', '**/login.php']
}
}
},
'bower-licensechecker': {
options: {
/*directory: 'path/to/bower',*/
acceptable: [ 'MIT', 'BSD', 'LICENSE.md' ],
printTotal: true,
warn: {
nonBower: true,
noLicense: true,
allGood: true,
noGood: true
},
log: {
outFile: '.licenses',
nonBower: true,
noLicense: true,
allGood: true,
noGood: true,
}
}
},
license: {
all: {
// Target-specific file lists and/or options go here.
options: {
// Target-specific options go here.
directory: 'bower_components',
output: 'license/LICENSES'
},
},
},
});

require('load-grunt-tasks')(grunt);
grunt.loadNpmTasks('grunt-mocha-webdriver');
grunt.loadNpmTasks('grunt-license-bower');
grunt.loadNpmTasks('grunt-bower-licensechecker');
grunt.loadNpmTasks('grunt-license-bower');

grunt.registerTask('default', ['wiredep', 'bower_concat', 'bowercopy', 'concat', 'uglify', 'cssmin', 'tags', 'cachebreaker']);
grunt.registerTask('default', ['wiredep', 'bower_concat', 'bowercopy', 'concat', 'uglify', 'cssmin', 'tags', 'cachebreaker', 'bower-licensechecker', 'license']);

};
Loading

0 comments on commit dd07b9f

Please sign in to comment.