@@ -22131,7 +22131,7 @@ The following characters are not allowed in files that are uploaded due to limit
2213122131 1
2213222132 ];
2213322133 try {
22134- const supportsColor = __webpack_require__("./node_modules/.pnpm/supports-color@5.5 .0/node_modules/supports-color/index.js");
22134+ const supportsColor = __webpack_require__("./node_modules/.pnpm/supports-color@7.2 .0/node_modules/supports-color/index.js");
2213522135 if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) exports1.colors = [
2213622136 20,
2213722137 21,
@@ -23058,14 +23058,13 @@ The following characters are not allowed in files that are uploaded due to limit
2305823058 }
2305923059 }
2306023060 },
23061- "./node_modules/.pnpm/has-flag@3 .0.0/node_modules/has-flag/index.js": function(module) {
23061+ "./node_modules/.pnpm/has-flag@4 .0.0/node_modules/has-flag/index.js": function(module) {
2306223062 "use strict";
23063- module.exports = (flag, argv)=>{
23064- argv = argv || process.argv;
23063+ module.exports = (flag, argv = process.argv)=>{
2306523064 const prefix = flag.startsWith('-') ? '' : 1 === flag.length ? '-' : '--';
23066- const pos = argv.indexOf(prefix + flag);
23067- const terminatorPos = argv.indexOf('--');
23068- return -1 !== pos && (-1 === terminatorPos ? true : pos < terminatorPos );
23065+ const position = argv.indexOf(prefix + flag);
23066+ const terminatorPosition = argv.indexOf('--');
23067+ return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition );
2306923068 };
2307023069 },
2307123070 "./node_modules/.pnpm/http-proxy-agent@7.0.2/node_modules/http-proxy-agent/dist/index.js": function(__unused_webpack_module, exports1, __webpack_require__) {
@@ -32743,15 +32742,16 @@ The following characters are not allowed in files that are uploaded due to limit
3274332742 return buf && buf.length ? this.write(buf) : '';
3274432743 }
3274532744 },
32746- "./node_modules/.pnpm/supports-color@5.5 .0/node_modules/supports-color/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
32745+ "./node_modules/.pnpm/supports-color@7.2 .0/node_modules/supports-color/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
3274732746 "use strict";
3274832747 const os = __webpack_require__("os");
32749- const hasFlag = __webpack_require__("./node_modules/.pnpm/has-flag@3.0.0/node_modules/has-flag/index.js");
32750- const env = process.env;
32748+ const tty = __webpack_require__("tty");
32749+ const hasFlag = __webpack_require__("./node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js");
32750+ const { env } = process;
3275132751 let forceColor;
32752- if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false')) forceColor = false ;
32753- else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) forceColor = true ;
32754- if ('FORCE_COLOR' in env) forceColor = 0 === env.FORCE_COLOR.length || 0 !== parseInt(env.FORCE_COLOR, 10);
32752+ if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) forceColor = 0 ;
32753+ else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) forceColor = 1 ;
32754+ if ('FORCE_COLOR' in env) forceColor = 'true' === env.FORCE_COLOR ? 1 : 'false' === env.FORCE_COLOR ? 0 : 0 === env.FORCE_COLOR.length ? 1 : Math.min( parseInt(env.FORCE_COLOR, 10), 3 );
3275532755 function translateLevel(level) {
3275632756 if (0 === level) return false;
3275732757 return {
@@ -32761,23 +32761,26 @@ The following characters are not allowed in files that are uploaded due to limit
3276132761 has16m: level >= 3
3276232762 };
3276332763 }
32764- function supportsColor(stream ) {
32765- if (false === forceColor) return 0;
32764+ function supportsColor(haveStream, streamIsTTY ) {
32765+ if (0 === forceColor) return 0;
3276632766 if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) return 3;
3276732767 if (hasFlag('color=256')) return 2;
32768- if (stream && !stream.isTTY && true !== forceColor) return 0;
32769- const min = forceColor ? 1 : 0;
32768+ if (haveStream && !streamIsTTY && void 0 === forceColor) return 0;
32769+ const min = forceColor || 0;
32770+ if ('dumb' === env.TERM) return min;
3277032771 if ('win32' === process.platform) {
3277132772 const osRelease = os.release().split('.');
32772- if (Number(process.versions.node.split('.')[0]) >= 8 && Number( osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) return Number(osRelease[2]) >= 14931 ? 3 : 2;
32773+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) return Number(osRelease[2]) >= 14931 ? 3 : 2;
3277332774 return 1;
3277432775 }
3277532776 if ('CI' in env) {
3277632777 if ([
3277732778 'TRAVIS',
3277832779 'CIRCLECI',
3277932780 'APPVEYOR',
32780- 'GITLAB_CI'
32781+ 'GITLAB_CI',
32782+ 'GITHUB_ACTIONS',
32783+ 'BUILDKITE'
3278132784 ].some((sign)=>sign in env) || 'codeship' === env.CI_NAME) return 1;
3278232785 return min;
3278332786 }
@@ -32795,17 +32798,16 @@ The following characters are not allowed in files that are uploaded due to limit
3279532798 if (/-256(color)?$/i.test(env.TERM)) return 2;
3279632799 if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) return 1;
3279732800 if ('COLORTERM' in env) return 1;
32798- env.TERM;
3279932801 return min;
3280032802 }
3280132803 function getSupportLevel(stream) {
32802- const level = supportsColor(stream);
32804+ const level = supportsColor(stream, stream && stream.isTTY );
3280332805 return translateLevel(level);
3280432806 }
3280532807 module.exports = {
3280632808 supportsColor: getSupportLevel,
32807- stdout: getSupportLevel(process.stdout ),
32808- stderr: getSupportLevel(process.stderr )
32809+ stdout: translateLevel(supportsColor(true, tty.isatty(1)) ),
32810+ stderr: translateLevel(supportsColor(true, tty.isatty(2)) )
3280932811 };
3281032812 },
3281132813 "./node_modules/.pnpm/tar-stream@3.1.7/node_modules/tar-stream/constants.js": function(module, __unused_webpack_exports, __webpack_require__) {
@@ -90947,7 +90949,8 @@ var __webpack_exports__ = {};
9094790949 console.log(`✅ Found commit hash from GitHub API: ${commitHash}`);
9094890950 return commitHash;
9094990951 }
90950- } catch (apiError) {
90952+ } catch (error) {
90953+ const apiError = error;
9095190954 console.warn(`⚠️ GitHub API failed: ${apiError.message}`);
9095290955 const alternativeBranches = [
9095390956 'master',
@@ -90966,7 +90969,8 @@ var __webpack_exports__ = {};
9096690969 console.log(`✅ Found commit hash from alternative branch ${altBranch}: ${commitHash}`);
9096790970 return commitHash;
9096890971 }
90969- } catch (altError) {
90972+ } catch (error) {
90973+ const altError = error;
9097090974 console.log(`❌ Alternative branch ${altBranch} also failed: ${altError.message}`);
9097190975 }
9097290976 }
@@ -90988,7 +90992,8 @@ var __webpack_exports__ = {};
9098890992 console.log(`⚠️ No successful runs found, using latest workflow run for ${targetBranch}: ${latestRun.head_sha}`);
9098990993 return latestRun.head_sha.substring(0, 10);
9099090994 }
90991- } catch (workflowError) {
90995+ } catch (error) {
90996+ const workflowError = error;
9099290997 console.warn(`⚠️ Failed to get workflow runs: ${workflowError.message}`);
9099390998 }
9099490999 console.log(`🔧 No workflow runs found for ${targetBranch}, trying to fetch from remote...`);
@@ -91025,7 +91030,8 @@ var __webpack_exports__ = {};
9102591030 console.error(`❌ Failed to get target branch commit: ${error}`);
9102691031 console.error(`Repository: ${this.repository.owner}/${this.repository.repo}`);
9102791032 console.error(`Target branch: ${targetBranch}`);
91028- throw new Error(`Failed to get target branch (${targetBranch}) commit: ${error.message}`);
91033+ const apiError = error;
91034+ throw new Error(`Failed to get target branch (${targetBranch}) commit: ${apiError.message}`);
9102991035 }
9103091036 }
9103191037 async listArtifacts() {
@@ -91059,6 +91065,50 @@ var __webpack_exports__ = {};
9105991065 });
9106091066 return downloadResponse.data;
9106191067 }
91068+ async findExistingComment(prNumber, commentPrefix) {
91069+ const { owner, repo } = this.repository;
91070+ try {
91071+ const { data: comments } = await this.octokit.rest.issues.listComments({
91072+ owner,
91073+ repo,
91074+ issue_number: prNumber
91075+ });
91076+ const existingComment = comments.find((comment)=>comment.body.startsWith(commentPrefix));
91077+ return existingComment ? existingComment.id : null;
91078+ } catch (error) {
91079+ const apiError = error;
91080+ console.warn(`Failed to find existing comment: ${apiError.message}`);
91081+ return null;
91082+ }
91083+ }
91084+ async updateOrCreateComment(prNumber, body) {
91085+ const { owner, repo } = this.repository;
91086+ const commentPrefix = '## Rsdoctor Bundle Diff Analysis';
91087+ try {
91088+ const existingCommentId = await this.findExistingComment(prNumber, commentPrefix);
91089+ if (existingCommentId) {
91090+ console.log(`Updating existing comment: ${existingCommentId}`);
91091+ await this.octokit.rest.issues.updateComment({
91092+ owner,
91093+ repo,
91094+ comment_id: existingCommentId,
91095+ body
91096+ });
91097+ } else {
91098+ console.log('Creating new comment');
91099+ await this.octokit.rest.issues.createComment({
91100+ owner,
91101+ repo,
91102+ issue_number: prNumber,
91103+ body
91104+ });
91105+ }
91106+ } catch (error) {
91107+ const apiError = error;
91108+ console.error(`Failed to update/create comment: ${apiError.message}`);
91109+ throw error;
91110+ }
91111+ }
9106291112 }
9106391113 var yauzl = __webpack_require__("./node_modules/.pnpm/yauzl@3.2.0/node_modules/yauzl/index.js");
9106491114 async function downloadArtifact(artifactId, fileName) {
@@ -91120,7 +91170,7 @@ var __webpack_exports__ = {};
9112091170 jsonData: jsonData
9112191171 };
9112291172 } catch (error) {
91123- console.error(`❌ Failed to download and extract artifact: ${error.message }`);
91173+ console.error(`❌ Failed to download and extract artifact: ${error}`);
9112491174 throw error;
9112591175 }
9112691176 }
@@ -91149,13 +91199,13 @@ var __webpack_exports__ = {};
9114991199 if (artifactDetails.expired_at) console.log(`⚠️ Warning: This artifact has expired and may not be downloadable`);
9115091200 }
9115191201 } catch (detailError) {
91152- console.warn(`⚠️ Could not get artifact details: ${detailError.message }`);
91202+ console.warn(`⚠️ Could not get artifact details: ${detailError || 'Unknown error' }`);
9115391203 }
9115491204 console.log(`📥 Downloading artifact...`);
9115591205 try {
9115691206 return await downloadArtifact(artifact.id, fileName);
9115791207 } catch (downloadError) {
91158- console.error(`❌ Download failed with error: ${downloadError.message }`);
91208+ console.error(`❌ Download failed with error: ${downloadError}`);
9115991209 console.error(`💡 This usually means:`);
9116091210 console.error(" - Token lacks 'actions:read' permission for downloading artifacts");
9116191211 console.error(" - Artifact is from a different workflow run");
@@ -91405,7 +91455,7 @@ var __webpack_exports__ = {};
9140591455 ]
9140691456 ];
9140791457 await core.summary.addTable(mainTable).addSeparator();
91408- await core.summary.addSeparator().addRaw('<sub>Generated by Bundle Size Action</sub>') ;
91458+ await core.summary.addSeparator();
9140991459 await core.summary.write();
9141091460 console.log('✅ Bundle analysis report generated successfully');
9141191461 }
@@ -91468,7 +91518,7 @@ var __webpack_exports__ = {};
9146891518 ]);
9146991519 await core.summary.addTable(fileTable);
9147091520 }
91471- await core.summary.addSeparator().addRaw('<sub>Generated by Bundle Size Action</sub>') ;
91521+ await core.summary.addSeparator();
9147291522 await core.summary.write();
9147391523 console.log('✅ Bundle size report card generated successfully');
9147491524 }
@@ -91586,40 +91636,30 @@ var __webpack_exports__ = {};
9158691636 });
9158791637 } catch (npxError) {
9158891638 console.log(`⚠️ npx approach also failed: ${npxError}`);
91589- throw new Error(`Failed to run rsdoctor: ${e .message}`);
91639+ throw new Error(`Failed to run rsdoctor: ${npxError .message}`);
9159091640 }
9159191641 }
9159291642 const diffHtmlPath = external_path_default().join(tempOutDir, 'rsdoctor-diff.html');
9159391643 try {
9159491644 const uploadRes = await uploadArtifact(diffHtmlPath, currentCommitHash);
9159591645 console.log(`✅ Uploaded bundle diff HTML, artifact id: ${uploadRes.id}`);
91596- const runLink = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
91597- await core.summary.addHeading('🧮 Bundle Diff (Rsdoctor)', 3).addLink('Open workflow run to download the diff HTML', runLink ).addSeparator();
91646+ const artifactDownloadLink = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}/artifacts/${uploadRes.id }`;
91647+ await core.summary.addHeading('🧮 Bundle Diff (Rsdoctor)', 3).addLink('Download Bundle Diff HTML Report ', artifactDownloadLink ).addSeparator();
9159891648 if (isPullRequestEvent()) {
9159991649 const { context } = __webpack_require__("./node_modules/.pnpm/@actions+github@4.0.0/node_modules/@actions/github/lib/github.js");
91600- const octokit = __webpack_require__("./node_modules/.pnpm/@actions+github@4.0.0/node_modules/@actions/github/lib/github.js").getOctokit((0, core.getInput)('github_token', {
91601- required: true
91602- }));
9160391650 const bundleAnalysisMarkdown = generateBundleAnalysisMarkdown(currentBundleAnalysis, baselineBundleAnalysis || void 0);
9160491651 const commentBody = `## Rsdoctor Bundle Diff Analysis
91605-
91606- A detailed bundle diff analysis has been generated using Rsdoctor. You can download and view the interactive HTML report from the workflow artifacts.
9160791652
91608- 📦 **Download Link**: [Download Bundle Diff Report](${runLink})
91653+ A detailed bundle diff analysis has been generated using Rsdoctor. You can download and view the interactive HTML report from the workflow artifacts.
9160991654
91610- ${bundleAnalysisMarkdown}
91655+ 📦 **Download Link**: [Download Bundle Diff Report](${artifactDownloadLink})
9161191656
91612- *Generated by Bundle Size Action* `;
91657+ ${bundleAnalysisMarkdown} `;
9161391658 try {
91614- await octokit.rest.issues.createComment({
91615- owner: context.repo.owner,
91616- repo: context.repo.repo,
91617- issue_number: context.payload.pull_request.number,
91618- body: commentBody
91619- });
91620- console.log('✅ Added bundle diff comment to PR');
91659+ await githubService.updateOrCreateComment(context.payload.pull_request.number, commentBody);
91660+ console.log('✅ Added/updated bundle diff comment to PR');
9162191661 } catch (commentError) {
91622- console.warn(`⚠️ Failed to add comment to PR: ${commentError}`);
91662+ console.warn(`⚠️ Failed to add/update comment to PR: ${commentError}`);
9162391663 }
9162491664 }
9162591665 } catch (e) {
0 commit comments