Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(edit-docs): initialize database automatically
Elian Doranf3d753cc468b
diff --git a/electron-docs-main.ts b/electron-docs-main.tsindex ce32393fa6..276c8a9f3e 100644--- a/electron-docs-main.ts+++ b/electron-docs-main.ts@@ -3,6 +3,8 @@ import fsExtra from "fs-extra";import path from "path";import type NoteMeta from "./src/services/meta/note_meta.js";import type { NoteMetaFile } from "./src/services/meta/note_meta.js";+import cls from "./src/services/cls.js";+import { initializeTranslations } from "./src/services/i18n.js";const NOTE_ID_USER_GUIDE = "pOsGYCXsbNQG";const destRootPath = path.join("src", "public", "app", "doc_notes", "en", "User Guide");@@ -12,8 +14,20 @@ async function startElectron() {}async function main() {+ await initializeTranslations();+ await importData();+await startElectron();- await exportData();+ // await exportData();+}++async function importData() {+ const sql = (await import("./src/services/sql.js")).default;+ const sqlInit = (await import("./src/services/sql_init.js")).default;++ cls.init(() => {+ sqlInit.createInitialDatabase();+ });}async function exportData() {diff --git a/src/services/import/zip.ts b/src/services/import/zip.tsindex 49cde38f6e..ab4a21adcb 100644--- a/src/services/import/zip.ts+++ b/src/services/import/zip.ts@@ -636,7 +636,7 @@ export function readZipFile(buffer: Buffer, processEntryCallback: (zipfile: yauz}function resolveNoteType(type: string | undefined): NoteType {- // BC for ZIPs created in Triliun 0.57 and older+ // BC for ZIPs created in Trilium 0.57 and olderif (type === "relation-map") {return "relationMap";} else if (type === "note-map") {diff --git a/src/services/sql.ts b/src/services/sql.tsindex b39cbe1ad9..16771b5e69 100644--- a/src/services/sql.ts+++ b/src/services/sql.ts@@ -278,6 +278,7 @@ function transactional<T>(func: (statement: Statement) => T) {return ret;} catch (e) {+ console.warn("Got error ", e);const entityChangeIds = cls.getAndClearEntityChangeIds();if (entityChangeIds.length > 0) {