diff --git a/karma.conf.js b/karma.conf.js index 403dc3899..91b30a31e 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -31,7 +31,7 @@ export default function (config) { }, webpack: { - externals: webpackConfig.externals, + node: webpackConfig.node, module: webpackConfig.module }, diff --git a/package.json b/package.json index 1b986c71d..ee69e7833 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mermaid", - "version": "7.0.13", + "version": "7.0.14", "description": "Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.", "main": "dist/mermaid.core.js", "keywords": [ @@ -24,7 +24,7 @@ "karma": "node -r babel-register node_modules/.bin/karma start karma.conf.js --single-run", "jest": "jest --coverage --runInBand", "test": "yarn lint && yarn karma", - "jison": "gulp jison", + "jison": "node -r babel-register node_modules/.bin/gulp jison", "prepublishOnly": "yarn build && yarn release && yarn test" }, "repository": { diff --git a/src/diagrams/classDiagram/parser/classDiagram.js b/src/diagrams/classDiagram/parser/classDiagram.js index a569f8742..3bf44688a 100644 --- a/src/diagrams/classDiagram/parser/classDiagram.js +++ b/src/diagrams/classDiagram/parser/classDiagram.js @@ -84,22 +84,22 @@ performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* actio var $0 = $$.length - 1; switch (yystate) { case 5: - this.$=$$[$0-1]+$$[$0]; + this.$=$$[$0-1]+$$[$0]; break; case 6: - this.$=$$[$0]; + this.$=$$[$0]; break; case 7: - yy.addRelation($$[$0]); + yy.addRelation($$[$0]); break; case 8: - $$[$0-1].title = yy.cleanupLabel($$[$0]); yy.addRelation($$[$0-1]); + $$[$0-1].title = yy.cleanupLabel($$[$0]); yy.addRelation($$[$0-1]); break; case 12: /*console.log($$[$0-3],JSON.stringify($$[$0-1]));*/yy.addMembers($$[$0-3],$$[$0-1]); break; case 13: - this.$ = [$$[$0]]; + this.$ = [$$[$0]]; break; case 14: $$[$0].push($$[$0-1]);this.$=$$[$0]; @@ -117,28 +117,28 @@ case 18: /*console.log('sep found',$$[$0]);*/ break; case 19: - this.$ = {'id1':$$[$0-2],'id2':$$[$0], relation:$$[$0-1], relationTitle1:'none', relationTitle2:'none'}; + this.$ = {'id1':$$[$0-2],'id2':$$[$0], relation:$$[$0-1], relationTitle1:'none', relationTitle2:'none'}; break; case 20: this.$ = {id1:$$[$0-3], id2:$$[$0], relation:$$[$0-1], relationTitle1:$$[$0-2], relationTitle2:'none'} break; case 21: - this.$ = {id1:$$[$0-3], id2:$$[$0], relation:$$[$0-2], relationTitle1:'none', relationTitle2:$$[$0-1]}; + this.$ = {id1:$$[$0-3], id2:$$[$0], relation:$$[$0-2], relationTitle1:'none', relationTitle2:$$[$0-1]}; break; case 22: - this.$ = {id1:$$[$0-4], id2:$$[$0], relation:$$[$0-2], relationTitle1:$$[$0-3], relationTitle2:$$[$0-1]} + this.$ = {id1:$$[$0-4], id2:$$[$0], relation:$$[$0-2], relationTitle1:$$[$0-3], relationTitle2:$$[$0-1]} break; case 23: - this.$={type1:$$[$0-2],type2:$$[$0],lineType:$$[$0-1]}; + this.$={type1:$$[$0-2],type2:$$[$0],lineType:$$[$0-1]}; break; case 24: - this.$={type1:'none',type2:$$[$0],lineType:$$[$0-1]}; + this.$={type1:'none',type2:$$[$0],lineType:$$[$0-1]}; break; case 25: - this.$={type1:$$[$0-1],type2:'none',lineType:$$[$0]}; + this.$={type1:$$[$0-1],type2:'none',lineType:$$[$0]}; break; case 26: - this.$={type1:'none',type2:'none',lineType:$$[$0]}; + this.$={type1:'none',type2:'none',lineType:$$[$0]}; break; case 27: this.$=yy.relationType.AGGREGATION; @@ -731,14 +731,14 @@ exports.parser = parser; exports.Parser = parser.Parser; exports.parse = function () { return parser.parse.apply(parser, arguments); }; exports.main = function commonjsMain(args) { - // if (!args[1]) { - // console.log('Usage: '+args[0]+' FILE'); - // process.exit(1); - // } - // var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); - // return exports.parser.parse(source); + if (!args[1]) { + console.log('Usage: '+args[0]+' FILE'); + process.exit(1); + } + var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); + return exports.parser.parse(source); }; if (typeof module !== 'undefined' && require.main === module) { exports.main(process.argv.slice(1)); } -} +} \ No newline at end of file diff --git a/src/diagrams/example/parser/example.js b/src/diagrams/example/parser/example.js index 1be7baf59..b20104feb 100644 --- a/src/diagrams/example/parser/example.js +++ b/src/diagrams/example/parser/example.js @@ -84,19 +84,19 @@ performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* actio var $0 = $$.length - 1; switch (yystate) { case 1: - return yy; + return yy; break; case 4: - + break; case 6: - yy.setInfo(true); + yy.setInfo(true); break; case 7: - yy.setMessage($$[$0]); + yy.setMessage($$[$0]); break; case 8: - this.$ = $$[$0-1].substring(1).trim().replace(/\\n/gm, "\n"); + this.$ = $$[$0-1].substring(1).trim().replace(/\\n/gm, "\n"); break; } }, @@ -621,14 +621,14 @@ exports.parser = parser; exports.Parser = parser.Parser; exports.parse = function () { return parser.parse.apply(parser, arguments); }; exports.main = function commonjsMain(args) { - // if (!args[1]) { - // console.log('Usage: '+args[0]+' FILE'); - // process.exit(1); - // } - // var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); - // return exports.parser.parse(source); + if (!args[1]) { + console.log('Usage: '+args[0]+' FILE'); + process.exit(1); + } + var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); + return exports.parser.parse(source); }; if (typeof module !== 'undefined' && require.main === module) { exports.main(process.argv.slice(1)); } -} +} \ No newline at end of file diff --git a/src/diagrams/flowchart/parser/dot.js b/src/diagrams/flowchart/parser/dot.js index 3b2ee295c..652fc3f4b 100644 --- a/src/diagrams/flowchart/parser/dot.js +++ b/src/diagrams/flowchart/parser/dot.js @@ -119,12 +119,12 @@ case 42: yy.addLink($$[$0-1],$$[$0].id,$$[$0].op); this.$={op:$$[$0-2],id:$$[$0-1]}; - + break; case 44: this.$={op:$$[$0-1],id:$$[$0]}; - + break; case 48: yy.addVertex($$[$0-1]);this.$=$$[$0-1]; @@ -731,14 +731,14 @@ exports.parser = parser; exports.Parser = parser.Parser; exports.parse = function () { return parser.parse.apply(parser, arguments); }; exports.main = function commonjsMain(args) { - // if (!args[1]) { - // console.log('Usage: '+args[0]+' FILE'); - // process.exit(1); - // } - // var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); - // return exports.parser.parse(source); + if (!args[1]) { + console.log('Usage: '+args[0]+' FILE'); + process.exit(1); + } + var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); + return exports.parser.parse(source); }; if (typeof module !== 'undefined' && require.main === module) { exports.main(process.argv.slice(1)); } -} +} \ No newline at end of file diff --git a/src/diagrams/flowchart/parser/flow.js b/src/diagrams/flowchart/parser/flow.js index cea85c398..5c7e37dd9 100644 --- a/src/diagrams/flowchart/parser/flow.js +++ b/src/diagrams/flowchart/parser/flow.js @@ -952,14 +952,14 @@ exports.parser = parser; exports.Parser = parser.Parser; exports.parse = function () { return parser.parse.apply(parser, arguments); }; exports.main = function commonjsMain(args) { - // if (!args[1]) { - // console.log('Usage: '+args[0]+' FILE'); - // process.exit(1); - // } - // var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); - // return exports.parser.parse(source); + if (!args[1]) { + console.log('Usage: '+args[0]+' FILE'); + process.exit(1); + } + var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); + return exports.parser.parse(source); }; if (typeof module !== 'undefined' && require.main === module) { exports.main(process.argv.slice(1)); } -} +} \ No newline at end of file diff --git a/src/diagrams/gantt/parser/gantt.js b/src/diagrams/gantt/parser/gantt.js index 1ab47bfd6..909f01f8d 100644 --- a/src/diagrams/gantt/parser/gantt.js +++ b/src/diagrams/gantt/parser/gantt.js @@ -84,16 +84,16 @@ performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* actio var $0 = $$.length - 1; switch (yystate) { case 1: - return $$[$0-1]; + return $$[$0-1]; break; case 2: - this.$ = [] + this.$ = [] break; case 3: $$[$0-1].push($$[$0]);this.$ = $$[$0-1] break; case 4: case 5: - this.$ = $$[$0] + this.$ = $$[$0] break; case 6: case 7: this.$=[]; @@ -647,14 +647,14 @@ exports.parser = parser; exports.Parser = parser.Parser; exports.parse = function () { return parser.parse.apply(parser, arguments); }; exports.main = function commonjsMain(args) { - // if (!args[1]) { - // console.log('Usage: '+args[0]+' FILE'); - // process.exit(1); - // } - // var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); - // return exports.parser.parse(source); + if (!args[1]) { + console.log('Usage: '+args[0]+' FILE'); + process.exit(1); + } + var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); + return exports.parser.parse(source); }; if (typeof module !== 'undefined' && require.main === module) { exports.main(process.argv.slice(1)); } -} +} \ No newline at end of file diff --git a/src/diagrams/gitGraph/parser/gitGraph.js b/src/diagrams/gitGraph/parser/gitGraph.js index ae105f45e..30c60b898 100644 --- a/src/diagrams/gitGraph/parser/gitGraph.js +++ b/src/diagrams/gitGraph/parser/gitGraph.js @@ -84,7 +84,7 @@ performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* actio var $0 = $$.length - 1; switch (yystate) { case 1: - return $$[$0-1]; + return $$[$0-1]; break; case 2: yy.setDirection($$[$0-3]); return $$[$0-1]; @@ -126,7 +126,7 @@ case 17: this.$=$$[$0] break; case 18: -this.$ = $$[$0-1]+ ":" + $$[$0] +this.$ = $$[$0-1]+ ":" + $$[$0] break; case 19: this.$ = $$[$0-1]+ ":" + yy.count; yy.count = 0 @@ -135,7 +135,7 @@ case 20: yy.count = 0 break; case 21: - yy.count += 1 + yy.count += 1 break; } }, @@ -687,14 +687,14 @@ exports.parser = parser; exports.Parser = parser.Parser; exports.parse = function () { return parser.parse.apply(parser, arguments); }; exports.main = function commonjsMain(args) { - // if (!args[1]) { - // console.log('Usage: '+args[0]+' FILE'); - // process.exit(1); - // } - // var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); - // return exports.parser.parse(source); + if (!args[1]) { + console.log('Usage: '+args[0]+' FILE'); + process.exit(1); + } + var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); + return exports.parser.parse(source); }; if (typeof module !== 'undefined' && require.main === module) { exports.main(process.argv.slice(1)); } -} +} \ No newline at end of file diff --git a/src/diagrams/sequenceDiagram/parser/sequenceDiagram.js b/src/diagrams/sequenceDiagram/parser/sequenceDiagram.js index c366e8aad..38e32aec2 100644 --- a/src/diagrams/sequenceDiagram/parser/sequenceDiagram.js +++ b/src/diagrams/sequenceDiagram/parser/sequenceDiagram.js @@ -84,16 +84,16 @@ performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* actio var $0 = $$.length - 1; switch (yystate) { case 3: - yy.apply($$[$0]);return $$[$0]; + yy.apply($$[$0]);return $$[$0]; break; case 4: - this.$ = [] + this.$ = [] break; case 5: $$[$0-1].push($$[$0]);this.$ = $$[$0-1] break; case 6: case 7: - this.$ = $$[$0] + this.$ = $$[$0] break; case 8: this.$=[]; @@ -149,7 +149,7 @@ case 19: this.$=$$[$0-1]; break; case 21: - this.$ = $$[$0-3].concat([{type: 'and', parText:$$[$0-1], signalType: yy.LINETYPE.PAR_AND}, $$[$0]]); + this.$ = $$[$0-3].concat([{type: 'and', parText:$$[$0-1], signalType: yy.LINETYPE.PAR_AND}, $$[$0]]); break; case 22: @@ -164,16 +164,16 @@ case 23: this.$ = [$$[$0-1], {type:'addNote', placement:yy.PLACEMENT.OVER, actor:$$[$0-2].slice(0, 2), text:$$[$0]}]; break; case 26: - this.$ = [$$[$0-2], $$[$0]]; + this.$ = [$$[$0-2], $$[$0]]; break; case 27: - this.$ = $$[$0]; + this.$ = $$[$0]; break; case 28: - this.$ = yy.PLACEMENT.LEFTOF; + this.$ = yy.PLACEMENT.LEFTOF; break; case 29: - this.$ = yy.PLACEMENT.RIGHTOF; + this.$ = yy.PLACEMENT.RIGHTOF; break; case 30: this.$ = [$$[$0-4],$$[$0-1],{type: 'addMessage', from:$$[$0-4].actor, to:$$[$0-1].actor, signalType:$$[$0-3], msg:$$[$0]}, @@ -192,22 +192,22 @@ case 33: this.$={type: 'addActor', actor:$$[$0]} break; case 34: - this.$ = yy.LINETYPE.SOLID_OPEN; + this.$ = yy.LINETYPE.SOLID_OPEN; break; case 35: - this.$ = yy.LINETYPE.DOTTED_OPEN; + this.$ = yy.LINETYPE.DOTTED_OPEN; break; case 36: - this.$ = yy.LINETYPE.SOLID; + this.$ = yy.LINETYPE.SOLID; break; case 37: - this.$ = yy.LINETYPE.DOTTED; + this.$ = yy.LINETYPE.DOTTED; break; case 38: - this.$ = yy.LINETYPE.SOLID_CROSS; + this.$ = yy.LINETYPE.SOLID_CROSS; break; case 39: - this.$ = yy.LINETYPE.DOTTED_CROSS; + this.$ = yy.LINETYPE.DOTTED_CROSS; break; case 40: this.$ = $$[$0].substring(1).trim().replace(/\\n/gm, "\n"); @@ -708,27 +708,27 @@ case 3:/* skip comments */ break; case 4:/* skip comments */ break; -case 5: this.begin('ID'); return 10; +case 5: this.begin('ID'); return 10; break; -case 6: this.begin('ALIAS'); return 39; +case 6: this.begin('ALIAS'); return 39; break; -case 7: this.popState(); this.popState(); this.begin('LINE'); return 12; +case 7: this.popState(); this.popState(); this.begin('LINE'); return 12; break; -case 8: this.popState(); this.popState(); return 5; +case 8: this.popState(); this.popState(); return 5; break; -case 9: this.begin('LINE'); return 20; +case 9: this.begin('LINE'); return 20; break; -case 10: this.begin('LINE'); return 22; +case 10: this.begin('LINE'); return 22; break; -case 11: this.begin('LINE'); return 23; +case 11: this.begin('LINE'); return 23; break; -case 12: this.begin('LINE'); return 24; +case 12: this.begin('LINE'); return 24; break; -case 13: this.begin('LINE'); return 25; +case 13: this.begin('LINE'); return 25; break; -case 14: this.begin('LINE'); return 27; +case 14: this.begin('LINE'); return 27; break; -case 15: this.popState(); return 13; +case 15: this.popState(); return 13; break; case 16:return 21; break; @@ -740,9 +740,9 @@ case 19:return 30; break; case 20:return 28; break; -case 21: this.begin('ID'); return 15; +case 21: this.begin('ID'); return 15; break; -case 22: this.begin('ID'); return 16; +case 22: this.begin('ID'); return 16; break; case 23:return 18; break; @@ -752,7 +752,7 @@ case 25:return 33; break; case 26:return 5; break; -case 27: yy_.yytext = yy_.yytext.trim(); return 39; +case 27: yy_.yytext = yy_.yytext.trim(); return 39; break; case 28:return 42; break; @@ -797,14 +797,14 @@ exports.parser = parser; exports.Parser = parser.Parser; exports.parse = function () { return parser.parse.apply(parser, arguments); }; exports.main = function commonjsMain(args) { - // if (!args[1]) { - // console.log('Usage: '+args[0]+' FILE'); - // process.exit(1); - // } - // var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); - // return exports.parser.parse(source); + if (!args[1]) { + console.log('Usage: '+args[0]+' FILE'); + process.exit(1); + } + var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); + return exports.parser.parse(source); }; if (typeof module !== 'undefined' && require.main === module) { exports.main(process.argv.slice(1)); } -} +} \ No newline at end of file diff --git a/todo.md b/todo.md index a4ae803bc..1dcaa5ded 100644 --- a/todo.md +++ b/todo.md @@ -9,6 +9,7 @@ - Get familar with jison - git graph requires a blank line at the end. why? - Move cli to mermaid-cli project ? + - think about it - Remove 'lodash' as dependency - https://github.com/lodash/babel-plugin-lodash - https://www.npmjs.com/package/lodash-webpack-plugin @@ -22,5 +23,4 @@ - Generate them into system temp folder instead - Replace phantomjs with Chrome headless - `yarn jest` is disabled -- Don't manually change jison generated files - - Removed 'fs' dependency from it +- Travis build failed diff --git a/webpack.config.base.js b/webpack.config.base.js index 546db70d8..23b90a038 100644 --- a/webpack.config.base.js +++ b/webpack.config.base.js @@ -16,6 +16,9 @@ export const jsConfig = () => { entry: { mermaid: './src/mermaid.js' }, + node: { + fs: 'empty' // jison generated code requires 'fs' + }, output: { path: path.join(__dirname, './dist/'), filename: '[name].js',