Skip to content

Commit

Permalink
chore: update dist
Browse files Browse the repository at this point in the history
  • Loading branch information
brenoepics committed Sep 26, 2024
1 parent 1d5de1f commit 172632b
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 18 deletions.
93 changes: 76 additions & 17 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137647,44 +137647,103 @@ async function uploadCoverageArtifact(filePath, artifactName) {
return await artifactClient.uploadArtifact(artifactName, files, rootDirectory);
}

;// CONCATENATED MODULE: ./src/templates/badge.ts

const baseUrl = "https://img.shields.io/badge/";
function buildBadgeUrl({ text, style, label, labelColor, color }) {
return `${baseUrl}${text}-${text}?style=${style}&label=${encodeURIComponent(label)}&labelColor=${labelColor}&color=${color}`;
}
function getCoverageBadge(percentage) {
let color = "blue";
const label = "Code Health";
if (percentage === undefined) {
percentage = "N/A";
color = "lightgrey";
core.warning("No code health data found in the analysis output! you may need to update vue-mess-detector to >= 0.54.1");
}
if (typeof percentage === "number") {
if (percentage < 40) {
color = "red";
}
else if (percentage < 70) {
color = "yellow";
}
else {
color = "green";
}
}
const badgeUrl = buildBadgeUrl({
text: `${percentage.toString()}%`,
style: "flat",
label,
labelColor: "8A2BE2",
color
});
return `![${label}](${badgeUrl})`;
}

;// CONCATENATED MODULE: ./src/templates/comment.ts

const comment = `
## 🎉 Vue Mess Detector Analysis Results 🎉

📊 **Coverage Information:**
const comment = `
## 📊 Vue Mess Detector Analysis Results

#### Code Health: {{coverageBadge}}
{{coverageInfo}}
{{artifactText}}

_For any issues, please report them [here](https://github.com/brenoepics/vmd-action/issues) 🐞._
###### For any issues, please [report them here](https://github.com/brenoepics/vmd-action/issues/).
`;
const coverageInfo = `
Errors: {{errors}}
Warnings: {{warnings}}
Total Lines: {{linesCount}}
Total Files: {{filesCount}}
Points: {{points}}
`;
const artifactText = `
🚀 The detailed coverage report has been successfully uploaded! You can access it [here](../actions/runs/{{runId}}/artifacts/{{artifactId}}) 🔗.
[See analysis details here](../actions/runs/{{runId}}/artifacts/{{artifactId}})
`;
/**
* TODO: this is a tweak to remove the progress,in the future would be great to have a fully parsed errors, warns... message.
*
*/
function getCommentTemplate(codeHealthOutput, artifactId) {
const coverageInfo = codeHealthOutput
.filter((_, index) => index !== 1) // Skip the progress element (index 1)
.map(element => element.info)
.join("\n");
return comment
function getCoverageInfo(result) {
return result.codeHealthOutput.map(element => element.info).join("\n");
}
function replaceCodeHealth(message, health) {
return message
.replace(/{{coverageInfo}}/g, coverageInfo)
.replace(/{{errors}}/g, health.errors.toString())
.replace(/{{warnings}}/g, health.warnings.toString())
.replace(/{{linesCount}}/g, health.linesCount.toString())
.replace(/{{filesCount}}/g, health.filesCount.toString())
.replace(/{{points}}/g, health.points.toString());
}
function replaceRepoData(message, artifactId) {
return message
.replace(/{{artifactText}}/g, artifactId ? artifactText : "")
.replace(/{{artifactId}}/g, String(artifactId ?? 0))
.replace(/{{runId}}/g, github.context.runId.toString())
.replace(/{{repository/g, github.context.repo.repo)
.replace(/{{repositoryOwner/g, github.context.repo.owner);
}
function replaceBadges(message, result) {
return message.replace(/{{coverageBadge}}/g, getCoverageBadge(result.codeHealth?.points));
}
function getCommentTemplate(result, artifactId) {
let message = replaceRepoData(comment, artifactId);
if (result.codeHealth) {
message = replaceCodeHealth(message, result.codeHealth);
}
else {
message = message.replace(/{{coverageInfo}}/g, getCoverageInfo(result));
}
message = replaceBadges(message, result);
return message;
}

;// CONCATENATED MODULE: ./src/github/comments.ts



async function commentOnPullRequest(parsedOutput, artifactId) {
async function commentOnPullRequest(analysis, artifactId) {
if (!github.context.payload.pull_request) {
throw new Error("No pull request found in the context!");
}
Expand All @@ -137696,7 +137755,7 @@ async function commentOnPullRequest(parsedOutput, artifactId) {
const { owner, repo } = github.context.repo;
const pull_number = github.context.payload.pull_request.number;
try {
const commentBody = getCommentTemplate(parsedOutput.codeHealthOutput, artifactId);
const commentBody = getCommentTemplate(analysis, artifactId);
await octokit.rest.issues.createComment({
owner,
repo,
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

0 comments on commit 172632b

Please sign in to comment.