-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Render function as mentioned in issue #146, only works in browser con…
…text Updated build scripts New way for bundling content in dist, tobe tested, currently to be considered beta
- Loading branch information
Showing
35 changed files
with
104,262 additions
and
14,743 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
5,488 changes: 2,928 additions & 2,560 deletions
5,488
dist/mermaid.full.js → dist/mermaid-legacy.slim.js
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
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
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,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']); |
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,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' | ||
])); | ||
|
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,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']); |
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,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'); }) |
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,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); | ||
}); | ||
}); |
Oops, something went wrong.