Skip to content

Commit

Permalink
Merge pull request #492 from Rocko1204/feat/additional-fields-package…
Browse files Browse the repository at this point in the history
…-version

feat: additional fields for package version result (VersionNumber, CodeCoverage)
  • Loading branch information
shetzel authored Apr 5, 2024
2 parents 8f68b44 + c4375d2 commit 9296f90
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/interfaces/packagingInterfacesAndType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ export type PackageVersionCreateRequestResult = {
CreatedDate: string;
HasMetadataRemoved: boolean | null;
HasPassedCodeCoverageCheck: boolean | null;
CodeCoverage: number | null;
VersionNumber: string | null;
CreatedBy: string;
ConvertedFromVersionId: string | null;
};
Expand Down
21 changes: 19 additions & 2 deletions src/package/packageVersionCreateRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@salesforce/packaging', 'package_version_create');

const QUERY =
'SELECT Id, Status, Package2Id, Package2.Name, Package2VersionId, Package2Version.SubscriberPackageVersionId, Package2Version.HasPassedCodeCoverageCheck, Tag, Branch, ' +
'SELECT Id, Status, Package2Id, Package2.Name, Package2VersionId, Package2Version.SubscriberPackageVersionId, Package2Version.HasPassedCodeCoverageCheck,Package2Version.CodeCoverage, Tag, Branch, ' +
'Package2Version.MajorVersion, Package2Version.MinorVersion, Package2Version.PatchVersion, Package2Version.BuildNumber, ' +
'CreatedDate, Package2Version.HasMetadataRemoved, CreatedById, IsConversionRequest, Package2Version.ConvertedFromVersionId ' +
'FROM Package2VersionCreateRequest ' +
'%s' + // WHERE, if applicable
Expand Down Expand Up @@ -66,7 +67,15 @@ async function query(query: string, connection: Connection): Promise<PackageVers
Schema & {
Package2Version: Pick<
PackagingSObjects.Package2Version,
'HasMetadataRemoved' | 'SubscriberPackageVersionId' | 'ConvertedFromVersionId' | 'HasPassedCodeCoverageCheck'
| 'HasMetadataRemoved'
| 'SubscriberPackageVersionId'
| 'ConvertedFromVersionId'
| 'HasPassedCodeCoverageCheck'
| 'CodeCoverage'
| 'MajorVersion'
| 'MinorVersion'
| 'PatchVersion'
| 'BuildNumber'
>;
} & {
Package2: Pick<PackagingSObjects.Package2, 'Name'>;
Expand All @@ -85,6 +94,14 @@ async function query(query: string, connection: Connection): Promise<PackageVers
Error: [],
CreatedDate: formatDate(new Date(record.CreatedDate)),
HasMetadataRemoved: record.Package2Version != null ? record.Package2Version.HasMetadataRemoved : null,
CodeCoverage:
record.Package2Version?.CodeCoverage != null
? record.Package2Version.CodeCoverage.apexCodeCoveragePercentage
: null,
VersionNumber:
record.Package2Version != null
? `${record.Package2Version.MajorVersion}.${record.Package2Version.MinorVersion}.${record.Package2Version.PatchVersion}.${record.Package2Version.BuildNumber}`
: null,
HasPassedCodeCoverageCheck:
record.Package2Version != null ? record.Package2Version.HasPassedCodeCoverageCheck : null,
CreatedBy: record.CreatedById,
Expand Down
4 changes: 4 additions & 0 deletions test/package/packageConvert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ describe('packageConvert', () => {
Package2Id: '0Ho4p0000004DdnCAE',
Package2Name: null,
HasPassedCodeCoverageCheck: null,
CodeCoverage: null,
VersionNumber: null,
Package2VersionId: '05i4p0000004H7lAAE',
Status: 'Success',
SubscriberPackageVersionId: null,
Expand All @@ -261,6 +263,8 @@ describe('packageConvert', () => {
Error: [],
HasMetadataRemoved: null,
HasPassedCodeCoverageCheck: null,
CodeCoverage: null,
VersionNumber: null,
Id: '0Ho3i000000Gmj6YYa',
Package2Id: undefined,
Package2Name: null,
Expand Down
2 changes: 2 additions & 0 deletions test/package/packageTest.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const VERSION_CREATE_RESPONSE_KEYS = [
'CreatedDate',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'CodeCoverage',
'VersionNumber',
'CreatedBy',
'ConvertedFromVersionId',
];
Expand Down
34 changes: 34 additions & 0 deletions test/package/packageVersionCreate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ describe('Package Version Create', () => {
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'CodeCoverage',
'VersionNumber',
'Id',
'Package2Id',
'Package2Name',
Expand Down Expand Up @@ -191,6 +193,8 @@ describe('Package Version Create', () => {
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'CodeCoverage',
'VersionNumber',
'Id',
'Package2Id',
'Package2Name',
Expand Down Expand Up @@ -219,6 +223,8 @@ describe('Package Version Create', () => {
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'CodeCoverage',
'VersionNumber',
'Id',
'Package2Id',
'Package2Name',
Expand Down Expand Up @@ -251,6 +257,8 @@ describe('Package Version Create', () => {
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'CodeCoverage',
'VersionNumber',
'Id',
'Package2Id',
'Package2Name',
Expand Down Expand Up @@ -281,6 +289,8 @@ describe('Package Version Create', () => {
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'CodeCoverage',
'VersionNumber',
'Id',
'Package2Id',
'Package2Name',
Expand Down Expand Up @@ -310,6 +320,8 @@ describe('Package Version Create', () => {
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'CodeCoverage',
'VersionNumber',
'Id',
'Package2Id',
'Package2Name',
Expand Down Expand Up @@ -340,6 +352,8 @@ describe('Package Version Create', () => {
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'CodeCoverage',
'VersionNumber',
'Id',
'Package2Id',
'Package2Name',
Expand All @@ -363,6 +377,8 @@ describe('Package Version Create', () => {
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'CodeCoverage',
'VersionNumber',
'Id',
'Package2Id',
'Package2Name',
Expand Down Expand Up @@ -410,6 +426,8 @@ describe('Package Version Create', () => {
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'CodeCoverage',
'VersionNumber',
'Id',
'Package2Id',
'Package2Name',
Expand Down Expand Up @@ -457,6 +475,8 @@ describe('Package Version Create', () => {
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'CodeCoverage',
'VersionNumber',
'Id',
'Package2Id',
'Package2Name',
Expand Down Expand Up @@ -502,6 +522,8 @@ describe('Package Version Create', () => {
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'CodeCoverage',
'VersionNumber',
'Id',
'Package2Id',
'Package2Name',
Expand All @@ -526,6 +548,8 @@ describe('Package Version Create', () => {
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'CodeCoverage',
'VersionNumber',
'Id',
'Package2Id',
'Package2Name',
Expand All @@ -550,6 +574,8 @@ describe('Package Version Create', () => {
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'CodeCoverage',
'VersionNumber',
'Id',
'Package2Id',
'Package2Name',
Expand Down Expand Up @@ -579,6 +605,8 @@ describe('Package Version Create', () => {
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'CodeCoverage',
'VersionNumber',
'Id',
'Package2Id',
'Package2Name',
Expand Down Expand Up @@ -782,6 +810,8 @@ describe('Package Version Create', () => {
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'CodeCoverage',
'VersionNumber',
'Id',
'Package2Id',
'Package2Name',
Expand Down Expand Up @@ -850,6 +880,8 @@ describe('Package Version Create', () => {
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'CodeCoverage',
'VersionNumber',
'Id',
'Package2Id',
'Package2Name',
Expand Down Expand Up @@ -930,6 +962,8 @@ describe('Package Version Create', () => {
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'CodeCoverage',
'VersionNumber',
'Id',
'Package2Id',
'Package2Name',
Expand Down

0 comments on commit 9296f90

Please sign in to comment.