diff --git a/.commitlintrc.json b/.commitlintrc.json
new file mode 100644
index 0000000000..67b3aa1856
--- /dev/null
+++ b/.commitlintrc.json
@@ -0,0 +1,5 @@
+{
+ "extends": [
+ "@commitlint/config-conventional"
+ ]
+}
\ No newline at end of file
diff --git a/.eslintignore b/.eslintignore
index 7e54e3631c..9d8891de0f 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -1 +1,3 @@
-**/*.spec.js
\ No newline at end of file
+dist/**
+.github/**
+docs/Setup.md
diff --git a/.eslintrc.json b/.eslintrc.json
index b223ac86ce..9c755a0e2b 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -2,19 +2,51 @@
"env": {
"browser": true,
"es6": true,
+ "jest/globals": true,
"node": true
},
"parser": "@babel/eslint-parser",
"parserOptions": {
- "ecmaFeatures": {
- "experimentalObjectRestSpread": true,
- "jsx": true
- },
- "sourceType": "module"
+ "ecmaFeatures": {
+ "experimentalObjectRestSpread": true,
+ "jsx": true
+ },
+ "sourceType": "module"
},
- "extends": ["prettier", "eslint:recommended"],
- "plugins": ["prettier"],
+ "extends": [
+ "eslint:recommended",
+ "plugin:jsdoc/recommended",
+ "plugin:json/recommended",
+ "plugin:markdown/recommended",
+ "plugin:prettier/recommended"
+ ],
+ "plugins": ["html", "jest", "jsdoc", "json", "prettier"],
"rules": {
- "prettier/prettier": ["error"]
- }
+ "no-prototype-builtins": "off",
+ "no-unused-vars": "off",
+ "jsdoc/check-indentation": "off",
+ "jsdoc/check-alignment": "off",
+ "jsdoc/check-line-alignment": "off",
+ "jsdoc/multiline-blocks": "off",
+ "jsdoc/newline-after-description": "off",
+ "jsdoc/tag-lines": "off",
+ "cypress/no-async-tests": "off",
+ "json/*": ["error", "allowComments"],
+ "no-empty": ["error", { "allowEmptyCatch": true }]
+ },
+ "overrides": [
+ {
+ "files": "./**/*.html",
+ "rules": {
+ "no-undef": "off",
+ "jsdoc/require-jsdoc": "off"
+ }
+ },
+ {
+ "files": "./**/*.md/*.html",
+ "rules": {
+ "prettier/prettier": "off"
+ }
+ }
+ ]
}
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000000..176a458f94
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+* text=auto
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index 74e02e6cb8..f8e453bd3a 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -24,7 +24,7 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.
**Code Sample**
-If applicable, add the code sample or a link to the [live editor](https://mermaid-js.github.io/mermaid-live-editor).
+If applicable, add the code sample or a link to the [live editor](https://mermaid.live).
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml
new file mode 100644
index 0000000000..66909e1dfe
--- /dev/null
+++ b/.github/codeql/codeql-config.yml
@@ -0,0 +1,4 @@
+name: "CodeQL config"
+paths-ignore:
+ - dist
+ - cypress
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index c5b27177d4..9de58cc4f9 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -1,12 +1,17 @@
version: 2
updates:
- package-ecosystem: npm
+ open-pull-requests-limit: 10
directory: /
target-branch: develop
schedule:
interval: weekly
+ day: monday
+ time: "07:00"
- package-ecosystem: github-actions
directory: /
target-branch: develop
schedule:
interval: weekly
+ day: monday
+ time: "07:00"
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index d1ae7edec7..2514aac48f 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -8,6 +8,6 @@ Describe the way your implementation works or what design decisions you made if
### :clipboard: Tasks
Make sure you
-- [ ] :book: have read the [contribution guidelines](https://github.com/mermaid-js/mermaid/blob/develop/CONTRIBUTING.md)
-- [ ] :computer: have added unit/e2e tests (if appropriate)
-- [ ] :bookmark: targeted `develop` branch
+- [ ] :book: have read the [contribution guidelines](https://github.com/mermaid-js/mermaid/blob/develop/CONTRIBUTING.md)
+- [ ] :computer: have added unit/e2e tests (if appropriate)
+- [ ] :bookmark: targeted `develop` branch
diff --git a/.github/stale.yml b/.github/stale.yml
index 761f26cb99..0a784cd769 100644
--- a/.github/stale.yml
+++ b/.github/stale.yml
@@ -15,5 +15,5 @@ markComment: >
If you are still interested in this issue and it is still relevant you can comment to revive it.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: >
- This issue has been been automatically closed due to a lack of activity.
- This is done to maintain a clean list of issues that the community is interested in developing.
+ This issue has been been automatically closed due to a lack of activity.
+ This is done to maintain a clean list of issues that the community is interested in developing.
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index a530e188ce..72495c4e91 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -1,6 +1,15 @@
name: Build
-on: [push, pull_request]
+on:
+ push: {}
+ pull_request:
+ types:
+ - opened
+ - synchronize
+ - ready_for_review
+
+permissions:
+ contents: read
jobs:
build:
@@ -9,10 +18,10 @@ jobs:
matrix:
node-version: [16.x]
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
- name: Setup Node.js ${{ matrix.node-version }}
- uses: actions/setup-node@v2
+ uses: actions/setup-node@v3
with:
cache: yarn
node-version: ${{ matrix.node-version }}
@@ -30,29 +39,7 @@ jobs:
run: yarn build
- name: Upload Build as Artifact
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v3
with:
name: dist
path: dist
-
- - name: Run Unit Tests
- run: |
- yarn test --coverage
-
- #- name: Upload Test Results
- # uses: coverallsapp/github-action@v1.0.1
- # with:
- # github-token: ${{ secrets.GITHUB_TOKEN }}
- # parallel: true
-
- # - name: Run E2E Tests
- # run: yarn e2e
- # env:
- # PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
- # CYPRESS_CACHE_FOLDER: .cache/Cypress
-
- #- name: Post Upload Test Results
- # uses: coverallsapp/github-action@master
- # with:
- # github-token: ${{ secrets.GITHUB_TOKEN }}
- # parallel-finished: true
diff --git a/.github/workflows/check-readme-in-sync.yml b/.github/workflows/check-readme-in-sync.yml
new file mode 100644
index 0000000000..13912e5b9f
--- /dev/null
+++ b/.github/workflows/check-readme-in-sync.yml
@@ -0,0 +1,35 @@
+# Reference: https://github.com/Yash-Singh1/eslint-plugin-userscripts/blob/main/.github/workflows/readme-in-sync.yml
+
+name: Check if README and docs/README are in sync
+
+on:
+ push:
+ branches:
+ - gh-pages
+ pull_request:
+ branches:
+ - gh-pages
+
+permissions:
+ contents: read
+
+jobs:
+ check:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v3
+
+ - name: Check for difference in README.md and docs/README.md
+ run: |
+ if [ -z "$(diff README.md docs/README.md --brief)" ]
+ then
+ echo "README.md and docs/README.md are in sync"
+ else
+ echo "Make sure that README.md and docs/README.md are in sync"
+ echo
+ echo "Difference:"
+ echo
+ diff README.md docs/README.md -u
+ exit 1
+ fi
diff --git a/.github/workflows/checks b/.github/workflows/checks.yml
similarity index 62%
rename from .github/workflows/checks
rename to .github/workflows/checks.yml
index bc60f59777..c434e03a67 100644
--- a/.github/workflows/checks
+++ b/.github/workflows/checks.yml
@@ -1,4 +1,10 @@
-on: [push]
+on:
+ push: {}
+ pull_request:
+ types:
+ - opened
+ - synchronize
+ - ready_for_review
name: Static analysis
@@ -6,6 +12,7 @@ jobs:
test:
runs-on: ubuntu-latest
name: check tests
+ if: github.repository_owner == 'mermaid'
steps:
- uses: actions/checkout@v2
with:
@@ -13,7 +20,6 @@ jobs:
- uses: testomatio/check-tests@stable
with:
framework: cypress
- tests: "./cypress/integration/**/**.spec.js"
+ tests: "./cypress/e2e/**/**.spec.js"
token: ${{ secrets.GITHUB_TOKEN }}
has-tests-label: true
-
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
new file mode 100644
index 0000000000..2db07ad77a
--- /dev/null
+++ b/.github/workflows/codeql.yml
@@ -0,0 +1,63 @@
+
+name: "CodeQL"
+
+on:
+ push:
+ branches: [ develop ]
+ pull_request:
+ # The branches below must be a subset of the branches above
+ branches: [ develop ]
+ types:
+ - opened
+ - synchronize
+ - ready_for_review
+
+jobs:
+ analyze:
+ name: Analyze
+ runs-on: ubuntu-latest
+ permissions:
+ actions: read
+ contents: read
+ security-events: write
+
+ strategy:
+ fail-fast: false
+ matrix:
+ language: [ 'javascript' ]
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
+ # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v3
+
+ # Initializes the CodeQL tools for scanning.
+ - name: Initialize CodeQL
+ uses: github/codeql-action/init@v2
+ with:
+ config-file: ./.github/codeql/codeql-config.yml
+ languages: ${{ matrix.language }}
+ # If you wish to specify custom queries, you can do so here or in a config file.
+ # By default, queries listed here will override any specified in a config file.
+ # Prefix the list here with "+" to use these queries and those in the config file.
+ # queries: ./path/to/local/query, your-org/your-repo/queries@main
+
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
+ # If this step fails, then you should remove it and run the build manually (see below)
+ - name: Autobuild
+ uses: github/codeql-action/autobuild@v2
+
+ # âšī¸ Command-line programs to run using the OS shell.
+ # đ See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
+
+ # âī¸ If the Autobuild fails above, remove it and uncomment the following three lines
+ # and modify them (or add more) to build your code if your project
+ # uses a compiled language
+
+ #- run: |
+ # make bootstrap
+ # make release
+
+ - name: Perform CodeQL Analysis
+ uses: github/codeql-action/analyze@v2
diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml
new file mode 100644
index 0000000000..845c763e8c
--- /dev/null
+++ b/.github/workflows/dependency-review.yml
@@ -0,0 +1,20 @@
+# Dependency Review Action
+#
+# This Action will scan dependency manifest files that change as part of a Pull Reqest, surfacing known-vulnerable versions of the packages declared or updated in the PR. Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable packages will be blocked from merging.
+#
+# Source repository: https://github.com/actions/dependency-review-action
+# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement
+name: 'Dependency Review'
+on: [pull_request]
+
+permissions:
+ contents: read
+
+jobs:
+ dependency-review:
+ runs-on: ubuntu-latest
+ steps:
+ - name: 'Checkout Repository'
+ uses: actions/checkout@v3
+ - name: 'Dependency Review'
+ uses: actions/dependency-review-action@v2
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e
similarity index 54%
rename from .github/workflows/e2e.yml
rename to .github/workflows/e2e
index 0a01f30390..5b716e429e 100644
--- a/.github/workflows/e2e.yml
+++ b/.github/workflows/e2e
@@ -2,6 +2,9 @@ name: E2E
on: [push, pull_request]
+permissions:
+ contents: read
+
jobs:
build:
runs-on: ubuntu-latest
@@ -9,10 +12,10 @@ jobs:
matrix:
node-version: [16.x]
steps:
- - uses: actions/checkout@v2.3.4
+ - uses: actions/checkout@v3
- name: Setup Node.js ${{ matrix.node-version }}
- uses: actions/setup-node@v2
+ uses: actions/setup-node@v3
with:
cache: yarn
node-version: ${{ matrix.node-version }}
@@ -29,24 +32,7 @@ jobs:
- name: Run Build
run: yarn build
- # - name: Run e2e Tests
- # run: |
- # yarn e2e
-
- #- name: Upload Test Results
- # uses: coverallsapp/github-action@v1.0.1
- # with:
- # github-token: ${{ secrets.GITHUB_TOKEN }}
- # parallel: true
-
- name: Run E2E Tests
run: yarn e2e
env:
- PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
CYPRESS_CACHE_FOLDER: .cache/Cypress
-
- #- name: Post Upload Test Results
- # uses: coverallsapp/github-action@master
- # with:
- # github-token: ${{ secrets.GITHUB_TOKEN }}
- # parallel-finished: true
diff --git a/.github/workflows/issue-triage.yml b/.github/workflows/issue-triage.yml
index 46cbd91b8c..3dbcf94b06 100644
--- a/.github/workflows/issue-triage.yml
+++ b/.github/workflows/issue-triage.yml
@@ -8,7 +8,7 @@ jobs:
triage:
runs-on: ubuntu-latest
steps:
- - uses: andymckay/labeler@1.0.3
+ - uses: andymckay/labeler@1.0.4
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
add-labels: "Status: Triage"
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
new file mode 100644
index 0000000000..050667a8f8
--- /dev/null
+++ b/.github/workflows/lint.yml
@@ -0,0 +1,39 @@
+name: Lint
+
+on:
+ push: {}
+ pull_request:
+ types:
+ - opened
+ - synchronize
+ - ready_for_review
+
+permissions:
+ contents: read
+
+jobs:
+ lint:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ node-version: [16.x]
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: Setup Node.js ${{ matrix.node-version }}
+ uses: actions/setup-node@v3
+ with:
+ cache: yarn
+ node-version: ${{ matrix.node-version }}
+
+ - name: Install Yarn
+ run: npm i yarn --global
+
+ - name: Install Packages
+ run: |
+ yarn install --frozen-lockfile
+ env:
+ CYPRESS_CACHE_FOLDER: .cache/Cypress
+
+ - name: Run Linting
+ run: yarn lint
diff --git a/.github/workflows/lock-closed-issue.yml b/.github/workflows/lock-closed-issue.yml
deleted file mode 100644
index 11c3f35ddc..0000000000
--- a/.github/workflows/lock-closed-issue.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-name: Lock closed issue
-
-on:
- issues:
- types: [closed]
-
-jobs:
- triage:
- runs-on: ubuntu-latest
- steps:
- - uses: Dunning-Kruger/lock-issues@v1.1
- with:
- repo-token: "${{ secrets.GITHUB_TOKEN }}"
diff --git a/.github/workflows/pr-labeler-config-validator.yml b/.github/workflows/pr-labeler-config-validator.yml
new file mode 100644
index 0000000000..af5c477d64
--- /dev/null
+++ b/.github/workflows/pr-labeler-config-validator.yml
@@ -0,0 +1,19 @@
+name: Validate PR Labeler Configuration
+on:
+ push: {}
+ pull_request:
+ types:
+ - opened
+ - synchronize
+ - ready_for_review
+
+jobs:
+ pr-labeler:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout Repository
+ uses: actions/checkout@v3
+ - name: Validate Configuration
+ uses: Yash-Singh1/pr-labeler-config-validator@releases/v0.0.3
+ with:
+ configuration-path: .github/pr-labeler.yml
diff --git a/.github/workflows/release-preview-publish.yml b/.github/workflows/release-preview-publish.yml
index 8136ff8bd8..70e9b42c08 100644
--- a/.github/workflows/release-preview-publish.yml
+++ b/.github/workflows/release-preview-publish.yml
@@ -9,9 +9,9 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
- name: Setup Node.js
- uses: actions/setup-node@v2
+ uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Install Yarn
diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml
index 62382a882a..4a14ee74eb 100644
--- a/.github/workflows/release-publish.yml
+++ b/.github/workflows/release-publish.yml
@@ -8,11 +8,11 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2.3.4
+ - uses: actions/checkout@v3
- uses: fregante/setup-git-user@v1
- name: Setup Node.js
- uses: actions/setup-node@v2
+ uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Install Yarn
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000000..c91f286bc8
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,34 @@
+name: Unit Tests
+
+on: [push, pull_request]
+
+permissions:
+ contents: read
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ node-version: [16.x]
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: Setup Node.js ${{ matrix.node-version }}
+ uses: actions/setup-node@v3
+ with:
+ cache: yarn
+ node-version: ${{ matrix.node-version }}
+
+ - name: Install Yarn
+ run: npm i yarn --global
+
+ - name: Install Packages
+ run: |
+ yarn install --frozen-lockfile
+ env:
+ CYPRESS_CACHE_FOLDER: .cache/Cypress
+
+ - name: Run Unit Tests
+ run: |
+ yarn ci --coverage
diff --git a/.github/workflows/unlock-reopened-issues.yml b/.github/workflows/unlock-reopened-issues.yml
index 09469ed8bb..346cd51a6b 100644
--- a/.github/workflows/unlock-reopened-issues.yml
+++ b/.github/workflows/unlock-reopened-issues.yml
@@ -1,6 +1,6 @@
name: Unlock reopened issue
-on:
+on:
issues:
types: [reopened]
diff --git a/.github/workflows/update-browserlist.yml b/.github/workflows/update-browserlist.yml
new file mode 100644
index 0000000000..4155ec988e
--- /dev/null
+++ b/.github/workflows/update-browserlist.yml
@@ -0,0 +1,18 @@
+name: Update Browserslist
+on:
+ schedule:
+ - cron: '0 7 * * 1'
+ workflow_dispatch:
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - run: npx browserslist@latest --update-db
+ - name: Commit changes
+ uses: EndBug/add-and-commit@v9
+ with:
+ author_name: ${{ github.actor }}
+ author_email: ${{ github.actor }}@users.noreply.github.com
+ message: 'chore: update browsers list'
diff --git a/.gitignore b/.gitignore
index efe4e39ac4..8ce4bf724c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,8 +4,7 @@ node_modules/
coverage/
.idea/
-dist/*.js
-dist/*.map
+dist
yarn-error.log
.npmrc
@@ -13,10 +12,6 @@ token
package-lock.json
-dist/classTest.html
-
-dist/sequenceTest.html
-
.vscode/
cypress/platform/current.html
cypress/platform/experimental.html
@@ -25,3 +20,6 @@ local/
_site
Gemfile.lock
/.vs
+
+cypress/screenshots/
+cypress/snapshots/
\ No newline at end of file
diff --git a/.husky/commit-msg b/.husky/commit-msg
new file mode 100755
index 0000000000..59f6536e22
--- /dev/null
+++ b/.husky/commit-msg
@@ -0,0 +1,4 @@
+#!/bin/sh
+# . "$(dirname "$0")/_/husky.sh"
+
+# npx --no-install commitlint --edit $1
diff --git a/.husky/pre-commit b/.husky/pre-commit
new file mode 100755
index 0000000000..025779ed2b
--- /dev/null
+++ b/.husky/pre-commit
@@ -0,0 +1,4 @@
+#!/bin/sh
+. "$(dirname "$0")/_/husky.sh"
+
+yarn pre-commit
diff --git a/.lintstagedrc.json b/.lintstagedrc.json
new file mode 100644
index 0000000000..41d79218a8
--- /dev/null
+++ b/.lintstagedrc.json
@@ -0,0 +1,5 @@
+{
+ "*.{js,json,html,md}": [
+ "yarn lint:fix"
+ ]
+}
\ No newline at end of file
diff --git a/.percy.old.yml b/.percy.old.yml
deleted file mode 100644
index 5499b41f20..0000000000
--- a/.percy.old.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-version: 1
-snapshot:
- widths: [1280]
\ No newline at end of file
diff --git a/.prettierrc b/.prettierrc
deleted file mode 100644
index e9eb8060dd..0000000000
--- a/.prettierrc
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "printWidth": 100,
- "singleQuote": true,
- "endOfLine": "auto"
-}
diff --git a/.prettierrc.json b/.prettierrc.json
new file mode 100644
index 0000000000..8cadfefaf7
--- /dev/null
+++ b/.prettierrc.json
@@ -0,0 +1,8 @@
+{
+ "endOfLine": "auto",
+ "plugins": [
+ "prettier-plugin-jsdoc"
+ ],
+ "printWidth": 100,
+ "singleQuote": true
+}
\ No newline at end of file
diff --git a/.tern-project b/.tern-project
index cf97514117..d8b9e54f9d 100644
--- a/.tern-project
+++ b/.tern-project
@@ -3,12 +3,9 @@
"libs": [
"browser"
],
- "loadEagerly": [
- "path/to/your/js/**/*.js"
- ],
+ "loadEagerly": [],
"dontLoad": [
- "node_modules/**",
- "path/to/your/js/**/*.js"
+ "node_modules/**"
],
"plugins": {
"modules": {},
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 98c9666a96..0000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-dist: trusty
-language: node_js
-node_js:
- - "10"
-cache:
- npm: false
-script:
- - yarn build
- - yarn test --coverage
- - yarn e2e
-after_success:
- - cat ./coverage/lcov.info | ./node_modules/.bin/coveralls
diff --git a/.webpack/loaders/jison.js b/.webpack/loaders/jison.js
new file mode 100644
index 0000000000..0d5ebc7e5b
--- /dev/null
+++ b/.webpack/loaders/jison.js
@@ -0,0 +1,25 @@
+const { Generator } = require('jison');
+const validate = require('schema-utils');
+
+const schema = {
+ title: 'Jison Parser options',
+ type: 'object',
+ properties: {
+ 'token-stack': {
+ type: 'boolean',
+ },
+ debug: {
+ type: 'boolean',
+ },
+ },
+ additionalProperties: false,
+};
+
+module.exports = function jisonLoader(source) {
+ const options = this.getOptions();
+ (validate.validate || validate)(schema, options, {
+ name: 'Jison Loader',
+ baseDataPath: 'options',
+ });
+ return new Generator(source, options).generate();
+};
diff --git a/.webpack/webpack.config.babel.js b/.webpack/webpack.config.babel.js
new file mode 100644
index 0000000000..9dfd834b7e
--- /dev/null
+++ b/.webpack/webpack.config.babel.js
@@ -0,0 +1,45 @@
+import { merge, mergeWithCustomize, customizeObject } from 'webpack-merge';
+import nodeExternals from 'webpack-node-externals';
+import baseConfig from './webpack.config.base';
+
+export default (_env, args) => {
+ switch (args.mode) {
+ case 'development':
+ return [
+ baseConfig,
+ merge(baseConfig, {
+ externals: [nodeExternals()],
+ output: {
+ filename: '[name].core.js',
+ },
+ }),
+ ];
+ case 'production':
+ return [
+ // umd
+ merge(baseConfig, {
+ output: {
+ filename: '[name].min.js',
+ },
+ }),
+ // esm
+ mergeWithCustomize({
+ customizeObject: customizeObject({
+ 'output.library': 'replace',
+ }),
+ })(baseConfig, {
+ experiments: {
+ outputModule: true,
+ },
+ output: {
+ library: {
+ type: 'module',
+ },
+ filename: '[name].esm.min.mjs',
+ },
+ }),
+ ];
+ default:
+ throw new Error('No matching configuration was found!');
+ }
+};
diff --git a/.webpack/webpack.config.base.js b/.webpack/webpack.config.base.js
new file mode 100644
index 0000000000..055f59dfc9
--- /dev/null
+++ b/.webpack/webpack.config.base.js
@@ -0,0 +1,54 @@
+import path from 'path';
+
+export const resolveRoot = (...relativePath) => path.resolve(__dirname, '..', ...relativePath);
+
+export default {
+ amd: false, // https://github.com/lodash/lodash/issues/3052
+ target: 'web',
+ entry: {
+ mermaid: './src/mermaid.js',
+ },
+ resolve: {
+ extensions: ['.wasm', '.mjs', '.js', '.json', '.jison'],
+ fallback: {
+ fs: false, // jison generated code requires 'fs'
+ path: require.resolve('path-browserify'),
+ },
+ },
+ output: {
+ path: resolveRoot('./dist'),
+ filename: '[name].js',
+ library: {
+ name: 'mermaid',
+ type: 'umd',
+ export: 'default',
+ },
+ globalObject: 'typeof self !== "undefined" ? self : this',
+ },
+ module: {
+ rules: [
+ {
+ test: /\.js$/,
+ include: [resolveRoot('./src'), resolveRoot('./node_modules/dagre-d3-renderer/lib')],
+ use: {
+ loader: 'babel-loader',
+ },
+ },
+ {
+ // load scss to string
+ test: /\.scss$/,
+ use: ['css-to-string-loader', 'css-loader', 'sass-loader'],
+ },
+ {
+ test: /\.jison$/,
+ use: {
+ loader: path.resolve(__dirname, './loaders/jison.js'),
+ options: {
+ 'token-stack': true,
+ },
+ },
+ },
+ ],
+ },
+ devtool: 'source-map',
+};
diff --git a/.webpack/webpack.config.e2e.babel.js b/.webpack/webpack.config.e2e.babel.js
new file mode 100644
index 0000000000..3ec2bdcd78
--- /dev/null
+++ b/.webpack/webpack.config.e2e.babel.js
@@ -0,0 +1,37 @@
+import baseConfig, { resolveRoot } from './webpack.config.base';
+import { merge } from 'webpack-merge';
+
+export default merge(baseConfig, {
+ mode: 'development',
+ entry: {
+ mermaid: './src/mermaid.js',
+ e2e: './cypress/platform/viewer.js',
+ 'bundle-test': './cypress/platform/bundle-test.js',
+ },
+ output: {
+ globalObject: 'window',
+ },
+ devServer: {
+ compress: true,
+ port: 9000,
+ static: [
+ { directory: resolveRoot('cypress', 'platform') },
+ { directory: resolveRoot('dist') },
+ { directory: resolveRoot('demos') },
+ ],
+ },
+ externals: {
+ mermaid: 'mermaid',
+ },
+ module: {
+ rules: [
+ {
+ test: /\.js$/,
+ exclude: /node_modules/,
+ use: {
+ loader: 'babel-loader',
+ },
+ },
+ ],
+ },
+});
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dede59be01..e7385b9b77 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,7 +23,7 @@
- Missing fontawesome icon support [\#830](https://github.com/knsv/mermaid/issues/830)
- Docs for integration with wiki.js? [\#829](https://github.com/knsv/mermaid/issues/829)
- Is this project still maintained? [\#826](https://github.com/knsv/mermaid/issues/826)
-- typroa [\#823](https://github.com/knsv/mermaid/issues/823)
+- typora [\#823](https://github.com/knsv/mermaid/issues/823)
- Maintain the order of the nodes in Flowchart [\#815](https://github.com/knsv/mermaid/issues/815)
- Overlap, Overflow and cut titles in flowchart [\#814](https://github.com/knsv/mermaid/issues/814)
- How load mermaidApi notejs electron [\#813](https://github.com/knsv/mermaid/issues/813)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index d719b9523e..9ed0a7eddf 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -2,16 +2,24 @@
So you want to help? That's great!
-![Image of happy people jumping with excitement](https://media.giphy.com/media/BlVnrxJgTGsUw/giphy.gif)
+![Happy people jumping with excitement](https://media.giphy.com/media/BlVnrxJgTGsUw/giphy.gif)
Here are a few things to know to get you started on the right path.
+## Development Installation
+```bash
+git clone git@github.com:mermaid-js/mermaid.git
+cd mermaid
+yarn
+yarn test
+```
+
## Committing code
We make all changes via pull requests. As we have many pull requests from developers new to mermaid, the current approach is to have *knsv, Knut Sveidqvist* as a main reviewer of changes and merging pull requests. More precisely like this:
* Large changes reviewed by knsv or other developer asked to review by knsv
-* Smaller low-risk changes like dependecies, documentation etc can be merged by active collaborators
+* Smaller low-risk changes like dependencies, documentation etc can be merged by active collaborators
* documentation (updates to the docs folder is also allowed via direct commits)
To commit code, create a branch, let it start with the type like feature or bug followed by the issue number for reference and some describing text.
@@ -35,13 +43,13 @@ The documentation is written in Markdown, for more information about Markdown [s
If you want to preview the documentation site on your machine, you need to install `docsify-cli`:
-```
+```sh
$ npm i docsify-cli -g
-````
+```
If you are more familiar with Yarn, you can use the following command:
-```
+```sh
$ yarn global add docsify-cli
```
@@ -50,7 +58,7 @@ If the installation is successful, the command `docsify` will be available in yo
You can now run the following command to serve the documentation site:
-```
+```sh
$ docsify serve docs
```
@@ -76,7 +84,7 @@ This is important so that, if someone else does a change to the grammar that doe
### **Add e2e tests**
-This tests the rendering and visual apearance of the diagram. This ensures that the rendering of that feature in the e2e will be reviewed in the release process going forward. Less chance that it breaks!
+This tests the rendering and visual appearance of the diagram. This ensures that the rendering of that feature in the e2e will be reviewed in the release process going forward. Less chance that it breaks!
To start working with the e2e tests, run `yarn dev` to start the dev server, after that start cypress by running `cypress open` in the mermaid folder. (Make sure you have path to cypress in order, the binary is located in node_modules/.bin).
@@ -85,7 +93,7 @@ The rendering tests are very straightforward to create. There is a function imgS
When running in ci it will take a snapshot of the rendered diagram and compare it with the snapshot from last build and flag for review it if it differs.
This is what a rendering test looks like:
-```
+```javascript
it('should render forks and joins', () => {
imgSnapshotTest(
`
@@ -114,7 +122,7 @@ Finally, if it is not in the documentation, no one will know about it and then *
The docs are located in the docs folder and are ofc written in markdown. Just pick the right section and start typing. If you want to add to the structure as in adding a new section and new file you do that via the _navbar.md.
-The changes in master is reflected in http://mermaid-js.github.io/mermaid/ once released the updates are commited to https://mermaid-js.github.io/#/
+The changes in master is reflected in https://mermaid-js.github.io/mermaid/ once released the updates are committed to https://mermaid-js.github.io/#/
## Last words
@@ -123,4 +131,4 @@ Don't get daunted if it is hard in the beginning. We have a great community with
[Join our slack community if you want closer contact!](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE)
-![Image of superhero wishing you good luck](https://media.giphy.com/media/l49JHz7kJvl6MCj3G/giphy.gif)
+![A superhero wishing you good luck](https://media.giphy.com/media/l49JHz7kJvl6MCj3G/giphy.gif)
diff --git a/README.md b/README.md
index 5868e0bb36..0e49ea4dae 100644
--- a/README.md
+++ b/README.md
@@ -1,64 +1,79 @@
-# mermaid [![Build Status](https://travis-ci.org/mermaid-js/mermaid.svg?branch=master)](https://travis-ci.org/mermaid-js/mermaid) [![NPM](https://img.shields.io/npm/v/mermaid)](https://www.npmjs.com/package/mermaid) [![Coverage Status](https://coveralls.io/repos/github/mermaid-js/mermaid/badge.svg?branch=master)](https://coveralls.io/github/mermaid-js/mermaid?branch=master) [![Join our Slack!](https://img.shields.io/static/v1?message=join%20chat&color=9cf&logo=slack&label=slack)](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) [![This project is using Percy.io for visual regression testing.](https://percy.io/static/images/percy-badge.svg)](https://percy.io/Mermaid/mermaid)
+# mermaid [![Build Status](https://travis-ci.org/mermaid-js/mermaid.svg?branch=master)](https://travis-ci.org/mermaid-js/mermaid) [![NPM](https://img.shields.io/npm/v/mermaid)](https://www.npmjs.com/package/mermaid) [![Coverage Status](https://coveralls.io/repos/github/mermaid-js/mermaid/badge.svg?branch=master)](https://coveralls.io/github/mermaid-js/mermaid?branch=master) [![Join our Slack!](https://img.shields.io/static/v1?message=join%20chat&color=9cf&logo=slack&label=slack)](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE)
-![banner](./img/header.png)
+English | [įŽäŊä¸æ](./README.zh-CN.md)
+
+
:trophy: **Mermaid was nominated and won the [JS Open Source Awards (2019)](https://osawards.com/javascript/2019) in the category "The most exciting use of technology"!!!**
+
+
**Thanks to all involved, people committing pull requests, people answering questions! đ**
-
+
## About
-Mermaid is a Javascript based diagramming and charting tool that uses Markdown-inspired text definitions and a renderer to create and modify complex diagrams. The main purpose of Mermaid is to help documentation catch up with development.
+Mermaid is a JavaScript based diagramming and charting tool that uses Markdown-inspired text definitions and a renderer to create and modify complex diagrams. The main purpose of Mermaid is to help documentation catch up with development.
> Doc-Rot is a Catch-22 that Mermaid helps to solve.
Diagramming and documentation costs precious developer time and gets outdated quickly.
-But not having diagrams or docs ruins productivity and hurts organizational learning.
-Mermaid addresses this problem by cutting the time, effort and tooling that is required to create modifiable diagrams and charts, for smarter and more reusable content.
-The text definitions for Mermaid diagrams allows for it to be updated easily, it can also be made part of production scripts (and other pieces of code).
-So less time needs to be spent on documenting, as a separate and laborious task.
-Even non-programmers can create diagrams through the [Mermaid Live Editor](https://mermaid-js.github.io/mermaid-live-editor/).
+But not having diagrams or docs ruins productivity and hurts organizational learning.
+Mermaid addresses this problem by enabling users to create easily modifiable diagrams, it can also be made part of production scripts (and other pieces of code).
+
+
+Mermaid allows even non-programmers to easily create detailed diagrams through the [Mermaid Live Editor](https://mermaid.live/).
[Tutorials](./docs/Tutorials.md) has video tutorials.
Use Mermaid with your favorite applications, check out the list of [Integrations and Usages of Mermaid](./docs/integrations.md).
-For a more detailed introduction to Mermaid and some of its more basic uses, look to the [Beginner's Guide](./docs/n00b-overview.md) and [Usage](./docs/usage.md).
+You can also use Mermaid within [GitHub](https://github.blog/2022-02-14-include-diagrams-markdown-files-mermaid/) as well many of your other favorite applications, check out the list of [Integrations and Usages of Mermaid](./docs/integrations.md).
+
+For a more detailed introduction to Mermaid and some of its more basic uses, look to the [Beginner's Guide](./docs/n00b-overview.md), [Usage](./docs/usage.md) and [Tutorials](./docs/Tutorials.md).
đ [CDN](https://unpkg.com/mermaid/) | đ [Documentation](https://mermaidjs.github.io) | đ [Contribution](https://github.com/mermaid-js/mermaid/blob/develop/CONTRIBUTING.md) | đ [Changelog](./docs/CHANGELOG.md)
+
+
+In our release process we rely heavily on visual regression tests using [applitools](https://applitools.com/). Applitools is a great service which has been easy to use and integrate with our tests.
+
+
+
+
+
+
+
## Examples
-__The following are some examples of the diagrams, charts and graphs that can be made using Mermaid and the Markdown-inspired text specific to it. Click here jump into the [text syntax](https://mermaid-js.github.io/mermaid/#/n00b-syntaxReference).__
-
- Flow - [docs - live editor] - | |
-graph TD + +### Flowchart [docs - live editor] + +``` +flowchart LR + A[Hard] -->|Text| B(Round) B --> C{Decision} C -->|One| D[Result 1] C -->|Two| E[Result 2] - |
- - - | -
- Sequence - [docs - live editor] - | |
+``` +```mermaid +flowchart LR + +A[Hard] -->|Text| B(Round) +B --> C{Decision} +C -->|One| D[Result 1] +C -->|Two| E[Result 2] +``` + + +### Sequence diagram [docs - live editor] + +``` sequenceDiagram Alice->>John: Hello John, how are you? loop Healthcheck @@ -68,43 +83,48 @@ Note right of John: Rational thoughts! John-->>Alice: Great! John->>Bob: How about you? Bob-->>John: Jolly good! - |
- - - | -
- Gantt - [docs - live editor] - | |
+``` +```mermaid +sequenceDiagram +Alice->>John: Hello John, how are you? +loop Healthcheck + John->>John: Fight against hypochondria +end +Note right of John: Rational thoughts! +John-->>Alice: Great! +John->>Bob: How about you? +Bob-->>John: Jolly good! +``` + +### Gantt chart [docs - live editor] + +``` gantt -section Section -Completed :done, des1, 2014-01-06,2014-01-08 -Active :active, des2, 2014-01-07, 3d -Parallel 1 : des3, after des1, 1d -Parallel 2 : des4, after des1, 1d -Parallel 3 : des5, after des3, 1d -Parallel 4 : des6, after des4, 1d - |
- - - | -
- Class - [docs - live editor] - | |
+ section Section + Completed :done, des1, 2014-01-06,2014-01-08 + Active :active, des2, 2014-01-07, 3d + Parallel 1 : des3, after des1, 1d + Parallel 2 : des4, after des1, 1d + Parallel 3 : des5, after des3, 1d + Parallel 4 : des6, after des4, 1d +``` +```mermaid +gantt + section Section + Completed :done, des1, 2014-01-06,2014-01-08 + Active :active, des2, 2014-01-07, 3d + Parallel 1 : des3, after des1, 1d + Parallel 2 : des4, after des1, 1d + Parallel 3 : des5, after des3, 1d + Parallel 4 : des6, after des4, 1d +``` + +### Class diagram [docs - live editor] + +``` classDiagram -Class01 <|-- AveryLongClass : Cool -<<interface>> Class01 +Class01 <|-- AveryLongClass : Cool +< |
- - - | -
- State - [docs - live editor] - | |
+``` +```mermaid +classDiagram +Class01 <|-- AveryLongClass : Cool +< |
- - - | -
- Pie - [docs - live editor] - | |
+``` + +### Pie chart [docs - live editor] + +``` +pie +"Dogs" : 386 +"Cats" : 85.9 +"Rats" : 15 +``` +```mermaid pie "Dogs" : 386 -"Cats" : 85 +"Cats" : 85.9 "Rats" : 15 - |
- - - | -
- Git - [experimental - live editor] - | |
Coming soon! | -|
- User Journey - [docs - live editor] - | |
- +``` + +### Git graph [experimental - live editor] + +### User Journey diagram [docs - live editor] +``` journey title My working day section Go to work @@ -187,14 +206,101 @@ pie section Go home Go downstairs: 5: Me Sit down: 3: Me - |
- - - | -