Skip to content

Commit

Permalink
feat(prepare-c-flag): add noAnchestors option to config (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rocko1204 authored Feb 6, 2024
1 parent 6591083 commit ab8ca59
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
6 changes: 6 additions & 0 deletions packages/sfp-cli/resources/schemas/pooldefinition.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@
"type": "boolean",
"default":false
},
"noAnchestors": {
"title": "Disable second-generation managed package (2GP) ancestors in the scratch org.",
"description": "Don't include second-generation managed package (2GP) ancestors in the scratch org when set to true",
"type": "boolean",
"default":false
},
"fetchArtifacts": {
"title": "Fetch Artifacts using below mechanism",
"description": "Fetch artifacts from artifact registry using below mechanism",
Expand Down
11 changes: 7 additions & 4 deletions packages/sfp-cli/src/core/scratchorg/ScratchOrgOperator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ScratchOrgRequest } from '@salesforce/core';
import { COLOR_KEY_MESSAGE } from '@flxblio/sfp-logger';
import getFormattedTime from '../utils/GetFormattedTime';
import SFPStatsSender from '../stats/SFPStatsSender';
import { PoolConfig } from './pool/PoolConfig';
const retry = require('async-retry');

export default class ScratchOrgOperator {
Expand All @@ -16,7 +17,8 @@ export default class ScratchOrgOperator {
alias: string,
config_file_path: string,
expiry: number,
waitTime: number = 6
waitTime: number = 6,
poolConfig: Partial<PoolConfig>
): Promise<ScratchOrg> {
SFPLogger.log('Parameters: ' + alias + ' ' + config_file_path + ' ' + expiry + ' ', LoggerLevel.TRACE);

Expand All @@ -26,7 +28,8 @@ export default class ScratchOrgOperator {
alias,
config_file_path,
Duration.days(expiry),
Duration.minutes(waitTime)
Duration.minutes(waitTime),
poolConfig
);
SFPLogger.log(JSON.stringify(scatchOrgResult), LoggerLevel.TRACE);

Expand Down Expand Up @@ -81,11 +84,11 @@ export default class ScratchOrgOperator {
);
}

private async requestAScratchOrg(alias: string, definitionFile: string, expireIn: Duration, waitTime: Duration) {
private async requestAScratchOrg(alias: string, definitionFile: string, expireIn: Duration, waitTime: Duration, poolConfig: Partial<PoolConfig>) {
const createCommandOptions: ScratchOrgRequest = {
durationDays: expireIn.days,
nonamespace: false,
noancestors: false,
noancestors: poolConfig.noAnchestors || false,
wait: waitTime,
retry: 3,
definitionfile: definitionFile,
Expand Down
3 changes: 1 addition & 2 deletions packages/sfp-cli/src/core/scratchorg/pool/PoolConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,5 @@ export interface PoolConfig {
scratchOrgs?: ScratchOrg[];
failedToCreate?: number;
maxRetryCount?:number;


noAnchestors?:boolean;
}
4 changes: 2 additions & 2 deletions packages/sfp-cli/src/core/scratchorg/pool/PoolCreateImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export default class PoolCreateImpl extends PoolBaseImpl {
}
return ok(this.pool);


}

private async computeAllocation(): Promise<number> {
Expand Down Expand Up @@ -198,7 +198,7 @@ export default class PoolCreateImpl extends PoolBaseImpl {
const startTime = Date.now();
for (let i = 1; i <= pool.to_allocate; i++) {
const scratchOrgPromise: Promise<ScratchOrg> = scratchOrgCreationLimiter.schedule(() =>
scratchOrgOperator.create(`SO` + i, this.pool.configFilePath, this.pool.expiry, this.pool.waitTime)
scratchOrgOperator.create(`SO` + i, this.pool.configFilePath, this.pool.expiry, this.pool.waitTime, this.pool)
);
scratchOrgPromises.push(scratchOrgPromise);
}
Expand Down

0 comments on commit ab8ca59

Please sign in to comment.