Skip to content

Commit a96569a

Browse files
Merge branch 'main' into mock-plugin-list-tests-import
2 parents 329c4bc + ed61a43 commit a96569a

File tree

213 files changed

+819
-956
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

213 files changed

+819
-956
lines changed

Sources/NodesGenerator/Config.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public struct Config: Codable, Equatable {
3838
public var dependencyInjectionImports: Set<String>
3939
public var builderImports: Set<String>
4040
public var flowImports: Set<String>
41+
public var interfaceImports: Set<String>
4142
public var pluginListImports: Set<String>
4243
public var viewControllerImports: Set<String>
4344
public var dependencies: [Variable]
@@ -94,6 +95,7 @@ extension Config {
9495
dependencyInjectionImports = ["NeedleFoundation"]
9596
builderImports = []
9697
flowImports = []
98+
interfaceImports = []
9799
pluginListImports = []
98100
viewControllerImports = []
99101
dependencies = []
@@ -168,6 +170,9 @@ extension Config {
168170
flowImports =
169171
(try? decoder.decode(CodingKeys.flowImports))
170172
?? defaults.flowImports
173+
interfaceImports =
174+
(try? decoder.decode(CodingKeys.interfaceImports))
175+
?? defaults.interfaceImports
171176
pluginListImports =
172177
(try? decoder.decode(CodingKeys.pluginListImports))
173178
?? defaults.pluginListImports

Sources/NodesGenerator/Resources/Stencils/Interface-SwiftUI.stencil

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,17 @@ import {{ import }}
66
{% endfor %}
77
{% endif %}
88

9-
// This file defines the protocols and types in the interface requiring public ACL for use in another module.
9+
/*
10+
This file contains the protocols and types of the interface requiring public ACL for use in another module.
11+
*/
1012
{% if node_name != "App" %}
1113

12-
// MARK: - Listener
13-
1414
/// Defines the delegate protocol through which the `Context` interfaces with its listener.
1515
/// @mockable
1616
@MainActor
1717
internal protocol {{ node_name }}Listener: AnyObject {}
1818
{% endif %}
1919

20-
// MARK: - Flow
21-
2220
/// @mockable
2321
@MainActor
2422
{% if plugin_list_name %}
@@ -27,8 +25,6 @@ internal protocol {{ node_name }}Flow: {{ plugin_list_name }}Flow {}
2725
internal protocol {{ node_name }}Flow: {{ view_controllable_flow_type }} {}
2826
{% endif %}
2927

30-
// MARK: - Builder
31-
3228
{% if is_periphery_comment_enabled %}
3329
// periphery:ignore
3430
{% endif %}

Sources/NodesGenerator/Resources/Stencils/Interface.stencil

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,17 @@ import {{ import }}
66
{% endfor %}
77
{% endif %}
88

9-
// This file defines the protocols and types in the interface requiring public ACL for use in another module.
9+
/*
10+
This file contains the protocols and types of the interface requiring public ACL for use in another module.
11+
*/
1012
{% if node_name != "App" %}
1113

12-
// MARK: - Listener
13-
1414
/// Defines the delegate protocol through which the `Context` interfaces with its listener.
1515
/// @mockable
1616
@MainActor
1717
internal protocol {{ node_name }}Listener: AnyObject {}
1818
{% endif %}
1919

20-
// MARK: - Flow
21-
2220
/// @mockable
2321
@MainActor
2422
{% if owns_view %}
@@ -35,8 +33,6 @@ internal protocol {{ node_name }}Flow: Flow {
3533
internal protocol {{ node_name }}Flow: Flow {}
3634
{% endif %}
3735

38-
// MARK: - Builder
39-
4036
{% if is_periphery_comment_enabled %}
4137
// periphery:ignore
4238
{% endif %}

Sources/NodesGenerator/Resources/Stencils/PluginInterface.stencil

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import {{ import }}
66
{% endfor %}
77
{% endif %}
88

9-
// This file defines the protocols and types in the plugin interface requiring public ACL for use in another module.
9+
/*
10+
This file contains the protocols and types of the plugin interface requiring public ACL for use in another module.
11+
*/
1012

1113
/// Dynamic state from the caller provided to the plugin to use in determining whether it is enabled.
1214
/// - NOTE: An alias to a tuple is supported.

Sources/NodesGenerator/Resources/Stencils/PluginList.stencil

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,25 +79,6 @@ public final class {{ plugin_list_name }}PluginListComponent: Component
7979

8080
// MARK: - Plugin List
8181

82-
/// Declares the type of key used to identify plugins within the collection.
83-
/// - NOTE: May be any ``Hashable`` type such as ``String`` or an enumeration.
84-
internal typealias {{ plugin_list_name }}PluginListKeyType = String
85-
86-
/// Dynamic state from the caller provided to the plugins to use in determining whether they are enabled.
87-
/// - NOTE: An alias to a tuple is supported.
88-
internal typealias {{ plugin_list_name }}PluginListStateType = Void
89-
90-
{% if is_periphery_comment_enabled %}
91-
// periphery:ignore
92-
{% endif %}
93-
/// @mockable
94-
@MainActor
95-
internal protocol {{ plugin_list_name }}PluginList {
96-
func createAll() -> [{{ plugin_list_name }}Builder]
97-
func create() -> {{ plugin_list_name }}Builder?
98-
func create(key: {{ plugin_list_name }}PluginListKeyType) -> {{ plugin_list_name }}Builder?
99-
}
100-
10182
{% if is_periphery_comment_enabled %}
10283
// periphery:ignore
10384
{% endif %}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//{{ file_header }}
2+
{% if plugin_list_interface_imports %}
3+
4+
{% for import in plugin_list_interface_imports %}
5+
import {{ import }}
6+
{% endfor %}
7+
{% endif %}
8+
9+
/*
10+
This file contains the protocols and types of the plugin list interface requiring public ACL for use in another module.
11+
*/
12+
13+
/// Declares the type of key used to identify plugins within the collection.
14+
/// - NOTE: May be any ``Hashable`` type such as ``String`` or an enumeration.
15+
internal typealias {{ plugin_list_name }}PluginListKeyType = String
16+
17+
/// Dynamic state from the caller provided to the plugins to use in determining whether they are enabled.
18+
/// - NOTE: An alias to a tuple is supported.
19+
internal typealias {{ plugin_list_name }}PluginListStateType = Void
20+
21+
{% if is_periphery_comment_enabled %}
22+
// periphery:ignore
23+
{% endif %}
24+
/// @mockable
25+
@MainActor
26+
internal protocol {{ plugin_list_name }}PluginList {
27+
func createAll() -> [{{ plugin_list_name }}Builder]
28+
func create() -> {{ plugin_list_name }}Builder?
29+
func create(key: {{ plugin_list_name }}PluginListKeyType) -> {{ plugin_list_name }}Builder?
30+
}

Sources/NodesGenerator/StencilContexts/PluginListStencilContext.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public struct PluginListStencilContext: StencilContext {
1212
private let fileHeader: String
1313
private let pluginListName: String
1414
private let pluginListImports: [String]
15+
private let pluginListInterfaceImports: [String]
1516
private let pluginListTestsImports: [String]
1617
private let viewControllableFlowType: String
1718
private let isPeripheryCommentEnabled: Bool
@@ -22,6 +23,7 @@ public struct PluginListStencilContext: StencilContext {
2223
"file_header": fileHeader,
2324
"plugin_list_name": pluginListName,
2425
"plugin_list_imports": pluginListImports,
26+
"plugin_list_interface_imports": pluginListInterfaceImports,
2527
"plugin_list_tests_imports": pluginListTestsImports,
2628
"view_controllable_flow_type": viewControllableFlowType,
2729
"is_periphery_comment_enabled": isPeripheryCommentEnabled,
@@ -33,6 +35,7 @@ public struct PluginListStencilContext: StencilContext {
3335
fileHeader: String,
3436
pluginListName: String,
3537
pluginListImports: Set<String>,
38+
pluginListInterfaceImports: Set<String>,
3639
pluginListTestsImports: Set<String>,
3740
viewControllableFlowType: String,
3841
isPeripheryCommentEnabled: Bool,
@@ -41,6 +44,7 @@ public struct PluginListStencilContext: StencilContext {
4144
self.fileHeader = fileHeader
4245
self.pluginListName = pluginListName
4346
self.pluginListImports = pluginListImports.sortedImports()
47+
self.pluginListInterfaceImports = pluginListInterfaceImports.sortedImports()
4448
self.pluginListTestsImports = pluginListTestsImports.sortedImports()
4549
self.viewControllableFlowType = viewControllableFlowType
4650
self.isPeripheryCommentEnabled = isPeripheryCommentEnabled

Sources/NodesGenerator/StencilRenderer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public final class StencilRenderer {
4949
includeTests: Bool
5050
) throws -> [String: String] {
5151
let additional: [StencilTemplate] = includeTests ? [.pluginListTests] : []
52-
let stencils: [StencilTemplate] = [.pluginList] + additional
52+
let stencils: [StencilTemplate] = [.pluginList, .pluginListInterface] + additional
5353
return try render(stencils: stencils, with: context.dictionary)
5454
}
5555

Sources/NodesGenerator/StencilTemplate.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public enum StencilTemplate: CustomStringConvertible, Equatable, Sendable {
2323
case pluginInterface
2424
case pluginTests
2525
case pluginList
26+
case pluginListInterface
2627
case pluginListTests
2728
case state
2829
case viewController(Variation)
@@ -199,6 +200,8 @@ public enum StencilTemplate: CustomStringConvertible, Equatable, Sendable {
199200
"PluginTests"
200201
case .pluginList:
201202
"PluginList"
203+
case .pluginListInterface:
204+
"PluginListInterface"
202205
case .pluginListTests:
203206
"PluginListTests"
204207
case .state:
@@ -238,6 +241,8 @@ public enum StencilTemplate: CustomStringConvertible, Equatable, Sendable {
238241
description.appending(variation.suffix)
239242
case .pluginList, .pluginListTests:
240243
description
244+
case .pluginListInterface:
245+
description
241246
case .state:
242247
description
243248
case let .viewController(variation), let .viewControllerTests(variation):
@@ -282,6 +287,7 @@ public enum StencilTemplate: CustomStringConvertible, Equatable, Sendable {
282287
case .interface:
283288
config.baseImports
284289
.union(["Nodes"])
290+
.union(config.interfaceImports)
285291
case .plugin:
286292
config.baseImports
287293
.union(["Nodes"])
@@ -296,6 +302,8 @@ public enum StencilTemplate: CustomStringConvertible, Equatable, Sendable {
296302
.union(["Nodes"])
297303
.union(config.dependencyInjectionImports)
298304
.union(config.pluginListImports)
305+
case .pluginListInterface:
306+
config.baseImports
299307
case .pluginListTests:
300308
config.baseTestImports
301309
.union(["NodesTesting"])

Sources/NodesGenerator/XcodeTemplatePermutations/PluginListXcodeTemplatePermutation.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ internal struct PluginListXcodeTemplatePermutation: XcodeTemplatePermutation {
1616
internal init(name: String, config: Config) {
1717
self.name = name
1818
let pluginList: StencilTemplate = .pluginList
19+
let pluginListInterface: StencilTemplate = .pluginListInterface
1920
let pluginListTests: StencilTemplate = .pluginListTests
20-
stencils = [pluginList] + (config.isTestTemplatesGenerationEnabled ? [pluginListTests] : [])
21+
stencils = [pluginList, pluginListInterface]
22+
+ (config.isTestTemplatesGenerationEnabled ? [pluginListTests] : [])
2123
stencilContext = PluginListStencilContext(
2224
fileHeader: XcodeTemplateConstants.fileHeader,
2325
pluginListName: XcodeTemplateConstants.variable(XcodeTemplateConstants.productName),
2426
pluginListImports: pluginList.imports(with: config),
27+
pluginListInterfaceImports: pluginListInterface.imports(with: config),
2528
pluginListTestsImports: pluginListTests.imports(with: config),
2629
viewControllableFlowType: config.viewControllableFlowType,
2730
isPeripheryCommentEnabled: config.isPeripheryCommentEnabled,

0 commit comments

Comments
 (0)