From e77101138a64b53905f9c6e38da8788b5523469f Mon Sep 17 00:00:00 2001 From: ryanml Date: Thu, 15 Jul 2021 19:24:52 -0700 Subject: [PATCH] Cleaning up bundle link formatting (metamaskbot) (#11539) --- development/metamaskbot-build-announce.js | 43 ++++++++++++++++++----- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/development/metamaskbot-build-announce.js b/development/metamaskbot-build-announce.js index 26f2174dc..f8ec42f0a 100755 --- a/development/metamaskbot-build-announce.js +++ b/development/metamaskbot-build-announce.js @@ -40,17 +40,42 @@ async function start() { .join(', '); // links to bundle browser builds + const bundles = {}; const fileType = '.html'; const sourceMapRoot = '/build-artifacts/source-map-explorer/'; const bundleFiles = await glob(`.${sourceMapRoot}*${fileType}`); - const bundleLinks = bundleFiles - .map((bundleFile) => { - const fileName = bundleFile.split(sourceMapRoot)[1]; - const bundleName = fileName.split(fileType)[0]; - const url = `${BUILD_LINK_BASE}${sourceMapRoot}${fileName}`; - return `${bundleName}`; - }) - .join(', '); + + bundleFiles.forEach((bundleFile) => { + const fileName = bundleFile.split(sourceMapRoot)[1]; + const bundleName = fileName.split(fileType)[0]; + const url = `${BUILD_LINK_BASE}${sourceMapRoot}${fileName}`; + let fileRoot = bundleName; + let fileIndex; + + if (bundleName.indexOf('-') > -1) { + const split = bundleName.split('-'); + // Handle bundles that have hyphens in their name + if (split.length === 2 && !isNaN(parseInt(split[1], 10))) { + fileRoot = split[0]; + fileIndex = split[1]; + } else if (split.length === 3) { + fileRoot = [split[0], split[1]].join('-'); + fileIndex = split[2]; + } + } + + const link = `${fileIndex || fileRoot}`; + + if (fileRoot in bundles) { + bundles[fileRoot].push(link); + } else { + bundles[fileRoot] = [link]; + } + }); + + const bundleMarkup = ``; const coverageUrl = `${BUILD_LINK_BASE}/coverage/index.html`; const coverageLink = `Report`; @@ -67,7 +92,7 @@ async function start() { const contentRows = [ `builds: ${buildLinks}`, - `bundle viz: ${bundleLinks}`, + `bundle viz: ${bundleMarkup}`, `build viz: ${depVizLink}`, `code coverage: ${coverageLink}`, `storybook: ${storybookLink}`,