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
@@ -72,6 +72,13 @@ describe('discoverPlugins', () => {
expect(JSON.parse(row.granted_permissions)).toEqual(['db:own']); // grants preserved
});
it('tolerates a UTF-8 BOM in trek-plugin.json (Windows-authored plugins)', () => {
writePlugin('bom-plug', { type: 'integration' });
const mp = path.join(codeRoot, 'bom-plug', 'trek-plugin.json');
fs.writeFileSync(mp, '\uFEFF' + fs.readFileSync(mp, 'utf8'));
expect(discoverPlugins(db).discovered).toEqual(['bom-plug']);
});
it('skips an invalid manifest and logs the reason', () => {
writePlugin('bad', { type: 'not-a-type' });
const res = discoverPlugins(db);