Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
Esteban Ordano | ebf1dfe890 |
|
@ -1,2 +0,0 @@
|
|||
|
||||
node_modules/
|
41
README.md
41
README.md
|
@ -1,41 +0,0 @@
|
|||
# bitcore-build-zcash
|
||||
|
||||
A helper to add tasks to gulp.
|
||||
|
||||
## Getting started
|
||||
|
||||
Install with:
|
||||
|
||||
```sh
|
||||
npm install bitcore-build-zcash
|
||||
```
|
||||
|
||||
and use and require in your gulp file:
|
||||
|
||||
```javascript
|
||||
var gulp = require('gulp');
|
||||
var bitcoreTasks = require('bitcore-build-zcash');
|
||||
|
||||
bitcoreTasks('submodule');
|
||||
gulp.task('default', ['lint', 'test', 'browser', 'coverage']);
|
||||
```
|
||||
|
||||
### Notes
|
||||
|
||||
* There's no default task to allow for each submodule to set up their own configuration
|
||||
* If the module is node-only, avoid adding the browser tasks with:
|
||||
```javascript
|
||||
var bitcoreTasks = require('bitcore-build-zcash');
|
||||
bitcoreTasks('submodule', {skipBrowsers: true});
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
See [CONTRIBUTING.md](https://github.com/bitpay/bitcore) on the main bitcore repo for information about how to contribute.
|
||||
|
||||
## License
|
||||
|
||||
Code released under [the MIT license](https://github.com/bitpay/bitcore/blob/master/LICENSE).
|
||||
|
||||
Copyright 2015 BitPay, Inc. Bitcore is a trademark maintained by BitPay, Inc.
|
||||
|
281
index.js
281
index.js
|
@ -1,3 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
var gulp = require('gulp');
|
||||
|
||||
/**
|
||||
* @file gulpfile.js
|
||||
*
|
||||
|
@ -17,54 +21,38 @@
|
|||
* </ul>`
|
||||
* <li> `browser` - generate files needed for browser (browserify)
|
||||
* <ul>
|
||||
* <li> `browser:uncompressed` - build uncomprssed browser bundle (`bitcore-*.js`)
|
||||
* <li> `browser:compressed` - build compressed browser bundle (`bitcore-*.min.js`)
|
||||
* <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 maintainers)
|
||||
* <li> `release` - automates release process (only for bitcore maintainers)
|
||||
* </ul>
|
||||
*/
|
||||
'use strict';
|
||||
function startGulp(name) {
|
||||
|
||||
var gulp = require('gulp');
|
||||
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 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');
|
||||
runsequence.use(gulp);
|
||||
var shell = require('gulp-shell');
|
||||
var uglify = require('gulp-uglify');
|
||||
var bump = require('gulp-bump');
|
||||
var git = require('gulp-git');
|
||||
|
||||
function ignoreerror() {
|
||||
/* jshint ignore:start */ // using `this` in this context is weird
|
||||
this.emit('end');
|
||||
/* jshint ignore:end */
|
||||
}
|
||||
|
||||
function startGulp(name, opts) {
|
||||
|
||||
opts = opts || {};
|
||||
var browser = !opts.skipBrowser;
|
||||
var fullname = name ? 'bitcore-' + name : 'bitcore';
|
||||
var files = ['lib/**/*.js'];
|
||||
var tests = ['test/**/*.js'];
|
||||
var alljs = files.concat(tests);
|
||||
|
||||
var buildPath = './node_modules/bitcore-build-zcash/';
|
||||
var buildModulesPath = buildPath + 'node_modules/';
|
||||
var buildBinPath = buildPath + 'node_modules/.bin/';
|
||||
function ignoreerror() {
|
||||
/* jshint ignore:start */ // using `this` in this context is weird
|
||||
this.emit('end');
|
||||
/* jshint ignore:end */
|
||||
}
|
||||
|
||||
/**
|
||||
* testing
|
||||
*/
|
||||
var testmocha = function() {
|
||||
return gulp.src(tests).pipe(new mocha({
|
||||
reporter: 'spec'
|
||||
|
@ -72,64 +60,57 @@ function startGulp(name, opts) {
|
|||
};
|
||||
|
||||
var testkarma = shell.task([
|
||||
buildModulesPath + 'karma/bin/karma start ' + buildPath + 'karma.conf.js'
|
||||
'./node_modules/karma/bin/karma start'
|
||||
]);
|
||||
|
||||
gulp.task('test:node', testmocha);
|
||||
/**
|
||||
* testing
|
||||
*/
|
||||
|
||||
gulp.task('test:node:nofail', function() {
|
||||
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);
|
||||
|
||||
if (browser) {
|
||||
gulp.task('test', function(callback) {
|
||||
runsequence(['test:node'], ['test:browser'], callback);
|
||||
});
|
||||
} else {
|
||||
gulp.task('test', ['test:node']);
|
||||
}
|
||||
|
||||
gulp.task('noop', function() {
|
||||
});
|
||||
|
||||
/**
|
||||
* file generation
|
||||
*/
|
||||
if (browser) {
|
||||
|
||||
var browserifyCommand;
|
||||
|
||||
if (name !== 'lib') {
|
||||
browserifyCommand = buildBinPath + 'browserify --require ./index.js:' + fullname + ' --external bitcore-lib-zcash -o ' + fullname + '.js';
|
||||
} else {
|
||||
browserifyCommand = buildBinPath + 'browserify --require ./index.js:bitcore-lib-zcash -o bitcore-lib-zcash.js';
|
||||
}
|
||||
|
||||
gulp.task('browser:uncompressed', shell.task([
|
||||
browserifyCommand
|
||||
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(fullname + '.js')
|
||||
return gulp.src('bitcore-' + name + '.js')
|
||||
.pipe(uglify({
|
||||
mangle: true,
|
||||
compress: true
|
||||
}))
|
||||
.pipe(rename(fullname + '.min.js'))
|
||||
.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 ' + buildBinPath + 'browserify -t brfs -o tests.js'
|
||||
'find test/ -type f -name "*.js" | xargs ./node_modules/.bin/browserify -t brfs -o tests.js'
|
||||
]));
|
||||
|
||||
gulp.task('browser', function(callback) {
|
||||
runsequence(['browser:compressed'], callback);
|
||||
runsequence(['browser:compressed'], ['browser:maketests'], callback);
|
||||
});
|
||||
}
|
||||
|
||||
gulp.task('errors', shell.task([
|
||||
'node ./lib/errors/build.js'
|
||||
]));
|
||||
|
||||
|
||||
/**
|
||||
* code quality and documentation
|
||||
|
@ -141,9 +122,9 @@ function startGulp(name, opts) {
|
|||
.pipe(jshint.reporter('default'));
|
||||
});
|
||||
|
||||
gulp.task('plato', shell.task([buildBinPath + 'plato -d report -r -l .jshintrc -t ' + fullname + ' lib']));
|
||||
gulp.task('plato', shell.task(['plato -d report -r -l .jshintrc -t bitcore-' + name + ' lib']));
|
||||
|
||||
gulp.task('coverage', shell.task([buildBinPath + './istanbul cover ' + buildBinPath + '_mocha -- --recursive']));
|
||||
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());
|
||||
|
@ -165,13 +146,17 @@ function startGulp(name, opts) {
|
|||
return gulp.watch(alljs, ['test:node']);
|
||||
});
|
||||
|
||||
if (browser) {
|
||||
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
|
||||
|
@ -185,177 +170,9 @@ function startGulp(name, opts) {
|
|||
return gulp.watch(alljs, ['lint']);
|
||||
});
|
||||
|
||||
if (browser) {
|
||||
gulp.task('watch:browser', function() {
|
||||
return gulp.watch(alljs, ['browser']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Release automation
|
||||
*/
|
||||
|
||||
gulp.task('release:install', function() {
|
||||
return shell.task([
|
||||
'npm install',
|
||||
]);
|
||||
});
|
||||
|
||||
var releaseFiles = ['./package.json'];
|
||||
if (browser) {
|
||||
releaseFiles.push('./bower.json');
|
||||
}
|
||||
|
||||
var bump_version = function(importance) {
|
||||
return gulp.src(releaseFiles)
|
||||
.pipe(bump({
|
||||
type: importance
|
||||
}))
|
||||
.pipe(gulp.dest('./'));
|
||||
};
|
||||
|
||||
var tempBranch = 'releases/' + new Date().getTime() + '-build';
|
||||
gulp.task('release:checkout-releases', function(cb) {
|
||||
git.branch(tempBranch, {
|
||||
args: ''
|
||||
}, function() {
|
||||
git.checkout(tempBranch, {
|
||||
args: ''
|
||||
}, cb);
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('release:cleanup', function(cb) {
|
||||
git.branch(tempBranch, {
|
||||
args: '-D'
|
||||
}, cb);
|
||||
});
|
||||
|
||||
gulp.task('release:checkout-master', function(cb) {
|
||||
git.checkout('master', {
|
||||
args: ''
|
||||
}, cb);
|
||||
});
|
||||
|
||||
gulp.task('release:sign-built-files', shell.task([
|
||||
'gpg --yes --out ' + fullname + '.js.sig --detach-sig ' + fullname + '.js',
|
||||
'gpg --yes --out ' + fullname + '.min.js.sig --detach-sig ' + fullname + '.min.js'
|
||||
]));
|
||||
|
||||
var buildFiles = ['./package.json'];
|
||||
var signatureFiles = [];
|
||||
if (browser) {
|
||||
buildFiles.push(fullname + '.js');
|
||||
buildFiles.push(fullname + '.js.sig');
|
||||
buildFiles.push(fullname + '.min.js');
|
||||
buildFiles.push(fullname + '.min.js.sig');
|
||||
|
||||
buildFiles.push('./bower.json');
|
||||
|
||||
signatureFiles.push(fullname + '.js.sig');
|
||||
signatureFiles.push(fullname + '.min.js.sig');
|
||||
}
|
||||
var addFiles = function() {
|
||||
var pjson = require('../../package.json');
|
||||
return gulp.src(buildFiles)
|
||||
.pipe(git.add({
|
||||
args: '-f'
|
||||
}));
|
||||
};
|
||||
|
||||
var buildCommit = function() {
|
||||
var pjson = require('../../package.json');
|
||||
return gulp.src(buildFiles)
|
||||
.pipe(git.commit('Build: ' + pjson.version, {
|
||||
args: ''
|
||||
}));
|
||||
};
|
||||
|
||||
gulp.task('release:add-signed-files', ['release:sign-built-files'], addFiles);
|
||||
gulp.task('release:add-built-files', addFiles);
|
||||
|
||||
if (browser) {
|
||||
gulp.task('release:build-commit', [
|
||||
'release:add-signed-files'
|
||||
], buildCommit);
|
||||
} else {
|
||||
gulp.task('release:build-commit', [
|
||||
'release:add-built-files'
|
||||
], buildCommit);
|
||||
}
|
||||
|
||||
gulp.task('release:version-commit', function() {
|
||||
var pjson = require('../../package.json');
|
||||
return gulp.src(releaseFiles)
|
||||
.pipe(git.commit('Bump package version to ' + pjson.version, {
|
||||
args: ''
|
||||
}));
|
||||
});
|
||||
|
||||
gulp.task('release:push', function(cb) {
|
||||
git.push('bitpay', 'master', {
|
||||
args: ''
|
||||
}, cb);
|
||||
});
|
||||
|
||||
gulp.task('release:push-tag', function(cb) {
|
||||
var pjson = require('../../package.json');
|
||||
var name = 'v' + pjson.version;
|
||||
git.tag(name, 'Release ' + name, function() {
|
||||
git.push('bitpay', name, cb);
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('release:publish', shell.task([
|
||||
'npm publish'
|
||||
]));
|
||||
|
||||
|
||||
// requires https://hub.github.com/
|
||||
var release = function(importance, cb) {
|
||||
var bumper = 'release:bump:' + importance;
|
||||
return runsequence(
|
||||
// Checkout the release temporal branch
|
||||
'release:checkout-releases',
|
||||
// Run npm install
|
||||
'release:install',
|
||||
// Run tests with gulp test
|
||||
'test',
|
||||
// Update package.json and bower.json
|
||||
bumper,
|
||||
// build browser files
|
||||
browser ? 'browser' : 'noop',
|
||||
// Commit
|
||||
'release:build-commit',
|
||||
// Run git push bitpay $VERSION
|
||||
'release:push-tag',
|
||||
// Run npm publish
|
||||
'release:publish',
|
||||
// Checkout the `master` branch
|
||||
'release:checkout-master',
|
||||
// Bump package.json and bower.json, again
|
||||
bumper,
|
||||
// Version commit with no binary files to master
|
||||
'release:version-commit',
|
||||
// Push to master
|
||||
'release:push',
|
||||
// remove release branch
|
||||
'release:cleanup',
|
||||
cb);
|
||||
};
|
||||
|
||||
['patch', 'minor', 'major'].forEach(function(importance) {
|
||||
gulp.task('release:' + importance, function(cb) {
|
||||
release(importance, cb);
|
||||
});
|
||||
gulp.task('release:bump:' + importance, function() {
|
||||
bump_version(importance);
|
||||
});
|
||||
});
|
||||
gulp.task('release', ['release:patch']);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
module.exports = startGulp;
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
// karma.conf.js
|
||||
module.exports = function(config) {
|
||||
|
||||
config.set({
|
||||
browsers: ['Firefox'],
|
||||
frameworks: ['mocha'],
|
||||
singleRun: true,
|
||||
files: [
|
||||
'./../../tests.js' // project root
|
||||
],
|
||||
plugins: [
|
||||
'karma-mocha',
|
||||
'karma-firefox-launcher'
|
||||
]
|
||||
});
|
||||
|
||||
};
|
46
package.json
46
package.json
|
@ -1,65 +1,37 @@
|
|||
{
|
||||
"name": "bitcore-build-zcash",
|
||||
"version": "0.5.4",
|
||||
"description": "A helper for common tasks to build bitcore-zcash modules'",
|
||||
"name": "gulp-bitcore",
|
||||
"version": "0.2.0",
|
||||
"description": "A helper for common tasks across bitcore modules'",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "gulp test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/str4d/bitcore-build-zcash"
|
||||
"url": "git://github.com/bitpay/gulp-bitcore"
|
||||
},
|
||||
"keywords": [
|
||||
"bitcore"
|
||||
],
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Esteban Ordano",
|
||||
"email": "esteban@bitpay.com"
|
||||
},
|
||||
{
|
||||
"name": "Manuel Araoz",
|
||||
"email": "maraoz@bitpay.com"
|
||||
},
|
||||
{
|
||||
"name": "Braydon Fuller",
|
||||
"email": "braydon@bitpay.com"
|
||||
},
|
||||
{
|
||||
"name": "Yemel Jardi",
|
||||
"email": "yemel@bitpay.com"
|
||||
}
|
||||
],
|
||||
"author": "Esteban Ordano",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/str4d/bitcore-build-zcash/issues"
|
||||
"url": "https://github.com/bitpay/gulp-bitcore/issues"
|
||||
},
|
||||
"homepage": "https://github.com/str4d/bitcore-build-zcash",
|
||||
"homepage": "https://github.com/bitpay/gulp-bitcore",
|
||||
"dependencies": {
|
||||
"brfs": "^1.2.0",
|
||||
"browserify": "~13.1.0",
|
||||
"chai": "~1.10.0",
|
||||
"browserify": "~6.3.3",
|
||||
"gulp": "^3.8.10",
|
||||
"gulp-bump": "^0.1.11",
|
||||
"gulp-coveralls": "^0.1.3",
|
||||
"gulp-git": "^0.5.5",
|
||||
"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",
|
||||
"istanbul": "^0.3.5",
|
||||
"karma": "^0.12.28",
|
||||
"karma-chrome-launcher": "^0.1.8",
|
||||
"karma-detect-browsers": "^2.0.0",
|
||||
"karma-firefox-launcher": "^0.1.4",
|
||||
"karma-mocha": "^0.1.9",
|
||||
"lodash": "^2.4.1",
|
||||
"mocha": "^2.0.1",
|
||||
"plato": "^1.3.0",
|
||||
"run-sequence": "^1.0.2",
|
||||
"zuul": "1.16.3"
|
||||
"run-sequence": "^1.0.2"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue