Skip to content

Commit

Permalink
Merge pull request #112 from tiagonnascimento/feature-addTargetOrgOnC…
Browse files Browse the repository at this point in the history
…ommand

feat: allowing to send target-org to command build type
  • Loading branch information
tiagonnascimento authored Sep 7, 2024
2 parents 791f15e + bb1ce18 commit 44c1bba
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ Each release is a different release. It may be necessary to perform deployments
},
{
"type": "command",
"command": "sf --version"
"command": "vlocity --nojob installVlocityInitial",
"includeTargetOrg": true,
"targetOrgFormat": "-sfdx.username"
}
]
}
Expand All @@ -119,7 +121,7 @@ Some considerations regarding this configuration file:
- For other types of deployments:
- If `type` is `datapack`, the `manifestFile` field is required;
- If `type` is `anonymousApex`, the `apexScript` field is required;
- If `type` is `command`, the `command` field is required - this could be any shell command that you want to execute.
- If `type` is `command`, the `command` field is required - this could be any shell command that you want to execute. There is also the possibility to instruct the plugin to include the connected target-org in any specific format that you want using for that the two optional parameters `includeTargetOrg` (default to `false`) and `targetOrgFormat` (default to `--target-org`).

## Files: package.xml

Expand Down
5 changes: 5 additions & 0 deletions src/modules/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ export default class Commands {
const [head, ...tail] = build.command.split(' ');
buildCommand = head;
buildCommandArgs = tail;
if (build.addTargetOrg) {
const targetOrgFormat = build.targetOrgFormat ?? '--target-org';
buildCommandArgs.push(targetOrgFormat);
buildCommandArgs.push(username);
}
} else {
console.error(`Build type not supported ${build.type}`);
throw new Error(`Build type not supported ${build.type}`);
Expand Down
2 changes: 2 additions & 0 deletions src/modules/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export type Build = {
apexScript?: string;
command?: string;
outputFormat?: string;
addTargetOrg?: boolean;
targetOrgFormat?: string;
};

export type Package = {
Expand Down
6 changes: 4 additions & 2 deletions test/commands/builds/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ describe('BuildsDeploy', () => {
},
{
type: 'command',
command: 'sf --version',
command: 'vlocity --nojob installVlocityInitial',
addTargetOrg: true,
targetOrgFormat: '-sfdx.username',
},
],
};
Expand Down Expand Up @@ -113,7 +115,7 @@ describe('BuildsDeploy', () => {
expect(ctx.stdout).to.contain('sf project deploy start');
expect(ctx.stdout).to.contain('vlocity -sfdx.username');
expect(ctx.stdout).to.contain('sf apex run');
expect(ctx.stdout).to.contain('sf --version');
expect(ctx.stdout).to.contain('vlocity --nojob installVlocityInitial -sfdx.username user@login');
expect(execSpawnSync.calledOnce).to.be.false;
expect(execSpawnSync.firstCall.args[0]).to.equal('sf'); // auth
expect(execSpawnSync.secondCall.args[0]).to.equal('sf'); // deploy
Expand Down

0 comments on commit 44c1bba

Please sign in to comment.