Skip to content

Commit dc5e29e

Browse files
Merge branch 'main' into xcode-template-tests
2 parents 47b69a1 + ed61a43 commit dc5e29e

File tree

217 files changed

+860
-969
lines changed

Some content is hidden

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

217 files changed

+860
-969
lines changed

Sources/NodesGenerator/Config.swift

+5
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

+3-7
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

+3-7
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

+3-1
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

-19
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 %}
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

+4
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

+1-1
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

+8
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

+4-1
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,

Tests/NodesGeneratorTests/ConfigTests.swift

+3
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ final class ConfigTests: XCTestCase, TestFactories {
157157
flowImports:
158158
- <flowImports-1>
159159
- <flowImports-2>
160+
interfaceImports:
161+
- <interfaceImports-1>
162+
- <interfaceImports-2>
160163
pluginListImports:
161164
- <pluginListImports-1>
162165
- <pluginListImports-2>

Tests/NodesGeneratorTests/StencilRendererTests.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ final class StencilRendererTests: XCTestCase, TestFactories {
294294
let context: PluginListStencilContext = givenPluginListStencilContext(mockCount: count)
295295
let templates: [String: String] = try stencilRenderer
296296
.renderPluginList(context: context, includeTests: false)
297-
expect(templates.keys.sorted()) == ["PluginList"]
297+
expect(templates.keys.sorted()) == ["PluginList", "PluginListInterface"]
298298
templates.forEach { name, template in
299299
assertSnapshot(of: template,
300300
as: .lines,
@@ -309,7 +309,7 @@ final class StencilRendererTests: XCTestCase, TestFactories {
309309
let context: PluginListStencilContext = givenPluginListStencilContext(mockCount: count)
310310
let templates: [String: String] = try stencilRenderer
311311
.renderPluginList(context: context, includeTests: true)
312-
expect(templates.keys.sorted()) == ["PluginList", "PluginListTests"]
312+
expect(templates.keys.sorted()) == ["PluginList", "PluginListInterface", "PluginListTests"]
313313
templates.forEach { name, template in
314314
assertSnapshot(of: template,
315315
as: .lines,

Tests/NodesGeneratorTests/StencilTemplateTests.swift

+15
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ final class StencilTemplateTests: XCTestCase, TestFactories {
7474
expect(name) == "PluginTests"
7575
case .pluginList:
7676
expect(name) == "PluginList"
77+
case .pluginListInterface:
78+
expect(name) == "PluginListInterface"
7779
case .pluginListTests:
7880
expect(name) == "PluginListTests"
7981
case .state:
@@ -125,6 +127,8 @@ final class StencilTemplateTests: XCTestCase, TestFactories {
125127
expect(filename) == "PluginTests"
126128
case .pluginList:
127129
expect(filename) == "PluginList"
130+
case .pluginListInterface:
131+
expect(filename) == "PluginListInterface"
128132
case .pluginListTests:
129133
expect(filename) == "PluginListTests"
130134
case .state:
@@ -337,6 +341,7 @@ final class StencilTemplateTests: XCTestCase, TestFactories {
337341
case .interface:
338342
expect(imports) == [
339343
"<baseImport>",
344+
"<interfaceImport>",
340345
"Nodes"
341346
]
342347
case .plugin:
@@ -361,6 +366,10 @@ final class StencilTemplateTests: XCTestCase, TestFactories {
361366
"<pluginListImport>",
362367
"Nodes"
363368
]
369+
case .pluginListInterface:
370+
expect(imports) == [
371+
"<baseImport>"
372+
]
364373
case .pluginListTests:
365374
expect(imports) == [
366375
"<baseTestImport>",
@@ -458,6 +467,7 @@ final class StencilTemplateTests: XCTestCase, TestFactories {
458467
case .interface:
459468
expect(imports) == [
460469
"<baseImport>",
470+
"<interfaceImport>",
461471
"Nodes"
462472
]
463473
case .plugin:
@@ -482,6 +492,10 @@ final class StencilTemplateTests: XCTestCase, TestFactories {
482492
"<pluginListImport>",
483493
"Nodes"
484494
]
495+
case .pluginListInterface:
496+
expect(imports) == [
497+
"<baseImport>"
498+
]
485499
case .pluginListTests:
486500
expect(imports) == [
487501
"<baseTestImport>",
@@ -533,6 +547,7 @@ extension StencilTemplate {
533547
.pluginInterface,
534548
.pluginTests,
535549
.pluginList,
550+
.pluginListInterface,
536551
.pluginListTests,
537552
.state,
538553
.viewController(.regular),

Tests/NodesGeneratorTests/Support/TestFactories.swift

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ extension TestFactories {
4040
config.dependencyInjectionImports = .mock(with: "dependencyInjectionImport", count: mockCount)
4141
config.builderImports = .mock(with: "builderImport", count: mockCount)
4242
config.flowImports = .mock(with: "flowImport", count: mockCount)
43+
config.interfaceImports = .mock(with: "interfaceImport", count: mockCount)
4344
config.pluginListImports = .mock(with: "pluginListImport", count: mockCount)
4445
config.viewControllerImports = .mock(with: "viewControllerImport", count: mockCount)
4546
config.dependencies = .mock(with: "dependency", count: mockCount)
@@ -263,6 +264,7 @@ extension TestFactories {
263264
fileHeader: "<fileHeader>",
264265
pluginListName: "<pluginListName>",
265266
pluginListImports: .mock(with: "pluginListImport", count: mockCount),
267+
pluginListInterfaceImports: .mock(with: "pluginListInterfaceImport", count: mockCount),
266268
pluginListTestsImports: .mock(with: "pluginListTestsImports", count: mockCount),
267269
viewControllableFlowType: "<viewControllableFlowType>",
268270
isPeripheryCommentEnabled: mockCount > 0,

Tests/NodesGeneratorTests/__Snapshots__/ConfigTests/testConfig.1.txt

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
▿ Variable
3939
- name: "<flowProperties-name-2>"
4040
- type: "<flowProperties-type-2>"
41+
▿ interfaceImports: 2 members
42+
- "<interfaceImports-1>"
43+
- "<interfaceImports-2>"
4144
- isObservableStoreEnabled: false
4245
- isPeripheryCommentEnabled: true
4346
- isPreviewProviderEnabled: true

Tests/NodesGeneratorTests/__Snapshots__/ConfigTests/testConfigWithEmptyFileContents.1.txt

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- "NeedleFoundation"
1313
- flowImports: 0 members
1414
- flowProperties: 0 elements
15+
- interfaceImports: 0 members
1516
- isObservableStoreEnabled: false
1617
- isPeripheryCommentEnabled: false
1718
- isPreviewProviderEnabled: false

Tests/NodesGeneratorTests/__Snapshots__/ConfigTests/testDecodingFromEmptyString.1.txt

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- "NeedleFoundation"
1313
- flowImports: 0 members
1414
- flowProperties: 0 elements
15+
- interfaceImports: 0 members
1516
- isObservableStoreEnabled: false
1617
- isPeripheryCommentEnabled: false
1718
- isPreviewProviderEnabled: false

0 commit comments

Comments
 (0)