Files
cfw-auth/scripts/check-better-auth-migration.mjs
imeepos e3057928a2 feat: add better authentication features and organization management
- Introduced new database migration for enhanced user and organization management.
- Updated package dependencies to include new Better Auth modules for API keys, Expo, and i18n.
- Implemented SMS functionality for phone verification and password resets.
- Enhanced authentication plugins with username and phone number support.
- Added performance configuration options for session cookie caching and API key updates.
- Updated email templates to include organization invitation messages.
- Improved testing coverage for new features and configurations.
2026-06-10 19:39:15 -07:00

62 lines
1.5 KiB
JavaScript

import { spawn } from "node:child_process";
import { mkdtemp, readFile, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { fileURLToPath } from "node:url";
const projectRoot = fileURLToPath(new URL("..", import.meta.url));
const expectedFile = fileURLToPath(
new URL("../docs/schema/better-auth-target.sql", import.meta.url),
);
function run(command, args) {
return new Promise((resolve, reject) => {
const child = spawn(command, args, {
cwd: projectRoot,
stdio: "inherit",
shell: process.platform === "win32",
});
child.on("error", reject);
child.on("exit", (code) => {
if (code === 0) {
resolve();
return;
}
reject(new Error(`${command} ${args.join(" ")} exited with code ${code}`));
});
});
}
const tempDir = await mkdtemp(join(tmpdir(), "cfw-auth-better-auth-"));
const generatedFile = join(tempDir, "better-auth.sql");
try {
await run("pnpm", [
"exec",
"auth",
"generate",
"--config",
"src/auth.migration.ts",
"--output",
generatedFile,
"-y",
]);
const [expected, generated] = await Promise.all([
readFile(expectedFile, "utf8"),
readFile(generatedFile, "utf8"),
]);
if (expected !== generated) {
throw new Error(
`${expectedFile} is out of date. Run pnpm db:generate and review the generated SQL.`,
);
}
console.log(`${expectedFile} is up to date.`);
} finally {
await rm(tempDir, { recursive: true, force: true });
}