extends SceneTree ## 列出发布包内 pck 的资源清单(T-WIN-023) ## ## 用途:`accept-release.sh` 用它断言**开发/验收工具不会被打进产物** —— ## 起因是一个真实缺陷:`export_filter="all_resources"` + `exclude_filter` 里没有 `build/*`, ## 于是 `build/` 下的探针脚本(含**故意不合规**的 `probe-ws-bad.gd`)与 ## `frame-vectors.json` 全被编译打包进 `OpenDance.pck`: ## pck 315,464 B → 加上 exclude 后 145,400 B(**54% 是测试夹具**)。 ## ## 用法: ## godot --headless --main-pack --script <本文件> [-- --json] const DEV_PREFIXES := ["res://build/", "res://tests/", "res://_scratch/", "res://dist-release/"] func _initialize() -> void: var args := OS.get_cmdline_user_args() var as_json := args.has("--json") var found: Array = [] _walk("res://", found) found.sort() var dev_entries: Array = [] for f in found: for prefix in DEV_PREFIXES: if f.begins_with(prefix): dev_entries.append(f) break if f.ends_with(".md"): if not dev_entries.has(f): dev_entries.append(f) if as_json: var report := { "entries": found, "count": found.size(), "devEntries": dev_entries, } var path := "" var i := args.find("--out") if i >= 0 and i + 1 < args.size(): path = args[i + 1] if path != "": var file := FileAccess.open(path, FileAccess.WRITE) if file != null: file.store_string(JSON.stringify(report, " ")) file.close() print("[pck] 清单已写入 %s(%d 项,开发残留 %d 项)" % [path, found.size(), dev_entries.size()]) else: print(JSON.stringify(report)) quit(0 if dev_entries.is_empty() else 1) return print("[pck] 文件数 %d" % found.size()) for f in found: print(" ", f) if dev_entries.is_empty(): print("[pck] ✓ 无开发/验收残留(build/ tests/ _scratch/ *.md)") else: print("[pck] ✗ 产物里混入了开发残留 %d 项:" % dev_entries.size()) for f in dev_entries: print(" · ", f) quit(0 if dev_entries.is_empty() else 1) func _walk(dir: String, out: Array) -> void: var d := DirAccess.open(dir) if d == null: return d.list_dir_begin() while true: var name := d.get_next() if name == "": break var path := dir.path_join(name) if dir != "res://" else "res://" + name if d.current_is_dir(): if name != "." and name != "..": _walk(path, out) else: out.append(path) d.list_dir_end()