From bfb2ec6a20a9619ea33010a938fe4543f7f90b0e Mon Sep 17 00:00:00 2001 From: Ilona Shishov Date: Sun, 17 Dec 2023 17:56:13 +0200 Subject: [PATCH] feat: added remediation and recommendation quickfix feature Signed-off-by: Ilona Shishov --- package-lock.json | 22 +++++++++++----------- package.json | 4 ++-- src/commands.ts | 3 ++- src/config.ts | 3 +++ src/extension.ts | 14 +++++++++++++- 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 64425fe1b..29778c600 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,9 +9,9 @@ "version": "0.7.4", "license": "Apache-2.0", "dependencies": { - "@fabric8-analytics/fabric8-analytics-lsp-server": "^0.8.1-ea.3", + "@fabric8-analytics/fabric8-analytics-lsp-server": "^0.8.1-ea.4", "@redhat-developer/vscode-redhat-telemetry": "^0.7.0", - "@RHEcosystemAppEng/exhort-javascript-api": "^0.1.1-ea.3", + "@RHEcosystemAppEng/exhort-javascript-api": "^0.1.1-ea.4", "fs": "^0.0.1-security", "path": "^0.12.7", "vscode-languageclient": "^8.1.0" @@ -81,11 +81,11 @@ }, "../fabric8-analytics-lsp-server": { "name": "@fabric8-analytics/fabric8-analytics-lsp-server", - "version": "0.8.0", + "version": "0.8.1-ea.2", "extraneous": true, "license": "Apache-2.0", "dependencies": { - "@RHEcosystemAppEng/exhort-javascript-api": "^0.1.1-ea.0", + "@RHEcosystemAppEng/exhort-javascript-api": "^0.1.1-ea.4", "@xml-tools/ast": "^5.0.5", "@xml-tools/parser": "^1.0.11", "json-to-ast": "^2.1.0", @@ -567,12 +567,12 @@ } }, "node_modules/@fabric8-analytics/fabric8-analytics-lsp-server": { - "version": "0.8.1-ea.3", - "resolved": "https://npm.pkg.github.com/download/@fabric8-analytics/fabric8-analytics-lsp-server/0.8.1-ea.3/bbd4fa192ffd70147819731afff77e35bb3ffed1", - "integrity": "sha512-ThCLKXCB7yax7gDssVDjIaRfyYcFEyYwBdr3Rscmn/XJPksEGMOrNCYhHl/jYTkrH4neXuX7Z0E47vWPeoXB3Q==", + "version": "0.8.1-ea.4", + "resolved": "https://npm.pkg.github.com/download/@fabric8-analytics/fabric8-analytics-lsp-server/0.8.1-ea.4/b14d5a1fc63f27b994f16b1fc3a58002cff14b9c", + "integrity": "sha512-Xvj5O6X0FRBCdozytm3u7UQTbh3fUxkav2q7BTUqTWft6blEb2Cl0GghCs14qGXeS19uS9TJwaZCVISU0x0YJA==", "license": "Apache-2.0", "dependencies": { - "@RHEcosystemAppEng/exhort-javascript-api": "^0.1.1-ea.3", + "@RHEcosystemAppEng/exhort-javascript-api": "^0.1.1-ea.4", "@xml-tools/ast": "^5.0.5", "@xml-tools/parser": "^1.0.11", "json-to-ast": "^2.1.0", @@ -949,9 +949,9 @@ } }, "node_modules/@RHEcosystemAppEng/exhort-javascript-api": { - "version": "0.1.1-ea.3", - "resolved": "https://npm.pkg.github.com/download/@RHEcosystemAppEng/exhort-javascript-api/0.1.1-ea.3/64de57546f9958f378c8ad22ec18cedaec95b4ed", - "integrity": "sha512-ydfi0HL3uFlejGeyJbCalJQAz0nPO4NKjBEaj/awb5qN/HIONzB6KnjGQI2rvws4Iwhi+LvRptfRgH3aZtwejw==", + "version": "0.1.1-ea.4", + "resolved": "https://npm.pkg.github.com/download/@RHEcosystemAppEng/exhort-javascript-api/0.1.1-ea.4/cad7237062cf4467fcf76ee9151dbfb50037e233", + "integrity": "sha512-qKmcb2rfP26iaSwdi5LKAj2l2kiyBRfvf/gD1gYwXoQBSNfrz3rMCQJb2HZoRmEQfn0mE/mqMe0ZEfgdDQBHCw==", "license": "Apache-2.0", "dependencies": { "@babel/core": "^7.23.2", diff --git a/package.json b/package.json index b141c1767..172da2247 100644 --- a/package.json +++ b/package.json @@ -296,9 +296,9 @@ "webpack-cli": "^5.1.4" }, "dependencies": { - "@fabric8-analytics/fabric8-analytics-lsp-server": "^0.8.1-ea.3", + "@fabric8-analytics/fabric8-analytics-lsp-server": "^0.8.1-ea.4", "@redhat-developer/vscode-redhat-telemetry": "^0.7.0", - "@RHEcosystemAppEng/exhort-javascript-api": "^0.1.1-ea.3", + "@RHEcosystemAppEng/exhort-javascript-api": "^0.1.1-ea.4", "fs": "^0.0.1-security", "path": "^0.12.7", "vscode-languageclient": "^8.1.0" diff --git a/src/commands.ts b/src/commands.ts index 693b9c19b..d3600da01 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -8,4 +8,5 @@ export const TRIGGER_FULL_STACK_ANALYSIS_FROM_STATUS_BAR = 'fabric8.stackAnalysi export const TRIGGER_FULL_STACK_ANALYSIS_FROM_EXPLORER = 'fabric8.stackAnalysisFromExplorer'; export const TRIGGER_FULL_STACK_ANALYSIS_FROM_PIE_BTN = 'fabric8.stackAnalysisFromPieBtn'; export const TRIGGER_FULL_STACK_ANALYSIS_FROM_EDITOR = 'fabric8.stackAnalysisFromEditor'; -export const TRIGGER_STACK_LOGS = 'fabric8.fabric8AnalyticsStackLogs'; \ No newline at end of file +export const TRIGGER_STACK_LOGS = 'fabric8.fabric8AnalyticsStackLogs'; +export const TRIGGER_REDHAT_REPOSITORY_RECOMMENDATION_NOTIFICATION = 'fabric8.RHRepositoryRecommendationNotification'; \ No newline at end of file diff --git a/src/config.ts b/src/config.ts index e5e982ca6..d53661222 100644 --- a/src/config.ts +++ b/src/config.ts @@ -12,6 +12,7 @@ import { getTelemetryId } from './redhatTelemetry'; class Config { telemetryId: string; triggerFullStackAnalysis: string; + triggerRHRepositoryRecommendationNotification: string; utmSource: string; exhortSnykToken: string; exhortOSSIndexUser: string; @@ -72,6 +73,7 @@ class Config { const apiConfig = this.getRhdaConfig(); this.triggerFullStackAnalysis = commands.TRIGGER_FULL_STACK_ANALYSIS; + this.triggerRHRepositoryRecommendationNotification = commands.TRIGGER_REDHAT_REPOSITORY_RECOMMENDATION_NOTIFICATION; this.utmSource = GlobalState.UTM_SOURCE; this.exhortSnykToken = apiConfig.exhortSnykToken; this.exhortOSSIndexUser = apiConfig.exhortOSSIndexUser; @@ -93,6 +95,7 @@ class Config { */ private setProcessEnv() { process.env['VSCEXT_TRIGGER_FULL_STACK_ANALYSIS'] = this.triggerFullStackAnalysis; + process.env['VSCEXT_TRIGGER_REDHAT_REPOSITORY_RECOMMENDATION_NOTIFICATION'] = this.triggerRHRepositoryRecommendationNotification; process.env['VSCEXT_UTM_SOURCE'] = this.utmSource; process.env['VSCEXT_EXHORT_SNYK_TOKEN'] = this.exhortSnykToken; process.env['VSCEXT_EXHORT_OSS_INDEX_USER'] = this.exhortOSSIndexUser; diff --git a/src/extension.ts b/src/extension.ts index 6f44dc03c..7d7e31f2a 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -10,7 +10,7 @@ import { import * as path from 'path'; import * as commands from './commands'; -import { GlobalState, extensionQualifiedId } from './constants'; +import { GlobalState, extensionQualifiedId, redhatMavenRepository, redhatMavenRepositoryDocumentationURL } from './constants'; import { generateRHDAReport } from './stackAnalysis'; import { globalConfig } from './config'; import { StatusMessages, PromptText } from './constants'; @@ -60,6 +60,17 @@ export function activate(context: vscode.ExtensionContext) { } ); + const rhRepositoryRecommendationNotification = vscode.commands.registerCommand( + commands.TRIGGER_REDHAT_REPOSITORY_RECOMMENDATION_NOTIFICATION, + () => { + const msg = `Important: If you apply Red Hat Dependency Analytics recommendations, + make sure the Red Hat GA Repository (${redhatMavenRepository}) has been added to your project configuration. + This ensures that the applied dependencies work correctly. + Learn how to add the repository: [Click here](${redhatMavenRepositoryDocumentationURL})`; + vscode.window.showWarningMessage(msg); + } + ); + registerStackAnalysisCommands(context); globalConfig.authorizeRHDA(context) @@ -146,6 +157,7 @@ export function activate(context: vscode.ExtensionContext) { context.subscriptions.push( disposableStackAnalysisCommand, disposableStackLogsCommand, + rhRepositoryRecommendationNotification, caStatusBarProvider, ); })