build-workflow
Advanced tools
Comparing version 0.0.25 to 0.0.27
@@ -124,1 +124,79 @@ # Usage | ||
override the base ones. | ||
### common-config.js file | ||
A `common-config.js` file looks like the one below | ||
```javascript | ||
module.exports = function ( grunt, pkg ) { | ||
var prepushFiles = [ | ||
'**/*.js', | ||
'!resources/hooks/*.js', | ||
'!node_modules/**/*.*', | ||
'!documentation/**/*.js', | ||
'!apidocs/**/*.js' | ||
]; | ||
var sourcesForDocs = [ | ||
'Gruntfile.js', | ||
'tasks/', | ||
'configs/', | ||
'grunt-deps/', | ||
'test-helpers/', | ||
'utils/', | ||
'./*.js' | ||
]; | ||
return { | ||
// this files are going to generate annotated docs using docco-husky-plus | ||
// for docco to work properly the package json also need to have some configuration | ||
// values. TODO: move the docco-husky config to this file too. | ||
// the `package.json` values to add are | ||
// | ||
// "docco_husky": { | ||
// // do not add `./` at the beginning or a `/` at the end. Docco is kinda picky | ||
// "content_dir": "docs", | ||
// "output_dir": "documentation", | ||
// "project_name": "Build Workflow", | ||
// "show_timestamp": true | ||
// } | ||
// | ||
// to execute the documentation task run | ||
// grunt exec:docs | ||
'docco_husky': { | ||
'sources': sourcesForDocs | ||
}, | ||
// this section controls the generation of the apidocs | ||
// you can provide a custom configuration object for yuidoc | ||
// or use the default one configured to use yuidoc-theme-blue | ||
// the documentation files can be specified using the files property | ||
"yuidoc": { | ||
//"config": "./grunt-deps/yuidoc/yuidoc.json", | ||
files: sourcesForDocs | ||
}, | ||
// by default the prepush task is executed by the prepush hook, if installed | ||
// the default prepush task will only execute the tasks under the filesToValidate | ||
// section. If other tasks are required to be executed during the | ||
// prepush you can specify them here. i.e. if you want to make the prepush to also | ||
// validate the tests are run you can add karma:one (assuming you have configured that task) | ||
// this will execute the validation tasks and the karma:one and fail if the task fail | ||
// preventing the push of code with untested paths | ||
prepushTasks: [ 'karma:one' ], | ||
// filesToValidate specify the tasks that are going to be executed when | ||
// running the `prepush` hook and `check-valid` task | ||
// to validate the files simply run `grunt check-valid` | ||
'filesToValidate': { | ||
'jsbeautifier': prepushFiles, | ||
'jscs': prepushFiles, | ||
'jshint': prepushFiles, | ||
'jsvalidate': prepushFiles, | ||
'codepainter': prepushFiles | ||
} | ||
}; | ||
}; | ||
``` |
@@ -32,2 +32,4 @@ module.exports = function ( grunt, pkg ) { | ||
prepushTasks: [ 'jsonlint' ], | ||
'filesToValidate': { | ||
@@ -34,0 +36,0 @@ 'jsbeautifier': prepushFiles, |
{ | ||
"name": "build-workflow", | ||
"version": "0.0.25", | ||
"version": "0.0.27", | ||
"description": "Simple gruntfile helper to define build workflows", | ||
@@ -50,3 +50,4 @@ "main": "config-loader.js", | ||
"grunt-contrib-clean": "~0.6.0", | ||
"grunt-newer": "~0.7.0" | ||
"grunt-newer": "~0.7.0", | ||
"twig": "~0.7.2" | ||
}, | ||
@@ -53,0 +54,0 @@ "docco_husky": { |
@@ -40,5 +40,9 @@ # Build Workflow | ||
- **validate-files**: a custom task to validate files passed as parameters. Useful to beautify the code from within an IDE. | ||
- **twig**: a simple twig template renderer | ||
__TODO: at some point all this tasks should be moved to their own repos in order to leave `build-workflow` a simple grunt | ||
management module__ | ||
## Usage | ||
[check usage here](docs/usage.md) |
@@ -8,80 +8,4 @@ module.exports = function ( grunt, pkg, options ) { | ||
var Promise = require( 'es6-promise' ).Promise; | ||
var exec = require( 'child_process' ).exec; | ||
// **lib module** | ||
// | ||
// this module include some utilities, like `lib.format`, `lib.isNullOrEmpty`, `lib.isNull`, `lib.extend`, etc | ||
var lib = require( 'grunt-ez-frontend/lib/lib.js' ); | ||
var gitHelper = { | ||
getTags: function () { | ||
return new Promise(function ( resolve, reject ) { | ||
exec( 'git for-each-ref --sort=\'-*authordate\' --format=\'%(tag)\' refs/tags', function ( err, stdout, stderr ) { | ||
if ( !err ) { | ||
var tags = stdout.split( '\n' ).filter(function ( entry ) { | ||
return !!entry; | ||
} ); | ||
resolve( { | ||
tags: tags | ||
} ); | ||
return; | ||
} | ||
reject( { | ||
error: err | ||
} ); | ||
} ); | ||
} ); | ||
}, | ||
getCommits: function ( options ) { | ||
var opts = { | ||
from: '', | ||
to: '', | ||
name: '', | ||
args: '--pretty=format:\'%h$|$%s$|$%b$|$%ct$|$%an$-$-$\' --no-merges' | ||
}; | ||
lib.extend( opts, options ); | ||
var range = opts.from ? opts.from + '..' : ''; | ||
range = range + opts.to; | ||
var gitCmd = 'git log ' + opts.args + ' ' + range; | ||
grunt.verbose.write( 'command to execute on git', gitCmd ); | ||
var me = this; | ||
return new Promise(function ( resolve, reject ) { | ||
exec( gitCmd, function ( err, stdout ) { | ||
if ( !err ) { | ||
var commits = me.parseLog( stdout ); | ||
resolve( { | ||
commits: commits | ||
} ); | ||
return; | ||
} | ||
reject( { | ||
error: err | ||
} ); | ||
} ); | ||
} ); | ||
}, | ||
getCommitGroups: function ( tags ) { | ||
var groups = []; | ||
for ( var i = 0; i < tags.length; i++ ) { | ||
var tagNext = tags[ i + 1 ]; | ||
var currentTag = tags[ i ]; | ||
var group = { | ||
name: currentTag, | ||
from: tagNext, | ||
to: currentTag | ||
}; | ||
( typeof tagNext !== 'undefined' ) && groups.push( group ); | ||
} | ||
return groups; | ||
} | ||
}; | ||
gruntTaskUtils.registerTasks( { | ||
@@ -93,3 +17,6 @@ 'changelog': { | ||
done = me.async(); | ||
var Promise = require( 'es6-promise' ).Promise; | ||
var gitHelper = require( '../utils/git-helper' )( grunt ); | ||
var opts = this.options( { | ||
@@ -96,0 +23,0 @@ renderer: function ( data ) { |
@@ -16,3 +16,4 @@ module.exports = function ( grunt, pkg, options ) { | ||
filesToValidate: options.commonConfig.filesToValidate, | ||
forceBeautify: false | ||
forceBeautify: false, | ||
prepushTasks: options.commonConfig.prepushTasks || [] | ||
} ); | ||
@@ -22,2 +23,8 @@ | ||
tasksToRun = tasksToRun || []; | ||
if ( opts.prepushTasks ) { | ||
tasksToRun = tasksToRun.concat( opts.prepushTasks ); | ||
} | ||
if ( tasksToRun.length > 0 ) { | ||
@@ -24,0 +31,0 @@ grunt.task.run( tasksToRun ); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
166064
95
2234
48
23