Skip to content

Commit

Permalink
feat: incorporate deploy url
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Oct 15, 2024
1 parent 33b4f9f commit 0c13053
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 31 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"@salesforce/source-deploy-retrieve": "^12.7.4",
"@salesforce/source-tracking": "^7.1.16",
"@salesforce/ts-types": "^2.0.12",
"ansis": "^3.3.2"
"ansis": "^3.3.2",
"terminal-link": "^3.0.0"
},
"devDependencies": {
"@oclif/plugin-command-snapshot": "^5.2.17",
Expand Down
19 changes: 10 additions & 9 deletions src/commands/project/deploy/resume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,16 @@ export default class DeployMetadataResume extends SfCommand<DeployResultJson> {
new DeployStages({
title: 'Resuming Deploy',
jsonEnabled: this.jsonEnabled(),
}).start({
deploy,
username: deployOpts['target-org'],
...(flags.verbose
? {
deployUrl: this.deployUrl,
}
: {}),
});
}).start(
{
deploy,
username: deployOpts['target-org'],
},
{
deployUrl: this.deployUrl,
verbose: flags.verbose ?? deployOpts.verbose,
}
);

result = await deploy.pollStatus(500, wait.seconds);

Expand Down
11 changes: 4 additions & 7 deletions src/commands/project/deploy/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,10 @@ export default class DeployMetadata extends SfCommand<DeployResultJson> {
{ username, deploy },
{
message,
...(flags.verbose
? {
deploySize: this.zipSize,
deployFileCount: this.zipFileCount,
deployUrl: this.deployUrl,
}
: {}),
deployUrl: this.deployUrl,
verbose: flags.verbose,
deploySize: this.zipSize,
deployFileCount: this.zipFileCount,
}
);

Expand Down
21 changes: 11 additions & 10 deletions src/commands/project/deploy/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export default class DeployMetadataValidate extends SfCommand<DeployResultJson>
if (!deploy.id) {
throw new SfError('The deploy id is not available.');
}
this.log(`Deploy ID: ${ansis.bold(deploy.id)}`);

this.deployUrl = buildDeployUrl(flags['target-org'], deploy.id);

if (flags.async) {
Expand All @@ -211,15 +211,16 @@ export default class DeployMetadataValidate extends SfCommand<DeployResultJson>
new DeployStages({
title: 'Validating Deployment',
jsonEnabled: this.jsonEnabled(),
}).start({
deploy,
username,
...(flags.verbose
? {
deployUrl: this.deployUrl,
}
: {}),
});
}).start(
{
deploy,
username,
},
{
deployUrl: this.deployUrl,
verbose: flags.verbose,
}
);

const result = await deploy.pollStatus(500, flags.wait?.seconds);
process.exitCode = determineExitCode(result);
Expand Down
22 changes: 18 additions & 4 deletions src/utils/deployStages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { MultiStageOutput } from '@oclif/multi-stage-output';
import { Lifecycle, Messages } from '@salesforce/core';
import { MetadataApiDeploy, MetadataApiDeployStatus, RequestStatus } from '@salesforce/source-deploy-retrieve';
import { SourceMemberPollingEvent } from '@salesforce/source-tracking';
import terminalLink from 'terminal-link';
import { getZipFileSize } from './output.js';

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
Expand All @@ -28,6 +29,7 @@ type Data = {
deploySize: number;
deployFileCount: number;
deployUrl: string;
verbose: boolean;
};

function round(value: number, precision: number): number {
Expand Down Expand Up @@ -67,7 +69,16 @@ export class DeployStages {
postStagesBlock: [
{
label: 'Status',
get: (data): string | undefined => data?.status,
get: (data): string | undefined => {
if (!terminalLink.isSupported) return data?.status;
if (!data?.deployUrl) return data?.status;

return data?.status
? terminalLink(data.status, data.deployUrl, {
fallback: (text, url) => `${text} (${url})`,
})
: undefined;
},
bold: true,
type: 'dynamic-key-value',
},
Expand All @@ -84,19 +95,22 @@ export class DeployStages {
},
{
label: 'Deploy URL',
get: (data): string | undefined => data?.deployUrl,
get: (data): string | undefined => {
if (!data?.verbose) return;
return data?.deployUrl;
},
type: 'static-key-value',
},
{
label: 'Size',
get: (data): string | undefined =>
data?.deploySize ? `${getZipFileSize(data.deploySize)} of ~39 MB limit` : undefined,
data?.deploySize && data?.verbose ? `${getZipFileSize(data.deploySize)} of ~39 MB limit` : undefined,
type: 'static-key-value',
},
{
label: 'Files',
get: (data): string | undefined =>
data?.deployFileCount ? `${data.deployFileCount} of 10,000 limit` : undefined,
data?.deployFileCount && data?.verbose ? `${data.deployFileCount} of 10,000 limit` : undefined,
type: 'static-key-value',
},
],
Expand Down

0 comments on commit 0c13053

Please sign in to comment.