Skip to content

Commit cf021fd

Browse files
committed
feat: New preference to enable/disable analysis upon open or save manifest documents.
Signed-off-by: John Steele <[email protected]>
1 parent a450036 commit cf021fd

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,18 @@
181181
"type": "object",
182182
"title": "Red Hat Dependency Analytics configuration",
183183
"properties": {
184+
"redHatDependencyAnalytics.analyzeOnOpenDocument": {
185+
"type": "boolean",
186+
"default": false,
187+
"markdownDescription": "Automatically run analysis upon opening any supported manifest file (package.json, pom.xml, go.mod, requirements.txt, build.gradle, Dockerfile, Containerfile).",
188+
"scope": "window"
189+
},
190+
"redHatDependencyAnalytics.analyzeOnSaveDocument": {
191+
"type": "boolean",
192+
"default": false,
193+
"markdownDescription": "Automatically run analysis upon saving any supported manifest file (package.json, pom.xml, go.mod, requirements.txt, build.gradle, Dockerfile, Containerfile).",
194+
"scope": "window"
195+
},
184196
"redhat.telemetry.enabled": {
185197
"type": "boolean",
186198
"default": null,

src/config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import { getTelemetryId } from './redhatTelemetry';
1010
* Represents the configuration settings for the extension.
1111
*/
1212
class Config {
13+
14+
analyzeOnOpenDocument: string;
15+
analyzeOnSaveDocument: string;
16+
1317
telemetryId: string;
1418
stackAnalysisCommand: string;
1519
trackRecommendationAcceptanceCommand: string;
@@ -74,6 +78,9 @@ class Config {
7478
loadData() {
7579
const rhdaConfig = this.getRhdaConfig();
7680

81+
this.analyzeOnOpenDocument = rhdaConfig.analyzeOnOpenDocument ? 'true' : 'false';
82+
this.analyzeOnSaveDocument = rhdaConfig.analyzeOnSaveDocument ? 'true' : 'false';
83+
7784
this.stackAnalysisCommand = commands.STACK_ANALYSIS_COMMAND;
7885
this.trackRecommendationAcceptanceCommand = commands.TRACK_RECOMMENDATION_ACCEPTANCE_COMMAND;
7986
this.utmSource = GlobalState.UTM_SOURCE;
@@ -112,6 +119,11 @@ class Config {
112119
* @private
113120
*/
114121
private async setProcessEnv(): Promise<void> {
122+
123+
process.env['VSCEXT_ANALYZE_ON_OPEN_DOCUMENT'] = this.analyzeOnOpenDocument;
124+
process.env['VSCEXT_ANALYZE_ON_SAVE_DOCUMENT'] = this.analyzeOnSaveDocument;
125+
126+
115127
process.env['VSCEXT_STACK_ANALYSIS_COMMAND'] = this.stackAnalysisCommand;
116128
process.env['VSCEXT_TRACK_RECOMMENDATION_ACCEPTANCE_COMMAND'] = this.trackRecommendationAcceptanceCommand;
117129
process.env['VSCEXT_UTM_SOURCE'] = this.utmSource;

test/config.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ suite('Config module', () => {
7171

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

74+
expect(process.env['VSCEXT_ANALYZE_ON_OPEN_DOCUMENT']).to.eq('false');
75+
expect(process.env['VSCEXT_ANALYZE_ON_SAVE_DOCUMENT']).to.eq('false');
76+
7477
expect(process.env['VSCEXT_STACK_ANALYSIS_COMMAND']).to.eq(commands.STACK_ANALYSIS_COMMAND);
7578
expect(process.env['VSCEXT_TRACK_RECOMMENDATION_ACCEPTANCE_COMMAND']).to.eq(commands.TRACK_RECOMMENDATION_ACCEPTANCE_COMMAND);
7679
expect(process.env['VSCEXT_UTM_SOURCE']).to.eq(GlobalState.UTM_SOURCE);

0 commit comments

Comments
 (0)