From f605231a36c004b98cb8a88ea3ceaaa7d0c20dbd Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Fri, 4 Apr 2025 21:40:18 -0400 Subject: [PATCH] Fixes --- scripts/generateEquicordPluginList.ts | 29 ++++++++++++++++---------- scripts/generatePluginList.ts | 30 ++++++++++++++++----------- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/scripts/generateEquicordPluginList.ts b/scripts/generateEquicordPluginList.ts index 6fbd61bf..c52bb2a7 100644 --- a/scripts/generateEquicordPluginList.ts +++ b/scripts/generateEquicordPluginList.ts @@ -169,17 +169,24 @@ async function parseFile(fileName: string) { data.hasCommands = true; if (!isArrayLiteralExpression(value)) throw fail("commands is not an array literal"); data.commands = value.elements.map((e) => { - if (!isObjectLiteralExpression(e)) throw fail("commands array contains non-object literals"); - const nameProperty = e.properties.find((p): p is PropertyAssignment => { - return isPropertyAssignment(p) && isIdentifier(p.name) && p.name.escapedText === 'name'; - }); - const descriptionProperty = e.properties.find((p): p is PropertyAssignment => { - return isPropertyAssignment(p) && isIdentifier(p.name) && p.name.escapedText === 'description'; - }); - if (!nameProperty || !descriptionProperty) throw fail("Command missing required properties"); - const name = isStringLiteral(nameProperty.initializer) ? nameProperty.initializer.text : ''; - const description = isStringLiteral(descriptionProperty.initializer) ? descriptionProperty.initializer.text : ''; - return { name, description }; + if (isObjectLiteralExpression(e)) { + const nameProperty = e.properties.find((p): p is PropertyAssignment => { + return isPropertyAssignment(p) && isIdentifier(p.name) && p.name.escapedText === 'name'; + }); + const descriptionProperty = e.properties.find((p): p is PropertyAssignment => { + return isPropertyAssignment(p) && isIdentifier(p.name) && p.name.escapedText === 'description'; + }); + if (!nameProperty || !descriptionProperty) throw fail("command missing required properties"); + const name = isStringLiteral(nameProperty.initializer) ? nameProperty.initializer.text : ''; + const description = isStringLiteral(descriptionProperty.initializer) ? descriptionProperty.initializer.text : ''; + return { name, description }; + } else if (isCallExpression(e) && isIdentifier(e.expression)) { + const [nameArg] = e.arguments; + if (!isStringLiteral(nameArg)) throw fail("first argument must be a string"); + const name = nameArg.text; + return { name, description: "" }; + } + throw fail("commands array contains invalid elements"); }); break; case "authors": diff --git a/scripts/generatePluginList.ts b/scripts/generatePluginList.ts index e8af78b4..06ff869d 100644 --- a/scripts/generatePluginList.ts +++ b/scripts/generatePluginList.ts @@ -169,19 +169,25 @@ async function parseFile(fileName: string) { data.hasCommands = true; if (!isArrayLiteralExpression(value)) throw fail("commands is not an array literal"); data.commands = value.elements.map((e) => { - if (!isObjectLiteralExpression(e)) throw fail("commands array contains non-object literals"); - const nameProperty = e.properties.find((p): p is PropertyAssignment => { - return isPropertyAssignment(p) && isIdentifier(p.name) && p.name.escapedText === 'name'; - }); - const descriptionProperty = e.properties.find((p): p is PropertyAssignment => { - return isPropertyAssignment(p) && isIdentifier(p.name) && p.name.escapedText === 'description'; - }); - if (!nameProperty || !descriptionProperty) throw fail("Command missing required properties"); - const name = isStringLiteral(nameProperty.initializer) ? nameProperty.initializer.text : ''; - const description = isStringLiteral(descriptionProperty.initializer) ? descriptionProperty.initializer.text : ''; - return { name, description }; + if (isObjectLiteralExpression(e)) { + const nameProperty = e.properties.find((p): p is PropertyAssignment => { + return isPropertyAssignment(p) && isIdentifier(p.name) && p.name.escapedText === 'name'; + }); + const descriptionProperty = e.properties.find((p): p is PropertyAssignment => { + return isPropertyAssignment(p) && isIdentifier(p.name) && p.name.escapedText === 'description'; + }); + if (!nameProperty || !descriptionProperty) throw fail("command missing required properties"); + const name = isStringLiteral(nameProperty.initializer) ? nameProperty.initializer.text : ''; + const description = isStringLiteral(descriptionProperty.initializer) ? descriptionProperty.initializer.text : ''; + return { name, description }; + } else if (isCallExpression(e) && isIdentifier(e.expression)) { + const [nameArg] = e.arguments; + if (!isStringLiteral(nameArg)) throw fail("first argument must be a string"); + const name = nameArg.text; + return { name, description: "" }; + } + throw fail("commands array contains invalid elements"); }); - break; case "authors": if (!isArrayLiteralExpression(value)) throw fail("authors is not an array literal"); data.authors = value.elements.map(e => {