feat(edit-docs): initialize database automatically

This commit is contained in:
Elian Doran
2025-03-10 17:04:17 +02:00
parent 6a549af34a
commit f3d753cc46
3 changed files with 17 additions and 2 deletions

View File

@@ -3,6 +3,8 @@ import fsExtra from "fs-extra";
import path from "path"; import path from "path";
import type NoteMeta from "./src/services/meta/note_meta.js"; import type NoteMeta from "./src/services/meta/note_meta.js";
import type { NoteMetaFile } 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 NOTE_ID_USER_GUIDE = "pOsGYCXsbNQG";
const destRootPath = path.join("src", "public", "app", "doc_notes", "en", "User Guide"); const destRootPath = path.join("src", "public", "app", "doc_notes", "en", "User Guide");
@@ -12,8 +14,20 @@ async function startElectron() {
} }
async function main() { async function main() {
await initializeTranslations();
await importData();
await startElectron(); 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() { async function exportData() {

View File

@@ -636,7 +636,7 @@ export function readZipFile(buffer: Buffer, processEntryCallback: (zipfile: yauz
} }
function resolveNoteType(type: string | undefined): NoteType { 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 older
if (type === "relation-map") { if (type === "relation-map") {
return "relationMap"; return "relationMap";
} else if (type === "note-map") { } else if (type === "note-map") {

View File

@@ -278,6 +278,7 @@ function transactional<T>(func: (statement: Statement) => T) {
return ret; return ret;
} catch (e) { } catch (e) {
console.warn("Got error ", e);
const entityChangeIds = cls.getAndClearEntityChangeIds(); const entityChangeIds = cls.getAndClearEntityChangeIds();
if (entityChangeIds.length > 0) { if (entityChangeIds.length > 0) {