fix(plugins): tolerate a UTF-8 BOM in trek-plugin.json

Windows editors love to prepend a BOM, and a bare JSON.parse then dies
with an "Unexpected token" pointing at an invisible character - in the
SDK CLIs (dev/validate/entry/submit) and, worse, server-side: a BOM in
an author repo travels through pack into the artifact and fails
discovery and registry install. Strip it at every manifest/JSON read
(readJsonFile in the SDK, parseJsonText in the installer).
This commit is contained in:
Maurice
2026-07-04 20:09:59 +02:00
committed by Maurice
parent d110f8f0ce
commit 91217e83fa
11 changed files with 47 additions and 12 deletions
+2 -1
View File
@@ -10,6 +10,7 @@ import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { execFileSync } from 'node:child_process';
import { readJsonFile } from './json.js';
const DEFAULT_REGISTRY = 'mauriceboe/TREK-Plugins';
@@ -69,7 +70,7 @@ export function submitEntry(entry: EntryLike, opts: { registry?: string; branch?
let toWrite = entry;
let action = 'add';
if (fs.existsSync(abs)) {
const existing = JSON.parse(fs.readFileSync(abs, 'utf8')) as EntryLike;
const existing = readJsonFile<EntryLike>(abs);
toWrite = mergeOnto(existing, entry);
action = 'update';
}