/**
 * One-off / utility: normalize `public $timestamps` to 4-space class-body indent.
 */
import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const modelsDir = path.join(__dirname, "..", "app", "Models");

let changed = 0;
for (const f of fs.readdirSync(modelsDir).filter((x) => x.endsWith(".php"))) {
  const fp = path.join(modelsDir, f);
  let c = fs.readFileSync(fp, "utf8");
  const n = c.replace(
    /^(\s+)public \$timestamps = (.+)$/gm,
    (_, __, rest) => `    public $timestamps = ${rest}`
  );
  if (n !== c) {
    fs.writeFileSync(fp, n);
    changed++;
  }
}
console.log(`normalize_model_timestamps_indent: updated ${changed} file(s)`);
