From da94210c39a7777bd17607bf34c32ea96612bda8 Mon Sep 17 00:00:00 2001 From: ceasium Date: Thu, 21 Nov 2024 22:29:00 +0800 Subject: [PATCH] src reviseFormat Please enter the commit message for your changes. Lines starting --- teams/Roach/Gacha.png | Bin 4080 -> 0 bytes teams/Roach/resource/{src/src => }/anime.mbt | 0 teams/Roach/resource/{src/src => }/draw.mbt | 0 teams/Roach/resource/{src/src => }/event.mbt | 0 teams/Roach/resource/{src/src => }/game.mbt | 0 .../resource/{src/src => }/lib/hello.mbt | 0 .../resource/{src/src => }/lib/hello_test.mbt | 0 .../resource/{src/src => }/lib/moon.pkg.json | 0 .../resource/{src/src => }/moon.pkg.json | 0 teams/Roach/resource/{src/src => }/sprite.mbt | 0 teams/Roach/resource/src/.gitignore | 2 - teams/Roach/resource/src/Gacha.html | 73 --- teams/Roach/resource/src/build.mts | 560 ------------------ teams/Roach/resource/src/coin.png | Bin 146 -> 0 bytes teams/Roach/resource/{src/src => }/top.mbt | 0 teams/Roach/resource/version.md | 1 + teams/Roach/resource/{src/src => }/voice.mbt | 0 .../resource/{src => }/w4png/Moon.aseprite | Bin teams/Roach/resource/{src => }/w4png/Moon.png | Bin .../Roach/resource/{src => }/w4png/OIP-C.jpg | Bin .../resource/{src => }/w4png/Sun.aseprite | Bin teams/Roach/resource/{src => }/w4png/Sun.png | Bin teams/Roach/resource/{src => }/w4png/hex.png | Bin .../resource/{src => }/w4png/hexcircle.jpg | Bin 24 files changed, 1 insertion(+), 635 deletions(-) delete mode 100644 teams/Roach/Gacha.png rename teams/Roach/resource/{src/src => }/anime.mbt (100%) rename teams/Roach/resource/{src/src => }/draw.mbt (100%) rename teams/Roach/resource/{src/src => }/event.mbt (100%) rename teams/Roach/resource/{src/src => }/game.mbt (100%) rename teams/Roach/resource/{src/src => }/lib/hello.mbt (100%) rename teams/Roach/resource/{src/src => }/lib/hello_test.mbt (100%) rename teams/Roach/resource/{src/src => }/lib/moon.pkg.json (100%) rename teams/Roach/resource/{src/src => }/moon.pkg.json (100%) rename teams/Roach/resource/{src/src => }/sprite.mbt (100%) delete mode 100644 teams/Roach/resource/src/.gitignore delete mode 100644 teams/Roach/resource/src/Gacha.html delete mode 100644 teams/Roach/resource/src/build.mts delete mode 100644 teams/Roach/resource/src/coin.png rename teams/Roach/resource/{src/src => }/top.mbt (100%) create mode 100644 teams/Roach/resource/version.md rename teams/Roach/resource/{src/src => }/voice.mbt (100%) rename teams/Roach/resource/{src => }/w4png/Moon.aseprite (100%) rename teams/Roach/resource/{src => }/w4png/Moon.png (100%) rename teams/Roach/resource/{src => }/w4png/OIP-C.jpg (100%) rename teams/Roach/resource/{src => }/w4png/Sun.aseprite (100%) rename teams/Roach/resource/{src => }/w4png/Sun.png (100%) rename teams/Roach/resource/{src => }/w4png/hex.png (100%) rename teams/Roach/resource/{src => }/w4png/hexcircle.jpg (100%) diff --git a/teams/Roach/Gacha.png b/teams/Roach/Gacha.png deleted file mode 100644 index fcb7288477a00130bb35fa2d34a2247a06745734..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4080 zcmeHKX;c$e6i(G6Ef%R_pdw&Ys8&D_6*LHn?4Uv+V-$jwdbARdU2%cZ!VwN}LEr=g zOhs0c(ZPly6ChXwjK~rZd--{^T~t zYJ>Yjy78gpYqRcaeLtjJ(36?4@n{du=i|pi{Mmk^W9kdqAK&g9x#i$;W3iswkloH7 z;DuzNlhBD0ryr*uqzCCjmGqc)YN5xNMZ&D)ROv#H9}A-b;$Bm?<-s?NPU)AP8bH--CAA~i z6OaS7OK44u-n;2@BjQaXmyEIHmEg(TU|^7Bud*`9zmwJRy9U+}z&D%qqu5k8pq8l^Eg%I67?@)Ko|hLjgQGA6S=T`I5GJLt_^a-+SN#|f@O&;zOiQCO zlN5w6^%!(pL&pnRO@01vZ&qvv=>!n>4GLNH^~x1d?g|m`ZDC6%-UNF#19Zx38U?nJ z>Cd7S!39E}?w+9R*rw6iS-J}A)sY4XXyv5{JWSP>YXTo$|Fa0aD<^=YeT}k7?H~Fb zN=T+QL8cmHcWSZn&#FwXi+@$ho)=CKs z{=#qvb5AZCmhqb^R9YzJs^?m6KkyThjne7KLxS*61^ds=gX)`294InGD?xqyv7WANWQJU2tLo<>=85d7?a%ykpNsMW5YntFhfz=$NQ18)`W*Dpk3ybi*xAdd` z;wp$bl(Jxl)=>JRaT5bov;w{5HsD}WOJCI@DKdzu()$R?aV}|U))c^6-8KFZD=Mbl zfGwk=(6c;ShUMEGo-pynk>%Fq(_|IW(@FI+64)jU?JYVSr9A(z?B5R8t6>Wo5DtC8 z?OqPi!iK%O25d3)8c?M$EUc>5c{WrB#GM2EhPxP9?RDL~aBuFVU7JtZWwz&NPlUWs z&@_sj$+3AvR_5jBq!iVzHctj)ufc_4ixC~3{s!*%3N}zpBJtWKM2i)qYJq#3)-De7 z{*Ku&%RGyxsCEkK<`ak!djwCcu9zEn_>8U&;jqERkUPCgF~)!kJ?Xt77BR)JHM?X-s&~cjuroNxsXbpCR?~;iZRTeU#D_nz7E#kg`5GmBxRoae9bu*fRtd%@ zu1Ds*nyAOundMi9CzKfsigkh=YIH{isR>CZhD@D11EBF1jz>rO;Vq?!6SyR{;pwDO SY7z3)j&ro#X#;KB7xgFnx)O!} diff --git a/teams/Roach/resource/src/src/anime.mbt b/teams/Roach/resource/anime.mbt similarity index 100% rename from teams/Roach/resource/src/src/anime.mbt rename to teams/Roach/resource/anime.mbt diff --git a/teams/Roach/resource/src/src/draw.mbt b/teams/Roach/resource/draw.mbt similarity index 100% rename from teams/Roach/resource/src/src/draw.mbt rename to teams/Roach/resource/draw.mbt diff --git a/teams/Roach/resource/src/src/event.mbt b/teams/Roach/resource/event.mbt similarity index 100% rename from teams/Roach/resource/src/src/event.mbt rename to teams/Roach/resource/event.mbt diff --git a/teams/Roach/resource/src/src/game.mbt b/teams/Roach/resource/game.mbt similarity index 100% rename from teams/Roach/resource/src/src/game.mbt rename to teams/Roach/resource/game.mbt diff --git a/teams/Roach/resource/src/src/lib/hello.mbt b/teams/Roach/resource/lib/hello.mbt similarity index 100% rename from teams/Roach/resource/src/src/lib/hello.mbt rename to teams/Roach/resource/lib/hello.mbt diff --git a/teams/Roach/resource/src/src/lib/hello_test.mbt b/teams/Roach/resource/lib/hello_test.mbt similarity index 100% rename from teams/Roach/resource/src/src/lib/hello_test.mbt rename to teams/Roach/resource/lib/hello_test.mbt diff --git a/teams/Roach/resource/src/src/lib/moon.pkg.json b/teams/Roach/resource/lib/moon.pkg.json similarity index 100% rename from teams/Roach/resource/src/src/lib/moon.pkg.json rename to teams/Roach/resource/lib/moon.pkg.json diff --git a/teams/Roach/resource/src/src/moon.pkg.json b/teams/Roach/resource/moon.pkg.json similarity index 100% rename from teams/Roach/resource/src/src/moon.pkg.json rename to teams/Roach/resource/moon.pkg.json diff --git a/teams/Roach/resource/src/src/sprite.mbt b/teams/Roach/resource/sprite.mbt similarity index 100% rename from teams/Roach/resource/src/src/sprite.mbt rename to teams/Roach/resource/sprite.mbt diff --git a/teams/Roach/resource/src/.gitignore b/teams/Roach/resource/src/.gitignore deleted file mode 100644 index b1283a7..0000000 --- a/teams/Roach/resource/src/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -target/ -.mooncakes/ diff --git a/teams/Roach/resource/src/Gacha.html b/teams/Roach/resource/src/Gacha.html deleted file mode 100644 index 2502def..0000000 --- a/teams/Roach/resource/src/Gacha.html +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - WASM-4 Game - - - - - - - - diff --git a/teams/Roach/resource/src/build.mts b/teams/Roach/resource/src/build.mts deleted file mode 100644 index 7eed615..0000000 --- a/teams/Roach/resource/src/build.mts +++ /dev/null @@ -1,560 +0,0 @@ -import fs from 'node:fs' -import querystring from 'node:querystring' -import markdownit from 'markdown-it' -import * as octokit from 'octokit' - -const ghClient = new octokit.Octokit({ - auth: process.env.GITHUB_TOKEN, -}) - -const md = markdownit({ - html: true, - linkify: true, - typographer: true, -}) - -function githubBtn( - authorName: string, - repoName: string, - option: { large: boolean }, -): string { - const { large } = option - return `` -} - -async function getPRInfo(prNumber: number) { - return ( - await ghClient.request('GET /repos/{owner}/{repo}/pulls/{pull_number}', { - owner: 'moonbitlang', - repo: 'MoonBit-Code-JAM-2024', - pull_number: prNumber, - headers: { - 'X-GitHub-Api-Version': '2022-11-28', - }, - }) - ).data -} - -type MetaInfo = { - title?: string - control?: string - readme?: string - cover: boolean - prInfo: Awaited> -} - -const metaInfos = new Map() - -async function getPulls(page: number) { - return await ghClient.request('GET /repos/{owner}/{repo}/pulls', { - state: 'closed', - owner: 'moonbitlang', - repo: 'MoonBit-Code-JAM-2024', - per_page: 100, - page, - headers: { - 'X-GitHub-Api-Version': '2022-11-28', - }, - }) -} - -async function allPulls() { - let pagesRemaining = true - const pulls: Awaited>['data'] = [] - let page = 1 - while (pagesRemaining) { - const res = await getPulls(page) - pulls.push(...res.data) - - const linkHeader = res.headers.link - pagesRemaining = linkHeader?.includes(`rel=\"next\"`) ?? false - page++ - } - return pulls -} - -async function collectMetaInfos(): Promise { - const pulls = await allPulls() - for (const pull of pulls) { - const pull_number = pull.number - const files = await ghClient.request( - 'GET /repos/{owner}/{repo}/pulls/{pull_number}/files', - { - owner: 'moonbitlang', - repo: 'MoonBit-Code-JAM-2024', - pull_number, - headers: { - 'X-GitHub-Api-Version': '2022-11-28', - }, - }, - ) - for (const file of files.data) { - const [teams, teamName, name] = file.filename.split('/', 3) - if (teams === 'teams' && name === 'game.wasm') { - if (metaInfos.has(teamName)) { - continue - } - if (!fs.existsSync(`teams/${teamName}`)) { - continue - } - const prInfo = await getPRInfo(pull_number) - const metaInfo: MetaInfo = { - prInfo, - cover: false, - } - - const files = fs - .readdirSync(`teams/${teamName}`, { withFileTypes: true }) - .filter(d => d.isFile()) - .map(d => d.name) - - for (const file of files) { - const read = (file: string): string => - fs.readFileSync(`teams/${teamName}/${file}`, 'utf8') - switch (file) { - case 'cover.png': { - metaInfo.cover = true - continue - } - case 'README.md': { - metaInfo.readme = read(file) - continue - } - case 'title': { - metaInfo.title = read(file) - continue - } - case 'control': { - metaInfo.control = read(file) - continue - } - } - } - - console.log(`metainfo of ${teamName}:`, metaInfo) - metaInfos.set(teamName, metaInfo) - } - } - } -} - -function renderGameCard(teamName: string, metaInfo: MetaInfo): string { - const coverPath = metaInfo.cover - ? `${querystring.escape(teamName)}/cover.png` - : 'default-cover.png' - - const teamPath = querystring.escape(teamName) - const authorName = metaInfo.prInfo.head.user.login - const repoName = metaInfo.prInfo.head.repo?.name - - if (repoName === undefined) { - throw new Error(`renderGameCard: repoName is undefined`) - } - - const footer = metaInfo.title - ? `

${metaInfo.title}

${teamName}

` - : `

${teamName}

` - - return /*html*/ ` - -`.trim() -} - -function indexHtml(): string { - const gameCards = [...metaInfos.entries()] - .map(e => renderGameCard(...e)) - .join('\n') - - return /*html*/ ` - - - - - - MoonBit Code JAM 2024 - - - -
-
-
-

MoonBit Code JAM 2024

-

选手提交作品展示

- -
-
- ${gameCards} -
-
-
- - -` -} - -function gameIndexHtml(teamName: string, metaInfo: MetaInfo): string { - const title = metaInfo.title ?? teamName - const control = metaInfo.control ?? '' - const readme = metaInfo.readme ? md.render(metaInfo.readme) : '' - const authorName = metaInfo.prInfo.head.user.login - const repoName = metaInfo.prInfo.head.repo?.name - const authorUrl = metaInfo.prInfo.head.user.html_url - const avatarUrl = metaInfo.prInfo.head.user.avatar_url - const updateTime = metaInfo.prInfo.merged_at - - if (repoName === undefined || updateTime === null) { - throw new Error( - JSON.stringify( - { - title, - control, - readme, - avatarUrl, - updateTime, - }, - null, - 2, - ), - ) - } - - const updateDate = new Date(updateTime).toLocaleDateString('zh-CN', { - year: 'numeric', - month: 'long', - day: 'numeric', - }) - - const avatar = /*html*/ ` -
- - - -
- -

${updateDate}

-
-
- ` - return /*html*/ ` - - - - - - ${title} - - - -
-
- -

${control}

-

${title}

-

Star 仓库,为 ta 投票 - ${githubBtn(authorName, repoName, { large: true })} -

- ${avatar} -
- ${readme} -
-
-
- - -` -} - -function copyWasm4(dist: string) { - const wasm4Files = fs.readdirSync('node_modules/wasm4/assets/runtime/slim') - for (const file of wasm4Files) { - fs.copyFileSync( - `node_modules/wasm4/assets/runtime/slim/${file}`, - `dist/${dist}/${file === 'index.html' ? 'game.html' : file}`, - ) - } -} - -fs.rmSync('dist', { recursive: true, force: true }) -fs.mkdirSync('dist') -await collectMetaInfos() -fs.writeFileSync('dist/index.html', indexHtml()) -fs.copyFileSync('assets/default-cover.png', 'dist/default-cover.png') -for (const [teamName, metaInfo] of metaInfos) { - const gameIndex = gameIndexHtml(teamName, metaInfo) - fs.mkdirSync(`dist/${teamName}`) - copyWasm4(teamName) - for (const dirent of fs.readdirSync(`teams/${teamName}`, { - withFileTypes: true, - })) { - if (dirent.isDirectory()) { - fs.cpSync( - `teams/${teamName}/${dirent.name}`, - `dist/${teamName}/${dirent.name}`, - { - recursive: true, - }, - ) - } else { - fs.copyFileSync( - `teams/${teamName}/${dirent.name}`, - `dist/${teamName}/${ - dirent.name === 'game.wasm' ? 'cart.wasm' : dirent.name - }`, - ) - } - } - fs.writeFileSync(`dist/${teamName}/index.html`, gameIndex) -} diff --git a/teams/Roach/resource/src/coin.png b/teams/Roach/resource/src/coin.png deleted file mode 100644 index 360d5a07ffc9d6024a30aa3829a92ee8b742b16e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 146 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqjKx9jP7LeL$-D$|d^}woLnNjq zCnzvTB=*eoXa1+`y~H~|p+(za+MbHfj4>BYmUH*`oY{42z srV!0so^s8OS;XD1c-Mgw4m=DDDW7Ghr1?l40Gi9->FVdQ&MBb@08`T~g#Z8m diff --git a/teams/Roach/resource/src/src/top.mbt b/teams/Roach/resource/top.mbt similarity index 100% rename from teams/Roach/resource/src/src/top.mbt rename to teams/Roach/resource/top.mbt diff --git a/teams/Roach/resource/version.md b/teams/Roach/resource/version.md new file mode 100644 index 0000000..47b5b42 --- /dev/null +++ b/teams/Roach/resource/version.md @@ -0,0 +1 @@ +moon 0.1.20241106 (79e45ae 2024-11-06) ~/.moon/bin/moon moonc v0.1.20241106+8f17a3fc7 ~/.moon/bin/moonc moonrun 0.1.20241106 (79e45ae 2024-11-06) ~/.moon/bin/moonrun \ No newline at end of file diff --git a/teams/Roach/resource/src/src/voice.mbt b/teams/Roach/resource/voice.mbt similarity index 100% rename from teams/Roach/resource/src/src/voice.mbt rename to teams/Roach/resource/voice.mbt diff --git a/teams/Roach/resource/src/w4png/Moon.aseprite b/teams/Roach/resource/w4png/Moon.aseprite similarity index 100% rename from teams/Roach/resource/src/w4png/Moon.aseprite rename to teams/Roach/resource/w4png/Moon.aseprite diff --git a/teams/Roach/resource/src/w4png/Moon.png b/teams/Roach/resource/w4png/Moon.png similarity index 100% rename from teams/Roach/resource/src/w4png/Moon.png rename to teams/Roach/resource/w4png/Moon.png diff --git a/teams/Roach/resource/src/w4png/OIP-C.jpg b/teams/Roach/resource/w4png/OIP-C.jpg similarity index 100% rename from teams/Roach/resource/src/w4png/OIP-C.jpg rename to teams/Roach/resource/w4png/OIP-C.jpg diff --git a/teams/Roach/resource/src/w4png/Sun.aseprite b/teams/Roach/resource/w4png/Sun.aseprite similarity index 100% rename from teams/Roach/resource/src/w4png/Sun.aseprite rename to teams/Roach/resource/w4png/Sun.aseprite diff --git a/teams/Roach/resource/src/w4png/Sun.png b/teams/Roach/resource/w4png/Sun.png similarity index 100% rename from teams/Roach/resource/src/w4png/Sun.png rename to teams/Roach/resource/w4png/Sun.png diff --git a/teams/Roach/resource/src/w4png/hex.png b/teams/Roach/resource/w4png/hex.png similarity index 100% rename from teams/Roach/resource/src/w4png/hex.png rename to teams/Roach/resource/w4png/hex.png diff --git a/teams/Roach/resource/src/w4png/hexcircle.jpg b/teams/Roach/resource/w4png/hexcircle.jpg similarity index 100% rename from teams/Roach/resource/src/w4png/hexcircle.jpg rename to teams/Roach/resource/w4png/hexcircle.jpg