Skip to content

Commit

Permalink
Merge pull request #1618 from forcedotcom/jj/W-15639920_set_env
Browse files Browse the repository at this point in the history
NEW (Extension) @W-15639920@ CLI changes to pass java env variable to enable caching and path for delta runs
  • Loading branch information
jag-j authored Sep 5, 2024
2 parents fc0d01b + 1bd5a1f commit 6cd518b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/commands/scanner/run/dfa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,19 @@ export default class Dfa extends ScannerRunCommand {
summary: getMessage(BundleName.RunDfa, 'flags.pathexplimitSummary'),
description: getMessage(BundleName.RunDfa, 'flags.pathexplimitDescription'),
env: 'SFGE_PATH_EXPANSION_LIMIT'
})
}),
'enablecaching': Flags.boolean({
summary: '',
description: '',
env: 'SFGE_ENABLE_CACHING',
hidden: true
}),
'cachepath': Flags.string({
summary: '',
description: '',
env: 'SFGE_FILES_TO_ENTRIES_CACHE_LOCATION',
hidden: true
}),
// END: Config-overrideable engine flags.
};

Expand Down
6 changes: 6 additions & 0 deletions src/lib/EngineOptionsFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ export class RunDfaEngineOptionsFactory extends CommonEngineOptionsFactory {
if (inputs['pathexplimit'] != null) {
sfgeConfig.pathexplimit = inputs['pathexplimit'] as number;
}
if (inputs['enablecaching'] != null) {
sfgeConfig.enablecaching = inputs['enablecaching'] as boolean;
}
if (inputs['cachepath'] != null) {
sfgeConfig.cachepath = inputs['cachepath'] as string;
}
sfgeConfig.ruleDisableWarningViolation = getBooleanEngineOption(inputs, RULE_DISABLE_WARNING_VIOLATION_FLAG);
engineOptions.set(CUSTOM_CONFIG.SfgeConfig, JSON.stringify(sfgeConfig));

Expand Down
18 changes: 17 additions & 1 deletion src/lib/sfge/SfgeWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ type SfgeExecuteOptions = SfgeWrapperOptions & {
ruleThreadCount?: number;
ruleThreadTimeout?: number;
ruleDisableWarningViolation?: boolean;
enablecaching?: boolean;
cachepath?: string;
}

type SfgeTarget = {
Expand All @@ -57,6 +59,8 @@ type SfgeInput = {
targets: SfgeTarget[];
projectDirs: string[];
rulesToRun: string[];
enablecaching?: boolean;
cachepath?: string;
};

class SfgeSpinnerManager extends AsyncCreatable implements SpinnerManager {
Expand Down Expand Up @@ -209,6 +213,8 @@ export class SfgeExecuteWrapper extends AbstractSfgeWrapper {
private ruleThreadCount: number;
private ruleThreadTimeout: number;
private ruleDisableWarningViolation: boolean;
private enablecaching: boolean;
private cachepath: string;

constructor(options: SfgeExecuteOptions) {
super(options);
Expand All @@ -218,6 +224,8 @@ export class SfgeExecuteWrapper extends AbstractSfgeWrapper {
this.ruleThreadCount = options.ruleThreadCount;
this.ruleThreadTimeout = options.ruleThreadTimeout;
this.ruleDisableWarningViolation = options.ruleDisableWarningViolation;
this.enablecaching = options.enablecaching;
this.cachepath = options.cachepath;
}

protected getSupplementalFlags(): string[] {
Expand All @@ -231,6 +239,12 @@ export class SfgeExecuteWrapper extends AbstractSfgeWrapper {
if (this.ruleDisableWarningViolation != null) {
flags.push(`-DSFGE_RULE_DISABLE_WARNING_VIOLATION=${this.ruleDisableWarningViolation.toString()}`);
}
if (this.enablecaching != null && this.enablecaching) {
flags.push(`-DSFGE_DISABLE_CACHING=false`);
}
if (this.cachepath != null) {
flags.push(`-DSFGE_FILES_TO_ENTRIES_CACHE_LOCATION=${this.cachepath}`);
}
return flags;
}

Expand Down Expand Up @@ -291,7 +305,9 @@ export class SfgeExecuteWrapper extends AbstractSfgeWrapper {
pathExpLimit: sfgeConfig.pathexplimit,
ruleThreadCount: sfgeConfig.ruleThreadCount,
ruleThreadTimeout: sfgeConfig.ruleThreadTimeout,
ruleDisableWarningViolation: sfgeConfig.ruleDisableWarningViolation
ruleDisableWarningViolation: sfgeConfig.ruleDisableWarningViolation,
cachepath: sfgeConfig.cachepath,
enablecaching: sfgeConfig.enablecaching
});
return wrapper.execute();
}
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,6 @@ export type SfgeConfig = {
ruleDisableWarningViolation?: boolean;
jvmArgs?: string;
pathexplimit?: number;
enablecaching?: boolean;
cachepath?: string;
};

0 comments on commit 6cd518b

Please sign in to comment.