forked from bitpay/bitcore-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
162 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,7 @@ LICENSE.html | |
README.html | ||
examples.html | ||
npm-debug.log | ||
|
||
apiref | ||
bower_components | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Bitcore API Reference | ||
======= | ||
|
||
This site contains the reference docs for the bitcore library. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,113 @@ | ||
var gulp = require('gulp'), | ||
concat = require('gulp-concat'), | ||
path = require('path'), | ||
es = require('event-stream'); | ||
/** | ||
* @file gulpfile.js | ||
* | ||
* Defines tasks that can be run on gulp. | ||
* | ||
* Summary: | ||
* * test - Run tests | ||
* * watch:test - Waits for filesystem changes and runs tests | ||
* | ||
*/ | ||
'use strict'; | ||
|
||
var format = es.through( | ||
function (file) { | ||
if (file.isNull()) return this.emit('data', file); // pass along | ||
if (file.isStream()) return this.emit('error', new Error('Streaming not supported')); | ||
var gulp = require('gulp'); | ||
var browserify = require('gulp-browserify'); | ||
var closureCompiler = require('gulp-closure-compiler'); | ||
var istanbul = require('gulp-istanbul'); | ||
var jsdoc = require('gulp-jsdoc'); | ||
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 tap = require('gulp-tap'); | ||
|
||
//add indentation | ||
var contents = "\t" + file.contents.toString("utf8").split("\n").join("\n\t"); | ||
//add header | ||
contents = ["#", path.basename(file.path), "\n", contents].join(""); | ||
file.contents = new Buffer(contents, "utf8"); | ||
this.emit('data', file); | ||
}); | ||
var files = ['lib/**/*.js']; | ||
var tests = ['test/**/*.js']; | ||
var alljs = files.concat(tests); | ||
var jsdocReadme = 'doc/README.md'; | ||
|
||
gulp.task('examples', function () { | ||
//concat .js files from ./examples folder into ./examples.md | ||
return gulp.src("./examples/*.js").pipe(format).pipe(concat('examples.md')).pipe(gulp.dest('./')); | ||
function ignoreError() { | ||
/* jshint ignore:start */ // using `this` in this context is weird | ||
this.emit('end'); | ||
/* jshint ignore:end */ | ||
} | ||
|
||
function testMocha() { | ||
return gulp.src(tests).pipe(new mocha({reporter: 'spec'})); | ||
} | ||
|
||
gulp.task('test', testMocha); | ||
|
||
gulp.task('test-nofail', function() { | ||
return testMocha().on('error', ignoreError); | ||
}); | ||
|
||
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-nofail']); | ||
}); | ||
|
||
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('coverage', function() { | ||
gulp.src(files) | ||
.pipe(istanbul()) | ||
.pipe(tap(function(f) { | ||
// Make sure all files are loaded to get accurate coverage data | ||
require(f.path); | ||
})) | ||
.on('end', testMocha.pipe( | ||
istanbul.writeReports('coverage') | ||
)); | ||
}); | ||
|
||
gulp.task('jsdoc', function() { | ||
return gulp.src(files.concat([jsdocReadme])) | ||
.pipe(jsdoc.parser()) | ||
.pipe(jsdoc.generator('./apiref', { | ||
path: 'ink-docstrap', | ||
theme: 'flatly', | ||
})); | ||
}); | ||
|
||
gulp.task('default', ["examples"]); | ||
gulp.task('lint', function() { | ||
return gulp.src(alljs) | ||
.pipe(jshint()) | ||
.pipe(jshint.reporter('default')); | ||
}); | ||
|
||
gulp.task('browser', function() { | ||
return gulp.src('index.js') | ||
.pipe(browserify({ | ||
insertGlobals: true | ||
})) | ||
.pipe(rename('bitcore.js')) | ||
.pipe(gulp.dest('browser')); | ||
}); | ||
|
||
gulp.task('browser-test', function() { | ||
return shell('find test/ -type f -name "*.js" | xargs browserify -o browser/tests.js'); | ||
}); | ||
|
||
gulp.task('minify', function() { | ||
return gulp.src('dist/bitcore.js') | ||
.pipe(closureCompiler({ | ||
fileName: 'bitcore.min.js', | ||
compilerPath: 'node_modules/closure-compiler-jar/compiler.jar', | ||
compilerFlags: { | ||
language_in: 'ECMASCRIPT5', | ||
jscomp_off: 'suspiciousCode' | ||
} | ||
})) | ||
.pipe(gulp.dest('dist')); | ||
}); | ||
|
||
gulp.task('default', function(callback) { | ||
return runSequence(['lint', 'jsdoc', 'browser', 'test'], ['coverage', 'minify'], callback); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,14 +5,20 @@ | |
"author": "BitPay <[email protected]>", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha --recursive --reporter spec", | ||
"coverage": "istanbul cover _mocha -- --recursive" | ||
"lint": "gulp lint", | ||
"test": "gulp test", | ||
"coverage": "gulp coverage", | ||
"build": "gulp" | ||
}, | ||
"contributors": [ | ||
{ | ||
"name": "Daniel Cousens", | ||
"email": "[email protected]" | ||
}, | ||
{ | ||
"name": "Esteban Ordano", | ||
"email": "[email protected]" | ||
}, | ||
{ | ||
"name": "Gordon Hall", | ||
"email": "[email protected]" | ||
|
@@ -74,12 +80,25 @@ | |
"devDependencies": { | ||
"browserify": "~6.3.3", | ||
"chai": "~1.10.0", | ||
"closure-compiler-jar": "git://github.com/eordano/closure-compiler-jar.git", | ||
"grunt": "^0.4.5", | ||
"grunt-contrib-watch": "^0.6.1", | ||
"grunt-markdown": "^0.6.1", | ||
"grunt-shell": "^1.1.1", | ||
"lodash": "=2.4.1", | ||
"mocha": "~2.0.1" | ||
"gulp": "^3.8.10", | ||
"gulp-browserify": "^0.5.0", | ||
"gulp-closure-compiler": "^0.2.9", | ||
"gulp-insert": "^0.4.0", | ||
"gulp-istanbul": "^0.4.0", | ||
"gulp-jsdoc": "^0.1.4", | ||
"gulp-jshint": "^1.9.0", | ||
"gulp-mocha": "^2.0.0", | ||
"gulp-rename": "^1.2.0", | ||
"gulp-shell": "^0.2.10", | ||
"gulp-tap": "^0.1.3", | ||
"lodash": "^2.4.1", | ||
"mocha": "~2.0.1", | ||
"run-sequence": "^1.0.2" | ||
}, | ||
"license": "MIT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.