@@ -22,7 +22,20 @@ function findEolDate(currentVersion: string, eolDate: Record<string, string>): s
2222 return null ;
2323}
2424
25- export function buildNotificationMessage ( issue : UpgradeIssue , hasExtension : boolean ) : string {
25+ export type ExtensionState = "up-to-date" | "outdated" | "not-installed" ;
26+
27+ function getActionWord ( extensionState : ExtensionState , verb : string ) : string {
28+ switch ( extensionState ) {
29+ case "up-to-date" :
30+ return verb ;
31+ case "outdated" :
32+ return `update ${ ExtensionName . APP_MODERNIZATION_EXTENSION_NAME } extension and ${ verb } ` ;
33+ case "not-installed" :
34+ return `install ${ ExtensionName . APP_MODERNIZATION_EXTENSION_NAME } extension and ${ verb } ` ;
35+ }
36+ }
37+
38+ export function buildNotificationMessage ( issue : UpgradeIssue , extensionState : ExtensionState ) : string {
2639 const {
2740 packageId,
2841 currentVersion,
@@ -31,7 +44,7 @@ export function buildNotificationMessage(issue: UpgradeIssue, hasExtension: bool
3144 packageDisplayName
3245 } = issue ;
3346
34- const upgradeWord = hasExtension ? "upgrade" : `install ${ ExtensionName . APP_MODERNIZATION_EXTENSION_NAME } extension and upgrade` ;
47+ const upgradeWord = getActionWord ( extensionState , "upgrade" ) ;
3548
3649 if ( packageId === Upgrade . PACKAGE_ID_FOR_JAVA_RUNTIME ) {
3750 return `This project is using an older Java runtime (${ currentVersion } ). Would you like to ${ upgradeWord } it to the latest LTS version?` ;
@@ -51,7 +64,7 @@ export function buildNotificationMessage(issue: UpgradeIssue, hasExtension: bool
5164 }
5265}
5366
54- export function buildCVENotificationMessage ( issues : CveUpgradeIssue [ ] , hasExtension : boolean ) : string {
67+ export function buildCVENotificationMessage ( issues : CveUpgradeIssue [ ] , extensionState : ExtensionState ) : string {
5568
5669 if ( issues . length === 0 ) {
5770 return "No CVE issues found." ;
@@ -81,7 +94,7 @@ export function buildCVENotificationMessage(issues: CveUpgradeIssue[], hasExtens
8194 CVESeverityDistribution : severityText ,
8295 } ) ;
8396
84- const fixWord = hasExtension ? "fix" : `install ${ ExtensionName . APP_MODERNIZATION_EXTENSION_NAME } extension and fix` ;
97+ const fixWord = getActionWord ( extensionState , "fix" ) ;
8598
8699 if ( issues . length === 1 ) {
87100 return `${ severityText } CVE vulnerability is detected in this project. Would you like to ${ fixWord } it now?` ;
@@ -102,7 +115,7 @@ export function buildFixPrompt(issue: UpgradeIssue): string {
102115 return `upgrade ${ packageDisplayName } to ${ suggestedVersionName } ` ;
103116 }
104117 case UpgradeReason . CVE : {
105- return `fix all critical and high-severity CVE vulnerabilities in this project by invoking #appmod-validate-cves-for-java ` ;
118+ return `fix all CVE vulnerabilities in this project` ;
106119 }
107120 }
108121}
0 commit comments