Files
VCCPlusOSS/tests/macos/SoftwareLibraryOwnedRecordProbe.swift

31 lines
1.7 KiB
Swift

// SPDX-License-Identifier: GPL-3.0-or-later
// Read-only maintainer probe using the native catalog parser, not a parallel schema.
import Foundation
@main
struct SoftwareLibraryOwnedRecordProbe {
static func main() throws {
guard CommandLine.arguments.count > 1 else {
throw NSError(domain: "OwnedRecordProbe", code: 1,
userInfo: [NSLocalizedDescriptionKey: "Supply explicit local intake or portable publication-record JSON files."])
}
for path in CommandLine.arguments.dropFirst() {
let url = URL(fileURLWithPath: path)
let values = try url.resourceValues(forKeys: [.isRegularFileKey, .isSymbolicLinkKey, .fileSizeKey])
guard values.isRegularFile == true, values.isSymbolicLink != true,
let size = values.fileSize, size > 0, size <= 8 * 1024 * 1024 else {
throw SoftwareLibraryCatalog.Failure.invalid("invalid local intake/receipt file")
}
let object = try JSONDecoder().decode(LibraryJSON.self, from: Data(contentsOf: url))
let record = object["contract"] == .null ? object : object["contract"]
guard let game = try SoftwareLibraryOwnedGame.parse(record) else {
throw SoftwareLibraryCatalog.Failure.invalid("missing owned title contract")
}
print("PASS", game.gameID, "RAM", game.ramKiB, "CPU", game.processor,
"project", game.source.projectDirectory, "configuration", game.source.buildConfiguration ?? "project default",
"related source packages", game.source.companionPackages.count)
}
print("Read-only validation; no catalog, media, application or publication changed.")
}
}