mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 20:37:21 +00:00
fix cli for cloudflare proxy and plugins
- proper cli exists required for cloudflare proxy to dispose - updated cloudflare proxy to allow proxy options (e.g. remote) - updated config command to include proper required structure for the export on code mode
This commit is contained in:
@@ -7,13 +7,14 @@ import { withConfigOptions } from "cli/utils/options";
|
||||
export const sync: CliCommand = (program) => {
|
||||
withConfigOptions(program.command("sync"))
|
||||
.description("sync database")
|
||||
.option("--dump", "dump operations to console instead of executing them")
|
||||
.option("--force", "perform database syncing operations")
|
||||
.option("--drop", "include destructive DDL operations")
|
||||
.option("--out <file>", "output file")
|
||||
.option("--sql", "use sql output")
|
||||
.action(async (options) => {
|
||||
const app = await makeAppFromEnv(options);
|
||||
const schema = app.em.schema();
|
||||
console.info(c.dim("Checking database state..."));
|
||||
const stmts = await schema.sync({ drop: options.drop });
|
||||
|
||||
console.info("");
|
||||
@@ -24,22 +25,27 @@ export const sync: CliCommand = (program) => {
|
||||
// @todo: currently assuming parameters aren't used
|
||||
const sql = stmts.map((d) => d.sql).join(";\n") + ";";
|
||||
|
||||
if (options.dump) {
|
||||
if (options.force) {
|
||||
console.info(c.dim("Executing:") + "\n" + c.cyan(sql));
|
||||
await schema.sync({ force: true, drop: options.drop });
|
||||
|
||||
console.info(`\n${c.gray(`Executed ${c.cyan(stmts.length)} statement(s)`)}`);
|
||||
console.info(`${c.green("Database synced")}`);
|
||||
} else {
|
||||
if (options.out) {
|
||||
const output = options.sql ? sql : JSON.stringify(stmts, null, 2);
|
||||
await writeFile(options.out, output);
|
||||
console.info(`SQL written to ${c.cyan(options.out)}`);
|
||||
} else {
|
||||
console.info(options.sql ? c.cyan(sql) : stmts);
|
||||
console.info(c.dim("DDL to execute:") + "\n" + c.cyan(sql));
|
||||
|
||||
console.info(
|
||||
c.yellow(
|
||||
"\nNo statements have been executed. Use --force to perform database syncing operations",
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
await schema.sync({ force: true, drop: options.drop });
|
||||
console.info(c.cyan(sql));
|
||||
|
||||
console.info(`${c.gray(`Executed ${c.cyan(stmts.length)} statement(s)`)}`);
|
||||
console.info(`${c.green("Database synced")}`);
|
||||
process.exit(0);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user