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(icon-pack-builder): add manifest to zip
Elian Doran850528750ca9
diff --git a/apps/icon-pack-builder/src/index.ts b/apps/icon-pack-builder/src/index.tsindex 58907e2f69..3303816cad 100644--- a/apps/icon-pack-builder/src/index.ts+++ b/apps/icon-pack-builder/src/index.ts@@ -1,7 +1,9 @@import { createWriteStream } from "node:fs";++import cls from "@triliumnext/server/src/services/cls.js";+import type { IconPackData } from "./provider";import mdi from "./providers/mdi";-import cls from "@triliumnext/server/src/services/cls.js";process.env.TRILIUM_INTEGRATION_TEST = "memory-no-store";process.env.TRILIUM_RESOURCE_DIR = "../server/src";@@ -18,46 +20,35 @@ async function main() {const beccaLoader = await import("../../server/src/becca/becca_loader.js");await beccaLoader.beccaLoaded;- const becca = (await import("../../server/src/becca/becca.js")).default;- const rootNote = becca.getNote("root");const notesService = (await import("../../server/src/services/notes.js")).default;- const builtIconPacks = [- mdi()- ];-- function buildIconPack(iconPack: IconPackData) {- return new Promise(async (res, rej) => {- // Create the icon pack note.- const { note, branch } = notesService.createNewNote({- parentNoteId: "root",- type: "file",- title: iconPack.name,- mime: "application/json",- content: "Hello"- });- note.setLabel("iconPack", iconPack.prefix);-- // Export to zip.- const zipFilePath = `icon-pack-${iconPack.prefix}.zip`;- const fileOutputStream = createWriteStream(zipFilePath);- const { exportToZip } = (await import("@triliumnext/server/src/services/export/zip.js")).default;- const taskContext = new (await import("@triliumnext/server/src/services/task_context.js")).default(- "no-progress-reporting",- "export",- null- );- await exportToZip(taskContext, branch, "html", fileOutputStream, false, {- skipExtraFiles: true- });- await new Promise<void>((resolve) => {- fileOutputStream.on("finish", resolve);- });-- console.log(`Built icon pack: ${iconPack.name} (${zipFilePath})`);+ async function buildIconPack(iconPack: IconPackData) {+ // Create the icon pack note.+ const { note, branch } = notesService.createNewNote({+ parentNoteId: "root",+ type: "file",+ title: iconPack.name,+ mime: "application/json",+ content: JSON.stringify(iconPack.manifest)});+ note.setLabel("iconPack", iconPack.prefix);++ // Export to zip.+ const zipFilePath = `icon-pack-${iconPack.prefix}.zip`;+ const fileOutputStream = createWriteStream(zipFilePath);+ const { exportToZip } = (await import("@triliumnext/server/src/services/export/zip.js")).default;+ const taskContext = new (await import("@triliumnext/server/src/services/task_context.js")).default(+ "no-progress-reporting", "export", null+ );+ await exportToZip(taskContext, branch, "html", fileOutputStream, false, { skipExtraFiles: true });+ await new Promise<void>((resolve) => { fileOutputStream.on("finish", resolve); });++ console.log(`Built icon pack: ${iconPack.name} (${zipFilePath})`);}+ const builtIconPacks = [+ mdi()+ ];await Promise.all(builtIconPacks.map(buildIconPack));}diff --git a/apps/icon-pack-builder/src/provider.ts b/apps/icon-pack-builder/src/provider.tsindex 0a1de81afe..0787801eaf 100644--- a/apps/icon-pack-builder/src/provider.ts+++ b/apps/icon-pack-builder/src/provider.ts@@ -1,7 +1,7 @@-import { IconPackManifest } from "@triliumnext/server/src/services/icon_packs";+import type { IconPackManifest } from "@triliumnext/server/src/services/icon_packs";export interface IconPackData {name: string;prefix: string;- // manifest: IconPackManifest;+ manifest: IconPackManifest;}diff --git a/apps/icon-pack-builder/src/providers/mdi.ts b/apps/icon-pack-builder/src/providers/mdi.tsindex 71a8d68b25..c1816d0d3c 100644--- a/apps/icon-pack-builder/src/providers/mdi.ts+++ b/apps/icon-pack-builder/src/providers/mdi.ts@@ -12,8 +12,8 @@ export default function buildIcons(): IconPackData {return {name: "Material Design Icons",prefix: "mdi",- // manifest: {- // icons: extractClassNamesFromCss(cssFileContent, "mdi"),- // },+ manifest: {+ icons: extractClassNamesFromCss(cssFileContent, "mdi"),+ },};}