Files
pikasTech-unidesk/scripts/verify-web-probe-sentinel-monitor-web.ts
T
2026-07-01 02:57:19 +00:00

72 lines
2.1 KiB
TypeScript

import { readFileSync, statSync } from "node:fs";
import { rootPath } from "./src/config";
const checks: Array<{ readonly path: string; readonly contains: readonly string[]; readonly minBytes: number }> = [
{
path: "scripts/assets/web-probe-sentinel-monitor-web/monitor-web.js",
minBytes: 8_000,
contains: [
"createApp",
"/api/overview",
"data-monitor-trend-curve",
"data-monitor-independent-scroll",
"data-check-row",
"data-check-dialog",
"data-memory-axis-x",
"data-memory-axis-y",
"readMonitorDeepLink",
"data-monitor-deep-link-focus",
"rootCause",
],
},
{
path: "scripts/assets/web-probe-sentinel-monitor-web/monitor-web.css",
minBytes: 8_000,
contains: [
".memory-axis-line",
".memory-axis-label",
".memory-axis-title",
],
},
{
path: "scripts/assets/web-probe-sentinel-monitor-web/vendor/vue.esm-browser.prod.js",
minBytes: 150_000,
contains: ["createApp", "compiler"],
},
{
path: "scripts/assets/web-probe-sentinel-monitor-web/vendor/VUE-LICENSE",
minBytes: 500,
contains: ["MIT License"],
},
];
const failures: string[] = [];
for (const check of checks) {
const absolutePath = rootPath(check.path);
let text = "";
try {
const stat = statSync(absolutePath);
if (stat.size < check.minBytes) failures.push(`${check.path} is too small: ${stat.size} < ${check.minBytes}`);
text = readFileSync(absolutePath, "utf8");
} catch (error) {
failures.push(`${check.path} is missing: ${String(error)}`);
continue;
}
for (const needle of check.contains) {
if (!text.includes(needle)) failures.push(`${check.path} does not contain ${needle}`);
}
}
if (failures.length > 0) {
console.error(JSON.stringify({ ok: false, component: "web-probe-sentinel-monitor-web", failures, valuesRedacted: true }, null, 2));
process.exit(1);
}
console.log(JSON.stringify({
ok: true,
component: "web-probe-sentinel-monitor-web",
stack: "vue3-vendored-browser-build",
assets: checks.map((check) => check.path),
valuesRedacted: true,
}));