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 28, 2024
1 parent 04f9039 commit a197864
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 55 deletions.
146 changes: 92 additions & 54 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137535,7 +137535,7 @@ const {
} = getIpcExport();


;// CONCATENATED MODULE: ./src/packageManager.ts
;// CONCATENATED MODULE: ./src/helpers/package.ts



Expand Down Expand Up @@ -137615,7 +137615,8 @@ const readActionInputs = () => ({
runArgs: core.getInput("runArgs", { required: false }),
entryPoint: core.getInput("entryPoint", { required: false }),
srcDir: core.getInput("srcDir", { required: false }),
commentsEnabled: core.getBooleanInput("commentsEnabled", { required: true })
commentsEnabled: core.getBooleanInput("commentsEnabled", { required: true }),
skipBots: core.getBooleanInput("skipBots", { required: true })
});

// EXTERNAL MODULE: ./node_modules/.pnpm/@[email protected]/node_modules/@actions/artifact/lib/internal/client.js
Expand All @@ -137624,9 +137625,10 @@ var client = __nccwpck_require__(81462);


function generateArtifactName() {
const randomHash = Math.random().toString(36).substring(2, 10);
const timestamp = Date.now();
return `vmd-report-${randomHash}-${timestamp.toString()}`;
const prefix = "vmd-report";
const randomHash = Math.floor(Math.random() * 1e8).toString();
const timestamp = Date.now().toString();
return `${prefix}-${randomHash}-${timestamp}`;
}
async function uploadOutputArtifact(coverageFilePath) {
let artifactId;
Expand All @@ -137647,23 +137649,11 @@ async function uploadCoverageArtifact(filePath, artifactName) {
return await artifactClient.uploadArtifact(artifactName, files, rootDirectory);
}

;// CONCATENATED MODULE: ./src/utils/constants.ts
;// CONCATENATED MODULE: ./src/helpers/constants.ts
const LOW_HEALTH_THRESHOLD = 75;
const MEDIUM_HEALTH_THRESHOLD = 85;
const OK_HEALTH_THRESHOLD = 95;
const tagsRemover = (str) => str
.replace(/<bg_err>/g, "")
.replace(/<bg_warn>/g, "")
.replace(/<bg_info>/g, "")
.replace(/<bg_ok>/g, "")
.replace(/<\/bg_err>/g, "")
.replace(/<\/bg_warn>/g, "")
.replace(/<\/bg_info>/g, "")
.replace(/<\/bg_ok>/g, "")
.replace(/<text_warn>/g, "")
.replace(/<text_info>/g, "")
.replace(/<\/text_warn>/g, "")
.replace(/<\/text_info>/g, "");
const REPORT_PATH = "vmd-analysis.json";

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

Expand Down Expand Up @@ -137869,6 +137859,59 @@ async function commentOnPullRequest(commentBody) {
}
}

;// CONCATENATED MODULE: ./src/helpers/tags.ts
const tagsRemover = (str) => str
.replace(/<bg_err>/g, "")
.replace(/<bg_warn>/g, "")
.replace(/<bg_info>/g, "")
.replace(/<bg_ok>/g, "")
.replace(/<\/bg_err>/g, "")
.replace(/<\/bg_warn>/g, "")
.replace(/<\/bg_info>/g, "")
.replace(/<\/bg_ok>/g, "")
.replace(/<text_warn>/g, "")
.replace(/<text_info>/g, "")
.replace(/<\/text_warn>/g, "")
.replace(/<\/text_info>/g, "");

;// CONCATENATED MODULE: ./src/helpers/parser.ts



/**
* Parse the analysis output from the file system.
* @param resultPath - The path to the analysis output file.
* @returns The parsed analysis output.
*/
function parseAnalysisOutput(resultPath) {
try {
const fileContent = external_node_fs_default().readFileSync(resultPath, "utf-8");
const cleanedContent = tagsRemover(fileContent);
const parsedOutput = JSON.parse(cleanedContent);
core.debug("Parsed output:");
for (const element of parsedOutput.codeHealthOutput) {
core.debug(element.info);
}
return parsedOutput;
}
catch (error) {
core.setFailed(`Failed to parse analysis output: ${error.message}`);
return undefined;
}
}

;// CONCATENATED MODULE: ./src/helpers/group.ts

async function runGroup(groupName, fn) {
core.startGroup(groupName);
try {
await fn();
}
finally {
core.endGroup();
}
}

;// CONCATENATED MODULE: ./src/analyser.ts


Expand All @@ -137878,7 +137921,18 @@ async function commentOnPullRequest(commentBody) {



const coveragePath = "vmd-analysis.json";


async function runVueMessDetector(input) {
if (input.skipBots && github.context.payload.sender?.type === "Bot") {
core.warning("Bot detected, skipping analysis!");
return;
}
const pkg = input.packageManager || detectManager();
await runGroup(`Install Vue Mess Detector with ${pkg}`, () => runInstallGroup(pkg, input));
await runGroup("Run Vue Mess Detector", () => runAnalysisGroup(pkg, input));
await runGroup("Upload Vue Mess Detector Report", () => runUploadGroup(input));
}
async function installVMD(skipInstall, pkgManager, version) {
if (skipInstall) {
core.info("Skipping installation of vue-mess-detector!");
Expand All @@ -137892,41 +137946,26 @@ const runVMD = (pkgManager, input) => runPackage(pkgManager, "vue-mess-detector"
getPath(input),
...input.runArgs.split(" "),
"--output=json",
"--file-output=" + coveragePath
"--file-output=" + REPORT_PATH
]);
async function runVueMessDetector(input) {
try {
const pkgManager = input.packageManager || detectManager();
core.info(`Detected package manager: ${pkgManager}`);
await installVMD(input.skipInstall, pkgManager, input.version);
const runOutput = await runVMD(pkgManager, input);
core.debug(runOutput);
const analysisOutput = parseAnalysisOutput(coveragePath);
const artifact = await uploadOutputArtifact(coveragePath);
const commentBody = getCommentTemplate(analysisOutput, artifact);
await core.summary.addRaw(commentBody).write();
if (isPullRequest() && input.commentsEnabled) {
await commentOnPullRequest(commentBody);
}
}
catch (error) {
core.setFailed(error instanceof Error ? error.message : "Unknown error");
}
}
function parseAnalysisOutput(resultPath) {
try {
const fileContent = external_node_fs_default().readFileSync(resultPath, "utf-8");
const cleanedContent = tagsRemover(fileContent);
const parsedOutput = JSON.parse(cleanedContent);
core.info("Parsed output:");
parsedOutput.codeHealthOutput.forEach(element => {
core.info(element.info);
});
return parsedOutput;
async function runInstallGroup(pkgManager, input) {
core.info(`Detected package manager: ${pkgManager}`);
await installVMD(input.skipInstall, pkgManager, input.version);
}
async function runAnalysisGroup(pkgManager, input) {
const runOutput = await runVMD(pkgManager, input);
core.debug(runOutput);
}
async function runUploadGroup(input) {
const analysisOutput = parseAnalysisOutput(REPORT_PATH);
const artifact = await uploadOutputArtifact(REPORT_PATH);
if (analysisOutput === undefined || artifact === undefined) {
return;
}
catch (error) {
core.setFailed(`Failed to parse analysis output: ${error.message}`);
throw error;
const commentBody = getCommentTemplate(analysisOutput, artifact);
await core.summary.addRaw(commentBody).write();
if (isPullRequest() && input.commentsEnabled) {
await commentOnPullRequest(commentBody);
}
}

Expand All @@ -137950,7 +137989,6 @@ function run() {
});
}
catch (error) {
// Fail the workflow run if an error occurs
if (error instanceof Error)
core.setFailed(error.message);
}
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

0 comments on commit a197864

Please sign in to comment.