Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix(checks): report non-TypeScript example failures

yhh223d55480adf
diff --git a/build-tools/tasks/check-examples.js b/build-tools/tasks/check-examples.js
index 38897a830..8def10c45 100644
--- a/build-tools/tasks/check-examples.js
+++ b/build-tools/tasks/check-examples.js
@@ -10,6 +10,7 @@ import path from 'path';
import { execSync } from 'child_process';
import { fileURLToPath } from 'url';
import * as logger from '../utils/logger.js';
+import { exampleFailureLines } from '../utils/exampleDiagnostics.js';
// Every project directory that ships to users: the examples plus the editor's
// bundled new-project templates (templates/).
@@ -124,9 +125,8 @@ export async function checkExamples(rootDir) {
logger.success(example.name);
results.passed++;
} catch (err) {
- const stderr = err.stdout?.toString() || err.stderr?.toString() || err.message;
logger.error(`${example.name}`);
- const lines = stderr.split('\n').filter(l => l.includes('error TS'));
+ const lines = exampleFailureLines(err);
for (const line of lines.slice(0, 10)) {
logger.error(` ${line.trim()}`);
}
diff --git a/build-tools/utils/exampleDiagnostics.js b/build-tools/utils/exampleDiagnostics.js
new file mode 100644
index 000000000..e4e9f3629
--- /dev/null
+++ b/build-tools/utils/exampleDiagnostics.js
@@ -0,0 +1,9 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/** Compiler diagnostics when present; otherwise preserve process/filesystem failures. */
+export function exampleFailureLines(error) {
+ const all = [...new Set([error?.message, error?.stderr?.toString(), error?.stdout?.toString()]
+ .filter(Boolean).flatMap(text => text.split(/\r?\n/)).map(line => line.trim()).filter(Boolean))];
+ const typed = all.filter(line => line.includes('error TS'));
+ return typed.length ? typed : all.length ? all : ['Example check failed without diagnostics.'];
+}
diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjs
index 4bc31648d..ee9ec63e4 100644
--- a/tools/releaseNotes.mjs
+++ b/tools/releaseNotes.mjs
@@ -28,6 +28,8 @@ export const NOTES_FLOOR = 'v0.65.0';
* the reader recognises anyway.
*/
export const NOTED = {
+ 'fix(checks): report non-TypeScript example failures':
+ { internal: 'Example validation reports filesystem and process failures instead of dropping all non-TS diagnostics.' },
'perf(templates): minify the WeChat publishing profile':
{ note: "The WeChat starter's publishing profile minifies its game bundle." },
'feat(templates): add WeChat gameplay and host-service starter':
diff --git a/tools/tests/example-diagnostics.test.ts b/tools/tests/example-diagnostics.test.ts
new file mode 100644
index 000000000..f0e951e28
--- /dev/null
+++ b/tools/tests/example-diagnostics.test.ts
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+import { it, expect } from 'vitest';
+import { exampleFailureLines } from '../../build-tools/utils/exampleDiagnostics.js';
+it('keeps compiler errors without repeating wrapper noise', () => {
+ expect(exampleFailureLines({ message: 'Command failed', stdout: Buffer.from('src/game.ts(1,1): error TS2307: missing module\n') }))
+ .toEqual(['src/game.ts(1,1): error TS2307: missing module']);
+});
+it('reports filesystem and process failures that contain no TS diagnostics', () => {
+ expect(exampleFailureLines(new Error('EPERM: unlink temporary SDK mirror'))).toContain('EPERM: unlink temporary SDK mirror');
+ expect(exampleFailureLines({ message: 'Compiler timed out', stderr: Buffer.from('Process killed\r\n') }))
+ .toEqual(['Compiler timed out', 'Process killed']);
+});
+it('never returns an empty diagnostic for an unknown failure', () => {
+ expect(exampleFailureLines({})).toEqual(['Example check failed without diagnostics.']);
+});