Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from mermaid-js:master #13

Merged
merged 24 commits into from
Jul 9, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5b98232
fix #783: Add sub-resource integrity (SRI) hash to all CDN resources
jonmbake Jun 30, 2022
1c6371c
Add vitest
sidharthv96 Jul 6, 2022
e04bb15
Add dom testing
sidharthv96 Jul 6, 2022
b4fe60d
Remove mocha
sidharthv96 Jul 6, 2022
4c965fb
Cypress
sidharthv96 Jul 6, 2022
79fb9d1
Pin versions; Fix svelte kit
sidharthv96 Jul 6, 2022
0ea5d81
Fix cypress
sidharthv96 Jul 6, 2022
31de1c7
Fix security formatting.
sidharthv96 Jul 6, 2022
cab7ae5
Merge branch 'master' into vitest
sidharthv96 Jul 6, 2022
861fd44
Fix test
sidharthv96 Jul 6, 2022
1058565
Fix test
sidharthv96 Jul 6, 2022
e69b4de
Fix test
sidharthv96 Jul 6, 2022
1ab98b5
Merge pull request #878 from mermaid-js/vitest
sidharthv96 Jul 7, 2022
fb91377
chore(deps-dev): bump vitest from 0.17.0 to 0.17.1 (#880)
dependabot[bot] Jul 8, 2022
e410f77
chore(deps-dev): bump @sveltejs/kit (#882)
dependabot[bot] Jul 8, 2022
e39254d
chore(deps-dev): bump tailwindcss from 3.1.4 to 3.1.5 (#884)
dependabot[bot] Jul 8, 2022
8c37a3b
chore(deps-dev): bump svelte from 3.48.0 to 3.49.0 (#881)
dependabot[bot] Jul 8, 2022
852d426
chore(deps-dev): bump @vitest/ui from 0.17.0 to 0.17.1 (#883)
dependabot[bot] Jul 8, 2022
d7388b0
Use 'node-html-parser'
sidharthv96 Jul 8, 2022
185fd55
Merge pull request #869 from jonmbake/add-integrity-hash-sri
sidharthv96 Jul 8, 2022
67a4cff
Install deps before updating monaco
sidharthv96 Jul 8, 2022
57df1cf
Merge pull request #886 from mermaid-js/develop
sidharthv96 Jul 8, 2022
950de30
improve button to be link
johannchopin Jul 8, 2022
91c3564
Merge pull request #888 from johannchopin/feature/improve-view-button
sidharthv96 Jul 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/update-monaco-editor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: ./bin/update-monaco
- uses: actions/setup-node@v2
with:
node-version: 18
- run: node ./bin/update-monaco.js
- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
Expand Down
12 changes: 0 additions & 12 deletions bin/update-monaco

This file was deleted.

45 changes: 45 additions & 0 deletions bin/update-monaco.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import fs from 'fs';
import path from 'path';
import { parse } from 'node-html-parser';
import prettier from 'prettier';

// parse monaco version out of package.json
const packageJson = JSON.parse(fs.readFileSync('package.json'));
const monacoVersion = packageJson.dependencies['monaco-editor'].replace('^', '');

// fetch monaco sri info from cdnjs api
const cdnjsAPIResp = await fetch(
`https://api.cdnjs.com/libraries/monaco-editor/${monacoVersion}?fields=sri`
);
if (cdnjsAPIResp.ok) {
const respJson = await cdnjsAPIResp.json();
const htmlPath = path.join('src', 'app.html');
const appHtml = fs
.readFileSync(htmlPath, 'utf8')
// update monaco version of every asset in app.html
.replaceAll(/[0-9.]+\/min\/vs/g, `${monacoVersion}/min/vs`);
const root = parse(appHtml);
const updateIntegrity = (tag, attr) => {
for (const node of root
.getElementsByTagName(tag)
.filter((node) => node.getAttribute(attr)?.includes('monaco-editor'))) {
const file = node.getAttribute(attr).split(`${monacoVersion}/`)[1];
node.setAttribute('integrity', respJson.sri[file]);
}
};

updateIntegrity('script', 'src');
updateIntegrity('link', 'href');

fs.writeFileSync(
htmlPath,
prettier.format(root.toString(), {
singleQuote: false,
parser: 'html',
bracketSameLine: true,
useTabs: true
})
);
} else {
throw Error('Unable to fetch monaco sri data from cdnjs api.');
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
]
},
"volta": {
"node": "16.15.0",
"node": "18.5.0",
"yarn": "1.22.10"
},
"engines": {
Expand Down
14 changes: 11 additions & 3 deletions src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,38 @@
<link rel="manifest" href="%sveltekit.assets%/manifest.json" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css" />
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css"
integrity="sha512-HK5fgLBL+xu6dm/Ii3z4xhlSUyZgTT9tuc/hSrtw6uzJOvgRr2a9jyxxT1ely+B+xFAmJKVSTbpM/CuL7qxO8w=="
crossorigin="anonymous"
referrerpolicy="no-referrer" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.33.0/min/vs/editor/editor.main.min.css"
integrity="sha512-633RnebxsjmF57QUx9c85T6XILSAuJFzKnN5dVsUQ3nsc7c0bW649fCj1Z8ZkAbo5vAHnKZIsGqDokJRiABupA=="
crossorigin="anonymous"
referrerpolicy="no-referrer" />
<script>
var require = {
paths: { vs: 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.33.0/min/vs' }
paths: {
vs: "https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.33.0/min/vs",
},
};
</script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.33.0/min/vs/loader.min.js"
integrity="sha512-O9SYDgWAM3bEzit1z6mkFd+dxKUplO/oB8UwYGAkg2Zy/WzDUQ2mYA/ysk3c0CxiXAN4u8T9JeZ0Ahk2Jj/33Q=="
crossorigin="anonymous"
referrerpolicy="no-referrer"></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.33.0/min/vs/editor/editor.main.nls.min.js"
integrity="sha512-TShm8t61Zg9dutpJGD4KMy+VO4yVW0pgvHfeFjovzp+kBcSpblO7mBGSbL2ncApu0FfiqHiygwcef65+qiLRxg=="
crossorigin="anonymous"
referrerpolicy="no-referrer"></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.33.0/min/vs/editor/editor.main.js"
integrity="sha512-7p8WMGQI2IAHj9dn6uYYQYGsHNlpMp8Wv4Q1M0SNxM+8Rd16sHL7gXmktieLjh1iyWl41doD6NOiId7e+XCw6Q=="
crossorigin="anonymous"
referrerpolicy="no-referrer"></script>

%sveltekit.head%
</head>
<body>
Expand Down