-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
249 additions
and
46 deletions.
There are no files selected for viewing
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,40 @@ | ||
name: Publish release preview package | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'release/**' | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [10.x] | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Setup Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Install Yarn | ||
run: npm i yarn --global | ||
|
||
- name: Install Json | ||
run: npm i json --global | ||
|
||
- name: Install Packages | ||
run: yarn install | ||
|
||
- name: Publish | ||
run: | | ||
PREVIEW_VERSION=$(git rev-list --count --first-parent HEAD) | ||
VERSION=$(echo ${{github.ref}} | tail -c +20)-preview.$PREVIEW_VERSION | ||
echo $VERSION | ||
npm version --no-git-tag-version --allow-same-version $VERSION | ||
npm set //npm.pkg.github.com/:_authToken ${{ secrets.GITHUB_TOKEN }} | ||
npm set registry https://npm.pkg.github.com/knsv | ||
json -I -f package.json -e 'this.name="@knsv/mermaid"' # Package name needs to be set to a scoped one because GitHub registry requires this | ||
json -I -f package.json -e 'this.repository="git://github.com/knsv/mermaid"' # Repo url needs to have a specific format too | ||
npm publish | ||
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 |
---|---|---|
|
@@ -144,6 +144,20 @@ Example: https://unpkg.com/[email protected]/dist/ | |
|
||
yarn add mermaid | ||
|
||
### Preview builds | ||
Preview builds are created automatically for each release. They can be found in the [GitHub registry](https://github.com/knsv/mermaid/packages). | ||
Make sure to configure npm to use the GitHub package registry. Steps for that can be found [here](https://help.github.com/en/articles/configuring-npm-for-use-with-github-package-registry). | ||
|
||
If you want to get the latest preview for the next release | ||
``` | ||
yarn add @knsv/mermaid | ||
``` | ||
|
||
|
||
If you want to get the latest preview for a specific version | ||
``` | ||
yarn add @knsv/mermaid@<version> | ||
``` | ||
|
||
## Documentation | ||
|
||
|
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,16 @@ | ||
/* eslint-env jest */ | ||
describe('Rerendering', () => { | ||
|
||
it('should be able to render and rerender a graph via API', () => { | ||
const url = 'http://localhost:9000/rerender.html'; | ||
cy.viewport(1440, 1024); | ||
cy.visit(url); | ||
cy.get('#graph #A').should('have.text', 'XMas'); | ||
|
||
cy.get('body') | ||
.find('#rerender') | ||
.click({ force: true }); | ||
|
||
cy.get('#graph #A').should('have.text', 'Saturday'); | ||
}); | ||
}); |
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,33 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<title>Mermaid Quick Test Page</title> | ||
<link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgo="> | ||
</head> | ||
<body> | ||
<div id="graph"> | ||
</div> | ||
|
||
<script src="./mermaid.js"></script> | ||
<script> | ||
|
||
mermaid.init({ startOnLoad: false }); | ||
mermaid.mermaidAPI.initialize(); | ||
|
||
rerender('XMas'); | ||
|
||
function rerender(text) { | ||
var graphText = `graph TD | ||
A[${text}] -->|Get money| B(Go shopping)` | ||
var graph = mermaid.mermaidAPI.render('id', graphText); | ||
console.log('\x1b[35m%s\x1b[0m', '>> graph', graph) | ||
document.getElementById('graph').innerHTML=graph; | ||
} | ||
|
||
</script> | ||
<button id="rerender" onclick="rerender('Saturday')">Rerender</button> | ||
|
||
</body> | ||
</html> |
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
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
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
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
Oops, something went wrong.