Skip to content

Commit

Permalink
fix: nullish in template-literal
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Jul 30, 2024
1 parent ec30915 commit 345cf9f
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 23 deletions.
17 changes: 9 additions & 8 deletions src/commands/force/mdapi/retrieve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
RetrieveResult,
RetrieveVersionData,
} from '@salesforce/source-deploy-retrieve';
import { Optional, ensure } from '@salesforce/ts-types';
import { Optional, ensure, ensureString } from '@salesforce/ts-types';
import { Flags, loglevel, requiredOrgFlagWithDeprecations, Ux } from '@salesforce/sf-plugins-core';
import { Interfaces } from '@oclif/core';
import { resolveZipFileName, SourceCommand } from '../../../sourceCommand.js';
Expand Down Expand Up @@ -100,7 +100,7 @@ export class Retrieve extends SourceCommand {

protected retrieveResult: RetrieveResult | undefined;
private sourceDir: string | undefined;
private retrieveTargetDir: string | undefined;
private retrieveTargetDir!: string;
private zipFileName: string | undefined;
private unzip: boolean | undefined;
// will be set to `flags.wait` (which has a default value) when executed.
Expand All @@ -111,6 +111,7 @@ export class Retrieve extends SourceCommand {
private org!: Org | undefined;
public async run(): Promise<RetrieveCommandCombinedResult> {
this.flags = (await this.parse(Retrieve)).flags;
this.retrieveTargetDir = this.resolveOutputDir(this.flags.retrievetargetdir);
this.org = this.flags['target-org'];
await this.retrieve();
this.resolveSuccess();
Expand Down Expand Up @@ -185,7 +186,7 @@ export class Retrieve extends SourceCommand {
unzip: this.unzip,
});

this.log(`Retrieve ID: ${this.mdapiRetrieve.id}`);
this.log(`Retrieve ID: ${this.mdapiRetrieve.id ?? ''}`);

if (this.isAsync) {
this.spinner.stop('queued');
Expand Down Expand Up @@ -216,11 +217,11 @@ export class Retrieve extends SourceCommand {
protected formatResult(): RetrieveCommandResult | RetrieveCommandAsyncResult {
// async result
if (this.isAsync) {
let cmdFlags = `--jobid ${this.mdapiRetrieve?.id} --retrievetargetdir ${this.retrieveTargetDir}`;
const targetusernameFlag = this.flags['target-org'];
if (targetusernameFlag) {
cmdFlags += ` --targetusername ${targetusernameFlag.getUsername()}`;
}
const targetUsername = this.flags['target-org'].getUsername();

const cmdFlags = `--jobid ${ensureString(this.mdapiRetrieve?.id)} --retrievetargetdir ${this.retrieveTargetDir}${
targetUsername ? ` --targetusername ${targetUsername}` : ''
}`;
this.log('');
this.log(messages.getMessage('checkStatus', [cmdFlags]));
return {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/force/source/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const resultConverter = (input: StatusOutputRow): StatusResult => {
type,
// this string became the place to store information.
// The JSON now breaks out that info but preserves this property for backward compatibility
state: `${origin} ${actualState}${conflict ? ' (Conflict)' : ''}` as StatusStateString,
state: `${origin} ${actualState as string}${conflict ? ' (Conflict)' : ''}` as StatusStateString,
ignored,
filePath,
origin,
Expand Down
2 changes: 1 addition & 1 deletion src/deployCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const reportsFormatters = Object.keys(DefaultReportOptions);
export abstract class DeployCommand extends SourceCommand {
protected displayDeployId = once((id?: string) => {
if (!this.jsonEnabled()) {
this.log(`Deploy ID: ${id}`);
this.log(`Deploy ID: ${id ?? '<not present>'}`);
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/formatters/deployCancelResultFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class DeployCancelResultFormatter extends ResultFormatter {
}

public display(): void {
const deployId = getString(this.result, 'response.id');
const deployId = this.result.response.id;
if (this.isSuccess()) {
this.ux.log(`Successfully canceled ${deployId}`);
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/formatters/deployProgressStatusFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ export class DeployProgressStatusFormatter extends ProgressFormatter {
const testsTotal = getNumber(data, 'numberTestsTotal');
const testsCompleted = getNumber(data, 'numberTestsCompleted');
const testErrors = getNumber(data, 'numberTestErrors');
const deploys = `${componentsDeployed}/${componentsTotal} components deployed.`;
const deployErrors = componentErrors === 1 ? `${componentErrors} error.` : `${componentErrors} errors.`;
const tests = `${testsCompleted}/${testsTotal} tests completed.`;
const testErrs = testErrors === 1 ? `${testErrors} error.` : `${testErrors} errors.`;
const deploys = `${componentsDeployed ?? 0}/${componentsTotal ?? 0} components deployed.`;
const deployErrors = componentErrors === 1 ? `${componentErrors} error.` : `${componentErrors ?? 0} errors.`;
const tests = `${testsCompleted ?? 0}/${testsTotal ?? 0} tests completed.`;
const testErrs = testErrors === 1 ? `${testErrors} error.` : `${testErrors ?? 0} errors.`;
this.ux.log(`${deploys} ${deployErrors}`);
this.ux.log(`${tests} ${testErrs}`);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/formatters/deployResultFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export class DeployResultFormatter extends ResultFormatter {
if (deployMessages.length > failures.length) {
// if there's additional failures in the API response, find the failure and add it to the output
deployMessages.map((deployMessage) => {
if (!fileResponseFailures.has(`${deployMessage.componentType}#${deployMessage.fullName}`)) {
if (!fileResponseFailures.has(`${deployMessage.componentType ?? ''}#${deployMessage.fullName}`)) {
// duplicate the problem message to the error property for displaying in the table
failures.push(Object.assign(deployMessage, { error: deployMessage.problem }));
}
Expand Down Expand Up @@ -277,7 +277,7 @@ export class DeployResultFormatter extends ResultFormatter {

this.ux.log('');
this.ux.styledHeader(
chalk.red(`Test Failures [${asString(this.result.response.details.runTestResult?.numFailures)}]`)
chalk.red(`Test Failures [${asString(this.result.response.details.runTestResult?.numFailures) ?? ''}]`)
);
this.ux.table(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
Expand Down
4 changes: 3 additions & 1 deletion src/formatters/mdapi/mdDeployResultFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ export class MdDeployResultFormatter extends ResultFormatter {
const tests = this.sortTestResults(failures);

this.ux.log('');
this.ux.styledHeader(chalk.red(`Test Failures [${this.result.response.details.runTestResult?.numFailures}]`));
this.ux.styledHeader(
chalk.red(`Test Failures [${this.result.response.details.runTestResult?.numFailures ?? 0}]`)
);
this.ux.table(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
Expand Down
6 changes: 3 additions & 3 deletions src/formatters/mdapi/retrieveResultFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ export type RetrieveResultFormatterOptions = {
retrieveTargetDir: string;
zipFileName?: string;
unzip?: boolean;
} & ResultFormatterOptions
} & ResultFormatterOptions;

export type RetrieveCommandAsyncResult = {
done: boolean;
id: string;
state: RequestStatus | 'Queued';
status: RequestStatus | 'Queued';
timedOut: boolean;
}
};

export class RetrieveResultFormatter extends RetrieveFormatter {
protected zipFilePath: string;
Expand Down Expand Up @@ -67,7 +67,7 @@ export class RetrieveResultFormatter extends RetrieveFormatter {
this.ux.log(`Wrote retrieve zip to ${this.zipFilePath}`);
if (this.options.unzip) {
const extractPath = join(this.options.retrieveTargetDir, parse(this.options.zipFileName ?? '').name);
this.ux.log(`Extracted ${this.options.zipFileName} to: ${extractPath}`);
this.ux.log(`Extracted ${this.options.zipFileName ?? '<missing zipFileName>'} to: ${extractPath}`);
}
if (this.options.verbose) {
const retrievedFiles = ensureArray(this.result.fileProperties);
Expand Down
2 changes: 1 addition & 1 deletion src/formatters/source/pushResultFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export class PushResultFormatter extends ResultFormatter {
if (deployMessages.length > failures.length) {
// if there's additional failures in the API response, find the failure and add it to the output
deployMessages.map((deployMessage) => {
if (!fileResponseFailures.has(`${deployMessage.componentType}#${deployMessage.fullName}`)) {
if (!fileResponseFailures.has(`${deployMessage.componentType ?? ''}#${deployMessage.fullName}`)) {
// duplicate the problem message to the error property for displaying in the table
failures.push(
Object.assign(deployMessage, { error: deployMessage.problem }) as unknown as FileResponseFailure
Expand Down
2 changes: 1 addition & 1 deletion src/trackingFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const processConflicts = (conflicts: ChangeResult[], ux: Ux, message: string): v
const conflictMap = new Map<string, ConflictResponse>();
conflicts.forEach((c) => {
c.filenames?.forEach((f) => {
conflictMap.set(`${c.name}#${c.type}#${f}`, {
conflictMap.set(`${c.name ?? ''}#${c.type ?? ''}#${f}`, {
state: 'Conflict',
fullName: c.name as string,
type: c.type as string,
Expand Down

0 comments on commit 345cf9f

Please sign in to comment.