refactor(scripts): delete 20 one-off/legacy scripts

The scripts/ directory had accumulated 29 entries, half of which were
one-off fixes that had already done their job and several of which
were Supabase-era artifacts that don't apply now that the project
uses direct Postgres via `pg`.

Deleted (none referenced from package.json, CLAUDE.md, MEMORY.md,
.gitea/workflows/deploy.yml, db/seeds/, or src/):

Supabase-era one-offs (the project moved off Supabase JS/REST):
- apply-admin-create-stop.js (RPC installer against supabase.co)
- fix-archived-rls.js (RLS repair against supabase.co)
- seed.sh (pure supabase REST seeding)
- seed_tuxedo_tour.py (Python equivalent of the JS seed)

Codemods / lint fixers that ran once:
- fix-server-auth.js, fix-server-auth-ast.js
- fix-button-has-type.js, fix-control-has-associated-label.js

Versioned iteration history of one-off checks:
- check-stop-fns.js, check-stop-fns2.js, check-stop-fns3.js
- verify-stop-fns.js (only referenced by apply-admin-create-stop.js)

Other one-offs:
- cleanup-duplicate-stops.ts
- create-admin-user.ts, seed-admin.ts (superseded by provision-admin.ts)
- seed-tuxedo.ts (superseded by seed-tuxedo-2026.js)
- import-woo-to-route.ts (WooCommerce import, no longer used)
- upload-tuxedo-video.mjs, verify-email.ts, e2e-test.sh

Also updated one stale comment in src/actions/admin/users.ts that
referenced scripts/seed-admin.ts.

Kept (9 scripts, all live-referenced):
- migrate.js (package.json + deploy.yml + MEMORY.md)
- db-reset.js (package.json: db:reset)
- seed-tuxedo-2026.js (package.json: db:seed:tour)
- import-tuxedo-stops.ts (db/seeds preferred path)
- provision-admin.ts (CLAUDE.md production bootstrap)
- preflight-check.js, postflight-check.js (.gitea/workflows/deploy.yml)
- generate-pwa-icons.js, generate-pwa-screenshots.js (reproducible PWA
  build assets, referenced in design docs)

Verified: tsc clean, 174/175 tests pass (same baseline), package.json
scripts and deploy.yml all still resolve to kept scripts.
This commit is contained in:
Nora
2026-06-25 17:23:28 -06:00
parent a2285baeb4
commit a706746250
21 changed files with 1 additions and 2648 deletions
-73
View File
@@ -1,73 +0,0 @@
#!/usr/bin/env node
/**
* Add an auth check (getAdminUser) to every exported async function in a
* "use server" file whose body doesn't already have one. Idempotent.
*
* Usage: node scripts/fix-server-auth.js <file>...
*
* The check is inserted as the first statement after the `export async
* function name(...) {` line:
*
* const adminUser = await getAdminUser();
* if (!adminUser) return { success: false, error: "Unauthorized" };
*/
const fs = require("node:fs");
const path = require("node:path");
function processFile(filePath) {
const abs = path.resolve(filePath);
if (!fs.existsSync(abs)) {
console.error(`skip (not found): ${abs}`);
return 0;
}
let src = fs.readFileSync(abs, "utf8");
if (!src.includes('"use server"') && !src.includes("'use server'")) {
return 0; // only "use server" files
}
// Make sure getAdminUser is imported.
if (!/from\s+["']@\/lib\/admin-permissions["']/.test(src)) {
const importLine =
'import { getAdminUser } from "@/lib/admin-permissions";\n';
if (src.startsWith('"use server";\n')) {
src = src.replace(/^("use server";\n)/, `$1\n${importLine}`);
} else {
const m = src.match(/^(import .*?;\n)/m);
src = m ? src.replace(m[1], `${m[1]}${importLine}`) : importLine + src;
}
}
let count = 0;
src = src.replace(
/export async function (\w+)\s*\(([^)]*)\)\s*(?::\s*[^{]+)?\s*\{/g,
(match, name, params, offset) => {
const window = src.slice(offset, offset + 600);
// Already gated: skip.
if (/getAdminUser\s*\(\s*\)|getSession\s*\(\s*\)/.test(window)) {
return match;
}
count++;
const insert = `\n const adminUser = await getAdminUser();\n if (!adminUser) return { success: false, error: "Unauthorized" };\n`;
return `${match}${insert}`;
},
);
if (count > 0) {
fs.writeFileSync(abs, src, "utf8");
console.log(`patched (${count} functions): ${abs}`);
}
return count;
}
const files = process.argv.slice(2);
if (files.length === 0) {
console.error("usage: node scripts/fix-server-auth.js <file>...");
process.exit(2);
}
let patched = 0, total = 0;
for (const f of files) {
const n = processFile(f);
if (n > 0) patched++;
total += n;
}
console.log(`done — ${patched} files, ${total} functions`);