Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

build-workflow

Package Overview
Dependencies
Maintainers
1
Versions
126
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

build-workflow - npm Package Compare versions

Comparing version 0.0.21 to 0.0.23

grunt-deps/configs/clean.js

98

config-loader.js

@@ -18,21 +18,57 @@ /**

// these are the **default options**
var opts = {
// ### loadBaseTasksAndConfigs
// if the base tasks included in this repo should be loaded
// base tasks are:
// - changelog
// - check-valid
// - create-pkg-json
// - css-font
// - install-hooks
// - prepush task
// - run-i18n-targets
// - validate-file
loadBaseTasksAndConfigs: true,
// ### appPkgJSONPath
// the path to the package.json file
appPkgJSONPath: './package.json',
// ### gruntFileDirectory
// the directory where the grunt file lives
gruntFileDirectory: process.cwd(),
// ### customTasks
// the path to the local custom tasks for this grunt file
// The default configuration assumes the local tasks definitions
// are inside a folder called `grunt-deps/tasks`.
//
// Each task must be stored in a single file, the name of the task
// should match the name of the file.
customTasks: './grunt-deps/tasks/**/*.js',
// the place where the tasks configuration live
// ### taskConfigs
// the place where the local tasks configurations live
// the name of the file must correspond to the name of the task.
// i.e. the task `grunt-jshint` will require a file called `jshint.js`
// to configure it.
taskConfigs: './grunt-deps/configs/**/*.js',
// the tasks aliases for grunt, they actually enable the grunt workflows.
// ### workflows
// These folder contains the aliases, aliases can be defined in several files
// one for `build` other for `dev`. Usually only one file is required.
// That file is usually called `aliases.js`
workflows: './grunt-deps/workflows/**/*.js',
//common-config
// ### common-config
// This is a file that contains the common configuration for:
// - docco-husky
// - yuidoc
// - filesToValidate (which are used by the check-valid and prepush tasks)
commonConfig: './grunt-deps/common-config.js',
// ### filterDevOnly
// should only load the `grunt-*` tasks from the `devDependencies`
filterDevOnly: true

@@ -45,3 +81,9 @@ };

// only enable the reporting option if the flag `report-time` is passed when called
// grunt. Example: `grunt --report-time`
// grunt. Example: `grunt --report-time`.
//
// This will require you to install `time-grunt` which can be done running
//
// ```javascript
// npm i -D time-grunt
// ```
if ( grunt.option( 'report-time' )) {

@@ -58,2 +100,3 @@ // **Enable time-grunt**

var filterMethod = opts.filterDevOnly ? 'filterDev' : 'filterAll';
// the base path relative to the location of this file

@@ -63,8 +106,6 @@ // when called from within the gruntfile.js

// **load all grunt tasks without specifying them by name**.
//
// This is handy because it is not longer required
// to register a task calling grunt.loadNmpTasks('grunt-name-of-task');
// ### Auto load grunt tasks
// load all the grunt-tasks from the package.json dependencies sections. This is handy because
// it is not longer required to register a task calling `grunt.loadNmpTasks('grunt-name-of-task');`
var gruntDeps = require( 'matchdep' )[ filterMethod ]( 'grunt-*', path.join( basePath, opts.appPkgJSONPath ));
gruntDeps.forEach( grunt.loadNpmTasks );

@@ -80,13 +121,34 @@

var verbose = grunt.verbose;
// ### load the commonConfig module.
// The common config module has the configuration values for
// - docco-husky
// - yuidoc
// - check-valid. Which includes
// - jshint
// - jsvalidate
// - jscs
// - jsbeautifier
// - codepainter (optional)
var commonConfig = require( './load-common-config' )( grunt, opts );
// ### the build number
// the build number is set passing the `--build-number` flag to grunt. if this flag is not used. the version
// number will be replaced by `dev`
//
// Running:
//
// ```javascript
// grunt --build-number=1.5.2.5
// ```
// will override the value of the pkg.version and will be used by all the other tasks
// like `changelog`, `ez-frontend`, `yuidoc` and `docco-husky`
var pkg = grunt.file.readJSON( file );
var optionBuildNumber = grunt.option( 'build-number' ) || 'dev';
var optionBuildNumber = grunt.option( 'build-number' ) || 'dev';
// just in case make sure the `grunt.option` is set so if from other configuration files
// this options is used will have the right value
pkg.version = optionBuildNumber || pkg.version;
grunt.option( 'build-number', pkg.version );
// helper options are a set of arguments that are going to be passed to all the `base tasks` and `local tasks` definitions
var helperOptions = {

@@ -97,16 +159,20 @@ gruntTaskUtils: gruntTaskUtils,

//console.log(helperOptions);
// base tasks will only be loaded if the flag `opts.loadBaseTasksAndConfigs` is set to true.
opts.loadBaseTasksAndConfigs && require( './load-base-tasks' )( grunt, opts, pkg, helperOptions );
grunt.initConfig( {
// grunt files set the pkg object to be used in the expanded templates.
pkg: pkg
} );
// base configurations for tasks will be loaded only if the flag `opts.loadBaseTasksAndConfigs` is set to true.
var baseConfigs = opts.loadBaseTasksAndConfigs ? require( './load-base-tasks-configs' )( grunt, opts, pkg, helperOptions ) : {};
// load custom tasks in the `opts.customTasks` path
require( './load-tasks' )( grunt, opts, pkg, helperOptions );
// load the tasks configs from `opts.taskConfigs` path
require( './load-tasks-configs' )( grunt, opts, pkg, helperOptions, baseConfigs );
// load the workflows
// load the workflows (aliases) from the `opts.workflows` path
var workflows = grunt.file.expand( path.join( basePath, opts.workflows ));

@@ -116,4 +182,2 @@ workflows.forEach(function ( entry ) {

} );
//grunt.file.write('./config.json', JSON.stringify(grunt.config.get(), null, 2));
};

17

configs/exec.js

@@ -35,3 +35,3 @@ module.exports = function ( grunt, pkg, options ) {

return lib.format( 'node_modules/docco-husky/bin/generate {0}', filesOrFolders.join( ' ' ));
return lib.format( 'node_modules/docco-husky-plus/bin/generate {0}', filesOrFolders.join( ' ' ));
}

@@ -130,4 +130,5 @@ },

command: function ( glob ) {
glob = glob || './';
var server = glob === 'server';
var yuidoc = commonConfig.yuidoc || {};

@@ -138,6 +139,10 @@ var pathToConfig = yuidoc.config || path.resolve( __dirname, '../resources/json-configs/yuidoc.json' );

var files = yuidoc.files || glob.split( ',' );
var files = yuidoc.files || [];
var cmd = lib.format( 'node_modules/yuidocjs/lib/cli.js {0} -c {1} --project-name {2} --project-version {3}', files.join( ' ' ), pathToConfig, projectName, projectVersion );
if ( files.length === 0 ) {
grunt.fail.warn( 'No files provided. please add them to your common-config.js file to the yuidoc.files property' );
}
var cmd = lib.format( 'node_modules/yuidocjs/lib/cli.js {0} -c {1} --project-name {2} --project-version {3} {4}', files.join( ' ' ), pathToConfig, projectName, projectVersion, server ? '--server' : '' );
grunt.verbose.writeln( cmd );
return cmd;

@@ -166,3 +171,5 @@ }

return commands.join( '\n' );
var cmd = commands.join( '\n' );
grunt.verbose.writeln( cmd );
return cmd;
}

@@ -169,0 +176,0 @@ }

@@ -8,8 +8,16 @@ module.exports = function ( grunt, pkg, options ) {

var prepush = commonConfig.prepush || {};
var tryCatch = require( '../utils/try-catch' );
var config = path.resolve( __dirname, '../resources/json-configs/.jshintrc' );
// region ### jshint
//
// validate the javascript files against jshint
var getReporter = function () {
var reporter;
tryCatch(function () {
reporter = require( 'jshint-stylish' );
} );
return reporter;
};
return {

@@ -19,3 +27,3 @@ options: {

jshintrc: config,
reporter: require( 'jshint-stylish' )
reporter: getReporter()
}

@@ -26,3 +34,2 @@ // 'js-check': {

};
// endregion
};
# Usage
```bash
# first install grunt
npm i -D grunt
## install the module and its dependencies
# then install build-workflow
npm i -D build-workflow
```sh
npm i -D grunt build-workflow time-grunt matchdep grunt-ez-frontend
```
# then install deps
time-grunt matchdep es6-promise twig marked dot moment grunt-exec
jshint-stylish grunt-contrib-jshint grunt-jscs grunt-jsvalidate
grunt-ez-frontend grunt-jsonlint yuidoc-theme-blue
grunt-contrib-clean grunt-contrib-copy grunt-contrib-uglify
grunt-csso grunt-autoprefixer stringformat browserify-shim grunt-contrib-watch
grunt-karma karma-coverage
https://github.com/royriojas/karma-react-jsx-preprocessor/tarball/1824de4
https://github.com/royriojas/yuidoc/tarball/exampleurl
https://github.com/royriojas/grunt-jsbeautifier/tarball/e69f6ef
https://github.com/royriojas/docco-husky/tarball/f02aff8
```
by default **loading the custom base tasks in this package is true** so you will need also the following dependencies
### To enable changelog
```sh
npm i -D moment dot marked es6-promise
```
### To enable check-valid
```sh
# install the check-valid tasks
npm i -D grunt-contrib-jshint grunt-jscs grunt-jsvalidate https://github.com/royriojas/grunt-jsbeautifier/tarball/e69f6ef
# optional to enable a nice reporter that group errors per file
npm i -D jshint-stylish
# optional install grunt-codepainter
npm i -D grunt-codepainter
```
### To enable generation of documentation with docco-husky and yuidoc
```sh
# enable grunt-exec tasks
npm i -D grunt-exec
# docco-husky-plus
npm i -D docco-husky-plus
# yuidoc
npm i -D yuidoc-theme-blue https://github.com/royriojas/yuidoc/tarball/ed6e335
```
## Create a Gruntfile (or replace the one you have with)
```javascript
module.exports = function ( grunt ) {
'use strict';
// load the config-loader function and pass the grunt object
require( 'build-workflow' )( grunt, {
// uncomment this line to load the base tasks
// loadBaseTasksAndConfigs : false
} );
};
```
## Create the following structure:
```
+-- grunt-deps/
+--configs/
+--tasks/
+--workflows/
|--common-config.js
```
### grunt-deps
Contains the folders for custom `tasks`, `configs`, `workflows` and `common-config.js`
### file common format
`configs`, `tasks` and `workflows` files should exports a function. The function will look like the following:
```javascript
/**
* @param grunt {Object} the grunt object
* @param pkg {Object} the package json object for the current project
* @param opts {Object} the options object
* @param opts.commonConfig {Object} the result of calling the exported function from `common-config.js`
* @param opts.gruntTaskUtils {Object} the gruntTasksUtils module from `grunt-ez-frontend`
*/
module.exports = function (grunt, pkg, opts) {
'use strict';
var gruntTaskUtils = opts.gruntTaskUtils;
// configs files should return an object with the configuration to be set
// tasks and workflows do not need to do this
return {};
};
```
### configs
This folder will contain the tasks configurations.
As an example below is the configuration for the changelog tasks.
```javascript
//
// file changelog.js
//
module.exports = function (grunt, pkg, opts) {
'use strict';
var gruntTaksUtils = opts.gruntTaskUtils;
return {
'changelog': {
dest: './report/changelog/changelog.html',
options: {
'gitUrlForCommit': 'https://github.com/royriojas/build-workflow/commit/{0}',
'gitAuthorUrl': 'https://github.com/{0}',
'urlForBugId': 'https://github.com/royriojas/build-workflow/issues/{0}'
}
}
};
};
```
Grunt configs are set on the config object in grunt, but this could easily become unmanageable, so this module
will look for the tasks configs inside the `configs` folder, execute the exported function and set the value of
the config in the `grunt.config` object. If the base tasks were loaded the configurations described here will
override the base ones.

@@ -1,2 +0,2 @@

module.exports = function ( grunt ) {
module.exports = function ( grunt, pkg ) {

@@ -11,14 +11,22 @@ var prepushFiles = [

var sourcesForDocs = [
'Gruntfile.js',
'tasks/',
'configs/',
'grunt-deps/',
'test-helpers/',
'utils/',
'./*.js'
];
return {
'docco_husky': {
'sources': [
'Gruntfile.js',
'tasks/'
]
'sources': sourcesForDocs
},
// "yuidoc": {
// "config": "./grunt-deps/yuidoc/yuidoc.json"
// },
"yuidoc": {
//"config": "./grunt-deps/yuidoc/yuidoc.json",
files: sourcesForDocs
},

@@ -25,0 +33,0 @@ 'filesToValidate': {

@@ -7,3 +7,3 @@ module.exports = function ( grunt, pkg, opts ) {

var aliases = {
'default': [ 'jshint' ]
'default': [ 'clean', 'check-valid', 'exec:docs' ]
};

@@ -10,0 +10,0 @@

@@ -7,6 +7,7 @@ //

// load the config-loader function and pass the grunt object
require( './config-loader' )( grunt, {
filterDevOnly: false
// loadBaseTasksAndConfigs : false
} );
};

@@ -0,1 +1,57 @@

/*
"karma-react-jsx-preprocessor": "https://github.com/royriojas/karma-react-jsx-preprocessor/tarball/1824de4",
"marked": "~0.3.2",
"es6-promise": "~1.0.0",
"dot": "~1.0.2",
"yuidoc-theme-blue": "~0.1.8",
"time-grunt": "~1.0.0",
"jshint-stylish": "~0.4.0",
"grunt-jsvalidate": "~0.2.2",
"twig": "~0.7.2",
"docco-husky": "https://github.com/royriojas/docco-husky/tarball/54a9a7d",
"matchdep": "~0.3.0",
"grunt-contrib-jshint": "~0.10.0",
"grunt-jsonlint": "~1.0.4",
"moment": "~2.8.3",
"grunt-jsbeautifier": "https://github.com/royriojas/grunt-jsbeautifier/tarball/e69f6ef",
"grunt-jscs": "~0.7.1",
"grunt": "~0.4.5",
"grunt-ez-frontend": "~0.2.21",
"yuidocjs": "https://github.com/royriojas/yuidoc/tarball/ed6e335",
"grunt-exec": "~0.4.6",
"grunt-contrib-copy": "~0.5.0",
"sinon-chai": "~2.5.0",
"stringformat": "0.0.5",
"grunt-codepainter": "~1.1.0",
"grunt-contrib-clean": "~0.6.0",
"karma-chrome-launcher": "~0.1.4",
"karma-commonjs-plus": "0.0.25",
"karma-jasmine": "~0.1.5",
"karma-junit-reporter": "~0.2.2",
"karma-spec-reporter": "0.0.13",
"jasmine-spec-reporter": "~0.6.0",
"chai": "~1.9.1",
"esprima": "~1.2.2",
"grunt-karma": "~0.9.0",
"mocha": "~1.21.4",
"karma-mocha": "~0.1.9",
"reactify": "~0.14.0",
"browserify-transform-tools": "~1.2.1",
"grunt-contrib-uglify": "~0.5.1",
"karma-phantomjs-launcher": "~0.1.4",
"sinon": "~1.10.3",
"grunt-contrib-watch": "~0.6.1",
"react": "~0.11.1",
"karma-coverage": "~0.2.6",
"grunt-csso": "~0.6.3",
"karma-osx-reporter": "~0.1.0",
"karma": "~0.12.23",
"karma-chai-sinon": "~0.1.3",
"grunt-autoprefixer": "~1.0.1",
"browserify": "~5.11.1",
"browserify-shim": "~3.7.0",
"grunt-bump": "0.0.15",
"docco-husky-plus": "~0.4.1"
*/
var deps = [

@@ -49,3 +105,3 @@ 'time-grunt',

'https://github.com/royriojas/grunt-jsbeautifier/tarball/e69f6ef',
'https://github.com/royriojas/docco-husky/tarball/f02aff8'
'docco-husky-plus'
];

@@ -52,0 +108,0 @@

{
"name": "build-workflow",
"version": "0.0.21",
"version": "0.0.23",
"description": "Simple gruntfile helper to define build workflows",

@@ -29,54 +29,23 @@ "main": "config-loader.js",

"devDependencies": {
"karma-react-jsx-preprocessor": "https://github.com/royriojas/karma-react-jsx-preprocessor/tarball/1824de4",
"marked": "~0.3.2",
"es6-promise": "~1.0.0",
"dot": "~1.0.2",
"yuidoc-theme-blue": "~0.1.8",
"time-grunt": "~1.0.0",
"jshint-stylish": "~0.4.0",
"grunt-jsvalidate": "~0.2.2",
"twig": "~0.7.2",
"docco-husky": "https://github.com/royriojas/docco-husky/tarball/f02aff8",
"matchdep": "~0.3.0",
"grunt-contrib-jshint": "~0.10.0",
"grunt-jsonlint": "~1.0.4",
"grunt": "~0.4.5",
"grunt-ez-frontend": "~0.2.21",
"marked": "~0.3.2",
"dot": "~1.0.2",
"moment": "~2.8.3",
"grunt-jsvalidate": "~0.2.2",
"grunt-jsbeautifier": "https://github.com/royriojas/grunt-jsbeautifier/tarball/e69f6ef",
"grunt-contrib-jshint": "~0.10.0",
"grunt-jscs": "~0.7.1",
"grunt": "~0.4.5",
"grunt-ez-frontend": "~0.2.21",
"yuidocjs": "https://github.com/royriojas/yuidoc/tarball/exampleurl",
"jshint-stylish": "~0.4.0",
"grunt-codepainter": "~1.1.0",
"grunt-exec": "~0.4.6",
"grunt-contrib-copy": "~0.5.0",
"sinon-chai": "~2.5.0",
"stringformat": "0.0.5",
"grunt-codepainter": "~1.1.0",
"grunt-contrib-clean": "~0.6.0",
"karma-chrome-launcher": "~0.1.4",
"karma-commonjs-plus": "0.0.25",
"karma-jasmine": "~0.1.5",
"karma-junit-reporter": "~0.2.2",
"karma-spec-reporter": "0.0.13",
"jasmine-spec-reporter": "~0.6.0",
"chai": "~1.9.1",
"esprima": "~1.2.2",
"grunt-karma": "~0.9.0",
"mocha": "~1.21.4",
"karma-mocha": "~0.1.9",
"reactify": "~0.14.0",
"browserify-transform-tools": "~1.2.1",
"grunt-contrib-uglify": "~0.5.1",
"karma-phantomjs-launcher": "~0.1.4",
"sinon": "~1.10.3",
"grunt-contrib-watch": "~0.6.1",
"react": "~0.11.1",
"karma-coverage": "~0.2.6",
"grunt-csso": "~0.6.3",
"karma-osx-reporter": "~0.1.0",
"karma": "~0.12.23",
"karma-chai-sinon": "~0.1.3",
"grunt-autoprefixer": "~1.0.1",
"browserify": "~5.11.1",
"browserify-shim": "~3.7.0",
"grunt-bump": "0.0.15"
"docco-husky-plus": "~0.4.1",
"yuidoc-theme-blue": "~0.1.8",
"yuidocjs": "https://github.com/royriojas/yuidoc/tarball/ed6e335",
"grunt-bump": "0.0.15",
"grunt-jsonlint": "~1.0.4",
"grunt-contrib-clean": "~0.6.0"
},

@@ -83,0 +52,0 @@ "docco_husky": {

# Build Workflow
Simple helper to create grunt build workflows that are easy to configure and use.
Simple helper to create grunt build workflows that are easy to configure and use.
## what is it?
This is a simple module that aims to make simpler to create workflows based on grunt. This module helps you break
a grunt file in several modules that are easier to maintain and to reason about.
This module is inspired by this blog post [supercharging your gruntfile](http://www.html5rocks.com/en/tutorials/tooling/supercharging-your-gruntfile/)
The main differences are:
- config files exports a function that return an object. All the config objects receive the `grunt` object, the `pkg` object and `options` object.
The options object contains a `commonConfig` object that can be used to share some config info between task configurations,
and also exports the `gruntTaskUtils` module from `grunt-ez-frontend` a module that exports a registerTasks methods that allows you to register
both tasks and multiTasks by passing an object instead of using two different methods.
- allows load custom grunt tasks.
- do not use yaml, so the aliases should be defined in javascript
- provide some base common tasks described below
So, This module will
- help you break your gigantic grunt file
- provide some (optional) base tasks and tasks configurations like:
- **changelog**: Create a changelog from the git log info. For more info check the changelog section.
- **check-valid**: Beautify (with `jsbeautify`) and validate the javascript files with `jshint`, `jscs` and `jsvalidate`.
- **install-hooks**: Install `commit-msg` and `prepush` hooks for git. To enforce the rules for commit messages
and to verify all files configured to be beautified and validated are checked before pushing.
- **prepush**: the tasks that the prepush hook runs before any push is made.
- **i18n-from-yml**: Generate `i18n.{lang}.js` files from yml translations files. (this is actually inside grunt-ez-frontend)
- **i18n-to-ez-frontend**: create an `ez-frontend` task for each `i18n.{lang}.js` file to make each of them be
minified, had the right version and include the banner header.
- **run-i18n-targets**: execute all the `ez-frontend` targets created by the previous task.
- **css-font**: a custom task to create the css and less mixins for a font from the `selection.json`
file obtained from the [icomoon app](https://icomoon.io/app/#/select)
- **target, js-target, css-target**: tasks to run `ez-frontend` targets.
- **validate-files**: a custom task to validate files passed as parameters. Useful to beautify the code from within an IDE.
## Usage
check usage [here](./docs/usage.md.html)

@@ -101,4 +101,6 @@ module.exports = function ( grunt, pkg, options ) {

opts.jsonCodesOuput && grunt.file.write( opts.jsonCodesOuput, lib.format( 'var fontData = {0}', JSON.stringify( fontData )) );
grunt.log.ok( 'JSON Metadata File created: ' + opts.jsonCodesOuput );
if ( opts.jsonCodesOuput ) {
grunt.file.write( opts.jsonCodesOuput, lib.format( 'var fontData = {0}', JSON.stringify( fontData )) );
grunt.log.ok( 'JSON Metadata File created: ' + opts.jsonCodesOuput );
}
} );

@@ -105,0 +107,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc