mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 02:45:54 +01:00
chore(nx): move all monorepo-style in subfolder for processing
This commit is contained in:
@@ -1,43 +0,0 @@
|
||||
import { extractZip, initializeDatabase, startElectron } from "./electron-utils.js";
|
||||
import { initializeTranslations } from "@triliumnext/server/src/services/i18n.js";
|
||||
import debounce from "@triliumnext/client/src/services/debounce.js";
|
||||
import fs from "fs/promises";
|
||||
|
||||
const DEMO_ZIP_PATH = "db/demo.zip";
|
||||
|
||||
async function main() {
|
||||
await initializeTranslations();
|
||||
await initializeDatabase(false);
|
||||
|
||||
await startElectron();
|
||||
await registerHandlers();
|
||||
}
|
||||
|
||||
async function registerHandlers() {
|
||||
const events = (await import("@triliumnext/server/src/services/events.js")).default;
|
||||
const eraseService = (await import("@triliumnext/server/src/services/erase.js")).default;
|
||||
const debouncer = debounce(async () => {
|
||||
console.log("Exporting data");
|
||||
eraseService.eraseUnusedAttachmentsNow();
|
||||
await exportData();
|
||||
|
||||
const outputDir = "demo";
|
||||
await fs.rmdir(outputDir, { recursive: true }).catch(() => {});
|
||||
await extractZip(DEMO_ZIP_PATH, outputDir);
|
||||
}, 10_000);
|
||||
events.subscribe(events.ENTITY_CHANGED, async (e) => {
|
||||
if (e.entityName === "options") {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("Got entity changed ", e);
|
||||
debouncer();
|
||||
});
|
||||
}
|
||||
|
||||
async function exportData() {
|
||||
const { exportToZipFile } = (await import("@triliumnext/server/src/services/export/zip.js")).default;
|
||||
await exportToZipFile("root", "html", DEMO_ZIP_PATH);
|
||||
}
|
||||
|
||||
await main();
|
||||
Reference in New Issue
Block a user