Make CocoaPods an attribute of the Graph model
This commit is contained in:
parent
1a9b2a840d
commit
8dc7d4df27
|
@ -28,11 +28,13 @@ public class Graph: Encodable {
|
|||
public let name: String
|
||||
public let entryPath: AbsolutePath
|
||||
public let entryNodes: [GraphNode]
|
||||
|
||||
/// Projects that are part of the graph.
|
||||
|
||||
/// Dictionary whose keys are paths to directories where projects are defined, and the values are the representation of the projects.
|
||||
public var projects: [AbsolutePath: Project]
|
||||
|
||||
|
||||
|
||||
/// Dictionary whose keys are paths to directories where projects are defined, and the values are the CocoaPods nodes define in them.
|
||||
public var cocoapods: [AbsolutePath: CocoaPodsNode]
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
public convenience init(name: String, entryPath: AbsolutePath, cache: GraphLoaderCaching) {
|
||||
|
@ -50,7 +52,8 @@ public class Graph: Encodable {
|
|||
self.entryPath = entryPath
|
||||
self.cache = cache
|
||||
self.entryNodes = entryNodes
|
||||
self.projects = cache.projects
|
||||
projects = cache.projects
|
||||
cocoapods = cache.cocoapodsNodes
|
||||
}
|
||||
|
||||
// MARK: - Encodable
|
||||
|
@ -67,11 +70,6 @@ public class Graph: Encodable {
|
|||
|
||||
// MARK: - Graphing
|
||||
|
||||
/// Returns all the CocoaPods nodes that are part of the graph.
|
||||
public var cocoapods: [CocoaPodsNode] {
|
||||
Array(cache.cocoapodsNodes.values)
|
||||
}
|
||||
|
||||
/// Returns all the SwiftPM package nodes that are part of the graph.
|
||||
public var packages: [PackageNode] {
|
||||
cache.packages.values.flatMap { $0 }
|
||||
|
|
|
@ -68,6 +68,7 @@ public extension Graph {
|
|||
}
|
||||
|
||||
let cache = GraphLoaderCache()
|
||||
projects.forEach(cache.add(project:))
|
||||
let graph = Graph.test(name: projects.first?.name ?? "Test",
|
||||
entryPath: projects.first?.path ?? AbsolutePath("/test/path"),
|
||||
cache: cache,
|
||||
|
|
|
@ -156,7 +156,7 @@ public class GraphLinter: GraphLinting {
|
|||
/// - Parameter graph: Project graph.
|
||||
/// - Returns: Linting issues.
|
||||
private func lintCocoaPodsDependencies(graph: Graph) -> [LintingIssue] {
|
||||
graph.cocoapods.compactMap { node in
|
||||
graph.cocoapods.values.compactMap { node in
|
||||
let podfilePath = node.podfilePath
|
||||
if !FileHandler.shared.exists(podfilePath) {
|
||||
return LintingIssue(reason: "The Podfile at path \(podfilePath) referenced by some projects does not exist", severity: .error)
|
||||
|
|
|
@ -64,7 +64,7 @@ public final class CocoaPodsInteractor: CocoaPodsInteracting {
|
|||
let canUseBundler = canUseCocoaPodsThroughBundler()
|
||||
let canUseSystem = canUseSystemPod()
|
||||
|
||||
try graph.cocoapods.forEach { node in
|
||||
try graph.cocoapods.values.forEach { node in
|
||||
var command: [String]
|
||||
|
||||
if canUseBundler {
|
||||
|
|
|
@ -38,8 +38,7 @@ final class WorkspaceGeneratorIntegrationTests: TuistTestCase {
|
|||
(project: project, target: target, dependencies: [])
|
||||
}
|
||||
})
|
||||
let workspace = Workspace.test(path: temporaryPath,
|
||||
projects: projects.map(\.path))
|
||||
let workspace = Workspace.test(path: temporaryPath, projects: projects.map(\.path))
|
||||
|
||||
// When / Then
|
||||
try (0 ..< 50).forEach { _ in
|
||||
|
|
Loading…
Reference in New Issue