Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

Added ability to specify prefix on pooled scratch org alias #648

Merged
merged 3 commits into from
Mar 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions resources/so_pool_config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
"description": "Relax all IP ranges",
"type": "boolean"
},
"alias_prefix": {
"description": "Identifier for the pool of scratch orgs created",
"type": "string"
},
"relax_ip_ranges": {
"type": "array",
"items": [
Expand Down
4 changes: 3 additions & 1 deletion src/impl/pool/scratchorg/poolCreateImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ export default class PoolCreateImpl {
poolUser.username,
this.poolConfig.pool.config_file_path,
poolUser.expiry ? poolUser.expiry : this.poolConfig.pool.expiry,
this.hubOrg
this.hubOrg,
this.poolConfig.pool.alias_prefix
);
poolUser.scratchOrgs.push(scratchOrg);
this.totalAllocated++;
Expand Down Expand Up @@ -681,6 +682,7 @@ export interface Pool {
relax_all_ip_ranges: boolean;
relax_ip_ranges: IpRanges[];
max_allocation: number;
alias_prefix?: string;
}

export interface PoolUser {
Expand Down
13 changes: 10 additions & 3 deletions src/utils/scratchOrgUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,27 +107,34 @@ export default class ScratchOrgUtils {
adminEmail: string,
config_file_path: string,
expiry: number,
hubOrg: Org
hubOrg: Org,
alias_prefix?: string
): Promise<ScratchOrg> {
SFPowerkit.log(
'Parameters: ' + id + ' ' + adminEmail + ' ' + config_file_path + ' ' + expiry + ' ',
LoggerLevel.TRACE
);

let result;
let getSFDXCommand = `sfdx force:org:create -f ${config_file_path} -d ${expiry} -a SO${id} -w 10 -v ${hubOrg.getUsername()} --json`;
let getSFDXCommand = `sfdx force:org:create -f ${config_file_path} -d ${expiry} -w 10 -v ${hubOrg.getUsername()} --json`;

if (adminEmail) {
getSFDXCommand += ` adminEmail=${adminEmail}`;
}

if (alias_prefix) {
getSFDXCommand += ` --setalias ${alias_prefix}${id}`;
} else {
getSFDXCommand += ` --setalias SO${id}`;
}

result = child_process.execSync(getSFDXCommand, { stdio: 'pipe' });
const resultObject = JSON.parse(result);

SFPowerkit.log(JSON.stringify(result), LoggerLevel.TRACE);

let scratchOrg: ScratchOrg = {
alias: `SO${id}`,
alias: resultObject.result.alias,
orgId: resultObject.result.orgId,
username: resultObject.result.username,
signupEmail: adminEmail ? adminEmail : '',
Expand Down