Skip to content

Commit

Permalink
Render function as mentioned in issue #146, only works in browser con…
Browse files Browse the repository at this point in the history
…text

Updated build scripts
New way for bundling content in dist, tobe tested, currently to be considered beta
  • Loading branch information
knsv committed May 26, 2015
1 parent 05f3982 commit b4a96c9
Show file tree
Hide file tree
Showing 35 changed files with 104,262 additions and 14,743 deletions.
22,343 changes: 22,343 additions & 0 deletions dist/mermaid-legacy.full.js

Large diffs are not rendered by default.

5,488 changes: 2,928 additions & 2,560 deletions dist/mermaid.full.js → dist/mermaid-legacy.slim.js

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions dist/mermaid-legacy.slim.min.js

Large diffs are not rendered by default.

45 changes: 0 additions & 45 deletions dist/mermaid.full.min.js

This file was deleted.

22,309 changes: 22,309 additions & 0 deletions dist/mermaid.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions dist/mermaid.min.js

Large diffs are not rendered by default.

14,985 changes: 3,078 additions & 11,907 deletions dist/mermaid.slim.js

Large diffs are not rendered by default.

21 changes: 8 additions & 13 deletions dist/mermaid.slim.min.js

Large diffs are not rendered by default.

31,033 changes: 31,033 additions & 0 deletions dist/mermaidAPI.js

Large diffs are not rendered by default.

21,818 changes: 21,818 additions & 0 deletions dist/mermaidAPI.slim.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions dist/mermaidAPI.slim.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion editor/css/editor.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "/bower_components/lesshat/build/lesshat";
@import "./bower_components/lesshat/build/lesshat";
@import (reference) "settings";

body {
Expand Down
139 changes: 139 additions & 0 deletions gulp/tasks/dist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
var gulp = require('gulp');
var browserify = require('gulp-browserify');
var shell = require('gulp-shell');


var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var extReplace = require('gulp-ext-replace');
var rename = require('gulp-rename');
var istanbul = require('gulp-istanbul');
var insert = require('gulp-insert');

/**
* dist targets
* * dist - creates everything
* * mermaidAPI
* * mermaidAPI.slim
* * legacy - uses old build creates mermaid.full and mermaid.slim
* * mermaid - new build creates mermaid.js and mermaid.min.js, mermaid.no-d3.js mermaid.no-d3.min.js
*/

// Basic usage
gulp.task('slimDist', function() {
// Single entry point to browserify
return gulp.src('src/main.js')
.pipe(browserify())
/*.pipe(browserify({standalone: 'mermaid'}))
.on('prebundle', function(bundle) {
// Keep these external for the slim version.
slim_ext_libs.forEach(function(lib) {
bundle.external(lib);
});
})*/
.pipe(rename('mermaid-legacy.slim.js'))
.pipe(insert.prepend('(function () { var define = undefined; '))
.pipe(insert.append(' })();'))
.pipe(gulp.dest('./dist/'))
.pipe(uglify())
.pipe(extReplace('.min.js'))
.pipe(gulp.dest('./dist/'));
});

// 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'])
.pipe(concat('mermaid-legacy.full.js'))
.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'])
.pipe(concat('mermaid.full.min.js'))
.pipe(gulp.dest('./dist/'));
});


// Basic usage
//gulp.task('api', shell.task([
// 'browserify src/mermaid.js | uglify > dist/mermaid.min.js',
// 'browserify src/mermaid.js | uglify > dist/mermaid.min.js',
// 'browserify src/mermaidAPI.js -o dist/mermaidAPI.js'
// //'jison src/diagrams/sequenceDiagram/parser/sequenceDiagram.jison -o src/diagrams/sequenceDiagram/parser/sequenceDiagram.js'
//]));

// Basic usage
gulp.task('mermaid',['mermaidAPI','mermaidAPI.slim'],function() {
// Single entry point to browserify
var EXTERNALS = ['d3'];

gulp.src('src/mermaid.js')
.pipe(browserify({
external: ['d3'],
entry:'src/mermaid.js'
}))
.pipe(rename('mermaid.slim.js'))
// .on('prebundle', function(bundle){
// EXTERNALS.forEach(function(external){
// if(external.expose){
// bundle.require(external.require, {expose: external.expose} )
// }
// else{
// bundle.require(external.require)
// }
// })
// })
.pipe(gulp.dest('./dist/'))
.pipe(uglify())
.pipe(extReplace('.min.js'))
.pipe(gulp.dest('./dist/'));

return gulp.src('src/mermaid.js')
.pipe(browserify({
external: ['d3'],
entry:'src/mermaid.js'
}))
.pipe(rename('mermaid.js'))
.pipe(gulp.dest('./dist/'))
.pipe(uglify())
.pipe(extReplace('.min.js'))
.pipe(gulp.dest('./dist/'));
});
// Basic usage
gulp.task('mermaidAPI',function() {
return gulp.src('src/mermaidAPI.js')
.pipe(browserify({
}))
.pipe(gulp.dest('./dist/'))
//.pipe(uglify())
//.pipe(extReplace('.min.js'))
//.pipe(gulp.dest('./dist/'));
});

// Basic usage
gulp.task('mermaidAPI.slim',function() {
return gulp.src('src/mermaidAPI.js')
.pipe(browserify({
debug:true,
external: ['d3']
}))
.pipe(rename('mermaidAPI.slim.js'))
.pipe(gulp.dest('./dist/'))
.pipe(uglify())
.pipe(extReplace('.min.js'))
.pipe(gulp.dest('./dist/'));
});

// 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/'));
});

//gulp.task('dist', ['slimDist', 'fullDist','jasmine']);
gulp.task('legacy', ['slimDist', 'fullDist']);

gulp.task('dist', ['mermaidAPI', 'mermaidAPI.slim','legacy','mermaid']);
19 changes: 19 additions & 0 deletions gulp/tasks/jison.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var gulp = require('gulp');
var shell = require('gulp-shell');
var jison = require('gulp-jison');

gulp.task('jison', function() {
return gulp.src('./src/*.jison')
.pipe(jison({ moduleType: 'commonjs' }))
.pipe(gulp.dest('./src/parser'));
});

gulp.task('jison_legacy', shell.task([
'jison src/diagrams/flowchart/parser/flow.jison -o src/diagrams/flowchart/parser/flow.js',
'jison src/diagrams/flowchart/parser/dot.jison -o src/diagrams/flowchart/parser/dot.js',
'jison src/diagrams/sequenceDiagram/parser/sequenceDiagram.jison -o src/diagrams/sequenceDiagram/parser/sequenceDiagram.js',
'jison src/diagrams/example/parser/example.jison -o src/diagrams/example/parser/example.js',
'jison src/diagrams/gantt/parser/gantt.jison -o src/diagrams/gantt/parser/gantt.js',
//'jison src/diagrams/sequenceDiagram/parser/sequenceDiagram.jison -o src/diagrams/sequenceDiagram/parser/sequenceDiagram.js'
]));

35 changes: 35 additions & 0 deletions gulp/tasks/less.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
var gulp = require('gulp');
var path = require('path');
var less = require('gulp-less');
var rename = require('gulp-rename');
var concat = require('gulp-concat');

gulp.task('editor-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/'));
});

gulp.task('mermaid-less', function () {
gulp.src(['./src/less/*/mermaid.less'])
.pipe(less({
generateSourceMap: false, // default true
paths: [ path.join(__dirname, 'less', 'includes') ]
}))
.pipe(rename(function (path) {
if(path.dirname === 'default'){
path.basename = 'mermaid';
}else{
path.basename = 'mermaid.' + path.dirname;
}
path.dirname = '';
}))
.pipe(gulp.dest('./dist/'));
});


gulp.task('less',['mermaid-less', 'editor-less']);
47 changes: 47 additions & 0 deletions gulp/tasks/release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
var gulp = require('gulp');

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
.pipe(gulp.dest('./'));
// commit the changed version number
//.pipe(git.commit('bumps package version'))

// read only one file to get the version number
//.pipe(filter('package.json'))
// **tag it in the repository**
//.pipe(tag_version());
}

gulp.task('patch', function() { return inc('patch'); })
gulp.task('feature', function() { return inc('minor'); })
gulp.task('release', function() { return inc('major'); })
42 changes: 42 additions & 0 deletions gulp/tasks/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
var gulp = require('gulp');
var jasmine = require('gulp-jasmine');
var gulp = require('gulp');
var browserify = require('gulp-browserify');
var shell = require('gulp-shell');
var jison = require('gulp-jison');

var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var extReplace = require('gulp-ext-replace');
var rename = require('gulp-rename');
var istanbul = require('gulp-istanbul');
var insert = require('gulp-insert');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');

// Using gulp-jshint and jshint-stylish
gulp.task('lint', function() {
return gulp.src(['./src/**/*.js', '!**/parser/*.js'])
.pipe(jshint())
.pipe(jshint.reporter(stylish));
});

gulp.task('test',['coverage','tape','jasmine']);

gulp.task('jasmine',['jison','lint'], function () {
return gulp.src(['src/**/*.spec.js'])
.pipe(jasmine({includeStackTrace:true}));
});

gulp.task('tape', shell.task(['./node_modules/.bin/tape ./test/cli_test-*.js']));

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);
});
});
Loading

0 comments on commit b4a96c9

Please sign in to comment.