Initial commit of Descrybe v2 without local scratch artifacts.
Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Cross-platform goose migrate + sqlc generate (Windows / macOS / Linux).
|
||||
* Loads monorepo-root `.env` when DATABASE_URL is unset.
|
||||
*
|
||||
* Usage: node scripts/migrate.mjs
|
||||
*/
|
||||
import { spawnSync } from "node:child_process";
|
||||
import path from "node:path";
|
||||
import { loadRootEnv, repoRoot } from "./root-env.mjs";
|
||||
|
||||
const env = loadRootEnv(process.env);
|
||||
if (!env.DATABASE_URL) {
|
||||
console.error(
|
||||
"DATABASE_URL is required (set in monorepo-root .env or the shell; see .env.example)",
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const apiDir = path.join(repoRoot, "apps", "api");
|
||||
|
||||
function run(command, args, opts = {}) {
|
||||
const r = spawnSync(command, args, {
|
||||
cwd: apiDir,
|
||||
env,
|
||||
stdio: "inherit",
|
||||
shell: process.platform === "win32",
|
||||
...opts,
|
||||
});
|
||||
if (r.error) {
|
||||
console.error(r.error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
if (r.status !== 0) {
|
||||
process.exit(r.status ?? 1);
|
||||
}
|
||||
}
|
||||
|
||||
console.log("==> goose up (apps/api/sql/schema)");
|
||||
run("go", [
|
||||
"run",
|
||||
"github.com/pressly/goose/v3/cmd/goose@v3.24.3",
|
||||
"-dir",
|
||||
"sql/schema",
|
||||
"postgres",
|
||||
env.DATABASE_URL,
|
||||
"up",
|
||||
]);
|
||||
|
||||
console.log("==> sqlc generate");
|
||||
const sqlc = spawnSync("sqlc", ["generate"], {
|
||||
cwd: apiDir,
|
||||
env,
|
||||
stdio: "inherit",
|
||||
shell: process.platform === "win32",
|
||||
});
|
||||
if (sqlc.status !== 0) {
|
||||
console.log("sqlc not on PATH (or failed); using go run");
|
||||
run("go", [
|
||||
"run",
|
||||
"github.com/sqlc-dev/sqlc/cmd/sqlc@v1.28.0",
|
||||
"generate",
|
||||
]);
|
||||
}
|
||||
|
||||
console.log("==> done");
|
||||
Reference in New Issue
Block a user