Skip to content

Commit d6f2125

Browse files
committed
Merge branch 'main' of github.com:pnsk-lab/hikkaku
2 parents be4aaea + 2952495 commit d6f2125

19 files changed

Lines changed: 2225 additions & 21 deletions

File tree

bun.lock

Lines changed: 22 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"@egoist/tailwindcss-icons": "^1.9.0",
2020
"@iconify-json/tabler": "^1.2.26",
2121
"@tailwindcss/vite": "^4.1.7",
22-
"@types/bun": "latest",
22+
"@types/bun": "1.3.10",
2323
"@typescript/native-preview": "^7.0.0-dev.20260210.1",
2424
"monaco-editor": "^0.55.1",
2525
"oxc-minify": "^0.112.0",

docs/scripts/build-showcase.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { spawn } from 'node:child_process'
12
import {
23
access,
34
mkdir,
@@ -42,6 +43,28 @@ const pathExists = async (targetPath: string) => {
4243
}
4344
}
4445

46+
const runExampleBuild = (projectDir: string, exampleId: string) =>
47+
new Promise<void>((resolve, reject) => {
48+
const child = spawn('bun', ['run', 'example:build'], {
49+
cwd: projectDir,
50+
stdio: 'inherit',
51+
env: process.env,
52+
})
53+
54+
child.on('error', reject)
55+
child.on('exit', (code) => {
56+
if (code === 0) {
57+
resolve()
58+
return
59+
}
60+
reject(
61+
new Error(
62+
`Failed to build ${exampleId} example (exit code: ${code ?? 'unknown'}).`,
63+
),
64+
)
65+
})
66+
})
67+
4568
const toTitle = (id: string) =>
4669
id
4770
.split('-')
@@ -215,6 +238,43 @@ const collectExampleIds = async () => {
215238
return exampleIds.sort()
216239
}
217240

241+
const ensureSb3Artifacts = async (exampleIds: string[]) => {
242+
const missingArtifacts = await Promise.all(
243+
exampleIds.map(async (exampleId) => {
244+
const projectDir = path.join(examplesDir, exampleId)
245+
const sb3Path = path.join(projectDir, 'dist', 'project.sb3')
246+
return (await pathExists(sb3Path))
247+
? null
248+
: {
249+
exampleId,
250+
projectDir,
251+
sb3Path,
252+
}
253+
}),
254+
)
255+
256+
const missing = missingArtifacts.filter((item) => item !== null)
257+
if (missing.length === 0) {
258+
return
259+
}
260+
261+
console.warn(
262+
`[showcase] ${missing.length} example build artifact(s) are missing. Rebuilding examples before packaging.`,
263+
)
264+
265+
for (const item of missing) {
266+
console.log(
267+
`[showcase] rebuilding ${item.exampleId} to generate project.sb3`,
268+
)
269+
await runExampleBuild(item.projectDir, item.exampleId)
270+
if (!(await pathExists(item.sb3Path))) {
271+
throw new Error(
272+
`Failed to find ${item.sb3Path} after rebuilding ${item.exampleId}.`,
273+
)
274+
}
275+
}
276+
}
277+
218278
const main = async () => {
219279
const exampleIds = await collectExampleIds()
220280
if (exampleIds.length === 0) {
@@ -234,6 +294,8 @@ const main = async () => {
234294
console.warn(
235295
'[showcase] scratch asset host is unreachable. Generating fallback pages instead of packaged HTML.',
236296
)
297+
} else {
298+
await ensureSb3Artifacts(exampleIds)
237299
}
238300

239301
const buildJobs = exampleIds.map(async (exampleId) => {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../packages/skill/hikkaku

examples/bigint/AGENTS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* `src/main.ts`: The main entry point of the application.
2+
3+
* use `bun typecheck` to run type checking.

examples/bigint/package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "@repo/example-bigint",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"dev": "vite",
7+
"build": "bun run example:build",
8+
"typecheck": "tsgo",
9+
"example:build": "bun --bun vite build"
10+
},
11+
"dependencies": {
12+
"hikkaku": "workspace:*"
13+
},
14+
"devDependencies": {
15+
"@typescript/native-preview": "^7.0.0-dev.20260127.1",
16+
"vite": "8.0.0-beta.14"
17+
},
18+
"exports": {
19+
".": "./src/main.ts"
20+
},
21+
"author": {
22+
"name": "Kingping",
23+
"url": "https://scratch.mit.edu/users/Kangping/"
24+
}
25+
}

0 commit comments

Comments
 (0)