refactor(macos-pkg): emit retained PackageInfo fields directly (#16731)

This commit is contained in:
Vincent Koc authored and GitHub committed 2026-12-04 20:57:28 +08:00
1 parent d54bf13953
commit 80be901897
2 files changed
+19 -48

No files matched your search

+1 -19
View File
@@ -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
+18 -29
View File
@@ -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<InstallerXmlLimits>,
): Result<PackageInfoFacts, MacosPkgParseError> => {
): Result<
Omit<MacosPkgMetadata["packages"][number], "path">,
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"),
});