Skip to content

Commit

Permalink
Merge pull request #723 from salesforcecli/mradul/packaging/W-1539872…
Browse files Browse the repository at this point in the history
…4/fix-verbose

@W-15398724@ Remove codeCoverage field from non-verbose query response for package version list
  • Loading branch information
WillieRuemmele committed Jul 11, 2024
2 parents 5bc8207 + 1f65603 commit dc42ab9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/commands/package/version/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,17 @@ export class PackageVersionListCommand extends SfCommand<PackageVersionListComma
record.AncestorId = 'N/A';
}

const codeCoverage =
record.CodeCoverage?.apexCodeCoveragePercentage != null
function getCodeCoverage(): string {
if (!flags.verbose) {
return 'use --verbose for code coverage';
}

return record.CodeCoverage?.apexCodeCoveragePercentage != null
? `${record.CodeCoverage.apexCodeCoveragePercentage.toString()}%`
: Boolean(record.Package2.IsOrgDependent) || record.ValidationSkipped
? 'N/A'
: '';
}

const hasPassedCodeCoverageCheck =
record.Package2.IsOrgDependent === true || record.ValidationSkipped
Expand Down Expand Up @@ -192,7 +197,7 @@ export class PackageVersionListCommand extends SfCommand<PackageVersionListComma
CreatedDate: new Date(record.CreatedDate).toISOString().replace('T', ' ').substring(0, 16),
LastModifiedDate: new Date(record.LastModifiedDate).toISOString().replace('T', ' ').substring(0, 16),
InstallUrl: INSTALL_URL_BASE.toString() + record.SubscriberPackageVersionId,
CodeCoverage: codeCoverage,
CodeCoverage: getCodeCoverage(),
HasPassedCodeCoverageCheck: hasPassedCodeCoverageCheck as string | boolean,
ValidationSkipped: record.ValidationSkipped,
ValidatedAsync: record.ValidatedAsync,
Expand Down
5 changes: 4 additions & 1 deletion test/commands/package/packageVersion.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ describe('package:version:*', () => {
});
it('should list package versions in dev hub - json results', () => {
const command = `package:version:list -v ${session.hubOrg.username} --json`;
const output = execCmd<[PackageVersionListCommandResult]>(command, { ensureExitCode: 0 }).jsonOutput?.result;
const output = execCmd<PackageVersionListCommandResult>(command, { ensureExitCode: 0 }).jsonOutput?.result;
const keys = [
'Package2Id',
'Branch',
Expand Down Expand Up @@ -345,7 +345,10 @@ describe('package:version:*', () => {
];
expect(output).to.have.length.greaterThan(0);
expect(output?.at(0)).to.have.keys(keys);
const codeCoverage = output?.[0]?.CodeCoverage;
expect(codeCoverage).to.equal('use --verbose for code coverage');
});

it('should list package versions in dev hub - verbose json results', () => {
const command = `package:version:list --verbose -v ${session.hubOrg.username} --json`;
const output = execCmd<PackageVersionListCommandResult>(command, { ensureExitCode: 0 }).jsonOutput
Expand Down

0 comments on commit dc42ab9

Please sign in to comment.