From 34d26c7ecb4233ebb1a779a3d0dfbc1284dcc777 Mon Sep 17 00:00:00 2001 From: mkelvers Date: Tue, 16 Jun 2026 13:45:05 +0200 Subject: [PATCH] chore: remove old TypeScript build scripts --- package.json | 3 +- scripts/build-ts.ts | 85 ----------------------------------------- scripts/new-data-fix.ts | 73 ----------------------------------- 3 files changed, 1 insertion(+), 160 deletions(-) delete mode 100644 scripts/build-ts.ts delete mode 100644 scripts/new-data-fix.ts diff --git a/package.json b/package.json index fb1a5ce..2b1e449 100644 --- a/package.json +++ b/package.json @@ -5,9 +5,8 @@ "scripts": { "build:css": "bunx --bun @tailwindcss/cli -i ./static/assets/style.css -o ./dist/tailwind.css", "watch:css": "bunx --bun @tailwindcss/cli -i ./static/assets/style.css -o ./dist/tailwind.css --watch", - "build:ts": "bun ./scripts/build-ts.ts", "typecheck": "bunx tsc -p tsconfig.json --noEmit", - "build:assets": "bun run build:css && bun run build:ts", + "build:assets": "bun run build:css", "format": "bunx oxfmt", "format:check": "bunx oxfmt --check", "lint": "bun run lint:ts && bun run lint:go", diff --git a/scripts/build-ts.ts b/scripts/build-ts.ts deleted file mode 100644 index 0d67730..0000000 --- a/scripts/build-ts.ts +++ /dev/null @@ -1,85 +0,0 @@ -import { copyFile } from "node:fs/promises"; -import { spawnSync } from "node:child_process"; - -type BuildStep = { - name: string; - command: string[]; -}; - -const steps: BuildStep[] = [ - { - name: "player", - command: [ - "bun", - "build", - "./static/player/main.ts", - "--outdir", - "./dist/static/player", - "--target", - "browser", - "--splitting", - ], - }, -]; - -const startedAt = performance.now(); - -main().catch((error: unknown) => { - const message = error instanceof Error ? error.message : String(error); - console.error(`ts build failed: ${message}`); - process.exit(1); -}); - -async function main(): Promise { - steps.push({ - name: "app", - command: [ - "bun", - "build", - "./static/app.ts", - "--outdir", - "./dist/static", - "--target", - "browser", - "--root", - "./static", - "--entry-naming", - "[name].js", - ], - }); - - for (const step of steps) { - const result = spawnSync(step.command[0], step.command.slice(1), { - stdio: "pipe", - }); - - if (result.status !== 0) { - const detail = summarizeFailure(result.stderr, result.stdout); - console.error(`ts build failed at ${step.name}${detail === "" ? "" : `: ${detail}`}`); - process.exit(result.status ?? 1); - } - } - - await copyFile("./node_modules/htmx.org/dist/htmx.min.js", "./dist/static/htmx-lib.js"); - - const playerEntries = 1; - const totalEntries = playerEntries + 1; - const elapsedMs = Math.round(performance.now() - startedAt); - - console.log(`ts build ok (${totalEntries} entries, ${elapsedMs}ms)`); -} - -function summarizeFailure(stderr: Uint8Array, stdout: Uint8Array): string { - const combined = - `${Buffer.from(stderr).toString("utf8")}${Buffer.from(stdout).toString("utf8")}`.trim(); - if (combined === "") { - return ""; - } - - const lines = combined - .split(/\r?\n/) - .map((line) => line.trim()) - .filter((line) => line !== ""); - - return lines[lines.length - 1] ?? ""; -} diff --git a/scripts/new-data-fix.ts b/scripts/new-data-fix.ts deleted file mode 100644 index 8fba986..0000000 --- a/scripts/new-data-fix.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { mkdir, writeFile, access } from "node:fs/promises"; -import { constants as fsConstants } from "node:fs"; -import path from "node:path"; - -function toSlug(raw: string): string { - const trimmed = raw.trim().toLowerCase(); - const slug = trimmed.replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, ""); - return slug; -} - -function formatYYYYMMDD(date: Date): string { - const year = String(date.getFullYear()); - const month = String(date.getMonth() + 1).padStart(2, "0"); - const day = String(date.getDate()).padStart(2, "0"); - return `${year}${month}${day}`; -} - -async function fileExists(filePath: string): Promise { - try { - await access(filePath, fsConstants.F_OK); - return true; - } catch { - return false; - } -} - -async function main(): Promise { - const rawName = process.argv[2] ?? ""; - const slug = toSlug(rawName); - if (slug.length === 0) { - throw new Error("usage: bun scripts/new-data-fix.ts "); - } - - const id = `${formatYYYYMMDD(new Date())}_${slug}`; - const dir = path.join(process.cwd(), "internal", "database", "fixes"); - const filePath = path.join(dir, `${id}.go`); - - await mkdir(dir, { recursive: true }); - - if (await fileExists(filePath)) { - throw new Error(`data fix already exists: ${filePath}`); - } - - const contents = `package fixes - -import ( - "context" - "database/sql" - "fmt" -) - -func init() { - Register(Fix{ - ID: "${id}", - Apply: func(ctx context.Context, sqlDB *sql.DB) error { - // TODO: implement fix - // _, err := sqlDB.ExecContext(ctx, \`UPDATE ...\`) - // if err != nil { return fmt.Errorf("...: %w", err) } - return fmt.Errorf("unimplemented data fix: ${id}") - }, - }) -} -`; - - await writeFile(filePath, contents, { encoding: "utf8" }); - process.stdout.write(`${filePath}\n`); -} - -main().catch((error: unknown) => { - const message = error instanceof Error ? error.message : String(error); - process.stderr.write(`${message}\n`); - process.exitCode = 1; -});