mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-08-10 07:11:18 +02:00
- Removed ambiguous aliases: phpstan, cs-check, syntax - Split lint-biome into lint-css and lint-js with correct paths - Added lint meta-recipe and fix recipe (biome --unsafe + php-cs-fixer) - Fixed FormBootstrap dead null check, CSS shorthand override bug - Updated phpstan baseline, suppressed noDescendingSpecificity/noInnerDeclarations - Applied ~74 biome auto-fixes across CSS/JS
83 lines
2.1 KiB
JavaScript
83 lines
2.1 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Quick check: are dist files present and fresh?
|
|
* Exits 0 if ok, 1 if missing or stale.
|
|
*
|
|
* Staleness: any source file newer than the oldest dist file.
|
|
*/
|
|
|
|
import { existsSync, readdirSync, statSync } from "node:fs";
|
|
import { dirname, resolve } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const root = resolve(__dirname, "..");
|
|
const distDir = resolve(root, "app/public/assets/dist");
|
|
|
|
const distFiles = readdirSync(distDir).filter(
|
|
(f) => f.endsWith(".min.css") || f.endsWith(".min.js")
|
|
);
|
|
|
|
if (distFiles.length === 0) {
|
|
console.error("❌ No dist files found. Run: just build");
|
|
process.exit(1);
|
|
}
|
|
|
|
// Check each dist file exists
|
|
for (const f of distFiles) {
|
|
if (!existsSync(resolve(distDir, f))) {
|
|
console.error(`❌ Missing: dist/${f}. Run: just build`);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
// Check staleness: any source newer than the oldest dist?
|
|
function walkDir(dir, ext) {
|
|
const files = [];
|
|
const entries = readdirSync(dir, { withFileTypes: true });
|
|
for (const e of entries) {
|
|
const full = resolve(dir, e.name);
|
|
if (e.isDirectory() && e.name !== "components") {
|
|
files.push(...walkDir(full, ext));
|
|
} else if (e.isFile() && full.endsWith(ext)) {
|
|
files.push(full);
|
|
}
|
|
}
|
|
return files;
|
|
}
|
|
|
|
const cssSrcFiles = walkDir(
|
|
resolve(root, "app/public/assets/css"),
|
|
".css"
|
|
).filter((f) => !f.includes("filepond") && !f.includes("modern-normalize"));
|
|
|
|
const jsSrcFiles = walkDir(
|
|
resolve(root, "app/public/assets/js/app"),
|
|
".js"
|
|
);
|
|
|
|
const srcFiles = [...cssSrcFiles, ...jsSrcFiles];
|
|
|
|
const oldestDist = Math.min(
|
|
...distFiles.map((f) => statSync(resolve(distDir, f)).mtimeMs)
|
|
);
|
|
|
|
let stale = false;
|
|
for (const f of srcFiles) {
|
|
try {
|
|
if (statSync(f).mtimeMs > oldestDist) {
|
|
console.error(`❌ Stale dist (source newer than output): ${f}`);
|
|
stale = true;
|
|
}
|
|
} catch {
|
|
// file may not exist (e.g. entry files), skip
|
|
}
|
|
}
|
|
|
|
if (stale) {
|
|
console.error("❌ Run: just build");
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log("✅ Build output is up to date");
|