|
|
|
|
@ -20,22 +20,9 @@ async function main() {
|
|
|
|
|
await initializeTranslations();
|
|
|
|
|
const zipBuffer = await createImportZip();
|
|
|
|
|
await initializeDatabase();
|
|
|
|
|
cls.init(() => {
|
|
|
|
|
importData(zipBuffer);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await importData(zipBuffer);
|
|
|
|
|
await startElectron();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const events = (await import("./src/services/events.js")).default;
|
|
|
|
|
const debouncer = debounce(() => {
|
|
|
|
|
console.log("Exporting data");
|
|
|
|
|
exportData();
|
|
|
|
|
}, 10_000);;
|
|
|
|
|
events.subscribe(events.ENTITY_CHANGED, async () => {
|
|
|
|
|
console.log("Got entity changed");
|
|
|
|
|
debouncer();
|
|
|
|
|
});
|
|
|
|
|
await registerHandlers();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function initializeDatabase() {
|
|
|
|
|
@ -48,7 +35,9 @@ async function initializeDatabase() {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function importData(input: Buffer) {
|
|
|
|
|
function importData(input: Buffer) {
|
|
|
|
|
return new Promise<void>((resolve, reject) => {
|
|
|
|
|
cls.init(async () => {
|
|
|
|
|
const beccaLoader = ((await import("./src/becca/becca_loader.js")).default);
|
|
|
|
|
const notes = ((await import("./src/services/notes.js")).default);
|
|
|
|
|
beccaLoader.load();
|
|
|
|
|
@ -78,6 +67,9 @@ async function importData(input: Buffer) {
|
|
|
|
|
|
|
|
|
|
const { runOnDemandChecks } = (await import("./src/services/consistency_checks.js")).default;
|
|
|
|
|
await runOnDemandChecks(true);
|
|
|
|
|
resolve();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -162,4 +154,16 @@ async function cleanUpMeta() {
|
|
|
|
|
await fs.writeFile(metaPath, JSON.stringify(meta, null, 4));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function registerHandlers() {
|
|
|
|
|
const events = (await import("./src/services/events.js")).default;
|
|
|
|
|
const debouncer = debounce(() => {
|
|
|
|
|
console.log("Exporting data");
|
|
|
|
|
exportData();
|
|
|
|
|
}, 10_000);;
|
|
|
|
|
events.subscribe(events.ENTITY_CHANGED, async (e) => {
|
|
|
|
|
console.log("Got entity changed ", e);
|
|
|
|
|
debouncer();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await main();
|
|
|
|
|
|