Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New preference to enable/disable analysis upon open or save manifest … #734

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,18 @@
"type": "object",
"title": "Red Hat Dependency Analytics configuration",
"properties": {
"redHatDependencyAnalytics.analyzeOnOpenDocument": {
"type": "boolean",
"default": false,
"markdownDescription": "Automatically run analysis upon opening any supported manifest file (package.json, pom.xml, go.mod, requirements.txt, build.gradle, Dockerfile, Containerfile).",
"scope": "window"
},
"redHatDependencyAnalytics.analyzeOnSaveDocument": {
"type": "boolean",
"default": false,
"markdownDescription": "Automatically run analysis upon saving any supported manifest file (package.json, pom.xml, go.mod, requirements.txt, build.gradle, Dockerfile, Containerfile).",
"scope": "window"
},
"redhat.telemetry.enabled": {
"type": "boolean",
"default": null,
Expand Down
12 changes: 12 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import { getTelemetryId } from './redhatTelemetry';
* Represents the configuration settings for the extension.
*/
class Config {

analyzeOnOpenDocument: string;
analyzeOnSaveDocument: string;

telemetryId: string;
stackAnalysisCommand: string;
trackRecommendationAcceptanceCommand: string;
Expand Down Expand Up @@ -74,6 +78,9 @@ class Config {
loadData() {
const rhdaConfig = this.getRhdaConfig();

this.analyzeOnOpenDocument = rhdaConfig.analyzeOnOpenDocument ? 'true' : 'false';
this.analyzeOnSaveDocument = rhdaConfig.analyzeOnSaveDocument ? 'true' : 'false';

this.stackAnalysisCommand = commands.STACK_ANALYSIS_COMMAND;
this.trackRecommendationAcceptanceCommand = commands.TRACK_RECOMMENDATION_ACCEPTANCE_COMMAND;
this.utmSource = GlobalState.UTM_SOURCE;
Expand Down Expand Up @@ -112,6 +119,11 @@ class Config {
* @private
*/
private async setProcessEnv(): Promise<void> {

process.env['VSCEXT_ANALYZE_ON_OPEN_DOCUMENT'] = this.analyzeOnOpenDocument;
process.env['VSCEXT_ANALYZE_ON_SAVE_DOCUMENT'] = this.analyzeOnSaveDocument;


process.env['VSCEXT_STACK_ANALYSIS_COMMAND'] = this.stackAnalysisCommand;
process.env['VSCEXT_TRACK_RECOMMENDATION_ACCEPTANCE_COMMAND'] = this.trackRecommendationAcceptanceCommand;
process.env['VSCEXT_UTM_SOURCE'] = this.utmSource;
Expand Down
3 changes: 3 additions & 0 deletions test/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ suite('Config module', () => {

expect(globalConfig.telemetryId).to.equal(mockId);

expect(process.env['VSCEXT_ANALYZE_ON_OPEN_DOCUMENT']).to.eq('false');
expect(process.env['VSCEXT_ANALYZE_ON_SAVE_DOCUMENT']).to.eq('false');

expect(process.env['VSCEXT_STACK_ANALYSIS_COMMAND']).to.eq(commands.STACK_ANALYSIS_COMMAND);
expect(process.env['VSCEXT_TRACK_RECOMMENDATION_ACCEPTANCE_COMMAND']).to.eq(commands.TRACK_RECOMMENDATION_ACCEPTANCE_COMMAND);
expect(process.env['VSCEXT_UTM_SOURCE']).to.eq(GlobalState.UTM_SOURCE);
Expand Down
Loading