diff --git a/src/artifacts/MacosPkgArtifactReader.ts b/src/artifacts/MacosPkgArtifactReader.ts index 926147048a3..5ee846d0bb9 100644 --- a/src/artifacts/MacosPkgArtifactReader.ts +++ b/src/artifacts/MacosPkgArtifactReader.ts @@ -902,25 +902,7 @@ export class MacosPkgArtifactReader implements ArtifactReader { 0, metadataBudget.remainingRecords - (1 + parsed.value.bundles.length), ); - metadata.packages.push({ - path: pkg.path, - identifier: parsed.value.identifier, - version: parsed.value.version, - install_location: parsed.value.installLocation, - auth: parsed.value.auth, - postinstall_action: parsed.value.postinstallAction, - bundles: parsed.value.bundles.map((bundle) => ({ - id: bundle.id, - path: bundle.path, - cf_bundle_identifier: bundle.cfBundleIdentifier, - cf_bundle_version: bundle.cfBundleVersion, - ...(bundle.cfBundleShortVersion === null - ? {} - : { cf_bundle_short_version: bundle.cfBundleShortVersion }), - })), - preinstall: parsed.value.preinstall, - postinstall: parsed.value.postinstall, - }); + metadata.packages.push({ path: pkg.path, ...parsed.value }); } metadata.archive_kind = metadata.distribution !== null diff --git a/src/artifacts/macosPkg/InstallerXml.ts b/src/artifacts/macosPkg/InstallerXml.ts index 975e507c837..0fba073dfe5 100644 --- a/src/artifacts/macosPkg/InstallerXml.ts +++ b/src/artifacts/macosPkg/InstallerXml.ts @@ -18,25 +18,6 @@ import { decodeStrictUtf8 } from "../../domain/strictUtf8.js"; import { parseXmlDocumentWithinNodeLimit } from "../../domain/xmlDocument.js"; import { attributeOf, childElement, childElements } from "./xmlElements.js"; -export interface PackageBundleRecord { - readonly id: string | null; - readonly path: string | null; - readonly cfBundleIdentifier: string | null; - readonly cfBundleVersion: string | null; - readonly cfBundleShortVersion: string | null; -} - -export interface PackageInfoFacts { - readonly identifier: string | null; - readonly version: string | null; - readonly installLocation: string | null; - readonly auth: string | null; - readonly postinstallAction: string | null; - readonly bundles: readonly PackageBundleRecord[]; - readonly preinstall: string | null; - readonly postinstall: string | null; -} - export interface InstallerXmlLimits { readonly remainingRecords: number; readonly maxRecords: number; @@ -262,7 +243,10 @@ export const parseDistributionXml = ( export const parsePackageInfoXml = ( bytes: Buffer, limits?: Partial, -): Result => { +): Result< + Omit, + MacosPkgParseError +> => { const { remainingRecords, maxRecords, maxXmlNodes } = resolveXmlLimits(limits); if (remainingRecords < 1) @@ -292,16 +276,21 @@ export const parsePackageInfoXml = ( return ok({ identifier: attributeOf(info, "identifier"), version: attributeOf(info, "version"), - installLocation: attributeOf(info, "install-location"), + install_location: attributeOf(info, "install-location"), auth: attributeOf(info, "auth"), - postinstallAction: attributeOf(info, "postinstall-action"), - bundles: bundleElements.map((element) => ({ - id: attributeOf(element, "id"), - path: attributeOf(element, "path"), - cfBundleIdentifier: attributeOf(element, "CFBundleIdentifier"), - cfBundleVersion: attributeOf(element, "CFBundleVersion"), - cfBundleShortVersion: attributeOf(element, "CFBundleShortVersionString"), - })), + postinstall_action: attributeOf(info, "postinstall-action"), + bundles: bundleElements.map((element) => { + const bundle = { + id: attributeOf(element, "id"), + path: attributeOf(element, "path"), + cf_bundle_identifier: attributeOf(element, "CFBundleIdentifier"), + cf_bundle_version: attributeOf(element, "CFBundleVersion"), + }; + const shortVersion = attributeOf(element, "CFBundleShortVersionString"); + return shortVersion === null + ? bundle + : { ...bundle, cf_bundle_short_version: shortVersion }; + }), preinstall: scriptFile("preinstall"), postinstall: scriptFile("postinstall"), });