diff --git a/messages/deploy.metadata.md b/messages/deploy.metadata.md index 435514a9..50243502 100644 --- a/messages/deploy.metadata.md +++ b/messages/deploy.metadata.md @@ -78,7 +78,7 @@ Overrides your default org. # flags.metadata.summary -Metadata component names to deploy. Wildcards ( * ) supported as long as you use quotes, such as 'ApexClass:MyClass*' +Metadata component names to deploy. Wildcards ( `*` ) supported as long as you use quotes, such as `ApexClass:MyClass*` # flags.test-level.summary @@ -246,4 +246,4 @@ The `pushPackageDirectoriesSequentially` property is not respected by this comma # apiVersionMsgDetailed -%s v%s metadata to %s using the v%s %s API. +%s %s metadata to %s using the v%s %s API. diff --git a/src/commands/project/deploy/start.ts b/src/commands/project/deploy/start.ts index 54ae444c..dc215a0b 100644 --- a/src/commands/project/deploy/start.ts +++ b/src/commands/project/deploy/start.ts @@ -207,7 +207,7 @@ export default class DeployMetadata extends SfCommand { this.log( messages.getMessage('apiVersionMsgDetailed', [ action, - apiData.manifestVersion, + flags['metadata-dir'] ? '' : `v${apiData.manifestVersion}`, username, apiData.apiVersion, apiData.webService, diff --git a/src/commands/project/deploy/validate.ts b/src/commands/project/deploy/validate.ts index a88a4e92..5a5b81df 100644 --- a/src/commands/project/deploy/validate.ts +++ b/src/commands/project/deploy/validate.ts @@ -168,7 +168,7 @@ export default class DeployMetadataValidate extends SfCommand this.log( deployMessages.getMessage('apiVersionMsgDetailed', [ 'Validating Deployment of', - apiData.manifestVersion, + flags['metadata-dir'] ? '' : `v${apiData.manifestVersion}`, username, apiData.apiVersion, apiData.webService, diff --git a/src/commands/project/retrieve/start.ts b/src/commands/project/retrieve/start.ts index 42d01edc..d460f24f 100644 --- a/src/commands/project/retrieve/start.ts +++ b/src/commands/project/retrieve/start.ts @@ -192,7 +192,7 @@ export default class RetrieveMetadata extends SfCommand { this.log( messages.getMessage('apiVersionMsgDetailed', [ 'Retrieving', - apiData.manifestVersion, + `v${apiData.manifestVersion}`, flags['target-org'].getUsername(), apiData.apiVersion, ]) diff --git a/src/utils/deploy.ts b/src/utils/deploy.ts index 84b23a0f..697ffb87 100644 --- a/src/utils/deploy.ts +++ b/src/utils/deploy.ts @@ -13,6 +13,7 @@ import { ComponentSetBuilder, DeployResult, MetadataApiDeploy, + MetadataApiDeployOptions, RequestStatus, } from '@salesforce/source-deploy-retrieve'; import { SourceTracking } from '@salesforce/source-tracking'; @@ -119,21 +120,14 @@ export async function executeDeploy( id?: string, throwOnEmpty = false ): Promise<{ deploy?: MetadataApiDeploy; componentSet?: ComponentSet }> { - const apiOptions = { - checkOnly: opts['dry-run'] ?? false, - ignoreWarnings: opts['ignore-warnings'] ?? false, - rest: opts.api === 'REST', - rollbackOnError: !opts['ignore-errors'] || false, - ...(opts.tests ? { runTests: opts.tests } : {}), - ...(opts['test-level'] ? { testLevel: opts['test-level'] } : {}), - purgeOnDelete: opts['purge-on-delete'] ?? false, - }; + const apiOptions = buildApiOptions(opts); let deploy: MetadataApiDeploy | undefined; let componentSet: ComponentSet | undefined; const org = await Org.create({ aliasOrUsername: opts['target-org'] }); - const usernameOrConnection = org.getConnection(); + // for mdapi deploys, use the passed in api-version. + const usernameOrConnection = org.getConnection(opts['metadata-dir'] ? opts['api-version'] : undefined); if (opts['metadata-dir']) { if (id) { @@ -233,3 +227,14 @@ export const isNotResumable = (status?: RequestStatus): boolean => [RequestStatus.Succeeded, RequestStatus.Failed, RequestStatus.SucceededPartial, RequestStatus.Canceled].includes( status ); + +/** apply some defaults to the DeployOptions object */ +const buildApiOptions = (opts: Partial): MetadataApiDeployOptions['apiOptions'] => ({ + checkOnly: opts['dry-run'] ?? false, + ignoreWarnings: opts['ignore-warnings'] ?? false, + rest: opts.api === 'REST', + rollbackOnError: !opts['ignore-errors'] || false, + ...(opts.tests ? { runTests: opts.tests } : {}), + ...(opts['test-level'] ? { testLevel: opts['test-level'] } : {}), + purgeOnDelete: opts['purge-on-delete'] ?? false, +});