mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
Merge branch 'no-bloat'
This commit is contained in:
commit
df7dc21893
@ -46,8 +46,8 @@
|
|||||||
"dagre-layout": "^0.8.8",
|
"dagre-layout": "^0.8.8",
|
||||||
"graphlibrary": "^2.2.0",
|
"graphlibrary": "^2.2.0",
|
||||||
"he": "^1.2.0",
|
"he": "^1.2.0",
|
||||||
"lodash": "^4.17.11",
|
"lodash": "^4.17.5",
|
||||||
"moment": "^2.23.0",
|
"moment-mini": "^2.22.1",
|
||||||
"scope-css": "^1.2.1"
|
"scope-css": "^1.2.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -70,6 +70,7 @@
|
|||||||
"jest-image-snapshot": "^2.8.2",
|
"jest-image-snapshot": "^2.8.2",
|
||||||
"jest-puppeteer": "^4.2.0",
|
"jest-puppeteer": "^4.2.0",
|
||||||
"jison": "^0.4.18",
|
"jison": "^0.4.18",
|
||||||
|
"moment": "^2.23.0",
|
||||||
"node-sass": "^4.11.0",
|
"node-sass": "^4.11.0",
|
||||||
"puppeteer": "^1.17.0",
|
"puppeteer": "^1.17.0",
|
||||||
"sass-loader": "^7.1.0",
|
"sass-loader": "^7.1.0",
|
||||||
@ -81,8 +82,7 @@
|
|||||||
"yarn-upgrade-all": "^0.5.0"
|
"yarn-upgrade-all": "^0.5.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist",
|
"dist"
|
||||||
"src"
|
|
||||||
],
|
],
|
||||||
"yarn-upgrade-all": {
|
"yarn-upgrade-all": {
|
||||||
"ignore": [
|
"ignore": [
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import moment from 'moment'
|
import moment from 'moment-mini'
|
||||||
import { logger } from '../../logger'
|
import { logger } from '../../logger'
|
||||||
|
|
||||||
let dateFormat = ''
|
let dateFormat = ''
|
||||||
|
@ -155,9 +155,9 @@ function prettyPrintCommitHistory (commitArr) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
const label = [line, commit.id, commit.seq]
|
const label = [line, commit.id, commit.seq]
|
||||||
_.each(branches, function (value, key) {
|
for (let branch in branches) {
|
||||||
if (value === commit.id) label.push(key)
|
if (branches[branch] === commit.id) label.push(branch)
|
||||||
})
|
}
|
||||||
logger.debug(label.join(' '))
|
logger.debug(label.join(' '))
|
||||||
if (Array.isArray(commit.parent)) {
|
if (Array.isArray(commit.parent)) {
|
||||||
const newCommit = commits[commit.parent[0]]
|
const newCommit = commits[commit.parent[0]]
|
||||||
@ -188,9 +188,10 @@ export const clear = function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const getBranchesAsObjArray = function () {
|
export const getBranchesAsObjArray = function () {
|
||||||
const branchArr = _.map(branches, function (value, key) {
|
const branchArr = []
|
||||||
return { 'name': key, 'commit': commits[value] }
|
for (let branch in branches) {
|
||||||
})
|
branchArr.push({ name: branch, commit: commits[branches[branch]] })
|
||||||
|
}
|
||||||
return branchArr
|
return branchArr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import _ from 'lodash'
|
|
||||||
import * as d3 from 'd3'
|
import * as d3 from 'd3'
|
||||||
|
import _ from 'lodash'
|
||||||
|
|
||||||
import db from './gitGraphAst'
|
import db from './gitGraphAst'
|
||||||
import gitGraphParser from './parser/gitGraph'
|
import gitGraphParser from './parser/gitGraph'
|
||||||
@ -160,7 +160,7 @@ function cloneNode (svg, selector) {
|
|||||||
function renderCommitHistory (svg, commitid, branches, direction) {
|
function renderCommitHistory (svg, commitid, branches, direction) {
|
||||||
let commit
|
let commit
|
||||||
const numCommits = Object.keys(allCommitsDict).length
|
const numCommits = Object.keys(allCommitsDict).length
|
||||||
if (_.isString(commitid)) {
|
if (typeof commitid === 'string') {
|
||||||
do {
|
do {
|
||||||
commit = allCommitsDict[commitid]
|
commit = allCommitsDict[commitid]
|
||||||
logger.debug('in renderCommitHistory', commit.id, commit.seq)
|
logger.debug('in renderCommitHistory', commit.id, commit.seq)
|
||||||
@ -189,7 +189,13 @@ function renderCommitHistory (svg, commitid, branches, direction) {
|
|||||||
.attr('stroke', config.nodeStrokeColor)
|
.attr('stroke', config.nodeStrokeColor)
|
||||||
.attr('stroke-width', config.nodeStrokeWidth)
|
.attr('stroke-width', config.nodeStrokeWidth)
|
||||||
|
|
||||||
const branch = _.find(branches, ['commit', commit])
|
let branch
|
||||||
|
for (let branchName in branches) {
|
||||||
|
if (branches[branchName].commit === commit) {
|
||||||
|
branch = branches[branchName]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
if (branch) {
|
if (branch) {
|
||||||
logger.debug('found branch ', branch.name)
|
logger.debug('found branch ', branch.name)
|
||||||
svg.select('#node-' + commit.id + ' p')
|
svg.select('#node-' + commit.id + ' p')
|
||||||
@ -211,7 +217,7 @@ function renderCommitHistory (svg, commitid, branches, direction) {
|
|||||||
} while (commitid && allCommitsDict[commitid])
|
} while (commitid && allCommitsDict[commitid])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_.isArray(commitid)) {
|
if (Array.isArray(commitid)) {
|
||||||
logger.debug('found merge commmit', commitid)
|
logger.debug('found merge commmit', commitid)
|
||||||
renderCommitHistory(svg, commitid[0], branches, direction)
|
renderCommitHistory(svg, commitid[0], branches, direction)
|
||||||
branchNum++
|
branchNum++
|
||||||
@ -223,11 +229,11 @@ function renderCommitHistory (svg, commitid, branches, direction) {
|
|||||||
function renderLines (svg, commit, direction, branchColor) {
|
function renderLines (svg, commit, direction, branchColor) {
|
||||||
branchColor = branchColor || 0
|
branchColor = branchColor || 0
|
||||||
while (commit.seq > 0 && !commit.lineDrawn) {
|
while (commit.seq > 0 && !commit.lineDrawn) {
|
||||||
if (_.isString(commit.parent)) {
|
if (typeof commit.parent === 'string') {
|
||||||
svgDrawLineForCommits(svg, commit.id, commit.parent, direction, branchColor)
|
svgDrawLineForCommits(svg, commit.id, commit.parent, direction, branchColor)
|
||||||
commit.lineDrawn = true
|
commit.lineDrawn = true
|
||||||
commit = allCommitsDict[commit.parent]
|
commit = allCommitsDict[commit.parent]
|
||||||
} else if (_.isArray(commit.parent)) {
|
} else if (Array.isArray(commit.parent)) {
|
||||||
svgDrawLineForCommits(svg, commit.id, commit.parent[0], direction, branchColor)
|
svgDrawLineForCommits(svg, commit.id, commit.parent[0], direction, branchColor)
|
||||||
svgDrawLineForCommits(svg, commit.id, commit.parent[1], direction, branchColor + 1)
|
svgDrawLineForCommits(svg, commit.id, commit.parent[1], direction, branchColor + 1)
|
||||||
renderLines(svg, allCommitsDict[commit.parent[1]], direction, branchColor + 1)
|
renderLines(svg, allCommitsDict[commit.parent[1]], direction, branchColor + 1)
|
||||||
@ -246,7 +252,7 @@ export const draw = function (txt, id, ver) {
|
|||||||
// Parse the graph definition
|
// Parse the graph definition
|
||||||
parser.parse(txt + '\n')
|
parser.parse(txt + '\n')
|
||||||
|
|
||||||
config = _.extend(config, apiConfig, db.getOptions())
|
config = _.assign(config, apiConfig, db.getOptions())
|
||||||
logger.debug('effective options', config)
|
logger.debug('effective options', config)
|
||||||
const direction = db.getDirection()
|
const direction = db.getDirection()
|
||||||
allCommitsDict = db.getCommits()
|
allCommitsDict = db.getCommits()
|
||||||
@ -259,11 +265,12 @@ export const draw = function (txt, id, ver) {
|
|||||||
const svg = d3.select(`[id="${id}"]`)
|
const svg = d3.select(`[id="${id}"]`)
|
||||||
svgCreateDefs(svg)
|
svgCreateDefs(svg)
|
||||||
branchNum = 1
|
branchNum = 1
|
||||||
_.each(branches, function (v) {
|
for (let branch in branches) {
|
||||||
|
const v = branches[branch]
|
||||||
renderCommitHistory(svg, v.commit.id, branches, direction)
|
renderCommitHistory(svg, v.commit.id, branches, direction)
|
||||||
renderLines(svg, v.commit, direction)
|
renderLines(svg, v.commit, direction)
|
||||||
branchNum++
|
branchNum++
|
||||||
})
|
}
|
||||||
svg.attr('height', function () {
|
svg.attr('height', function () {
|
||||||
if (direction === 'BT') return Object.keys(allCommitsDict).length * config.nodeSpacing
|
if (direction === 'BT') return Object.keys(allCommitsDict).length * config.nodeSpacing
|
||||||
return (branches.length + 1) * config.branchOffset
|
return (branches.length + 1) * config.branchOffset
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import moment from 'moment'
|
import moment from 'moment-mini'
|
||||||
|
|
||||||
export const LEVELS = {
|
export const LEVELS = {
|
||||||
debug: 1,
|
debug: 1,
|
||||||
|
11
yarn.lock
11
yarn.lock
@ -6407,10 +6407,15 @@ mkdirp@0.5.1, mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdi
|
|||||||
dependencies:
|
dependencies:
|
||||||
minimist "0.0.8"
|
minimist "0.0.8"
|
||||||
|
|
||||||
|
moment-mini@^2.22.1:
|
||||||
|
version "2.22.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/moment-mini/-/moment-mini-2.22.1.tgz#bc32d73e43a4505070be6b53494b17623183420d"
|
||||||
|
integrity sha512-OUCkHOz7ehtNMYuZjNciXUfwTuz8vmF1MTbAy59ebf+ZBYZO5/tZKuChVWCX+uDo+4idJBpGltNfV8st+HwsGw==
|
||||||
|
|
||||||
moment@^2.23.0:
|
moment@^2.23.0:
|
||||||
version "2.23.0"
|
version "2.24.0"
|
||||||
resolved "https://registry.yarnpkg.com/moment/-/moment-2.23.0.tgz#759ea491ac97d54bac5ad776996e2a58cc1bc225"
|
resolved "https://registry.yarnpkg.com/moment/-/moment-2.24.0.tgz#0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b"
|
||||||
integrity sha512-3IE39bHVqFbWWaPOMHZF98Q9c3LDKGTmypMiTM2QygGXXElkFWIH7GxfmlwmY2vwa+wmNsoYZmG2iusf1ZjJoA==
|
integrity sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==
|
||||||
|
|
||||||
move-concurrently@^1.0.1:
|
move-concurrently@^1.0.1:
|
||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user