Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Mar 18, 2024. It is now read-only.

Commit 5ce4033

Browse files
feat(pool): Add an option to Pool Configuration for scratch org creation time (#903)
* feat(prepare): add wait time as an addition parameter in pool config Add waitTime as an optional config in pool defintion. This allows the command to wait for longer to create scratch orgs,as scratch orgs often created from shape take a considerable time Co-authored-by: azlam-abdulsalam <[email protected]>
1 parent 0cbb860 commit 5ce4033

6 files changed

Lines changed: 38 additions & 19 deletions

File tree

packages/core/src/scratchorg/ScratchOrgOperator.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
1-
import { Aliases, AuthInfo, Org, ScratchOrgRequest } from '@salesforce/core';
1+
import { Aliases, AuthInfo, Org } from '@salesforce/core';
22
import ScratchOrg from './ScratchOrg';
33
import PasswordGenerator from './PasswordGenerator';
44
import SFPLogger, { LoggerLevel } from '../logger/SFPLogger';
55
import { Duration } from '@salesforce/kit';
6+
import { ScratchOrgRequest } from '@salesforce/core';
67
const retry = require('async-retry');
78

89
export default class ScratchOrgOperator {
910
constructor(private hubOrg: Org) {}
1011

11-
public async create(alias: string, config_file_path: string, expiry: number): Promise<ScratchOrg> {
12+
public async create(
13+
alias: string,
14+
config_file_path: string,
15+
expiry: number,
16+
waitTime: number = 6
17+
): Promise<ScratchOrg> {
1218
SFPLogger.log('Parameters: ' + alias + ' ' + config_file_path + ' ' + expiry + ' ', LoggerLevel.TRACE);
1319

14-
let scatchOrgResult = await this.requestAScratchOrg(alias, config_file_path, Duration.days(expiry));
20+
let scatchOrgResult = await this.requestAScratchOrg(
21+
alias,
22+
config_file_path,
23+
Duration.days(expiry),
24+
Duration.minutes(waitTime)
25+
);
1526
SFPLogger.log(JSON.stringify(scatchOrgResult), LoggerLevel.TRACE);
1627

1728
//create scratchOrg object
@@ -57,12 +68,12 @@ export default class ScratchOrgOperator {
5768
);
5869
}
5970

60-
private async requestAScratchOrg(alias: string, definitionFile: string, expireIn: Duration) {
71+
private async requestAScratchOrg(alias: string, definitionFile: string, expireIn: Duration, waitTime: Duration) {
6172
const createCommandOptions: ScratchOrgRequest = {
6273
durationDays: expireIn.days,
6374
nonamespace: false,
6475
noancestors: false,
65-
wait: Duration.minutes(6),
76+
wait: waitTime,
6677
retry: 3,
6778
definitionfile: definitionFile,
6879
};

packages/sfpowerscripts-cli/package-lock.json

Lines changed: 11 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/sfpowerscripts-cli/resources/schemas/pooldefinition.schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
"description": "Tag or name to identify the scratch org pool",
2121
"type": "string"
2222
},
23+
"waitTime": {
24+
"title": "wait time",
25+
"description": "Time to wait for scratch org creation in minutes (default:6 mins)",
26+
"type": "integer",
27+
"default": 6
28+
},
2329
"expiry": {
2430
"title": "expiry",
2531
"description": "Duration of the scratch org (in days) (default:2)",

packages/sfpowerscripts-cli/src/impl/pool/PoolConfig.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import ScratchOrg from '@dxatscale/sfpowerscripts.core/lib/scratchorg/ScratchOrg
33
export interface PoolConfig {
44
tag: string;
55
maxAllocation: number;
6+
waitTime?: number;
67
expiry?: number;
78
batchSize?: number;
89
configFilePath: string;

packages/sfpowerscripts-cli/src/impl/pool/PoolCreateImpl.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ export default class PoolCreateImpl extends PoolBaseImpl {
159159
let scratchOrg: ScratchOrg = await this.scratchOrgOperator.create(
160160
`SO` + count,
161161
this.pool.configFilePath,
162-
this.pool.expiry
162+
this.pool.expiry,
163+
this.pool.waitTime
163164
);
164165

165166
let orgDetails = await new OrgDetailsFetcher(scratchOrg.username).getOrgDetails();

packages/sfpowerscripts-cli/src/impl/prepare/PrepareImpl.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ export default class PrepareImpl {
3030
if (!this.pool.batchSize) this.pool.batchSize = 5;
3131

3232
if (this.pool.succeedOnDeploymentErrors === undefined) this.pool.succeedOnDeploymentErrors = true;
33+
34+
if (!this.pool.waitTime) this.pool.waitTime = 6;
3335
}
3436

3537
public async exec() {

0 commit comments

Comments
 (0)