Skip to content

Commit 4e1fa11

Browse files
Added Enum Cases for New PluginListInterface File (#902)
* Added PluginListInterface File * Removed Duplicate Declarations from The PlugList Stencil File * Added Enum Cases for New PluginListInterface File * Update Sources/NodesGenerator/Resources/Stencils/PluginListInterface.stencil Co-authored-by: Christopher Fuller <christopher.fuller@gotinder.com> * New Snapshots for PluginListInterface File (#903) * Regened Snapshots for Addition of PluginListInterface File * More Snapshots * fixed snapshots --------- Co-authored-by: Christopher Fuller <christopher.fuller@gotinder.com>
1 parent ce91f7a commit 4e1fa11

25 files changed

+228
-9
lines changed

Sources/NodesGenerator/Config.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public struct Config: Codable, Equatable {
3939
public var builderImports: Set<String>
4040
public var flowImports: Set<String>
4141
public var pluginListImports: Set<String>
42+
public var pluginListInterfaceImports: Set<String>
4243
public var viewControllerImports: Set<String>
4344
public var dependencies: [Variable]
4445
public var analyticsProperties: [Variable]
@@ -95,6 +96,7 @@ extension Config {
9596
builderImports = []
9697
flowImports = []
9798
pluginListImports = []
99+
pluginListInterfaceImports = []
98100
viewControllerImports = []
99101
dependencies = []
100102
analyticsProperties = []
@@ -171,6 +173,9 @@ extension Config {
171173
pluginListImports =
172174
(try? decoder.decode(CodingKeys.pluginListImports))
173175
?? defaults.pluginListImports
176+
pluginListInterfaceImports =
177+
(try? decoder.decode(CodingKeys.pluginListInterfaceImports))
178+
?? defaults.pluginListInterfaceImports
174179
viewControllerImports =
175180
(try? decoder.decode(CodingKeys.viewControllerImports))
176181
?? defaults.viewControllerImports

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: 7 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):
@@ -296,6 +301,8 @@ public enum StencilTemplate: CustomStringConvertible, Equatable, Sendable {
296301
.union(["Nodes"])
297302
.union(config.dependencyInjectionImports)
298303
.union(config.pluginListImports)
304+
case .pluginListInterface:
305+
config.baseImports
299306
case .pluginListTests:
300307
config.baseTestImports
301308
.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,

Tests/NodesGeneratorTests/StencilRendererTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ final class StencilRendererTests: XCTestCase, TestFactories {
296296
let context: PluginListStencilContext = givenPluginListStencilContext(mockCount: count)
297297
let templates: [String: String] = try stencilRenderer
298298
.renderPluginList(context: context, includeTests: false)
299-
expect(templates.keys.sorted()) == ["PluginList"]
299+
expect(templates.keys.sorted()) == ["PluginList", "PluginListInterface"]
300300
templates.forEach { name, template in
301301
assertSnapshot(of: template,
302302
as: .lines,
@@ -311,7 +311,7 @@ final class StencilRendererTests: XCTestCase, TestFactories {
311311
let context: PluginListStencilContext = givenPluginListStencilContext(mockCount: count)
312312
let templates: [String: String] = try stencilRenderer
313313
.renderPluginList(context: context, includeTests: true)
314-
expect(templates.keys.sorted()) == ["PluginList", "PluginListTests"]
314+
expect(templates.keys.sorted()) == ["PluginList", "PluginListInterface", "PluginListTests"]
315315
templates.forEach { name, template in
316316
assertSnapshot(of: template,
317317
as: .lines,

Tests/NodesGeneratorTests/StencilTemplateTests.swift

Lines changed: 13 additions & 0 deletions
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:
@@ -361,6 +365,10 @@ final class StencilTemplateTests: XCTestCase, TestFactories {
361365
"<pluginListImport>",
362366
"Nodes"
363367
]
368+
case .pluginListInterface:
369+
expect(imports) == [
370+
"<baseImport>"
371+
]
364372
case .pluginListTests:
365373
expect(imports) == [
366374
"<baseTestImport>",
@@ -482,6 +490,10 @@ final class StencilTemplateTests: XCTestCase, TestFactories {
482490
"<pluginListImport>",
483491
"Nodes"
484492
]
493+
case .pluginListInterface:
494+
expect(imports) == [
495+
"<baseImport>"
496+
]
485497
case .pluginListTests:
486498
expect(imports) == [
487499
"<baseTestImport>",
@@ -533,6 +545,7 @@ extension StencilTemplate {
533545
.pluginInterface,
534546
.pluginTests,
535547
.pluginList,
548+
.pluginListInterface,
536549
.pluginListTests,
537550
.state,
538551
.viewController(.regular),

Tests/NodesGeneratorTests/Support/TestFactories.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ extension TestFactories {
257257
fileHeader: "<fileHeader>",
258258
pluginListName: "<pluginListName>",
259259
pluginListImports: .mock(with: "pluginListImport", count: mockCount),
260+
pluginListInterfaceImports: .mock(with: "pluginListInterfaceImport", count: mockCount),
260261
pluginListTestsImports: .mock(with: "pluginListTestsImports", count: mockCount),
261262
viewControllableFlowType: "<viewControllableFlowType>",
262263
isPeripheryCommentEnabled: mockCount > 0,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
▿ pluginListImports: 2 members
4747
- "<pluginListImports-1>"
4848
- "<pluginListImports-2>"
49+
- pluginListInterfaceImports: 0 members
4950
- publisherFailureType: "<publisherFailureType>"
5051
- publisherType: "<publisherType>"
5152
▿ reactiveImports: 2 members

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- isTestTemplatesGenerationEnabled: true
1919
- isViewInjectedTemplateEnabled: true
2020
- pluginListImports: 0 members
21+
- pluginListInterfaceImports: 0 members
2122
- publisherFailureType: "Never"
2223
- publisherType: "AnyPublisher"
2324
▿ reactiveImports: 1 member

0 commit comments

Comments
 (0)