refactor: split repo into docs/ mockup/ app/
- move static mockups from resource/ui to mockup/ - move React app scaffold from resource/ui to app/ - move prome.md + images to docs/ - drop empty resource/jsonfile and resource/ - add root .gitignore - rewrite README for new layout - fix paths in mockup/index.html (resource/ui -> mockup, docs/prome.md)
This commit is contained in:
1 parent
8e87e47017
commit
92a2adad6a
133 files changed
+23416
-50
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
|
||||
const branchKind = process.env.FUSION_BRANCH_KIND;
|
||||
|
||||
if (branchKind !== "feature") {
|
||||
if (branchKind !== "main") {
|
||||
console.warn(
|
||||
`Skipping database migrations because FUSION_BRANCH_KIND is ${branchKind ?? "unset"}`,
|
||||
);
|
||||
}
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
if (!process.env.DATABASE_URL_UNPOOLED) {
|
||||
console.warn(
|
||||
"Skipping database migrations because DATABASE_URL_UNPOOLED is not set",
|
||||
);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const isWindows = process.platform === "win32";
|
||||
const pnpmCommand = isWindows ? "pnpm.cmd" : "pnpm";
|
||||
const result = spawnSync(pnpmCommand, ["run", "db:migrate"], {
|
||||
env: process.env,
|
||||
shell: isWindows,
|
||||
stdio: "inherit",
|
||||
});
|
||||
|
||||
if (result.error) {
|
||||
console.error(result.error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
process.exit(result.status ?? 1);
|
||||
@@ -0,0 +1,53 @@
|
||||
import { realpathSync } from "node:fs";
|
||||
import { fileURLToPath, pathToFileURL } from "node:url";
|
||||
|
||||
import { closeDbExec, withMigrationRuntime } from "@agent-native/core/db";
|
||||
import { loadEnv } from "@agent-native/core/scripts";
|
||||
import {
|
||||
runAppReleaseMigrations,
|
||||
runFrameworkReleaseMigrations,
|
||||
} from "@agent-native/core/server";
|
||||
|
||||
loadEnv();
|
||||
|
||||
async function main(): Promise<void> {
|
||||
await withMigrationRuntime(async () => {
|
||||
await runFrameworkReleaseMigrations(null);
|
||||
await runAppReleaseMigrations();
|
||||
});
|
||||
}
|
||||
|
||||
// Guard: closeDbExec() below tears down the shared database pool, so this
|
||||
// script must run only as its own process (`pnpm migrate:production`). The
|
||||
// framework's action auto-discovery would otherwise mount it as a live route
|
||||
// and running the teardown in-process breaks every other request with "Cannot
|
||||
// use a pool after calling end on the pool." Throw instead of tearing down a
|
||||
// pool this process does not own.
|
||||
function isProcessEntrypoint(): boolean {
|
||||
const entry = process.argv[1];
|
||||
if (!entry) return false;
|
||||
try {
|
||||
return (
|
||||
pathToFileURL(realpathSync(entry)).href ===
|
||||
pathToFileURL(realpathSync(fileURLToPath(import.meta.url))).href
|
||||
);
|
||||
} catch {
|
||||
// coercion-ok: an unresolvable entry path is not this script, so the guard below throws.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isProcessEntrypoint()) {
|
||||
throw new Error(
|
||||
"scripts/migrate-production.ts must run as its own process " +
|
||||
"(pnpm migrate:production); it closes the shared database pool when it " +
|
||||
"finishes, so importing or invoking it in-process — e.g. via an " +
|
||||
"auto-discovered action route — would break every other request.",
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
await main();
|
||||
} finally {
|
||||
await closeDbExec();
|
||||
}
|
||||
Reference in new issue
Block a user