Initial commit
This commit is contained in:
commit
8c55df101b
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
"bitwise": false, // Prohibit bitwise operators (&, |, ^, etc.).
|
||||
"browser": true, // Standard browser globals e.g. `window`, `document`.
|
||||
"camelcase": false, // Permit only camelcase for `var` and `object indexes`.
|
||||
"curly": true, // Require {} for every new block or scope.
|
||||
"devel": false, // Allow development statements e.g. `console.log();`.
|
||||
"eqeqeq": true, // Require triple equals i.e. `===`.
|
||||
"esnext": true, // Allow ES.next specific features such as `const` and `let`.
|
||||
"freeze": true, // Forbid overwriting prototypes of native objects such as Array, Date and so on.
|
||||
"immed": true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
|
||||
"indent": 2, // Specify indentation spacing
|
||||
"latedef": true, // Prohibit variable use before definition.
|
||||
"newcap": false, // Require capitalization of all constructor functions e.g. `new F()`.
|
||||
"noarg": true, // Prohibit use of `arguments.caller` and `arguments.callee`.
|
||||
"node": true, // Enable globals available when code is running inside of the NodeJS runtime environment.
|
||||
"noempty": true, // Prohibit use of empty blocks.
|
||||
"nonew": true, // Prohibits the use of constructor functions for side-effects
|
||||
"quotmark": "single", // Define quotes to string values.
|
||||
"regexp": true, // Prohibit `.` and `[^...]` in regular expressions.
|
||||
"smarttabs": false, // Supress warnings about mixed tabs and spaces
|
||||
"strict": true, // Require `use strict` pragma in every file.
|
||||
"trailing": true, // Prohibit trailing whitespaces.
|
||||
"undef": true, // Require all non-global variables be declared before they are used.
|
||||
"unused": true, // Warn unused variables.
|
||||
|
||||
"maxparams": 4, // Maximum number of parameters for a function
|
||||
"maxstatements": 15, // Maximum number of statements in a function
|
||||
"maxcomplexity": 6, // Cyclomatic complexity (http://en.wikipedia.org/wiki/Cyclomatic_complexity)
|
||||
"maxdepth": 4, // Maximum depth of nested control structures
|
||||
"maxlen": 120, // Maximum number of cols in a line
|
||||
"multistr": true, // Allow use of multiline EOL escaping
|
||||
|
||||
"predef": [ // Extra globals.
|
||||
"after",
|
||||
"afterEach",
|
||||
"before",
|
||||
"beforeEach",
|
||||
"define",
|
||||
"describe",
|
||||
"exports",
|
||||
"it",
|
||||
"module",
|
||||
"require"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,184 @@
|
|||
'use strict';
|
||||
|
||||
var gulp = require('gulp');
|
||||
|
||||
/**
|
||||
* @file gulpfile.js
|
||||
*
|
||||
* Defines tasks that can be run on gulp.
|
||||
*
|
||||
* Summary: <ul>
|
||||
* <li> `test` - runs all the tests on node and the browser (mocha and karma)
|
||||
* <ul>
|
||||
* <li> `test:node`
|
||||
* <li> `test:node:nofail` - internally used for watching (due to bug on gulp-mocha)
|
||||
* <li> `test:browser`
|
||||
* </ul>`
|
||||
* <li> `watch:test` - watch for file changes and run tests
|
||||
* <ul>
|
||||
* <li> `watch:test:node`
|
||||
* <li> `watch:test:browser`
|
||||
* </ul>`
|
||||
* <li> `browser` - generate files needed for browser (browserify)
|
||||
* <ul>
|
||||
* <li> `browser:uncompressed` - build `bitcore-*.js`
|
||||
* <li> `browser:compressed` - build `bitcore-*.min.js`
|
||||
* <li> `browser:maketests` - build `tests.js`, needed for testing without karma
|
||||
* </ul>`
|
||||
* <li> `errors` - autogenerate the `./lib/errors/index.js` file with error definitions
|
||||
* <li> `lint` - run `jshint`
|
||||
* <li> `coverage` - run `istanbul` with mocha to generate a report of test coverage
|
||||
* <li> `coveralls` - updates coveralls info
|
||||
* <li> `release` - automates release process (only for bitcore maintainers)
|
||||
* </ul>
|
||||
*/
|
||||
function startGulp(name) {
|
||||
|
||||
var coveralls = require('gulp-coveralls');
|
||||
var gutil = require('gulp-util');
|
||||
var jshint = require('gulp-jshint');
|
||||
var mocha = require('gulp-mocha');
|
||||
var rename = require('gulp-rename');
|
||||
var runsequence = require('run-sequence');
|
||||
var shell = require('gulp-shell');
|
||||
var uglify = require('gulp-uglify');
|
||||
|
||||
var files = ['lib/**/*.js'];
|
||||
var tests = ['test/**/*.js'];
|
||||
var alljs = files.concat(tests);
|
||||
|
||||
function ignoreerror() {
|
||||
/* jshint ignore:start */ // using `this` in this context is weird
|
||||
this.emit('end');
|
||||
/* jshint ignore:end */
|
||||
}
|
||||
|
||||
var testmocha = function() {
|
||||
return gulp.src(tests).pipe(new mocha({
|
||||
reporter: 'spec'
|
||||
}));
|
||||
};
|
||||
|
||||
var testkarma = shell.task([
|
||||
'./node_modules/karma/bin/karma start'
|
||||
]);
|
||||
|
||||
/**
|
||||
* testing
|
||||
*/
|
||||
|
||||
gulp.task('test:node', ['errors'], testmocha);
|
||||
|
||||
gulp.task('test:node:nofail', ['errors'], function() {
|
||||
return testmocha().on('error', ignoreerror);
|
||||
});
|
||||
|
||||
gulp.task('test:browser', ['browser:uncompressed', 'browser:maketests'], testkarma);
|
||||
|
||||
gulp.task('test', function(callback) {
|
||||
runsequence(['test:node'], ['test:browser'], callback);
|
||||
});
|
||||
|
||||
/**
|
||||
* file generation
|
||||
*/
|
||||
|
||||
gulp.task('browser:uncompressed', ['errors'], shell.task([
|
||||
'./node_modules/.bin/browserify index.js --insert-global-vars=true --standalone=bitcore-' +
|
||||
name + ' -o bitcore-' + name + '.js'
|
||||
]));
|
||||
|
||||
gulp.task('browser:compressed', ['browser:uncompressed'], function() {
|
||||
return gulp.src('bitcore-' + name + '.js')
|
||||
.pipe(uglify({
|
||||
mangle: true,
|
||||
compress: true
|
||||
}))
|
||||
.pipe(rename('bitcore-' + name + '.min.js'))
|
||||
.pipe(gulp.dest('.'))
|
||||
.on('error', gutil.log);
|
||||
});
|
||||
|
||||
gulp.task('browser:maketests', shell.task([
|
||||
'find test/ -type f -name "*.js" | xargs ./node_modules/.bin/browserify -t brfs -o tests.js'
|
||||
]));
|
||||
|
||||
gulp.task('browser', function(callback) {
|
||||
runsequence(['browser:compressed'], ['browser:maketests'], callback);
|
||||
});
|
||||
|
||||
gulp.task('errors', shell.task([
|
||||
'node ./lib/errors/build.js'
|
||||
]));
|
||||
|
||||
|
||||
/**
|
||||
* code quality and documentation
|
||||
*/
|
||||
|
||||
gulp.task('lint', function() {
|
||||
return gulp.src(alljs)
|
||||
.pipe(jshint())
|
||||
.pipe(jshint.reporter('default'));
|
||||
});
|
||||
|
||||
gulp.task('plato', shell.task(['plato -d report -r -l .jshintrc -t bitcore-' + name + ' lib']));
|
||||
|
||||
gulp.task('coverage', shell.task(['node_modules/.bin/./istanbul cover node_modules/.bin/_mocha -- --recursive']));
|
||||
|
||||
gulp.task('coveralls', ['coverage'], function() {
|
||||
gulp.src('coverage/lcov.info').pipe(coveralls());
|
||||
});
|
||||
|
||||
/**
|
||||
* watch tasks
|
||||
*/
|
||||
|
||||
gulp.task('watch:test', function() {
|
||||
// todo: only run tests that are linked to file changes by doing
|
||||
// something smart like reading through the require statements
|
||||
return gulp.watch(alljs, ['test']);
|
||||
});
|
||||
|
||||
gulp.task('watch:test:node', function() {
|
||||
// todo: only run tests that are linked to file changes by doing
|
||||
// something smart like reading through the require statements
|
||||
return gulp.watch(alljs, ['test:node']);
|
||||
});
|
||||
|
||||
gulp.task('watch:test:browser', function() {
|
||||
// todo: only run tests that are linked to file changes by doing
|
||||
// something smart like reading through the require statements
|
||||
return gulp.watch(alljs, ['test:browser']);
|
||||
});
|
||||
|
||||
gulp.task('watch:jsdoc', function() {
|
||||
// todo: only run tests that are linked to file changes by doing
|
||||
// something smart like reading through the require statements
|
||||
return gulp.watch(alljs, ['jsdoc']);
|
||||
});
|
||||
|
||||
gulp.task('watch:coverage', function() {
|
||||
// todo: only run tests that are linked to file changes by doing
|
||||
// something smart like reading through the require statements
|
||||
return gulp.watch(alljs, ['coverage']);
|
||||
});
|
||||
|
||||
gulp.task('watch:lint', function() {
|
||||
// todo: only lint files that are linked to file changes by doing
|
||||
// something smart like reading through the require statements
|
||||
return gulp.watch(alljs, ['lint']);
|
||||
});
|
||||
|
||||
gulp.task('watch:browser', function() {
|
||||
return gulp.watch(alljs, ['browser']);
|
||||
});
|
||||
|
||||
/* default task */
|
||||
gulp.task('default', function(callback) {
|
||||
return runsequence(['lint'], ['browser:uncompressed', 'test'], ['coverage', 'browser:compressed'],
|
||||
callback);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = startGulp;
|
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"name": "gulp-bitcore",
|
||||
"version": "0.1.0",
|
||||
"description": "A helper for common tasks across bitcore modules'",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "gulp test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/bitpay/gulp-bitcore"
|
||||
},
|
||||
"keywords": [
|
||||
"bitcore"
|
||||
],
|
||||
"author": "Esteban Ordano",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/bitpay/gulp-bitcore/issues"
|
||||
},
|
||||
"homepage": "https://github.com/bitpay/gulp-bitcore",
|
||||
"dependencies": {
|
||||
"brfs": "^1.2.0",
|
||||
"browserify": "~6.3.3",
|
||||
"gulp": "^3.8.10",
|
||||
"gulp-coveralls": "^0.1.3",
|
||||
"gulp-jshint": "^1.9.0",
|
||||
"gulp-mocha": "^2.0.0",
|
||||
"gulp-rename": "^1.2.0",
|
||||
"gulp-shell": "^0.2.10",
|
||||
"gulp-uglify": "^1.0.2",
|
||||
"gulp-util": "=3.0.1",
|
||||
"lodash": "^2.4.1",
|
||||
"plato": "^1.3.0",
|
||||
"run-sequence": "^1.0.2"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue