Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into Common.Recommendations2
Browse files Browse the repository at this point in the history
  • Loading branch information
HeikoTheissen committed Feb 27, 2024
2 parents 16b1219 + f1c25c8 commit ec740bf
Show file tree
Hide file tree
Showing 12 changed files with 429 additions and 347 deletions.
29 changes: 16 additions & 13 deletions lib/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ fs.readdirSync(vocabFolder)
colors.red(
`${vocabFolder + xmlfile}:${e.parser.line}:${e.parser.column}: ${
e.message
}`
)
}`,
),
);
process.exitCode = 1;
return;
}

// swap URLs of latest-version and alternate links
const namespace = Object.keys(json).find((item) =>
item.startsWith("com.sap.vocabularies.")
item.startsWith("com.sap.vocabularies."),
);
const links = json[namespace]["@Core.Links"];
const latestVersion = links.findIndex((l) => l.rel == "latest-version");
Expand All @@ -45,10 +45,12 @@ fs.readdirSync(vocabFolder)
links[latestVersion].rel = "alternate";
links[alternate].rel = "latest-version";
}
fs.writeFileSync(
vocabFolder + vocab + ".json",
prettier.format(JSON.stringify(json, omitLineNumbers), PRETTIER_OPTIONS)
);

prettier
.format(JSON.stringify(json, omitLineNumbers), PRETTIER_OPTIONS)
.then((prettyJson) => {
fs.writeFileSync(vocabFolder + vocab + ".json", prettyJson);
});

const markdown = lib.csdl2markdown(xmlfile, json);
fs.writeFileSync(vocabFolder + vocab + ".md", markdown.join("\n"));
Expand All @@ -71,17 +73,18 @@ fs.readdirSync(exampleFolder)
colors.red(
`${exampleFolder + xmlfile}:${e.parser.line}:${e.parser.column}: ${
e.message
}`
)
}`,
),
);
process.exitCode = 1;
return;
}

fs.writeFileSync(
exampleFolder + example + ".json",
prettier.format(JSON.stringify(json), PRETTIER_OPTIONS)
);
prettier
.format(JSON.stringify(json), PRETTIER_OPTIONS)
.then((prettyJson) => {
fs.writeFileSync(exampleFolder + example + ".json", prettyJson);
});
});

function omitLineNumbers(key, value) {
Expand Down
Loading

0 comments on commit ec740bf

Please sign in to comment.