19 changed files with 162 additions and 133 deletions
@ -1,48 +0,0 @@ |
|||||
'use strict'; |
|
||||
|
|
||||
module.exports = function(grunt) { |
|
||||
|
|
||||
//Load NPM tasks
|
|
||||
grunt.loadNpmTasks('grunt-contrib-watch'); |
|
||||
grunt.loadNpmTasks('grunt-markdown'); |
|
||||
grunt.loadNpmTasks('grunt-shell'); |
|
||||
|
|
||||
// Project Configuration
|
|
||||
grunt.initConfig({ |
|
||||
shell: { |
|
||||
browserify: { |
|
||||
options: { |
|
||||
stdout: true, |
|
||||
stderr: true |
|
||||
}, |
|
||||
command: grunt.option('target') === 'dev' ? |
|
||||
'./browser/build; docco lib/* ' : './browser/build' |
|
||||
} |
|
||||
}, |
|
||||
watch: { |
|
||||
readme: { |
|
||||
files: ['README.md', 'CONTRIBUTING.md'], |
|
||||
tasks: ['markdown'] |
|
||||
}, |
|
||||
scripts: { |
|
||||
files: ['**/*.js', '**/*.html', '!**/node_modules/**', '!browser/bundle.js', '!browser/testdata.js', '!docs/**', '!*.md', '!README.html', '!CONTRIBUTING.html'], |
|
||||
tasks: ['shell'], |
|
||||
}, |
|
||||
}, |
|
||||
markdown: { |
|
||||
all: { |
|
||||
files: [{ |
|
||||
expand: true, |
|
||||
src: '*.md', |
|
||||
dest: '.', |
|
||||
ext: '.html' |
|
||||
}] |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
|
|
||||
}); |
|
||||
|
|
||||
grunt.registerTask('default', ['shell','watch']); |
|
||||
|
|
||||
}; |
|
@ -1,4 +0,0 @@ |
|||||
#!/bin/bash |
|
||||
|
|
||||
browserify index.js -o browser/bitcore.js |
|
||||
find test/ -type f -name "*.js" | xargs browserify -o browser/tests.js |
|
@ -0,0 +1,4 @@ |
|||||
|
Bitcore API Reference |
||||
|
======= |
||||
|
|
||||
|
This site contains the reference docs for the bitcore library. |
@ -1,25 +1,113 @@ |
|||||
var gulp = require('gulp'), |
/** |
||||
concat = require('gulp-concat'), |
* @file gulpfile.js |
||||
path = require('path'), |
* |
||||
es = require('event-stream'); |
* 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( |
var gulp = require('gulp'); |
||||
function (file) { |
var browserify = require('gulp-browserify'); |
||||
if (file.isNull()) return this.emit('data', file); // pass along
|
var closureCompiler = require('gulp-closure-compiler'); |
||||
if (file.isStream()) return this.emit('error', new Error('Streaming not supported')); |
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 files = ['lib/**/*.js']; |
||||
var contents = "\t" + file.contents.toString("utf8").split("\n").join("\n\t"); |
var tests = ['test/**/*.js']; |
||||
//add header
|
var alljs = files.concat(tests); |
||||
contents = ["#", path.basename(file.path), "\n", contents].join(""); |
var jsdocReadme = 'doc/README.md'; |
||||
file.contents = new Buffer(contents, "utf8"); |
|
||||
this.emit('data', file); |
|
||||
}); |
|
||||
|
|
||||
gulp.task('examples', function () { |
function ignoreError() { |
||||
//concat .js files from ./examples folder into ./examples.md
|
/* jshint ignore:start */ // using `this` in this context is weird
|
||||
return gulp.src("./examples/*.js").pipe(format).pipe(concat('examples.md')).pipe(gulp.dest('./')); |
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); |
||||
|
}); |
||||
|
Loading…
Reference in new issue