Skip to content

Commit

Permalink
refactor: single-source to multi-source
Browse files Browse the repository at this point in the history
Signed-off-by: Ilona Shishov <[email protected]>
  • Loading branch information
IlonaShishov committed Nov 27, 2023
1 parent 2ee304f commit ce813d2
Show file tree
Hide file tree
Showing 28 changed files with 788 additions and 848 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ module.exports = {
"no-unsafe-finally": "error",
"new-parens": "error",
"no-throw-literal": "error",
"no-useless-catch": "off"
}
}
2 changes: 1 addition & 1 deletion .github/workflows/stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
const response = await github.request('POST /repos/' + repo_name + '/releases', {
tag_name: '${{ steps.bump.outputs.version }}',
name: '${{ steps.bump.outputs.version }}',
prerelease: true,
prerelease: false,
generate_release_notes: true
})
core.setOutput('upload_url', response.data.upload_url)
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@
"out": true // set this to false to include "out" folder in search results
},
"typescript.tsdk": "./node_modules/typescript/lib",
"redhat.telemetry.enabled": true // we want to use the TS server from our node_modules folder to control its version
"redhat.telemetry.enabled": true,
"redHatDependencyAnalytics.exhortOSSIndexToken": "123" // we want to use the TS server from our node_modules folder to control its version
}
66 changes: 51 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 15 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,19 @@
"redHatDependencyAnalytics.exhortSnykToken": {
"type": "string",
"default": "",
"description": "Red Hat Dependency Analytics server authentication token for Snyk.",
"description": "Red Hat Dependency Analytics authentication token for Snyk.",
"scope": "window"
},
"redHatDependencyAnalytics.exhortOSSIndexUser": {
"type": "string",
"default": "",
"description": "Red Hat Dependency Analytics authentication username for OSS Index.",
"scope": "window"
},
"redHatDependencyAnalytics.exhortOSSIndexToken": {
"type": "string",
"default": "",
"description": "Red Hat Dependency Analytics authentication token for OSS Index.",
"scope": "window"
},
"redHatDependencyAnalytics.matchManifestVersions": {
Expand Down Expand Up @@ -284,9 +296,9 @@
"webpack-cli": "^5.1.4"
},
"dependencies": {
"@fabric8-analytics/fabric8-analytics-lsp-server": "^0.7.1-ea.18",
"@fabric8-analytics/fabric8-analytics-lsp-server": "^0.8.1-ea.0",
"@redhat-developer/vscode-redhat-telemetry": "^0.7.0",
"@RHEcosystemAppEng/exhort-javascript-api": "^0.0.2-ea.49",
"@RHEcosystemAppEng/exhort-javascript-api": "^0.1.1-ea.0",
"fs": "^0.0.1-security",
"path": "^0.12.7",
"vscode-languageclient": "^8.1.0"
Expand Down
55 changes: 40 additions & 15 deletions src/caNotification.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,58 @@
'use strict';

interface CANotificationData {
data: string;
error: string;
done: boolean;
uri: string;
diagCount: number;
vulnCount: number;
}

class CANotification {
private data: string;
private done: boolean;
private uri: string;
private diagCount: number;
private vulnCount: number;
private readonly error: string;
private readonly done: boolean;
private readonly uri: string;
private readonly diagCount: number;
private readonly vulnCount: number;

private static readonly VULNERABILITY = 'vulnerability';
private static readonly VULNERABILITIES = 'vulnerabilities';
private static readonly NO_VULNERABILITIES = 'no vulnerabilities';

private static readonly SYNC_SPIN = 'sync~spin';
private static readonly WARNING = 'warning';
private static readonly SHIELD = 'shield';
private static readonly CHECK = 'check';

constructor(respData: CANotificationData) {
this.data = respData.data;
this.error = respData.error || '';
this.done = respData.done === true;
this.uri = respData.uri;
this.diagCount = respData.diagCount || 0;
this.vulnCount = respData.vulnCount || 0;
}

private vulnCountText(): string {
const vulnText = this.vulnCount === 1 ? CANotification.VULNERABILITY : CANotification.VULNERABILITIES;
return this.vulnCount > 0 ? `${this.vulnCount} ${vulnText}` : CANotification.NO_VULNERABILITIES;
}

private inProgressText(): string {
return `$(${CANotification.SYNC_SPIN}) Dependency analysis in progress`;
}

private warningText(): string {
return `$(${CANotification.WARNING}) Found ${this.vulnCountText()}`;
}

private defaultText(): string {
return `$(${CANotification.SHIELD})$(${CANotification.CHECK})`;
}

public errorMsg(): string {
return this.error;
}

public origin(): string {
return this.uri;
}
Expand All @@ -40,19 +70,14 @@ class CANotification {
return this.statusText().replace(/\$\((.*?)\)/g, '');
}

private vulnCountText(): string {
const vulns = this.vulnCount;
return vulns > 0 ? `${vulns} ${vulns === 1 ? 'vulnerability' : 'vulnerabilities'}` : `no vulnerabilities`;
}

public statusText(): string {
if (!this.isDone()) {
return `$(sync~spin) Dependency analysis in progress`;
return this.inProgressText();
}
if (this.hasWarning()) {
return `$(warning) Found ${this.vulnCountText()}`;
return this.warningText();
}
return `$(shield)$(check)`;
return this.defaultText();
}
}

Expand Down
15 changes: 5 additions & 10 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@
* Commonly used commands to trigger Stack Analysis and supporting actions
*/
export const TRIGGER_FULL_STACK_ANALYSIS = 'fabric8.stackAnalysis';
export const TRIGGER_FULL_STACK_ANALYSIS_FROM_STATUS_BAR =
'fabric8.stackAnalysisFromStatusBar';
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';
export const TRIGGER_REDHAT_REPOSITORY_RECOMMENDATION_NOTIFICATION = 'fabric8.RHRepositoryRecommendationNotification';
export const TRIGGER_FULL_STACK_ANALYSIS_FROM_STATUS_BAR = 'fabric8.stackAnalysisFromStatusBar';
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';
Loading

0 comments on commit ce813d2

Please sign in to comment.