Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Bao Zhiyuan committed Aug 29, 2024
1 parent 55966e6 commit db5b1b4
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 4 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ jobs:
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: build pages
run: |
mkdir dist
echo '<h1>Hello!</h1>' > dist/index.html
run: node .src/build.mjs
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'dist'
path: '.dist'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.dist
/index.html
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v22.1.0
52 changes: 52 additions & 0 deletions .src/build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import fs from 'node:fs'

fs.rmSync('.dist', { recursive: true, force: true })
fs.mkdirSync('.dist')

const games = fs
.readdirSync('.', { withFileTypes: true })
.filter(d => d.isDirectory() && !d.name.startsWith('.'))
.map(d => d.name)

const lis = games.map(d => `<li><a href='/${d}'>${d}</a></li>`)

const index = /*html*/ `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MoonBit Code JAM 2024</title>
</head>
<body>
<ul>
${lis}
</ul>
</body>
</html>
`

fs.writeFileSync('.dist/index.html', index)

const wasm4Files = fs.readdirSync('.templates/wasm4')

for (const game of games) {
const gameIndex = /*html*/ `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>${game}</title>
</head>
<body>
<iframe src="./game.html" frameborder="0" width="600" height="600"></iframe>
</body>
</html>
`
fs.mkdirSync(`.dist/${game}`)
for (const file of wasm4Files) {
fs.copyFileSync(`.templates/wasm4/${file}`, `.dist/${game}/${file}`)
}
fs.writeFileSync(`.dist/${game}/index.html`, gameIndex)
}
18 changes: 18 additions & 0 deletions .templates/wasm4/game.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"
/>
<link rel="shortcut icon" href="https://wasm4.org/img/favicon.ico" />
<title>WASM-4 Cart</title>
<link rel="stylesheet" href="wasm4.css" />
</head>
<body>
<div id="devtools"></div>
<script src="wasm4.js"></script>
<wasm4-app></wasm4-app>
</body>
</html>
1 change: 1 addition & 0 deletions .templates/wasm4/wasm4.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions .templates/wasm4/wasm4.js

Large diffs are not rendered by default.

Binary file added test/game.wasm
Binary file not shown.

0 comments on commit db5b1b4

Please sign in to comment.