Skip to content

Commit

Permalink
fix: remove arrayWithDeprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Jul 30, 2024
1 parent 6b45b22 commit 886657e
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 49 deletions.
20 changes: 9 additions & 11 deletions src/commands/force/mdapi/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@
import { Duration, env } from '@salesforce/kit';
import { Lifecycle, Messages, Org } from '@salesforce/core';
import { AsyncResult, DeployVersionData, MetadataApiDeploy } from '@salesforce/source-deploy-retrieve';
import {
arrayWithDeprecation,
Flags,
loglevel,
orgApiVersionFlagWithDeprecations,
Ux,
} from '@salesforce/sf-plugins-core';
import { Flags, loglevel, orgApiVersionFlagWithDeprecations, Ux } from '@salesforce/sf-plugins-core';
import { Interfaces } from '@oclif/core';
import {
DeployCommand,
Expand Down Expand Up @@ -76,8 +70,10 @@ export class Deploy extends DeployCommand {
summary: messages.getMessage('flags.testLevel.summary'),
options: ['NoTestRun', 'RunSpecifiedTests', 'RunLocalTests', 'RunAllTestsInOrg'],
}),
runtests: arrayWithDeprecation({
runtests: Flags.string({
char: 'r',
multiple: true,
delimiter: ',',
summary: messages.getMessage('flags.runTests.summary'),
}),
ignoreerrors: Flags.boolean({
Expand Down Expand Up @@ -128,7 +124,9 @@ export class Deploy extends DeployCommand {
resultsdir: Flags.directory({
summary: messages.getMessage('flags.resultsDir.summary'),
}),
coverageformatters: arrayWithDeprecation({
coverageformatters: Flags.string({
multiple: true,
delimiter: ',',
summary: messages.getMessage('flags.coverageFormatters.summary'),
options: reportsFormatters,
helpValue: reportsFormatters.join(','),
Expand Down Expand Up @@ -216,7 +214,7 @@ export class Deploy extends DeployCommand {

protected formatResult(): MdDeployResult | DeployCommandAsyncResult {
this.resultsDir = this.resolveOutputDir(
this.flags.coverageformatters,
this.flags.coverageformatters ?? [],
this.flags.junit,
this.flags.resultsdir,
this.deployResult?.response?.id,
Expand All @@ -242,7 +240,7 @@ export class Deploy extends DeployCommand {

if (!this.isAsync) {
this.maybeCreateRequestedReports({
coverageformatters: this.flags.coverageformatters,
coverageformatters: this.flags.coverageformatters ?? [],
junit: this.flags.junit,
org: this.org,
});
Expand Down
9 changes: 5 additions & 4 deletions src/commands/force/mdapi/deploy/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { Messages, Org } from '@salesforce/core';
import { Duration, env } from '@salesforce/kit';
import { RequestStatus } from '@salesforce/source-deploy-retrieve';
import {
arrayWithDeprecation,
Flags,
loglevel,
orgApiVersionFlagWithDeprecations,
Expand Down Expand Up @@ -65,7 +64,9 @@ export class Report extends DeployCommand {
resultsdir: Flags.directory({
summary: messages.getMessage('flags.resultsDir.summary'),
}),
coverageformatters: arrayWithDeprecation({
coverageformatters: Flags.string({
multiple: true,
delimiter: ',',
summary: messages.getMessage('flags.coverageFormatters.summary'),
options: reportsFormatters,
helpValue: reportsFormatters.join(','),
Expand Down Expand Up @@ -97,7 +98,7 @@ export class Report extends DeployCommand {
const deployId = this.resolveDeployId(this.flags.jobid);

this.resultsDir = this.resolveOutputDir(
this.flags.coverageformatters,
this.flags.coverageformatters ?? [],
this.flags.junit,
this.flags.resultsdir,
deployId,
Expand Down Expand Up @@ -160,7 +161,7 @@ export class Report extends DeployCommand {
);

this.maybeCreateRequestedReports({
coverageformatters: this.flags.coverageformatters,
coverageformatters: this.flags.coverageformatters ?? [],
junit: this.flags.junit,
org: this.org,
});
Expand Down
16 changes: 6 additions & 10 deletions src/commands/force/mdapi/retrieve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@ import {
RetrieveVersionData,
} from '@salesforce/source-deploy-retrieve';
import { Optional, ensure } from '@salesforce/ts-types';
import {
arrayWithDeprecation,
Flags,
loglevel,
requiredOrgFlagWithDeprecations,
Ux,
} from '@salesforce/sf-plugins-core';
import { Flags, loglevel, requiredOrgFlagWithDeprecations, Ux } from '@salesforce/sf-plugins-core';
import { Interfaces } from '@oclif/core';
import { resolveZipFileName, SourceCommand } from '../../../sourceCommand.js';
import { Stash } from '../../../stash.js';
Expand Down Expand Up @@ -66,7 +60,9 @@ export class Retrieve extends SourceCommand {
summary: messages.getMessage('flags.sourcedir.summary'),
exclusive: ['unpackaged', 'packagenames'],
}),
packagenames: arrayWithDeprecation({
packagenames: Flags.string({
multiple: true,
delimiter: ',',
char: 'p',
summary: messages.getMessage('flags.packagenames.summary'),
exclusive: ['sourcedir', 'unpackaged'],
Expand Down Expand Up @@ -123,7 +119,7 @@ export class Retrieve extends SourceCommand {

protected async retrieve(): Promise<void> {
const packagenames = this.flags.packagenames;
if (!packagenames && !this.flags.unpackaged) {
if (packagenames === this.unzip && !this.flags.unpackaged) {
this.sourceDir = this.resolveRootDir(this.flags.sourcedir);
}
this.retrieveTargetDir = this.resolveOutputDir(this.flags.retrievetargetdir);
Expand All @@ -135,7 +131,7 @@ export class Retrieve extends SourceCommand {
this.wait = waitFlag.minutes === -1 ? Duration.days(7) : waitFlag;
this.isAsync = this.wait.quantity === 0;

if (singlePackage && packagenames?.length > 1) {
if (singlePackage && packagenames?.length) {
throw new SfError(messages.getMessage('InvalidPackageNames', [packagenames.toString()]), 'InvalidPackageNames');
}

Expand Down
30 changes: 16 additions & 14 deletions src/commands/force/source/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ import { Lifecycle, Messages, Org } from '@salesforce/core';
import { Duration, env } from '@salesforce/kit';
import { SourceTracking } from '@salesforce/source-tracking';
import { AsyncResult, ComponentSetBuilder, DeployVersionData } from '@salesforce/source-deploy-retrieve';
import {
arrayWithDeprecation,
Flags,
loglevel,
orgApiVersionFlagWithDeprecations,
Ux,
} from '@salesforce/sf-plugins-core';
import { Flags, loglevel, orgApiVersionFlagWithDeprecations, Ux } from '@salesforce/sf-plugins-core';
import { Interfaces } from '@oclif/core';
import {
DeployCommand,
Expand Down Expand Up @@ -83,13 +77,15 @@ export class Deploy extends DeployCommand {
summary: messages.getMessage('flags.testLevel.summary'),
options: ['NoTestRun', 'RunSpecifiedTests', 'RunLocalTests', 'RunAllTestsInOrg'],
}),
runtests: arrayWithDeprecation({
runtests: Flags.string({
multiple: true,
delimiter: ',',
char: 'r',
summary: messages.getMessage('flags.runTests.summary'),
}),
ignoreerrors: Flags.boolean({
char: 'o',
// brfeak this
// break this
description: messages.getMessage('flags.ignoreErrors.description'),
summary: messages.getMessage('flags.ignoreErrors.summary'),
}),
Expand All @@ -113,14 +109,18 @@ export class Deploy extends DeployCommand {
verbose: Flags.boolean({
summary: messages.getMessage('flags.verbose.summary'),
}),
metadata: arrayWithDeprecation({
metadata: Flags.string({
multiple: true,
delimiter: ',',
char: 'm',
description: messages.getMessage('flags.metadata.description'),
summary: messages.getMessage('flags.metadata.summary'),
exactlyOne: xorFlags,
}),
sourcepath: arrayWithDeprecation({
sourcepath: Flags.string({
char: 'p',
multiple: true,
delimiter: ',',
description: messages.getMessage('flags.sourcePath.description'),
summary: messages.getMessage('flags.sourcePath.summary'),
exactlyOne: xorFlags,
Expand Down Expand Up @@ -153,7 +153,9 @@ export class Deploy extends DeployCommand {
resultsdir: Flags.directory({
summary: messages.getMessage('flags.resultsDir.summary'),
}),
coverageformatters: arrayWithDeprecation({
coverageformatters: Flags.string({
multiple: true,
delimiter: ',',
summary: messages.getMessage('flags.coverageFormatters.summary'),
options: reportsFormatters,
helpValue: reportsFormatters.join(','),
Expand Down Expand Up @@ -301,7 +303,7 @@ export class Deploy extends DeployCommand {

protected formatResult(): DeployCommandResult | DeployCommandAsyncResult {
this.resultsDir = this.resolveOutputDir(
this.flags.coverageformatters,
this.flags.coverageformatters ?? [],
this.flags.junit,
this.flags.resultsdir,
this.deployResult?.response?.id,
Expand All @@ -327,7 +329,7 @@ export class Deploy extends DeployCommand {

if (!this.isAsync) {
this.maybeCreateRequestedReports({
coverageformatters: this.flags.coverageformatters,
coverageformatters: this.flags.coverageformatters ?? [],
junit: this.flags.junit,
org: this.org,
});
Expand Down
9 changes: 5 additions & 4 deletions src/commands/force/source/deploy/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { Messages, SfProject } from '@salesforce/core';
import { Duration, env } from '@salesforce/kit';
import { ComponentSetBuilder } from '@salesforce/source-deploy-retrieve';
import {
arrayWithDeprecation,
Flags,
loglevel,
orgApiVersionFlagWithDeprecations,
Expand Down Expand Up @@ -65,7 +64,9 @@ export class Report extends DeployCommand {
resultsdir: Flags.directory({
summary: messages.getMessage('flags.resultsDir.summary'),
}),
coverageformatters: arrayWithDeprecation({
coverageformatters: Flags.string({
multiple: true,
delimiter: ',',
summary: messages.getMessage('flags.coverageFormatters.summary'),
options: reportsFormatters,
helpValue: reportsFormatters.join(','),
Expand All @@ -87,7 +88,7 @@ export class Report extends DeployCommand {
const deployId = this.resolveDeployId(this.flags.jobid);

this.resultsDir = this.resolveOutputDir(
this.flags.coverageformatters,
this.flags.coverageformatters ?? [],
this.flags.junit,
this.flags.resultsdir,
deployId,
Expand Down Expand Up @@ -151,7 +152,7 @@ export class Report extends DeployCommand {
);

this.maybeCreateRequestedReports({
coverageformatters: this.flags.coverageformatters,
coverageformatters: this.flags.coverageformatters ?? [],
junit: this.flags.junit,
org: this.flags['target-org'],
});
Expand Down
13 changes: 9 additions & 4 deletions src/commands/force/source/retrieve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
import { SourceTracking } from '@salesforce/source-tracking';
import { Interfaces } from '@oclif/core';
import {
arrayWithDeprecation,
Flags,
loglevel,
orgApiVersionFlagWithDeprecations,
Expand Down Expand Up @@ -65,7 +64,9 @@ export class Retrieve extends SourceCommand {
summary: messages.getMessage('flags.retrievetargetdir.summary'),
exclusive: ['packagenames', 'sourcepath'],
}),
sourcepath: arrayWithDeprecation({
sourcepath: Flags.string({
multiple: true,
delimiter: ',',
char: 'p',
description: messages.getMessage('flags.sourcePath.description'),
summary: messages.getMessage('flags.sourcePath.summary'),
Expand All @@ -85,13 +86,17 @@ export class Retrieve extends SourceCommand {
summary: messages.getMessage('flags.manifest.summary'),
exclusive: ['metadata', 'sourcepath'],
}),
metadata: arrayWithDeprecation({
metadata: Flags.string({
multiple: true,
delimiter: ',',
char: 'm',
description: messages.getMessage('flags.metadata.description'),
summary: messages.getMessage('flags.metadata.summary'),
exclusive: ['manifest', 'sourcepath'],
}),
packagenames: arrayWithDeprecation({
packagenames: Flags.string({
multiple: true,
delimiter: ',',
char: 'n',
summary: messages.getMessage('flags.packagename.summary'),
}),
Expand Down
2 changes: 1 addition & 1 deletion src/deployCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export abstract class DeployCommand extends SourceCommand {
if (resultsDir) {
return resultsDir;
}
if (coverageFormatters || junit) {
if (coverageFormatters.length || junit) {
if (deployId) {
return deployId;
}
Expand Down
1 change: 0 additions & 1 deletion test/commands/mdapi/retrieve.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ describe('force:mdapi:retrieve', () => {
sandbox.restore();
});

// Ensure SourceCommand.createComponentSet() args
const ensureCreateComponentSetArgs = (overrides?: Partial<ComponentSetOptions>) => {
const defaultArgs = {
packagenames: undefined,
Expand Down

0 comments on commit 886657e

Please sign in to comment.