Skip to content

Commit

Permalink
refactor: Export imports from library.json
Browse files Browse the repository at this point in the history
  • Loading branch information
d3xter666 committed Apr 8, 2024
1 parent 9cfd3af commit dd2cd26
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions scripts/metadataProvider/createPseudoModulesInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,17 @@ async function downloadAPIJsons(url: string) {

async function extractPseudoModuleNames() {
const apiJsonList = await readdir(RAW_API_JSON_FILES_FOLDER);


interface apiJSON {
symbols: {
name: string;
kind: string;
resource: string;
};
}

return apiJsonList.flatMap((library) => {
const libApiJson = require(path.resolve(RAW_API_JSON_FILES_FOLDER, library));
const libApiJson = require(path.resolve(RAW_API_JSON_FILES_FOLDER, library)) as apiJSON;
return libApiJson.symbols;
}).reduce((acc: Record<string, boolean>, symbol) => {
if (symbol.kind === "enum" && symbol.resource.endsWith("library.js")) {
Expand Down Expand Up @@ -118,14 +126,12 @@ async function addOverrides(enums: Record<string, UI5Enum[]>) {
}

stringBuilder.push(`declare module "${libName.replaceAll(".", "/")}/${enumEntry.name}" {`);

stringBuilder.push(`\timport ${enumEntry.name} from "${libName.replaceAll(".", "/")}/library";`);
stringBuilder.push("");
stringBuilder.push(buildJSDoc(enumEntry, "\t"));
stringBuilder.push(`\texport enum ${enumEntry.name} {`);
enumEntry.fields.forEach((value) => {
stringBuilder.push(buildJSDoc(value, "\t\t"));
stringBuilder.push(`\t\t${value.name} = "${value.name}",`);
});
stringBuilder.push(`\t}`);
stringBuilder.push(`\texport default ${enumEntry.name};`);

stringBuilder.push(`}`);
stringBuilder.push("");

Expand Down

0 comments on commit dd2cd26

Please sign in to comment.