generated from salesforcecli/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
176ac37
commit 19e484d
Showing
1 changed file
with
51 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |