Files
ps5upload/scripts/audit-scripts.mjs
T
PhantomPtrandClaude Opus 5.5 c7bb83d04d chore(scripts): rewrite release posts, drop outdated scripts; README highlights (#334)
release-posts.js
- Reads whole changelog groups (bold heading + wrapped bullets), not just
  the first line of each bullet.
- X: link counted as 23 chars, replies packed to fit 280, markdown stripped.
- Discord: full bullets when they fit 2000 chars, short ones otherwise;
  Reddit: real markdown sections instead of a code block.
- Says "pre-release" when GitHub does (gh), --prerelease/--stable to
  override; --only and --out to pick a platform and write files.
- make release-post calls it directly; the .sh wrapper is gone.

Removed (outdated)
- ps5-install-trace.py, ps5-install-watch.py, fpkg-mount-test.py: drove
  /api/pkg/install/start and the dpi-* routes, which no longer exist.
- gather-fakelibs.py: superseded by the app's Backport scan.
- pull_ps5_debug.py: pulled a debug dir the helper no longer writes to.

hw-test-loop.sh ran cargo from the repo root (no workspace there); it now
points at engine/Cargo.toml.

README: a Highlights section up top (unified install, Convert to FPKG,
sleep and wake), Android/web in the platforms badge, tested firmware 5.10 &
9.60.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 06:10:10 -07:00

80 lines
2.8 KiB
JavaScript
Executable File

#!/usr/bin/env node
import { spawnSync } from "node:child_process";
import fs from "node:fs";
import path from "node:path";
const repoRoot = path.resolve(import.meta.dirname, "..");
const strict = process.argv.includes("--strict");
const manualEntrypoints = new Set([
// Manual throughput harness against a live PS5 (see its header). Its only
// mention was in docs/, which moved to the ps5upload-docs repo.
"bench/multistream-hw-test.mjs",
"scripts/bundle-fonts.py",
"scripts/find-orphan-i18n.mjs",
"scripts/hw-test-loop.sh",
"scripts/i18n-fill-missing.mjs",
"scripts/i18n-prune-unused.mjs",
"scripts/release-posts.js",
"scripts/translate-i18n.py",
"tests/lab/README.md",
// Both test_*.py are hardware-lab manual entrypoints. The
// launch-only one was already documented; the install_launch one
// was passing the audit via an accidental self-reference (the
// grep counts the basename appearing in the file's own argparse
// help text). Rename-safe addition keeps strict-mode passes.
"tests/lab/test_install_launch.py",
"tests/lab/test_launch_only.py",
]);
function gitLsFiles(prefixes) {
const res = spawnSync("git", ["ls-files", ...prefixes], {
cwd: repoRoot,
encoding: "utf8",
});
if (res.status !== 0) throw new Error(res.stderr || "git ls-files failed");
return res.stdout.trim().split(/\n/).filter(Boolean);
}
function countRefs(needle, haystackFiles) {
const base = path.basename(needle);
let refs = 0;
for (const file of haystackFiles) {
if (file === "scripts/audit-scripts.mjs") continue;
try {
const text = fs.readFileSync(path.join(repoRoot, file), "utf8");
if (text.includes(base)) refs += 1;
} catch {
// Binary or unreadable tracked file: irrelevant for script references.
}
}
return refs;
}
const files = gitLsFiles(["scripts", "tests/lab", "bench"]);
const haystackFiles = gitLsFiles(["."]).filter((file) =>
!file.startsWith("client/node_modules/")
&& !file.startsWith("engine/target/")
&& !file.startsWith("client/src-tauri/target/")
&& !file.startsWith("client/dist/")
);
const executableLike = files.filter((f) => /\.(mjs|js|py|sh|ps1)$/i.test(f));
const rows = executableLike.map((file) => ({
file,
refs: countRefs(file, haystackFiles),
manual: manualEntrypoints.has(file),
}));
const suspicious = rows.filter((r) => r.refs === 0 && !r.manual);
process.stdout.write("[audit-scripts] tracked script/test utilities\n");
for (const r of rows) {
const mark = r.manual ? "manual" : r.refs === 0 ? "orphan?" : "used";
process.stdout.write(`${String(r.refs).padStart(3)} ${mark.padEnd(7)} ${r.file}\n`);
}
if (suspicious.length > 0) {
process.stdout.write("\n[audit-scripts] review these unreferenced files:\n");
for (const r of suspicious) process.stdout.write(` ${r.file}\n`);
if (strict) process.exit(1);
}