Skip to content

Build your personal knowledge base with Trilium Notes

refactor(edit-docs): drop the app version from the exported docs metadata

Elian Doranb2d034a8b9c4
diff --git a/apps/edit-docs/src/edit-docs.ts b/apps/edit-docs/src/edit-docs.ts
index 9e024228dd..7498d02b89 100644
--- a/apps/edit-docs/src/edit-docs.ts
+++ b/apps/edit-docs/src/edit-docs.ts
@@ -2,7 +2,7 @@ import debounce from "@triliumnext/client/src/services/debounce.js";
import type { AdvancedExportOptions, ExportFormat, NoteMeta, NoteMetaFile } from "@triliumnext/core";
import { cls } from "@triliumnext/core";
-import { parseNoteMetaFile, serverTextNoteHandler, standaloneTextNoteHandler } from "./help_meta_generator.js";
+import { parseNoteMetaFile, serverTextNoteHandler, standaloneTextNoteHandler, stripAppVersion } from "./help_meta_generator.js";
import fs from "fs/promises";
import { load } from "js-yaml";
import path from "path";
@@ -246,7 +246,7 @@ async function cleanUpMeta(outputPath: string, minify: boolean) {
const standaloneMetaPath = path.resolve(__dirname, "../../standalone/src/assets/help_meta.json");
await fs.writeFile(standaloneMetaPath, JSON.stringify(standaloneSubtree));
} else {
- await fs.writeFile(metaPath, JSON.stringify(meta, null, 4));
+ await fs.writeFile(metaPath, JSON.stringify(stripAppVersion(meta), null, 4));
}
}
diff --git a/apps/edit-docs/src/help_meta_generator.spec.ts b/apps/edit-docs/src/help_meta_generator.spec.ts
index 5078b2164d..6272508bbb 100644
--- a/apps/edit-docs/src/help_meta_generator.spec.ts
+++ b/apps/edit-docs/src/help_meta_generator.spec.ts
@@ -1,8 +1,8 @@
import type { HiddenSubtreeItem } from "@triliumnext/commons";
-import type { NoteMeta } from "@triliumnext/core";
+import type { NoteMeta, NoteMetaFile } from "@triliumnext/core";
import { describe, expect, it } from "vitest";
-import { parseNoteMetaFile, serverTextNoteHandler, standaloneTextNoteHandler } from "./help_meta_generator.js";
+import { parseNoteMetaFile, serverTextNoteHandler, standaloneTextNoteHandler, stripAppVersion } from "./help_meta_generator.js";
describe("Help meta generation (server)", () => {
it("preserves custom folder icon", () => {
@@ -306,3 +306,20 @@ describe("Help meta generation (standalone)", () => {
expect(items[0].type).toBe("book");
});
});
+
+describe("stripAppVersion", () => {
+ it("drops the version stamp and keeps everything else the docs metadata carries", () => {
+ const meta = {
+ formatVersion: 2,
+ appVersion: "0.105.0",
+ files: [{ noteId: "abc", title: "Note", attributes: [] }]
+ } as unknown as NoteMetaFile;
+
+ const stripped = stripAppVersion(meta);
+
+ expect("appVersion" in stripped).toBe(false);
+ expect(stripped).toStrictEqual({ formatVersion: 2, files: meta.files });
+ // The input is left alone: the minified branch of the export reads the same object.
+ expect(meta.appVersion).toBe("0.105.0");
+ });
+});
diff --git a/apps/edit-docs/src/help_meta_generator.ts b/apps/edit-docs/src/help_meta_generator.ts
index a16880e0a4..de89a594a9 100644
--- a/apps/edit-docs/src/help_meta_generator.ts
+++ b/apps/edit-docs/src/help_meta_generator.ts
@@ -59,6 +59,17 @@ export function parseNoteMetaFile(noteMetaFile: NoteMetaFile, handleTextNote: Te
return parsedMetaRoot?.children ?? [];
}
+/**
+ * Drops the app version the exporter stamps onto a meta file. Nothing reads it back — neither the
+ * importer nor {@link parseNoteMetaFile} — while it moves on every release, so keeping it rewrites
+ * the committed documentation metadata for a field no code consults. An export a user takes of
+ * their own notes keeps it, as a record of the build that wrote the zip.
+ */
+export function stripAppVersion(meta: NoteMetaFile): Omit<NoteMetaFile, "appVersion"> {
+ const { appVersion, ...rest } = meta;
+ return rest;
+}
+
interface CanonicalOccurrence {
iconClass: string;
docPath?: string;