2024-11-10 17:51:53 +11:00
|
|
|
/*
|
|
|
|
* darwin-apk © 2024 Gay Pizza Specifications
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2024-11-08 21:22:33 +11:00
|
|
|
|
|
|
|
import Foundation
|
2024-11-23 21:02:52 +11:00
|
|
|
import ArgumentParser
|
|
|
|
import darwin_apk
|
2024-11-08 21:22:33 +11:00
|
|
|
|
2024-11-23 21:02:52 +11:00
|
|
|
struct DpkGraphCommand: AsyncParsableCommand {
|
|
|
|
static let configuration = CommandConfiguration(commandName: "graph")
|
2024-11-08 21:22:33 +11:00
|
|
|
|
2024-11-23 21:02:52 +11:00
|
|
|
func run() async throws(ExitCode) {
|
2024-11-11 21:06:37 +11:00
|
|
|
let graph: ApkPackageGraph
|
2024-11-08 21:22:33 +11:00
|
|
|
do {
|
2024-11-23 21:02:52 +11:00
|
|
|
let localRepositories = try await ApkRepositoriesConfig()
|
|
|
|
graph = ApkPackageGraph(index: try await ApkIndexReader.resolve(localRepositories.repositories, fetch: .lazy))
|
2024-11-11 21:06:37 +11:00
|
|
|
graph.buildGraphNode()
|
|
|
|
|
|
|
|
try graph.pkgIndex.description.write(to: URL(filePath: "packages.txt"), atomically: false, encoding: .utf8)
|
2024-11-08 21:22:33 +11:00
|
|
|
} catch {
|
|
|
|
fatalError(error.localizedDescription)
|
|
|
|
}
|
2024-11-11 21:06:37 +11:00
|
|
|
|
|
|
|
if var out = TextFileWriter(URL(filePath: "shallowIsolates.txt")) {
|
|
|
|
for node in graph.shallowIsolates { print(node, to: &out) }
|
|
|
|
}
|
|
|
|
if var out = TextFileWriter(URL(filePath: "deepIsolates.txt")) {
|
|
|
|
for node in graph.deepIsolates { print(node, to: &out) }
|
|
|
|
}
|
2024-11-08 21:22:33 +11:00
|
|
|
}
|
|
|
|
}
|