From c96c0a18e1223104c9a4864b26afc73dbb10119e Mon Sep 17 00:00:00 2001 From: /home/neo <158327205+neoapps-dev@users.noreply.github.com> Date: Thu, 23 Apr 2026 14:30:32 +0300 Subject: [PATCH] fix: proper jsonc support --- scripts/registry.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/scripts/registry.js b/scripts/registry.js index 5cf0d0a..1d19a9f 100644 --- a/scripts/registry.js +++ b/scripts/registry.js @@ -1,11 +1,10 @@ import { readdirSync, readFileSync, writeFileSync, statSync } from "fs"; import { join } from "path"; - +import { parse } from "jsonc-parser"; const OUTPUT_FILE = "./registry.json"; const VALID_CATEGORIES = ["Skin", "Texture", "World", "Mod", "DLC"]; const REQUIRED_FIELDS = ["id", "name", "author", "description", "extended_description", "category", "thumbnail", "zips", "version"]; const IGNORED_DIRS = [".git", ".github", "scripts"]; - function validateMeta(meta, pkgDir) { const errors = []; for (const field of REQUIRED_FIELDS) { @@ -33,11 +32,6 @@ function validateMeta(meta, pkgDir) { return errors; } - -function stripJsonComments(str) { - return str.replace(/\/\/[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, ""); -} - const packages = []; const allErrors = []; let entries; @@ -63,7 +57,7 @@ for (const entry of entries) { let meta; try { - meta = JSON.parse(stripJsonComments(raw)); + meta = parse(raw); } catch (e) { allErrors.push({ package: entry, errors: [`meta.json is invalid JSON: ${e.message}`] }); continue; @@ -96,4 +90,4 @@ const registry = { }; writeFileSync(OUTPUT_FILE, JSON.stringify(registry, null, 2)); -console.log(`registry.json generated with ${packages.length} package(s)`); \ No newline at end of file +console.log(`registry.json generated with ${packages.length} package(s)`);