11import fs from 'fs' ;
22import open from 'open' ;
3+ < < < << << HEAD
34import { Logger } from '@salesforce/core' ;
45import { pushAssestUtilites } from '../file/fileUtil' ;
56import { ApexAssessmentInfo , MigratedObject , MigratedRecordInfo , RelatedObjectAssesmentInfo } from '../interfaces' ;
@@ -25,6 +26,10 @@ const apexConstants = { componentName: 'apex', title: 'Apex Classes Migration Re
2526// const lwcConstants = { componentName: 'lwc', title: 'LWC Components Migration Result' };
2627const migrationResultCSSfileName = 'reportGenerator.css' ;
2728const migrationReportHTMLfileName = 'migration_report.html' ;
29+ === === =
30+ import { ApexAssessmentInfo , LWCAssessmentInfo , MigratedObject , RelatedObjectAssesmentInfo } from '../interfaces' ;
31+ import { OmnistudioOrgDetails } from '../orgUtils' ;
32+ >>> >>> > 451 bd60 ( Comments addressed )
2833
2934export class ResultsBuilder {
3035 private static logger : Logger = new Logger ( 'ResultsBuilder ') ;
@@ -33,7 +38,11 @@ export class ResultsBuilder {
3338 results : MigratedObject [ ] ,
3439 relatedObjectMigrationResult : RelatedObjectAssesmentInfo ,
3540 instanceUrl : string,
41+ << << << < HEAD
3642 orgDetails : OmnistudioOrgDetails
43+ === === =
44+ omnistudioOrgDetails : OmnistudioOrgDetails
45+ >>> >>> > 451 bd60 ( Comments addressed )
3746 ) : Promise < void > {
3847 this . logger . info ( 'Generating directories' ) ;
3948 fs . mkdirSync ( resultsDir , { recursive : true } ) ;
@@ -66,6 +75,7 @@ export class ResultsBuilder {
6675 const details : ComponentDetail [ ] = [ ] ;
6776
6877 for ( const result of results ) {
78+ < < < << << HEAD
6979 const resultConstants = this. getResultConstant ( result . name ) ;
7080 details . push ( {
7181 name : resultConstants . componentName ,
@@ -75,6 +85,57 @@ export class ResultsBuilder {
7585 error : result . data ?. filter ( ( record ) => record . status === 'Error' ) . length || 0 ,
7686 skip : result . data ?. filter ( ( record ) => record . status === 'Skipped' ) . length || 0 ,
7787 } ) ;
88+ === = ===
89+ htmlBody += '<br />' + this . generateResult ( result , instanceUrl ) ;
90+ }
91+ htmlBody += '<br />' + this . generateApexAssesment ( relatedObjectMigrationResult . apexAssessmentInfos ) ;
92+ // TODO: Uncomment code once MVP for migration is completed
93+ // htmlBody += '<br />' + this.generateLwcAssesment(relatedObjectMigrationResult.lwcAssessmentInfos);
94+
95+ // Add rollback flags report if there are any enabled flags
96+ const enabledFlags = omnistudioOrgDetails . rollbackFlags || [ ] ;
97+ if ( enabledFlags . length > 0 ) {
98+ htmlBody += '<br />' + this . generateRollbackFlagsReport ( enabledFlags ) ;
99+ }
100+
101+ const doc = this . generateDocument ( htmlBody ) ;
102+ const fileUrl = process . cwd ( ) + '/migrationresults.html' ;
103+ fs . writeFileSync ( fileUrl , doc ) ;
104+ await open ( 'file://' + fileUrl ) ;
105+ }
106+
107+ private static generateDocument ( resultsAsHtml : string) : string {
108+ const document = `
109+ <html>
110+ <head>
111+ <title>OmniStudio Migration Results</title>
112+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/design-system/2.17.5/styles/salesforce-lightning-design-system.min.css" />
113+ </head>
114+ <body>
115+ <div style="margin: 20px;">
116+ <div class="slds-text-heading_large">OmniStudio Migration Results</div>
117+ ${ resultsAsHtml }
118+ </div>
119+ </div>
120+ </body>
121+ </html>
122+ ` ;
123+ return document ;
124+ }
125+
126+ private static generateResult ( migrationResult : MigratedObject , instanceUrl : string) : string {
127+ let errorsBody = '' ;
128+ let tableBody = '' ;
129+
130+ if ( migrationResult . errors ) {
131+ errorsBody = migrationResult . errors
132+ . map ( ( e ) => `<li class="slds-item slds-text-color_destructive">${ e } </li>` )
133+ . join ( '' ) ;
134+ errorsBody = `
135+ <div style="margin-block: 15px">
136+ <ul class="slds-list_dotted">${ errorsBody } </ul>
137+ </div>` ;
138+ >>> > >>> 451 bd60 ( Comments addressed )
78139 }
79140
80141 details . push ( {
@@ -348,6 +409,7 @@ export class ResultsBuilder {
348409 // this.generateReportForLwcResult(result.lwcAssessmentInfos, instanceUrl, orgDetails);
349410 }
350411
412+ <<<<<<< HEAD
351413 private static generateReportForApexResult(
352414 result: ApexAssessmentInfo[],
353415 instanceUrl: string,
@@ -526,4 +588,21 @@ export class ResultsBuilder {
526588 // </html>`;
527589 // fs.writeFileSync(resultsDir + '/' + lwcConstants.componentName + '.html', html);
528590 // }
591+ === === =
592+ private static generateRollbackFlagsReport ( enabledFlags : string[ ] ) : string {
593+ return `
594+ <div class="slds-box" style="background-color: white">
595+ <div class="slds-text-heading_medium">Rollback Flags Disabled</div>
596+ <div style="margin-block: 15px">
597+ <p>The following rollback flags were disabled during migration:</p>
598+ <ul class="slds-list_dotted">
599+ ${ enabledFlags . map ( ( flag ) => `<li class="slds-item slds-text-color_destructive">${ flag } </li>` ) . join ( '' ) }
600+ </ul>
601+ <p>
602+ <strong>Note:</strong> These flags are no longer supported after migration. For assistance, please contact support.
603+ </p>
604+ </div>
605+ </div>` ;
606+ }
607+ >>> > >>> 451 bd60 ( Comments addressed )
529608}
0 commit comments