2014-11-03 00:02:29 +01:00
|
|
|
var gulp = require('gulp');
|
2014-12-01 20:50:58 +01:00
|
|
|
var path = require('path');
|
2014-11-03 00:02:29 +01:00
|
|
|
var jison = require('gulp-jison');
|
2014-12-01 20:50:58 +01:00
|
|
|
var less = require('gulp-less');
|
2014-11-13 19:51:05 +01:00
|
|
|
var shell = require('gulp-shell');
|
|
|
|
var concat = require('gulp-concat');
|
|
|
|
var uglify = require('gulp-uglify');
|
|
|
|
var extReplace = require('gulp-ext-replace');
|
2014-11-21 08:03:43 +01:00
|
|
|
var rename = require('gulp-rename');
|
2014-11-27 18:21:15 +01:00
|
|
|
var istanbul = require('gulp-istanbul');
|
2014-12-03 19:29:44 +01:00
|
|
|
var bump = require('gulp-bump');
|
|
|
|
var tag_version = require('gulp-tag-version');
|
2014-12-10 07:17:07 +01:00
|
|
|
var jshint = require('gulp-jshint');
|
|
|
|
var stylish = require('jshint-stylish');
|
|
|
|
|
|
|
|
var paths = {
|
|
|
|
scripts: ['./src/*.js']
|
|
|
|
};
|
2014-11-03 00:02:29 +01:00
|
|
|
|
2014-11-11 08:12:03 +01:00
|
|
|
gulp.task('jison2', function() {
|
2014-11-03 00:02:29 +01:00
|
|
|
return gulp.src('./src/*.jison')
|
|
|
|
.pipe(jison({ moduleType: 'amd' }))
|
2014-12-04 17:58:05 +01:00
|
|
|
.pipe(gulp.dest('./src/parser'));
|
2014-11-03 00:02:29 +01:00
|
|
|
});
|
|
|
|
|
2014-11-11 08:12:03 +01:00
|
|
|
gulp.task('jison', shell.task([
|
2014-12-04 17:58:05 +01:00
|
|
|
'jison src/parser/flow.jison -o src/parser/flow.js',
|
|
|
|
'jison src/parser/dot.jison -o src/parser/dot.js',
|
|
|
|
'jison src/parser/js-sequence-diagram.jison -o src/parser/sequenceDiagram.js'
|
2014-11-19 19:29:55 +01:00
|
|
|
//'source scripts/compileJison.sh'
|
|
|
|
// 'jison src/parser/flow.jison -o src/parser/flow.js',
|
2014-12-04 17:58:05 +01:00
|
|
|
]));
|
2014-11-12 07:35:44 +01:00
|
|
|
|
2014-11-20 20:46:51 +01:00
|
|
|
gulp.task('jisonSd', shell.task([
|
|
|
|
//'jison src/parser/flow.jison -o src/parser/flow.js',
|
|
|
|
'jison src/parser/sequence.jison -o src/parser/sequence.js'
|
|
|
|
//'source scripts/compileFlow.sh'
|
|
|
|
]));
|
2014-11-13 19:51:05 +01:00
|
|
|
|
2014-12-03 19:29:44 +01:00
|
|
|
gulp.task('dist', ['slimDist', 'fullDist','jasmine']);
|
2014-11-21 08:03:43 +01:00
|
|
|
|
|
|
|
var jasmine = require('gulp-jasmine');
|
|
|
|
|
2014-11-25 18:58:47 +01:00
|
|
|
gulp.task('jasmine',['jison'], function () {
|
2014-11-24 22:03:32 +01:00
|
|
|
return gulp.src(['src/**/*.spec.js'])
|
2014-11-21 08:03:43 +01:00
|
|
|
.pipe(jasmine());
|
|
|
|
});
|
|
|
|
|
2014-11-27 18:21:15 +01:00
|
|
|
gulp.task('coverage', function (cb) {
|
|
|
|
gulp.src(['src/**/*.js', '!src/**/*.spec.js'])
|
|
|
|
.pipe(istanbul()) // Covering files
|
|
|
|
.on('finish', function () {
|
|
|
|
gulp.src(['src/**/*.spec.js'])
|
|
|
|
.pipe(jasmine())
|
|
|
|
.pipe(istanbul.writeReports()) // Creating the reports after tests runned
|
|
|
|
.on('end', cb);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-12-01 20:50:58 +01:00
|
|
|
gulp.task('less', function () {
|
|
|
|
gulp.src(['./editor/css/editor.less'])
|
|
|
|
.pipe(less({
|
|
|
|
generateSourceMap: false, // default true
|
|
|
|
paths: [ path.join(__dirname, 'less', 'includes') ]
|
|
|
|
}))
|
|
|
|
.pipe(concat('editor.css'))
|
|
|
|
.pipe(gulp.dest('./editor/css/'));
|
|
|
|
});
|
|
|
|
|
2014-11-21 08:03:43 +01:00
|
|
|
var browserify = require('gulp-browserify');
|
|
|
|
|
|
|
|
// Basic usage
|
|
|
|
gulp.task('slimDist', function() {
|
|
|
|
// Single entry point to browserify
|
|
|
|
return gulp.src('src/main.js')
|
|
|
|
.pipe(browserify())
|
|
|
|
.pipe(rename('mermaid.slim.js'))
|
2014-11-13 19:51:05 +01:00
|
|
|
.pipe(gulp.dest('./dist/'))
|
|
|
|
.pipe(uglify())
|
|
|
|
.pipe(extReplace('.min.js'))
|
|
|
|
.pipe(gulp.dest('./dist/'));
|
|
|
|
});
|
|
|
|
|
2014-12-01 20:50:58 +01:00
|
|
|
|
|
|
|
// Build editor
|
|
|
|
gulp.task('editor', function() {
|
|
|
|
/*gulp.src(['src/editor.js'])
|
|
|
|
.pipe(browserify())
|
|
|
|
.pipe(concat('main.js'))
|
|
|
|
.pipe(gulp.dest('./editor/'));*/
|
|
|
|
return gulp.src(['node_modules/d3/d3.min.js','node_modules/dagre-d3/dist/dagre-d3.min.js','dist/mermaid.slim.js','src/editor.js'])
|
|
|
|
.pipe(concat('build.js'))
|
|
|
|
.pipe(gulp.dest('./editor/'));
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2014-11-21 08:03:43 +01:00
|
|
|
// Basic usage
|
|
|
|
gulp.task('fullDist', ['slimDist'], function() {
|
|
|
|
// Single entry point to browserify
|
|
|
|
gulp.src(['node_modules/d3/d3.min.js','node_modules/dagre-d3/dist/dagre-d3.min.js','dist/mermaid.slim.js'])
|
2014-11-13 19:51:05 +01:00
|
|
|
.pipe(concat('mermaid.full.js'))
|
2014-11-21 08:03:43 +01:00
|
|
|
.pipe(gulp.dest('./dist/'));
|
|
|
|
return gulp.src(['node_modules/d3/d3.min.js','node_modules/dagre-d3/dist/dagre-d3.min.js','dist/mermaid.slim.min.js'])
|
2014-11-13 19:51:05 +01:00
|
|
|
.pipe(concat('mermaid.full.min.js'))
|
2014-11-21 08:03:43 +01:00
|
|
|
.pipe(gulp.dest('./dist/'));
|
2014-12-02 18:36:16 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
// Basic usage
|
|
|
|
gulp.task('npmDist', ['slimDist'], function() {
|
|
|
|
// Single entry point to browserify
|
|
|
|
return gulp.src('src/main.js')
|
|
|
|
.pipe(browserify())
|
|
|
|
.pipe(gulp.dest('./dist/'));
|
2014-12-03 19:29:44 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('bump', function(){
|
|
|
|
gulp.src('./bw.json')
|
|
|
|
.pipe(bump({key: "version"}))
|
|
|
|
.pipe(gulp.dest('./'));
|
|
|
|
});
|
|
|
|
|
|
|
|
// Assuming there's "version: 1.2.3" in package.json,
|
|
|
|
// tag the last commit as "v1.2.3"//
|
|
|
|
gulp.task('tag', function() {
|
|
|
|
return gulp.src(['./package.json']).pipe(tag_version());
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Bumping version number and tagging the repository with it.
|
|
|
|
* Please read http://semver.org/
|
|
|
|
*
|
|
|
|
* You can use the commands
|
|
|
|
*
|
|
|
|
* gulp patch # makes v0.1.0 → v0.1.1
|
|
|
|
* gulp feature # makes v0.1.1 → v0.2.0
|
|
|
|
* gulp release # makes v0.2.1 → v1.0.0
|
|
|
|
*
|
|
|
|
* To bump the version numbers accordingly after you did a patch,
|
|
|
|
* introduced a feature or made a backwards-incompatible release.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function inc(importance) {
|
|
|
|
// get all the files to bump version in
|
|
|
|
return gulp.src(['./package.json', './bower.json'])
|
|
|
|
// bump the version number in those files
|
|
|
|
.pipe(bump({type: importance}))
|
|
|
|
// save it back to filesystem
|
2014-12-03 19:35:00 +01:00
|
|
|
.pipe(gulp.dest('./'));
|
2014-12-03 19:29:44 +01:00
|
|
|
// commit the changed version number
|
2014-12-03 19:35:00 +01:00
|
|
|
//.pipe(git.commit('bumps package version'))
|
2014-12-03 19:29:44 +01:00
|
|
|
|
|
|
|
// read only one file to get the version number
|
2014-12-03 19:35:00 +01:00
|
|
|
//.pipe(filter('package.json'))
|
2014-12-03 19:29:44 +01:00
|
|
|
// **tag it in the repository**
|
2014-12-03 19:35:00 +01:00
|
|
|
//.pipe(tag_version());
|
2014-12-03 19:29:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
gulp.task('patch', function() { return inc('patch'); })
|
|
|
|
gulp.task('feature', function() { return inc('minor'); })
|
2014-12-10 07:17:07 +01:00
|
|
|
gulp.task('release', function() { return inc('major'); })
|
|
|
|
|
|
|
|
// Using gulp-jshint and jshint-stylish
|
|
|
|
gulp.task('lint', function() {
|
|
|
|
return gulp.src(paths.scripts)
|
|
|
|
.pipe(jshint())
|
|
|
|
.pipe(jshint.reporter(stylish));
|
|
|
|
});
|