diff --git a/app/src/App.ts b/app/src/App.ts index 633b9fa..2a8d203 100644 --- a/app/src/App.ts +++ b/app/src/App.ts @@ -5,7 +5,6 @@ import type { em as prototypeEm } from "data/prototype"; import { Connection } from "data/connection/Connection"; import type { Hono } from "hono"; import { - type InitialModuleConfigs, type ModuleConfigs, type Modules, ModuleManager, @@ -381,8 +380,10 @@ export class App< if (results.length > 0) { for (const { name, result } of results) { if (result) { - $console.log(`[Plugin:${name}] schema`); ctx.helper.ensureSchema(result); + if (ctx.flags.sync_required) { + $console.log(`[Plugin:${name}] schema, sync required`); + } } } } diff --git a/app/src/modes/hybrid.ts b/app/src/modes/hybrid.ts index 7a8022b..c7c1c37 100644 --- a/app/src/modes/hybrid.ts +++ b/app/src/modes/hybrid.ts @@ -23,26 +23,17 @@ export type HybridMode = AdapterConfig extends ? BkndModeConfig> : never; -export function hybrid({ - configFilePath = "bknd-config.json", - ...rest -}: HybridBkndConfig): BkndConfig { +export function hybrid(hybridConfig: HybridBkndConfig): BkndConfig { return { - ...rest, - config: undefined, app: async (args) => { const { config: appConfig, isProd, plugins, syncSchemaOptions, - } = await makeModeConfig( - { - ...rest, - configFilePath, - }, - args, - ); + } = await makeModeConfig(hybridConfig, args); + + const configFilePath = appConfig.configFilePath ?? "bknd-config.json"; if (appConfig?.options?.mode && appConfig?.options?.mode !== "db") { $console.warn("You should not set a different mode than `db` when using hybrid mode"); @@ -80,6 +71,13 @@ export function hybrid({ skipValidation: isProd, // secrets are required for hybrid mode secrets: appConfig.secrets, + onModulesBuilt: async (ctx) => { + if (ctx.flags.sync_required && !isProd && syncSchemaOptions.force) { + $console.log("[hybrid] syncing schema"); + await ctx.em.schema().sync(syncSchemaOptions); + } + await appConfig?.options?.manager?.onModulesBuilt?.(ctx); + }, ...appConfig?.options?.manager, }, }, diff --git a/biome.json b/biome.json index 95ea38a..dfaa243 100644 --- a/biome.json +++ b/biome.json @@ -68,7 +68,7 @@ "noArrayIndexKey": "off", "noImplicitAnyLet": "warn", "noConfusingVoidType": "off", - "noConsole": { "level": "warn", "options": { "allow": ["log"] } } + "noConsole": { "level": "warn", "options": { "allow": ["error"] } } }, "security": { "noDangerouslySetInnerHtml": "off"