Replace brocli framework with Node's built-in util.parseArgs and a declarative command registry. The CLI no longer hangs after completing because: - DB connections are lazily created and explicitly closed - Winston/Redis logging is excluded from the bundle entirely - process.exit() is always called with proper exit codes Additional improvements: - Bundle size reduced from 5.3MB to 1.2MB (native drivers externalized) - Proper column-aligned table output for list commands - --json flag on list commands for scripting/automation - Per-command --help with usage examples - Execution timing shown on success - Consistent exit codes (0=success, 1=error, 2=usage) - Docker wrapper sets DISABLE_REDIS_LOGS and uses exec
60 lines
1.5 KiB
TypeScript
60 lines
1.5 KiB
TypeScript
import type { InferSelectModel } from "drizzle-orm";
|
|
|
|
import { createDbMapping as createSchema } from "@homarr/core/infrastructure/db/mapping";
|
|
|
|
import * as mysqlSchema from "./mysql";
|
|
import * as pgSchema from "./postgresql";
|
|
import * as sqliteSchema from "./sqlite";
|
|
|
|
export type PostgreSqlSchema = typeof pgSchema;
|
|
export type MySqlSchema = typeof mysqlSchema;
|
|
|
|
export const schema = createSchema({
|
|
"better-sqlite3": () => sqliteSchema,
|
|
mysql2: () => mysqlSchema,
|
|
"node-postgres": () => pgSchema,
|
|
});
|
|
|
|
// Sadly we can't use export * from here as we have multiple possible exports
|
|
export const {
|
|
accounts,
|
|
apiKeys,
|
|
apps,
|
|
boardGroupPermissions,
|
|
boardUserPermissions,
|
|
boards,
|
|
groupMembers,
|
|
groupPermissions,
|
|
groups,
|
|
iconRepositories,
|
|
icons,
|
|
integrationGroupPermissions,
|
|
integrationItems,
|
|
integrationSecrets,
|
|
integrationUserPermissions,
|
|
integrations,
|
|
invites,
|
|
items,
|
|
medias,
|
|
onboarding,
|
|
searchEngines,
|
|
sections,
|
|
serverSettings,
|
|
sessions,
|
|
users,
|
|
verificationTokens,
|
|
sectionCollapseStates,
|
|
layouts,
|
|
itemLayouts,
|
|
sectionLayouts,
|
|
trustedCertificateHostnames,
|
|
cronJobConfigurations,
|
|
} = schema;
|
|
|
|
export type User = InferSelectModel<typeof schema.users>;
|
|
export type Account = InferSelectModel<typeof schema.accounts>;
|
|
export type Session = InferSelectModel<typeof schema.sessions>;
|
|
export type VerificationToken = InferSelectModel<typeof schema.verificationTokens>;
|
|
export type Integration = InferSelectModel<typeof schema.integrations>;
|
|
export type IntegrationSecret = InferSelectModel<typeof schema.integrationSecrets>;
|