Skip to content

Commit

Permalink
Merge branch 'dev' into ansi
Browse files Browse the repository at this point in the history
  • Loading branch information
blake-mealey committed Jan 29, 2023
2 parents 638b126 + 1a059c3 commit 066a72f
Show file tree
Hide file tree
Showing 31 changed files with 1,219 additions and 203 deletions.
41 changes: 29 additions & 12 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,47 @@ jobs:
os: [ubuntu-latest, windows-latest]

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '14'
node-version: 16

- name: pnpm setup
uses: pnpm/action-setup@v2.2.4
with:
version: 7.17.0
run_install: true

- name: cache pnpm modules
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-
- name: pnpm setup
uses: pnpm/action-setup@v2.1.0
with:
version: 6.31.0
run_install: true
- name: Install dependencies
run: pnpm install

- name: Install E2E test browsers
if: runner.os != 'Windows'
run: pnpm dlx playwright install --with-deps chromium

- run: pnpm run build
- run: pnpm run update
- run: pnpm run build
- run: pnpm run gen
working-directory: ./packages/site

- run: pnpm run test
env:
CI: true

- name: Run E2E tests
if: runner.os != 'Windows'
run: pnpm run test:e2e

- name: Upload E2E results
uses: actions/upload-artifact@v3
if: runner.os != 'Windows'
with:
name: playwright-report
path: playwright-report/
retention-days: 30
20 changes: 13 additions & 7 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,32 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '14'
node-version: 16

- name: cache pnpm modules
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-
- uses: pnpm/action-setup@v2.1.0
- name: pnpm setup
uses: pnpm/action-setup@v2.2.4
with:
version: 6.31.0
version: 7.17.0
run_install: true

- run: pnpm run build
- run: pnpm run update
- run: pnpm run build

- run: pnpm run test

- name: Run E2E tests
run: pnpm run test:e2e

- name: Deploy npm Packages
run: npx pleb publish
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ node_modules
tsconfig.tsbuildinfo
tmp

.DS_Store
.DS_Store
playwright-report/
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"dev": "pnpm -r --parallel watch",
"fmt": "prettier --write packages/**/*.ts",
"test": "cross-env NODE_OPTIONS=--max-old-space-size=4096 jest --colors",
"test:e2e": "npm run test:e2e:localserver & pnpm dlx playwright test",
"test:e2e:localserver": "node ./scripts/e2e/local-server.mjs",
"update": "npm run update:themes && npm run update:grammars",
"update:themes": "bash ./scripts/pullThemes.sh",
"update:grammars": "bash ./scripts/pullGrammars.sh"
Expand All @@ -21,7 +23,8 @@
]
},
"devDependencies": {
"@rollup/plugin-commonjs": "^23.0.7",
"@playwright/test": "^1.29.0",
"@rollup/plugin-commonjs": "^24.0.0",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-replace": "^5.0.2",
"@rollup/plugin-terser": "^0.2.1",
Expand All @@ -47,6 +50,7 @@
"rollup-plugin-copy": "^3.4.0",
"rollup-plugin-dts": "^5.1.1",
"rollup-plugin-esbuild": "^5.0.0",
"superstatic": "^9.0.0",
"ts-jest": "^29.0.5",
"tsup": "^6.5.0",
"typescript": "^4.9.4",
Expand All @@ -55,6 +59,6 @@
},
"license": "MIT",
"dependencies": {
"esbuild": "^0.16.7"
"esbuild": "^0.16.10"
}
}
4 changes: 2 additions & 2 deletions packages/renderer-path/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
"watch": "rollup -c -w"
},
"peerDependencies": {
"shiki": "^0.12.0"
"shiki": "^0.12.1"
},
"devDependencies": {
"@types/node": "^18.11.15",
"@types/node": "^18.11.17",
"@types/opentype.js": "^1.3.4",
"opentype.js": "^1.3.4",
"shiki": "^0.13.0"
Expand Down
6 changes: 3 additions & 3 deletions packages/renderer-svg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
},
"peerDependencies": {
"playwright": "^1.9.2",
"shiki": "^0.12.0"
"shiki": "^0.12.1"
},
"devDependencies": {
"@types/node": "^18.11.15",
"playwright": "^1.28.1",
"@types/node": "^18.11.17",
"playwright": "^1.29.0",
"shiki": "^0.13.0"
}
}
4 changes: 4 additions & 0 deletions packages/shiki/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
/test-results/
/playwright-report/
/playwright/.cache/
2 changes: 1 addition & 1 deletion packages/shiki/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"vscode-textmate": "^8.0.0"
},
"devDependencies": {
"@types/node": "^18.11.15"
"@types/node": "^18.11.17"
},
"browser": {
"fs": false,
Expand Down
1 change: 0 additions & 1 deletion packages/shiki/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export default defineConfig([
},
{
input: 'src/index.ts',
external,
output: {
file: 'dist/index.browser.mjs',
format: 'esm',
Expand Down
20 changes: 20 additions & 0 deletions packages/shiki/src/__tests__/__fixtures__/index_browser.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<html>
<head>
<title>Test Browser</title>
<link rel="modulepreload" href="/dist/index.browser.mjs" />
<script type="module">
import { getHighlighter } from './dist/index.browser.mjs'

const highlighter = await getHighlighter({
theme: 'nord',
langs: ['html']
})

const code = highlighter.codeToHtml(`<div>My HTML</div>`, { lang: 'html' })
document.getElementById('output').innerHTML = code
</script>
</head>
<body>
<div id="output"></div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<html>
<head>
<title>Test Browser - Custom CDN</title>
<link rel="modulepreload" href="/dist/index.browser.mjs" />
<script type="module">
import { getHighlighter, setCDN, setWasm } from './dist/index.browser.mjs'

setCDN('/assets')

const highlighter = await getHighlighter({
theme: 'nord',
langs: ['html']
})

const code = highlighter.codeToHtml(`<div>My HTML</div>`, { lang: 'html' })
document.getElementById('output').innerHTML = code
</script>
</head>
<body>
<div id="output"></div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<html>
<head>
<title>Test Browser - Custom Paths</title>
<link rel="modulepreload" href="/dist/index.browser.mjs" />
<script type="module">
import { getHighlighter } from './dist/index.browser.mjs'

const highlighter = await getHighlighter({
theme: 'nord',
langs: ['html'],
paths: {
languages: '/custom/langs',
themes: '/custom/theme',
wasm: '/custom/bin'
}
})

const code = highlighter.codeToHtml(`<div>My HTML</div>`, { lang: 'html' })
document.getElementById('output').innerHTML = code
</script>
</head>
<body>
<div id="output"></div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<html>
<head>
<title>Test Browser - Custom Wasm</title>
<link rel="modulepreload" href="/dist/index.browser.mjs" />
<script type="module">
import { getHighlighter, setWasm } from './dist/index.browser.mjs'

const response = await fetch('/assets/dist/onig.wasm')
setWasm(response)

const highlighter = await getHighlighter({
theme: 'nord',
langs: ['html']
})

const code = highlighter.codeToHtml(`<div>My HTML</div>`, { lang: 'html' })
document.getElementById('output').innerHTML = code
</script>
</head>
<body>
<div id="output"></div>
</body>
</html>
20 changes: 20 additions & 0 deletions packages/shiki/src/__tests__/__fixtures__/index_jsdelivr.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<html>
<head>
<title>Test jsDelivr</title>
<script src="https://cdn.jsdelivr.net/npm/shiki"></script>
<script>
shiki
.getHighlighter({
theme: 'nord',
langs: ['html']
})
.then(highlighter => {
const code = highlighter.codeToHtml(`<div>My HTML</div>`, { lang: 'html' })
document.getElementById('output').innerHTML = code
})
</script>
</head>
<body>
<div id="output"></div>
</body>
</html>
20 changes: 20 additions & 0 deletions packages/shiki/src/__tests__/__fixtures__/index_unpkg.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<html>
<head>
<title>Test unpgk</title>
<script src="https://unpkg.com/shiki"></script>
<script>
shiki
.getHighlighter({
theme: 'nord',
langs: ['html']
})
.then(highlighter => {
const code = highlighter.codeToHtml(`<div>My HTML</div>`, { lang: 'html' })
document.getElementById('output').innerHTML = code
})
</script>
</head>
<body>
<div id="output"></div>
</body>
</html>

0 comments on commit 066a72f

Please sign in to comment.