[TASK] Add flow tasks to Gulpfile

This commit is contained in:
Chris Clark
2015-01-07 10:01:06 -08:00
parent c0c8db6dcc
commit 3fc2d3c1d9
5 changed files with 77 additions and 10 deletions

7
.flowconfig Normal file
View File

@@ -0,0 +1,7 @@
[ignore]
[include]
[libs]
[options]

3
.gitignore vendored
View File

@@ -53,3 +53,6 @@ npm-debug.log
# Ignore dist folder, build for bower
dist/
# Ignore flow output directory
out/

View File

@@ -1,4 +1,9 @@
var gulp = require('gulp');
var gutil = require('gulp-util');
var watch = require('gulp-watch');
var plumber = require('gulp-plumber');
var filelog = require('gulp-filelog');
var cleanDest = require('gulp-clean-dest');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
@@ -6,6 +11,8 @@ var webpack = require('webpack');
var jshint = require('gulp-jshint');
var map = require('map-stream');
var bump = require('gulp-bump');
var react = require('gulp-react');
var flow = require('gulp-flowtype');
var argv = require('yargs').argv;
//var header = require('gulp-header');
@@ -50,6 +57,10 @@ var sjclSrc = [
'src/js/sjcl-custom/sjcl-jacobi.js'
];
function logPluginError(error) {
gutil.log(error.toString());
}
gulp.task('concat-sjcl', function() {
return gulp.src(sjclSrc)
.pipe(concat('sjcl.js'))
@@ -183,6 +194,25 @@ gulp.task('watch', function() {
gulp.watch('src/js/ripple/*', [ 'build-debug' ]);
});
// To use this, each javascript file must have /* @flow */ on the first line
gulp.task('typecheck', function() {
return gulp.src('src/js/ripple/*.js')
.pipe(flow({ // note: do not set the 'all' option, it is broken
weak: true, // remove this after all errors are addressed
killFlow: true
}));
});
gulp.task('strip', function() {
return gulp.src('src/js/ripple/*.js')
.pipe(watch('src/js/ripple/*.js'))
.pipe(cleanDest('out')) // delete outdated output file before stripping
.pipe(plumber()) // prevent an error in one file from ending build
.pipe(react({ stripTypes: true }).on('error', logPluginError))
.pipe(filelog())
.pipe(gulp.dest('out'));
});
gulp.task('version-bump', function() {
if (!argv.type) {
throw new Error("No type found, pass it in using the --type argument");

20
docs/BUILD.md Normal file
View File

@@ -0,0 +1,20 @@
Using Flow typechecking
=======================
Stage 1
-------
1. Add /* @flow */ to the top of a file you want to typecheck
2. Run `gulp typecheck` to generate a list of warnings
Stage 2
-------
When all source files have the /* @flow */ header and all warnings have been
addressed, remove the `weak: true` option from Gulpfile.js, run
`gulp typecheck` and remove all the additional warnings.
Stage 3
-------
Add type annotations to the source code and run `gulp strip` to strip
the type annotations and write the output to the `out` directory. After
type annotations are added, the program must be run from the `out` directory
because Node does not understand the annotations

View File

@@ -23,18 +23,25 @@
"ripple-wallet-generator": "1.0.1"
},
"devDependencies": {
"mocha": "~1.14.0",
"gulp": "~3.6.2",
"gulp-concat": "~2.2.0",
"gulp-jshint": "~1.5.5",
"gulp-uglify": "~0.3.0",
"gulp-rename": "~1.2.0",
"gulp-bump": "~0.1.10",
"webpack": "~1.1.11",
"map-stream": "~0.1.0",
"istanbul": "~0.2.10",
"coveralls": "~2.10.0",
"gulp": "~3.6.2",
"gulp-bump": "~0.1.10",
"gulp-clean-dest": "^0.1.0",
"gulp-concat": "~2.2.0",
"gulp-filelog": "^0.4.1",
"gulp-flowtype": "^0.4.1",
"gulp-jshint": "~1.5.5",
"gulp-plumber": "^0.6.6",
"gulp-react": "^2.0.0",
"gulp-rename": "~1.2.0",
"gulp-uglify": "~0.3.0",
"gulp-util": "^3.0.2",
"gulp-watch": "^3.0.0",
"istanbul": "~0.2.10",
"map-stream": "~0.1.0",
"mocha": "~1.14.0",
"nock": "^0.34.1",
"webpack": "~1.1.11",
"yargs": "~1.3.1"
},
"scripts": {