Skip to content

Commit

Permalink
feat: report for LWC
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhinavKumar-sf committed Sep 20, 2024
1 parent 176ac37 commit 19e484d
Showing 1 changed file with 51 additions and 5 deletions.
56 changes: 51 additions & 5 deletions src/utils/resultsbuilder/assessmentReporter.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,65 @@
import fs from 'fs';
import open from 'open';
import { AssessmentInfo } from '../interfaces';
import { AssessmentInfo, LWCAssessmentInfo } from '../interfaces';

export class AssessmentReporter {
public static async generate(result: AssessmentInfo, instanceUrl: string): Promise<void> {
let htmlBody = '';

htmlBody += '<br />' + this.generateResult(result, instanceUrl);
htmlBody += '<br />' + this.generateLwcAssesment(result.lwcAssessmentInfos);

const fileUrl = process.cwd() + '/migrationresults.html';
const fileUrl = process.cwd() + '/assessmentresults.html';
fs.writeFileSync(fileUrl, htmlBody);

await open('file://' + fileUrl);
}
private static generateResult(_result: AssessmentInfo, _instanceUrl: string): string {
return '';

private static generateLwcAssesment(lwcAssessmentInfos: LWCAssessmentInfo[]): string {
let tableBody = '';
tableBody += '<div class="slds-text-heading_large">LWC Assessment</div>';
for (const lwcAssessmentInfo of lwcAssessmentInfos) {
let changeInfoRows = '';

for (const changeInfo of lwcAssessmentInfo.changeInfos) {
changeInfoRows += `<tr class ="slds-hint_parent">
<td><div class="slds-truncate" title="${changeInfo.name}"><a href="${changeInfo.path}">${changeInfo.name}</div></td>
<td><div class="slds-truncate">${changeInfo.diff}</div></td>
</tr>`;
}
const changeInfoTable = `<table>
${changeInfoRows}
</table>`;
const row = `<tr class="slds-hint_parent">
<td><div class="slds-truncate" title="${lwcAssessmentInfo.name}">${lwcAssessmentInfo.name}</div></td>
<td>${changeInfoTable}</td>
</tr>`;
tableBody += row;
}
return this.getLWCAssesmentReport(tableBody);
}

private static getLWCAssesmentReport(tableContent: string): string {
const tableBody = `
<div style="margin-block:15px">
<table class="slds-table slds-table_cell-buffer slds-table_bordered slds-table_striped slds-table_col-bordered" aria-label="Results for LWC updates">
<thead>
<tr class="slds-line-height_reset">
<th class="" scope="col" style="width: 25%">
<div class="slds-truncate" title="Name">Name</div>
</th>
<th class="" scope="col" style="width: 10%">
<div class="slds-truncate" title="Changes">Status</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" title="Errors">Errors</div>
</th>
</tr>
</thead>
<tbody>
${tableContent}
</tbody>
</table>
</div>`;
return tableBody;
}
}

0 comments on commit 19e484d

Please sign in to comment.