Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to generate full API summary report behind a flag #1062

Merged
merged 18 commits into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ package-deps.json
.DS_Store

.env

common/api/summary/summary.exports.csv
10 changes: 9 additions & 1 deletion common/api/summary/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Using Excel to Sort Exports Summary Report
# Managing Summary Reports

## Using Excel to Sort Exports of Individual Packages

1. Open the appropriate `.csv` report file in Excel
2. Double-click on the line between the **A** and **B** columns to auto-resize column **A**
Expand All @@ -9,3 +11,9 @@
7. Press *Add Level*
8. In *Then by* option button, select *API Item*
9. Press *OK*

## Creating the Full Summary API Report

1. Delete any existing `common/api/summary/summary.exports.csv`
> The script will not overwrite any existing file
2. Set the `GENERATE_FULL_API_REPORT` environment variable to create a `summary.exports.csv` file
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@bentley/build-tools",
"comment": "",
"type": "none"
}
],
"packageName": "@bentley/build-tools",
"email": "31107829+calebmshafer@users.noreply.github.com"
}
26 changes: 19 additions & 7 deletions tools/build/scripts/extract-api-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,30 @@ if (undefined === argv.outDir) {

fs.ensureDir(path.normalize(argv.outDir));

let shouldGenerateFullReport = false;
if (undefined !== argv.gatherFullReport)
shouldGenerateFullReport = true;

// create output file
const trimmedApiSignature = (argv.apiSignature.split('.'))[0];
const sigFileName = path.basename(path.normalize(trimmedApiSignature));
const sigFilePath = path.join(argv.outDir, sigFileName + ".exports.csv");
fs.createFileSync(sigFilePath);
const sigFilePath = path.join(argv.outDir, `${shouldGenerateFullReport ? "summary" : sigFileName}.exports.csv`);

const outputLines = [];
outputLines.push("sep=;");
outputLines.push("Release Tag;API Item");
if (shouldGenerateFullReport) {
if (fs.existsSync(sigFilePath))
outputLines.push("");
else {
outputLines.push("sep=;");
outputLines.push("Package Name;Release Tag;API Item");
}
} else if (!shouldGenerateFullReport) {
calebmshafer marked this conversation as resolved.
Show resolved Hide resolved
fs.createFileSync(sigFilePath);
outputLines.push("sep=;");
outputLines.push("Release Tag;API Item");
}

// Open up the signature file

fs.readFile(argv.apiSignature, function (error, data) {
if (error) { throw error; }

Expand All @@ -52,7 +64,7 @@ fs.readFile(argv.apiSignature, function (error, data) {
if (null !== matches) {
const split = matches[1].split(/(<|extends|implements)/);
for (const previousLine of previousLines)
outputLines.push(`${previousLine};${split[0]}`);
outputLines.push(shouldGenerateFullReport ? `${sigFileName};${previousLine};${split[0]}` : `${previousLine};${split[0]}`);
}

previousLines = [];
Expand All @@ -75,5 +87,5 @@ fs.readFile(argv.apiSignature, function (error, data) {
}
});

fs.writeFileSync(sigFilePath, outputLines.join("\n"));
shouldGenerateFullReport ? fs.appendFileSync(sigFilePath, outputLines.join("\n")) : fs.writeFileSync(sigFilePath, outputLines.join("\n"));
});
5 changes: 5 additions & 0 deletions tools/build/scripts/extract-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,10 @@ spawn(require.resolve(".bin/api-extractor"), args).then((code) => {
spawn("node", extractSummaryArgs).then((code) => {
process.exit(code);
});

if (process.env.GENERATE_FULL_API_REPORT)
spawn("node", [...extractSummaryArgs, "--gatherFullReport"]).then((code) => {
process.exit(code);
});
});
handleInterrupts();