diff --git a/schemas/project-deploy-cancel.json b/schemas/project-deploy-cancel.json index 9e5a0c41..d8159593 100644 --- a/schemas/project-deploy-cancel.json +++ b/schemas/project-deploy-cancel.json @@ -106,6 +106,9 @@ }, "stateDetail": { "type": "string" + }, + "deployUrl": { + "type": "string" } }, "required": [ @@ -574,6 +577,9 @@ "stateDetail": { "type": "string" }, + "deployUrl": { + "type": "string" + }, "id": { "type": "string" }, diff --git a/schemas/project-deploy-quick.json b/schemas/project-deploy-quick.json index 9e5a0c41..2afa13d2 100644 --- a/schemas/project-deploy-quick.json +++ b/schemas/project-deploy-quick.json @@ -106,6 +106,9 @@ }, "stateDetail": { "type": "string" + }, + "deployUrl": { + "type": "string" } }, "required": [ @@ -580,6 +583,9 @@ "success": { "type": "boolean" }, + "deployUrl": { + "type": "string" + }, "done": { "type": "boolean" } diff --git a/schemas/project-deploy-report.json b/schemas/project-deploy-report.json index 9e5a0c41..d8159593 100644 --- a/schemas/project-deploy-report.json +++ b/schemas/project-deploy-report.json @@ -106,6 +106,9 @@ }, "stateDetail": { "type": "string" + }, + "deployUrl": { + "type": "string" } }, "required": [ @@ -574,6 +577,9 @@ "stateDetail": { "type": "string" }, + "deployUrl": { + "type": "string" + }, "id": { "type": "string" }, diff --git a/schemas/project-deploy-resume.json b/schemas/project-deploy-resume.json index 9e5a0c41..d73352a5 100644 --- a/schemas/project-deploy-resume.json +++ b/schemas/project-deploy-resume.json @@ -106,6 +106,9 @@ }, "stateDetail": { "type": "string" + }, + "deployUrl": { + "type": "string" } }, "required": [ @@ -582,6 +585,9 @@ }, "done": { "type": "boolean" + }, + "deployUrl": { + "type": "string" } }, "required": ["files", "status"] diff --git a/schemas/project-deploy-start.json b/schemas/project-deploy-start.json index 9e5a0c41..d8159593 100644 --- a/schemas/project-deploy-start.json +++ b/schemas/project-deploy-start.json @@ -106,6 +106,9 @@ }, "stateDetail": { "type": "string" + }, + "deployUrl": { + "type": "string" } }, "required": [ @@ -574,6 +577,9 @@ "stateDetail": { "type": "string" }, + "deployUrl": { + "type": "string" + }, "id": { "type": "string" }, diff --git a/schemas/project-deploy-validate.json b/schemas/project-deploy-validate.json index 9e5a0c41..f84e81ff 100644 --- a/schemas/project-deploy-validate.json +++ b/schemas/project-deploy-validate.json @@ -71,6 +71,9 @@ "errorStatusCode": { "type": "string" }, + "deployUrl": { + "type": "string" + }, "ignoreWarnings": { "type": "boolean" }, @@ -574,6 +577,9 @@ "stateDetail": { "type": "string" }, + "deployUrl": { + "type": "string" + }, "id": { "type": "string" }, diff --git a/src/commands/project/deploy/quick.ts b/src/commands/project/deploy/quick.ts index acf51145..34cebe43 100644 --- a/src/commands/project/deploy/quick.ts +++ b/src/commands/project/deploy/quick.ts @@ -76,6 +76,8 @@ export default class DeployMetadataQuick extends SfCommand { public static errorCodes = toHelpSection('ERROR CODES', DEPLOY_STATUS_CODES_DESCRIPTIONS); + private deployUrl?: string; + public async run(): Promise { const [{ flags }, cache] = await Promise.all([this.parse(DeployMetadataQuick), DeployCache.create()]); @@ -91,13 +93,13 @@ export default class DeployMetadataQuick extends SfCommand { rest: api === API['REST'], }); this.log(`Deploy ID: ${ansis.bold(deployId)}`); - const deployUrl = buildDeployUrl(deployId); - this.log(`Deploy URL: ${ansis.bold(deployUrl)}`); + this.deployUrl = buildDeployUrl(deployId); + this.log(`Deploy URL: ${ansis.bold(this.deployUrl)}`); if (flags.async) { const asyncFormatter = new AsyncDeployResultFormatter(deployId); if (!this.jsonEnabled()) asyncFormatter.display(); - return asyncFormatter.getJson(); + return this.mixinUrlMeta(await asyncFormatter.getJson()); } const mdapiDeploy = new MetadataApiDeploy({ @@ -125,7 +127,7 @@ export default class DeployMetadataQuick extends SfCommand { this.log(messages.getMessage('error.QuickDeployFailure', [deployId, result.response.status])); } - return formatter.getJson(); + return this.mixinUrlMeta(await formatter.getJson()); } protected catch(error: SfCommand.Error): Promise { @@ -140,6 +142,12 @@ export default class DeployMetadataQuick extends SfCommand { } return super.catch(error); } + private mixinUrlMeta(json: DeployResultJson): DeployResultJson { + if (this.deployUrl) { + json.deployUrl = this.deployUrl; + } + return json; + } } /** Resolve a job ID for a validated deploy using cache, most recent, or a job ID flag. */ diff --git a/src/commands/project/deploy/resume.ts b/src/commands/project/deploy/resume.ts index 47f7969f..6b3895e5 100644 --- a/src/commands/project/deploy/resume.ts +++ b/src/commands/project/deploy/resume.ts @@ -85,6 +85,8 @@ export default class DeployMetadataResume extends SfCommand { public static errorCodes = toHelpSection('ERROR CODES', DEPLOY_STATUS_CODES_DESCRIPTIONS); + private deployUrl?: string; + public async run(): Promise { const [{ flags }, cache] = await Promise.all([this.parse(DeployMetadataResume), DeployCache.create()]); const jobId = cache.resolveLatest(flags['use-most-recent'], flags['job-id'], true); @@ -131,8 +133,8 @@ export default class DeployMetadataResume extends SfCommand { ); this.log(`Deploy ID: ${ansis.bold(jobId)}`); - const deployUrl = buildDeployUrl(jobId); - this.log(`Deploy URL: ${ansis.bold(deployUrl)}`); + 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); @@ -154,6 +156,12 @@ export default class DeployMetadataResume extends SfCommand { if (!this.jsonEnabled()) formatter.display(); - return formatter.getJson(); + return this.mixinUrlMeta(await formatter.getJson()); + } + private mixinUrlMeta(json: DeployResultJson): DeployResultJson { + if (this.deployUrl) { + json.deployUrl = this.deployUrl; + } + return json; } } diff --git a/src/commands/project/deploy/start.ts b/src/commands/project/deploy/start.ts index 7e89901f..f5a122b8 100644 --- a/src/commands/project/deploy/start.ts +++ b/src/commands/project/deploy/start.ts @@ -179,6 +179,7 @@ export default class DeployMetadata extends SfCommand { private zipSize?: number; private zipFileCount?: number; + private deployUrl?: string; public async run(): Promise { const { flags } = await this.parse(DeployMetadata); @@ -246,8 +247,8 @@ export default class DeployMetadata extends SfCommand { throw new SfError('The deploy id is not available.'); } this.log(`Deploy ID: ${ansis.bold(deploy.id)}`); - const deployUrl = buildDeployUrl(deploy.id); - this.log(`Deploy URL: ${ansis.bold(deployUrl)}`); + this.deployUrl = buildDeployUrl(deploy.id); + this.log(`Deploy URL: ${ansis.bold(this.deployUrl)}`); if (flags.async) { if (flags['coverage-formatters']) { @@ -306,6 +307,9 @@ export default class DeployMetadata extends SfCommand { if (this.zipFileCount) { json.zipFileCount = this.zipFileCount; } + if (this.deployUrl) { + json.deployUrl = this.deployUrl; + } return json; } } diff --git a/src/commands/project/deploy/validate.ts b/src/commands/project/deploy/validate.ts index afaba7e4..942ace97 100644 --- a/src/commands/project/deploy/validate.ts +++ b/src/commands/project/deploy/validate.ts @@ -155,6 +155,8 @@ export default class DeployMetadataValidate extends SfCommand public static errorCodes = toHelpSection('ERROR CODES', DEPLOY_STATUS_CODES_DESCRIPTIONS); + private deployUrl?: string; + public async run(): Promise { const [{ flags }, api] = await Promise.all([this.parse(DeployMetadataValidate), resolveApi(this.configAggregator)]); @@ -196,13 +198,13 @@ export default class DeployMetadataValidate extends SfCommand throw new SfError('The deploy id is not available.'); } this.log(`Deploy ID: ${ansis.bold(deploy.id)}`); - const deployUrl = buildDeployUrl(deploy.id); - this.log(`Deploy URL: ${ansis.bold(deployUrl)}`); + this.deployUrl = buildDeployUrl(deploy.id); + this.log(`Deploy URL: ${ansis.bold(this.deployUrl)}`); if (flags.async) { const asyncFormatter = new AsyncDeployResultFormatter(deploy.id); if (!this.jsonEnabled()) asyncFormatter.display(); - return asyncFormatter.getJson(); + return this.mixinUrlMeta(await asyncFormatter.getJson()); } new DeployProgress(deploy, this.jsonEnabled()).start(); @@ -252,6 +254,12 @@ export default class DeployMetadataValidate extends SfCommand .setData({ deployId: deploy.id }); } - return formatter.getJson(); + return this.mixinUrlMeta(await formatter.getJson()); + } + private mixinUrlMeta(json: DeployResultJson): DeployResultJson { + if (this.deployUrl) { + json.deployUrl = this.deployUrl; + } + return json; } } diff --git a/src/utils/types.ts b/src/utils/types.ts index 103138e2..e8a7a8c9 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -45,6 +45,7 @@ export type AsyncDeployResultJson = Omit, 'stat files: FileResponse[]; zipSize?: number; zipFileCount?: number; + deployUrl?: string; }; type ConvertEntry = { @@ -79,6 +80,7 @@ export type DeployResultJson = replacements?: Record; zipSize?: number; zipFileCount?: number; + deployUrl?: string; }) | AsyncDeployResultJson;