Skip to content

Build your personal knowledge base with Trilium Notes

feat(setup): add a nice banner when DB not initialized

Elian Doranb574237dfbf1
diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.ts
index 149420541e..b8d7d33d19 100644
--- a/apps/desktop/src/main.ts
+++ b/apps/desktop/src/main.ts
@@ -180,7 +180,7 @@ async function onReady() {
tray.createTray();
} else {
- getLog().info(t("sql_init.db_not_initialized_desktop"));
+ getLog().banner(t("sql_init.db_not_initialized_desktop"));
await windowService.createSetupWindow();
}
diff --git a/apps/server/src/main.ts b/apps/server/src/main.ts
index 61ce2b00af..c7bb8d3798 100644
--- a/apps/server/src/main.ts
+++ b/apps/server/src/main.ts
@@ -66,7 +66,7 @@ async function startApplication() {
await startTriliumServer();
if (!sql_init.isDbInitialized()) {
- getLog().info(t("sql_init.db_not_initialized_server", { port }));
+ getLog().banner(t("sql_init.db_not_initialized_server", { port }));
}
}
diff --git a/packages/trilium-core/src/services/log.ts b/packages/trilium-core/src/services/log.ts
index 686d497ad3..ab3b262d73 100644
--- a/packages/trilium-core/src/services/log.ts
+++ b/packages/trilium-core/src/services/log.ts
@@ -12,6 +12,30 @@ export default class LogService {
console.error("ERROR: ", message);
}
+ banner(message: string) {
+ const maxContent = 76; // 80 - 4 (border + padding)
+ const words = message.split(" ");
+ const lines: string[] = [];
+ let current = "";
+
+ for (const word of words) {
+ const candidate = current ? `${current} ${word}` : word;
+ if (candidate.length > maxContent) {
+ if (current) lines.push(current);
+ current = word;
+ } else {
+ current = candidate;
+ }
+ }
+ if (current) lines.push(current);
+
+ const width = Math.min(Math.max(...lines.map((l) => l.length)), maxContent) + 4;
+ const top = `╔${"═".repeat(width)}╗`;
+ const mid = lines.map((l) => `║ ${l.padEnd(width - 4)} ║`).join("\n");
+ const bot = `╚${"═".repeat(width)}╝`;
+ console.log(`\n${top}\n${mid}\n${bot}\n`);
+ }
+
}
let log: LogService;