Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: api version for mdapi deploys #769

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions messages/deploy.metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
2 changes: 1 addition & 1 deletion src/commands/project/deploy/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export default class DeployMetadata extends SfCommand<DeployResultJson> {
this.log(
messages.getMessage('apiVersionMsgDetailed', [
action,
apiData.manifestVersion,
flags['metadata-dir'] ? '<version specified in manifest>' : `v${apiData.manifestVersion}`,
username,
apiData.apiVersion,
apiData.webService,
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 @@ -168,7 +168,7 @@ export default class DeployMetadataValidate extends SfCommand<DeployResultJson>
this.log(
deployMessages.getMessage('apiVersionMsgDetailed', [
'Validating Deployment of',
apiData.manifestVersion,
flags['metadata-dir'] ? '<version specified in manifest>' : `v${apiData.manifestVersion}`,
username,
apiData.apiVersion,
apiData.webService,
Expand Down
2 changes: 1 addition & 1 deletion src/commands/project/retrieve/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export default class RetrieveMetadata extends SfCommand<RetrieveResultJson> {
this.log(
messages.getMessage('apiVersionMsgDetailed', [
'Retrieving',
apiData.manifestVersion,
`v${apiData.manifestVersion}`,
flags['target-org'].getUsername(),
apiData.apiVersion,
])
Expand Down
25 changes: 15 additions & 10 deletions src/utils/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
ComponentSetBuilder,
DeployResult,
MetadataApiDeploy,
MetadataApiDeployOptions,
RequestStatus,
} from '@salesforce/source-deploy-retrieve';
import { SourceTracking } from '@salesforce/source-tracking';
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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<DeployOptions>): 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,
});
Loading