Skip to content

Commit

Permalink
refactor: use org get field, revert resume command for now
Browse files Browse the repository at this point in the history
  • Loading branch information
mcarvin8 committed Oct 14, 2024
1 parent b512688 commit 33db8f4
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/commands/project/deploy/quick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default class DeployMetadataQuick extends SfCommand<DeployResultJson> {
rest: api === API['REST'],
});
this.log(`Deploy ID: ${ansis.bold(deployId)}`);
this.deployUrl = buildDeployUrl(deployId);
this.deployUrl = buildDeployUrl(flags['target-org'], deployId);
this.log(`Deploy URL: ${ansis.bold(this.deployUrl)}`);

if (flags.async) {
Expand Down
20 changes: 2 additions & 18 deletions src/commands/project/deploy/resume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@ import { Duration } from '@salesforce/kit';
import { DeployResultFormatter } from '../../../formatters/deployResultFormatter.js';
import { DeployProgress } from '../../../utils/progressBar.js';
import { API, DeployResultJson } from '../../../utils/types.js';
import {
buildComponentSet,
determineExitCode,
executeDeploy,
isNotResumable,
buildDeployUrl,
} from '../../../utils/deploy.js';
import { buildComponentSet, determineExitCode, executeDeploy, isNotResumable } from '../../../utils/deploy.js';
import { DeployCache } from '../../../utils/deployCache.js';
import { DEPLOY_STATUS_CODES_DESCRIPTIONS } from '../../../utils/errorCodes.js';
import { coverageFormattersFlag } from '../../../utils/flags.js';
Expand Down Expand Up @@ -85,8 +79,6 @@ export default class DeployMetadataResume extends SfCommand<DeployResultJson> {

public static errorCodes = toHelpSection('ERROR CODES', DEPLOY_STATUS_CODES_DESCRIPTIONS);

private deployUrl?: string;

public async run(): Promise<DeployResultJson> {
const [{ flags }, cache] = await Promise.all([this.parse(DeployMetadataResume), DeployCache.create()]);
const jobId = cache.resolveLatest(flags['use-most-recent'], flags['job-id'], true);
Expand Down Expand Up @@ -133,8 +125,6 @@ export default class DeployMetadataResume extends SfCommand<DeployResultJson> {
);

this.log(`Deploy ID: ${ansis.bold(jobId)}`);
this.deployUrl = buildDeployUrl(jobId);
this.log(`Deploy URL: ${ansis.bold(this.deployUrl)}`);
new DeployProgress(deploy, this.jsonEnabled()).start();
result = await deploy.pollStatus(500, wait.seconds);

Expand All @@ -156,12 +146,6 @@ export default class DeployMetadataResume extends SfCommand<DeployResultJson> {

if (!this.jsonEnabled()) formatter.display();

return this.mixinUrlMeta(await formatter.getJson());
}
private mixinUrlMeta(json: DeployResultJson): DeployResultJson {
if (this.deployUrl) {
json.deployUrl = this.deployUrl;
}
return json;
return formatter.getJson();
}
}
2 changes: 1 addition & 1 deletion src/commands/project/deploy/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export default class DeployMetadata extends SfCommand<DeployResultJson> {
throw new SfError('The deploy id is not available.');
}
this.log(`Deploy ID: ${ansis.bold(deploy.id)}`);
this.deployUrl = buildDeployUrl(deploy.id);
this.deployUrl = buildDeployUrl(flags['target-org'], deploy.id);
this.log(`Deploy URL: ${ansis.bold(this.deployUrl)}`);

if (flags.async) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/project/deploy/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export default class DeployMetadataValidate extends SfCommand<DeployResultJson>
throw new SfError('The deploy id is not available.');
}
this.log(`Deploy ID: ${ansis.bold(deploy.id)}`);
this.deployUrl = buildDeployUrl(deploy.id);
this.deployUrl = buildDeployUrl(flags['target-org'], deploy.id);
this.log(`Deploy URL: ${ansis.bold(this.deployUrl)}`);

if (flags.async) {
Expand Down
6 changes: 3 additions & 3 deletions src/utils/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { ConfigAggregator, Messages, Org, OrgConfigProperties, SfError, SfProject } from '@salesforce/core';
import { ConfigAggregator, Messages, Org, SfError, SfProject } from '@salesforce/core';
import { Duration } from '@salesforce/kit';
import { Nullable } from '@salesforce/ts-types';
import {
Expand Down Expand Up @@ -242,7 +242,7 @@ const buildApiOptions = (opts: Partial<DeployOptions>): MetadataApiDeployOptions
purgeOnDelete: opts['purge-on-delete'] ?? false,
});

export function buildDeployUrl(deployId: string): string {
const orgInstanceUrl = OrgConfigProperties.ORG_INSTANCE_URL;
export function buildDeployUrl(org: Org, deployId: string): string {
const orgInstanceUrl = String(org.getField(Org.Fields.INSTANCE_URL));
return `${orgInstanceUrl}/lightning/setup/DeployStatus/page?address=%2Fchangemgmt%2FmonitorDeploymentsDetails.apexp%3FasyncId%3D${deployId}%26retURL%3D%252Fchangemgmt%252FmonitorDeployment.apexp`;
}

0 comments on commit 33db8f4

Please sign in to comment.