From 46ac0ff8a8485fe42b17e7ac9e9052921fe9bec6 Mon Sep 17 00:00:00 2001 From: Rocko1204 Date: Sun, 4 Feb 2024 23:40:22 +0100 Subject: [PATCH] feat(prepare-c-flag): add noAnchestors option to config --- .../resources/schemas/pooldefinition.schema.json | 6 ++++++ .../sfp-cli/src/core/scratchorg/ScratchOrgOperator.ts | 11 +++++++---- .../sfp-cli/src/core/scratchorg/pool/PoolConfig.ts | 3 +-- .../src/core/scratchorg/pool/PoolCreateImpl.ts | 4 ++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/sfp-cli/resources/schemas/pooldefinition.schema.json b/packages/sfp-cli/resources/schemas/pooldefinition.schema.json index b3102e17d..ce6cadc0a 100644 --- a/packages/sfp-cli/resources/schemas/pooldefinition.schema.json +++ b/packages/sfp-cli/resources/schemas/pooldefinition.schema.json @@ -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", diff --git a/packages/sfp-cli/src/core/scratchorg/ScratchOrgOperator.ts b/packages/sfp-cli/src/core/scratchorg/ScratchOrgOperator.ts index f354fbbd8..f8caee807 100644 --- a/packages/sfp-cli/src/core/scratchorg/ScratchOrgOperator.ts +++ b/packages/sfp-cli/src/core/scratchorg/ScratchOrgOperator.ts @@ -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 { @@ -16,7 +17,8 @@ export default class ScratchOrgOperator { alias: string, config_file_path: string, expiry: number, - waitTime: number = 6 + waitTime: number = 6, + poolConfig: Partial ): Promise { SFPLogger.log('Parameters: ' + alias + ' ' + config_file_path + ' ' + expiry + ' ', LoggerLevel.TRACE); @@ -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); @@ -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) { const createCommandOptions: ScratchOrgRequest = { durationDays: expireIn.days, nonamespace: false, - noancestors: false, + noancestors: poolConfig.noAnchestors || false, wait: waitTime, retry: 3, definitionfile: definitionFile, diff --git a/packages/sfp-cli/src/core/scratchorg/pool/PoolConfig.ts b/packages/sfp-cli/src/core/scratchorg/pool/PoolConfig.ts index b18fc05f2..39996186e 100644 --- a/packages/sfp-cli/src/core/scratchorg/pool/PoolConfig.ts +++ b/packages/sfp-cli/src/core/scratchorg/pool/PoolConfig.ts @@ -35,6 +35,5 @@ export interface PoolConfig { scratchOrgs?: ScratchOrg[]; failedToCreate?: number; maxRetryCount?:number; - - + noAnchestors?:boolean; } diff --git a/packages/sfp-cli/src/core/scratchorg/pool/PoolCreateImpl.ts b/packages/sfp-cli/src/core/scratchorg/pool/PoolCreateImpl.ts index f968c97cc..84671d6b2 100644 --- a/packages/sfp-cli/src/core/scratchorg/pool/PoolCreateImpl.ts +++ b/packages/sfp-cli/src/core/scratchorg/pool/PoolCreateImpl.ts @@ -145,7 +145,7 @@ export default class PoolCreateImpl extends PoolBaseImpl { } return ok(this.pool); - + } private async computeAllocation(): Promise { @@ -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 = 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); }