Skip to content

Commit 0c8075c

Browse files
committed
upgrade env
1 parent 9953faa commit 0c8075c

9 files changed

Lines changed: 930 additions & 2048 deletions

File tree

.github/workflows/cli.yml

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,40 @@ jobs:
2323
- name: Install dependencies
2424
run: npm ci
2525

26-
- name: Build CLI
26+
- name: Build CLI (local)
2727
run: npm run build:cli
2828

2929
- name: Install Chrome system dependencies
3030
run: |
3131
sudo apt-get update -y
3232
sudo apt-get install -y libgbm1
3333
34-
- name: Download test model
34+
- name: Smoke test — spritesheet
35+
run: npm run cli -- example.fbx --format spritesheet --frames 4 --width 64
36+
--height 64 --output ./sprite-sheet-test
37+
38+
- name: Verify output
3539
run: |
36-
curl -fsSL \
37-
"https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/main/2.0/Box/glTF-Binary/Box.glb" \
38-
-o test.glb
40+
test -f ./sprite-sheet-test/spritesheet.png || (echo "spritesheet.png not found" && exit 1)
41+
echo "Output files:"
42+
ls ./sprite-sheet-test/
3943
40-
- name: Smoke test — spritesheet
41-
run: node ./dist/cli/index.js test.glb --format spritesheet --frames 4 --width
42-
64 --height 64 --output ./test-out
44+
- name: Smoke test — Love2d
45+
run: npm run cli -- example.fbx --format love2d --frames 4 --width 64 --height
46+
64 --output ./love2d-test
47+
48+
- name: Verify output
49+
run: |
50+
test -f ./love2d-test/spritesheet.lua || (echo "spritesheet.lua not found" && exit 1)
51+
echo "Output files:"
52+
ls ./love2d-test/
53+
54+
- name: SmokeTest - Workflow
55+
run: npm run cli -- example.fbx --workflow platformer --cameraDistance 2.5
56+
--output ./workflow-test
4357

4458
- name: Verify output
4559
run: |
46-
test -f ./test-out/spritesheet.png || (echo "spritesheet.png not found" && exit 1)
60+
test -f ./workflow-test/spritesheet.png || (echo "spritesheet.png not found" && exit 1)
4761
echo "Output files:"
48-
ls ./test-out/
62+
ls ./workflow-test/

cli/browser.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,19 @@ export async function openPage(browser: Browser, port: number): Promise<Page> {
2727
if (msg.type() === "error") console.error(`[browser] ${text}`);
2828
else console.log(`[browser] ${text}`);
2929
});
30-
page.on("pageerror", (err) => console.error(`[browser:pageerror] ${err.message}`));
30+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
31+
page.on("pageerror", (err: any) =>
32+
console.error(`[browser:pageerror] ${err.message}`),
33+
);
3134

32-
await page.goto(`http://localhost:${port}`, { waitUntil: "networkidle0", timeout: 30000 });
35+
await page.goto(`http://localhost:${port}`, {
36+
waitUntil: "networkidle0",
37+
timeout: 30000,
38+
});
3339

34-
await page.waitForFunction(() => "__SSH_BRIDGE__" in window, { timeout: 15000 });
40+
await page.waitForFunction(() => "__SSH_BRIDGE__" in window, {
41+
timeout: 15000,
42+
});
3543

3644
return page;
3745
}

cli/index.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,21 @@ async function main() {
160160
);
161161
for (const f of files) console.log(` ${f}`);
162162
} finally {
163-
await browser?.close();
164-
if (serverProc) stopServer(serverProc);
163+
try {
164+
await browser?.close();
165+
} catch {
166+
// Browser might already be closed
167+
console.log("[sprite-sheet-helper] Browser already closed");
168+
}
169+
if (serverProc) {
170+
stopServer(serverProc);
171+
// Give server time to shut down
172+
await new Promise((r) => setTimeout(r, 100));
173+
console.log("[sprite-sheet-helper] Server stopped");
174+
}
165175
}
176+
177+
process.exit(0);
166178
}
167179

168180
main().catch((err: Error) => {

cli/inject.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export async function injectModel(
1212
const bytes = await readFile(modelPath);
1313
const base64 = bytes.toString("base64");
1414
const fileName = basename(modelPath);
15-
console.log(`[sprite-sheet-helper] File name: ${fileName}`);
1615

1716
const uuid = await page.evaluate(
1817
async (b64: string, name: string) => {
@@ -21,15 +20,12 @@ export async function injectModel(
2120

2221
const bytes = Uint8Array.from(atob(b64), (c) => c.charCodeAt(0));
2322
const file = new File([bytes], name);
24-
console.log("Injecting model passed: file", name);
2523

2624
const uuid = bridge.stores.entities.getState().addEntity("model", name);
2725
bridge.stores.transforms
2826
.getState()
2927
.initTransform(uuid, { position: [0, 0.8, 0] });
3028

31-
console.log("Injected model passed: uuid", uuid);
32-
3329
// const label = name ?? file.name ?? "Model";
3430
// const uuid = addEntity("model", label);
3531

@@ -50,11 +46,8 @@ export async function injectModel(
5046

5147
try {
5248
await bridge.stores.models.getState().loadFromFile(uuid, file);
53-
console.log("Injected model passed: loadFromFile", uuid);
5449
bridge.stores.entities.getState().selectEntity(uuid);
55-
console.log("Injected model passed: selectEntity", uuid);
5650
} catch (err) {
57-
console.log("Injected model passed: loadFromFile failed", err);
5851
throw new Error(
5952
`loadFromFile failed: ${(err as Error)?.message ?? err}`,
6053
);
@@ -66,8 +59,6 @@ export async function injectModel(
6659
fileName,
6760
);
6861

69-
console.log(`[sprite-sheet-helper] uuid: ${uuid}`);
70-
7162
// Wait for the React component to emit MODEL_READY event
7263
await page.evaluate((id: string) => {
7364
return new Promise<void>((resolve) => {

example.fbx

229 KB
Binary file not shown.

0 commit comments

Comments
 (0)