From 9017f8e7cafb58a8b7e2a1d2b159c9369bd61a91 Mon Sep 17 00:00:00 2001 From: Caleb Shafer <31107829+calebmshafer@users.noreply.github.com> Date: Mon, 29 Mar 2021 21:01:28 -0400 Subject: [PATCH 1/3] Add support for full API summary report --- .gitignore | 2 ++ common/api/summary/README.md | 8 +++++- .../create-full-summary_2021-03-30-01-01.json | 11 ++++++++ tools/build/scripts/extract-api-summary.js | 26 ++++++++++++++----- tools/build/scripts/extract-api.js | 5 ++++ 5 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 common/changes/@bentley/build-tools/create-full-summary_2021-03-30-01-01.json diff --git a/.gitignore b/.gitignore index b111e709226d..3c3021165724 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,5 @@ package-deps.json .DS_Store .env + +common/api/summary/summary.exports.csv diff --git a/common/api/summary/README.md b/common/api/summary/README.md index 191d6e69b102..0d86fdf0a835 100644 --- a/common/api/summary/README.md +++ b/common/api/summary/README.md @@ -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** @@ -9,3 +11,7 @@ 7. Press *Add Level* 8. In *Then by* option button, select *API Item* 9. Press *OK* + +## Creating the Full Summary API Report + +1. Set the `GENERATE_FULL_API_REPORT` environment variable to create a `summary.exports.csv` file diff --git a/common/changes/@bentley/build-tools/create-full-summary_2021-03-30-01-01.json b/common/changes/@bentley/build-tools/create-full-summary_2021-03-30-01-01.json new file mode 100644 index 000000000000..400e8489be06 --- /dev/null +++ b/common/changes/@bentley/build-tools/create-full-summary_2021-03-30-01-01.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "packageName": "@bentley/build-tools", + "comment": "", + "type": "none" + } + ], + "packageName": "@bentley/build-tools", + "email": "31107829+calebmshafer@users.noreply.github.com" +} \ No newline at end of file diff --git a/tools/build/scripts/extract-api-summary.js b/tools/build/scripts/extract-api-summary.js index ba99ca12f33e..ba20c5e2386d 100644 --- a/tools/build/scripts/extract-api-summary.js +++ b/tools/build/scripts/extract-api-summary.js @@ -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) { + 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; } @@ -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 = []; @@ -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")); }); diff --git a/tools/build/scripts/extract-api.js b/tools/build/scripts/extract-api.js index bb4ca1378988..bccec0296e25 100644 --- a/tools/build/scripts/extract-api.js +++ b/tools/build/scripts/extract-api.js @@ -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(); From 16de608c6d22811b19dabcd60114a1f93e7d8d15 Mon Sep 17 00:00:00 2001 From: Caleb Shafer <31107829+calebmshafer@users.noreply.github.com> Date: Mon, 29 Mar 2021 21:10:14 -0400 Subject: [PATCH 2/3] Update readme --- common/api/summary/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/api/summary/README.md b/common/api/summary/README.md index 0d86fdf0a835..f6b385b3e092 100644 --- a/common/api/summary/README.md +++ b/common/api/summary/README.md @@ -14,4 +14,6 @@ ## Creating the Full Summary API Report -1. Set the `GENERATE_FULL_API_REPORT` environment variable to create a `summary.exports.csv` file +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 From 7caaafd14be7ae0e3b28803db59b650bcd963360 Mon Sep 17 00:00:00 2001 From: Caleb Shafer <31107829+calebmshafer@users.noreply.github.com> Date: Tue, 30 Mar 2021 10:48:53 -0400 Subject: [PATCH 3/3] Update tools/build/scripts/extract-api-summary.js Co-authored-by: Bill Goehrig <33036725+wgoehrig@users.noreply.github.com> --- tools/build/scripts/extract-api-summary.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build/scripts/extract-api-summary.js b/tools/build/scripts/extract-api-summary.js index ba20c5e2386d..5d368dd93bbe 100644 --- a/tools/build/scripts/extract-api-summary.js +++ b/tools/build/scripts/extract-api-summary.js @@ -45,7 +45,7 @@ if (shouldGenerateFullReport) { outputLines.push("sep=;"); outputLines.push("Package Name;Release Tag;API Item"); } -} else if (!shouldGenerateFullReport) { +} else { fs.createFileSync(sigFilePath); outputLines.push("sep=;"); outputLines.push("Release Tag;API Item");