fix(tools): skin.mjs 显式报错尺寸不可读,补全测试覆盖

Finding 1: 尺寸校验不能无声跳过(null 被当作通过)。
新增 size-unreadable 错误码,当图片无法读取尺寸时显式报错。

Finding 2: 测试 10 是伪测试(.wav 太短,被长度守卫拦下)。
改用真实 PNG 字节但 .wav 扩展名,验证 isImage() 门控在。

新增两条用例:
- size-unreadable 错误场景(override 侧非 PNG)
- PNG 签名检查(长度足够但签名不对)

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-27 21:32:01 +08:00
co-authored by Claude Opus 5
parent 000f9e4290
commit 44264db8ba
2 changed files with 42 additions and 3 deletions
+12 -1
View File
@@ -69,7 +69,18 @@ export function validateOverrides(frameworkUiDir, overrideDir) {
if (needSizeCheck) {
const a = readPngSize(join(frameworkUiDir, ...rel.split(posix.sep)));
const b = readPngSize(join(overrideDir, ...rel.split(posix.sep)));
if (a && b && (a.width !== b.width || a.height !== b.height)) {
if (!a || !b) {
const side = !a ? '框架' : 'override';
errors.push({
path: rel,
code: 'size-unreadable',
message:
`框架 UI 图片必须是 PNG(无法读取尺寸:${side})。` +
`请改用 PNG,或连 .meta 一起提供(例外通道)`,
});
continue;
}
if (a.width !== b.width || a.height !== b.height) {
errors.push({
path: rel,
code: 'size-mismatch',