diff --git a/Sources/fxios/Commands/Nimbus/Nimbus.swift b/Sources/fxios/Commands/Nimbus/Nimbus.swift index 39b1926..642d844 100644 --- a/Sources/fxios/Commands/Nimbus/Nimbus.swift +++ b/Sources/fxios/Commands/Nimbus/Nimbus.swift @@ -25,7 +25,7 @@ struct Nimbus: ParsableCommand { enum NimbusConstants { static let nimbusFmlPath = "firefox-ios/nimbus.fml.yaml" static let nimbusFeaturesPath = "firefox-ios/nimbus-features" - static let nimbusFlaggableFeaturePath = "firefox-ios/Client/FeatureFlags/NimbusFlaggableFeature.swift" + static let nimbusFlaggableFeaturePath = "firefox-ios/Client/FeatureFlags/FeatureFlagID.swift" static let nimbusFeatureFlagLayerPath = "firefox-ios/Client/Nimbus/NimbusFeatureFlagLayer.swift" // swiftlint:disable:next line_length static let featureFlagsDebugViewControllerPath = "firefox-ios/Client/Frontend/Settings/Main/Debug/FeatureFlags/FeatureFlagsDebugViewController.swift" diff --git a/Sources/fxios/Commands/Nimbus/NimbusAdd.swift b/Sources/fxios/Commands/Nimbus/NimbusAdd.swift index 2a9dc49..7afcfc8 100644 --- a/Sources/fxios/Commands/Nimbus/NimbusAdd.swift +++ b/Sources/fxios/Commands/Nimbus/NimbusAdd.swift @@ -20,8 +20,8 @@ extension Nimbus { @Argument(help: "The feature name in camelCase (without 'Feature' suffix).") var featureName: String - @Flag(name: .long, help: "Add the feature to the QA settings UI.") - var qa = false + @Flag(name: .long, help: "Add the feature to the debuggable settings UI.") + var debuggable = false @Flag(name: .long, help: "Mark the feature as user-toggleable (requires implementing a preference key).") var userToggleable = false @@ -61,10 +61,10 @@ extension Nimbus { // 3. Update NimbusFlaggableFeature.swift let flaggableFeaturePath = repo.root.appendingPathComponent(NimbusConstants.nimbusFlaggableFeaturePath) - Herald.declare("Updating NimbusFlaggableFeature.swift...") + Herald.declare("Updating FeatureFlagID.swift...") try NimbusFlaggableFeatureEditor.addFeature( name: cleanName, - debug: qa, + debug: debuggable, userToggleable: userToggleable, filePath: flaggableFeaturePath ) @@ -74,8 +74,8 @@ extension Nimbus { Herald.declare("Updating NimbusFeatureFlagLayer.swift...") try NimbusFeatureFlagLayerEditor.addFeature(name: cleanName, filePath: flagLayerPath) - // 5. If --qa, update FeatureFlagsDebugViewController.swift - if qa { + // 5. If --debuggable, update FeatureFlagsDebugViewController.swift + if debuggable { let debugVCPath = repo.root.appendingPathComponent(NimbusConstants.featureFlagsDebugViewControllerPath) Herald.declare("Updating FeatureFlagsDebugViewController.swift...") try FeatureFlagsDebugViewControllerEditor.addFeature(name: cleanName, filePath: debugVCPath) diff --git a/Sources/fxios/Commands/Nimbus/NimbusFlaggableFeatureEditor.swift b/Sources/fxios/Commands/Nimbus/NimbusFlaggableFeatureEditor.swift index a3dc8d1..807b971 100644 --- a/Sources/fxios/Commands/Nimbus/NimbusFlaggableFeatureEditor.swift +++ b/Sources/fxios/Commands/Nimbus/NimbusFlaggableFeatureEditor.swift @@ -24,7 +24,7 @@ enum NimbusFlaggableFeatureEditor { // 1. Add enum case to NimbusFeatureFlagID content = try addEnumCase(name: name, to: content) - // 2. Add to debugKey if --qa + // 2. Add to debugKey if --debuggable if debug { content = try addToDebugKey(name: name, to: content) } @@ -103,7 +103,7 @@ enum NimbusFlaggableFeatureEditor { var lastCaseIndex: Int? for (index, line) in lines.enumerated() { - if line.contains("enum NimbusFeatureFlagID") { + if line.contains("enum FeatureFlagID") { inEnum = true continue } diff --git a/Sources/fxios/Commands/Nimbus/NimbusRemove.swift b/Sources/fxios/Commands/Nimbus/NimbusRemove.swift index d0cc05c..c3fa614 100644 --- a/Sources/fxios/Commands/Nimbus/NimbusRemove.swift +++ b/Sources/fxios/Commands/Nimbus/NimbusRemove.swift @@ -109,7 +109,7 @@ extension Nimbus { ) if !result.wasPresent { - reportSkipped("Feature not in QA settings (not added with --qa)") + reportSkipped("Feature not in debuggable settings (not added with --debuggable)") } else if result.removed { reportSuccess("Removed debug setting") } else { @@ -138,7 +138,7 @@ extension Nimbus { /// Removes the feature from NimbusFlaggableFeature.swift. Returns true if any failures occurred. private func removeFlaggableFeature(_ name: String, from path: URL) -> Bool { - Herald.declare("Updating NimbusFlaggableFeature.swift...") + Herald.declare("Updating FeatureFlagID.swift...") var hasFailures = false guard FileManager.default.fileExists(atPath: path.path) else { diff --git a/Tests/fxiosTests/NimbusTests.swift b/Tests/fxiosTests/NimbusTests.swift index 7d2a31a..aae7aef 100644 --- a/Tests/fxiosTests/NimbusTests.swift +++ b/Tests/fxiosTests/NimbusTests.swift @@ -44,9 +44,9 @@ struct NimbusTests { try FileManager.default.createDirectory(at: nimbusDir, withIntermediateDirectories: true) try FileManager.default.createDirectory(at: debugDir, withIntermediateDirectories: true) - // Create NimbusFlaggableFeature.swift + // Create FeatureFlagID.swift let flaggableFeatureContent = """ - enum NimbusFeatureFlagID: String, CaseIterable { + enum FeatureFlagID: String, CaseIterable { case alpha case zeta @@ -75,14 +75,14 @@ struct NimbusTests { } } """ - let flaggableFeaturePath = featureFlagsDir.appendingPathComponent("NimbusFlaggableFeature.swift") + let flaggableFeaturePath = featureFlagsDir.appendingPathComponent("FeatureFlagID.swift") try flaggableFeatureContent.write(to: flaggableFeaturePath, atomically: true, encoding: .utf8) // Create NimbusFeatureFlagLayer.swift let flagLayerContent = """ final class NimbusFeatureFlagLayer { public func checkNimbusConfigFor( - _ featureID: NimbusFeatureFlagID, + _ featureID: FeatureFlagID, from nimbus: FxNimbus = FxNimbus.shared ) -> Bool { switch featureID { @@ -448,7 +448,7 @@ struct NimbusTests { #expect(content.contains("nimbus-features/newFeature.yaml")) } - @Test("add command updates NimbusFlaggableFeature.swift") + @Test("add command updates FeatureFlagID.swift") func addCommandUpdatesFlaggableFeature() throws { let repoDir = try createValidRepo() defer { cleanup(repoDir) } @@ -462,7 +462,7 @@ struct NimbusTests { var command = try Nimbus.Add.parse(["beta"]) try command.run() - let filePath = repoDir.appendingPathComponent("firefox-ios/Client/FeatureFlags/NimbusFlaggableFeature.swift") + let filePath = repoDir.appendingPathComponent("firefox-ios/Client/FeatureFlags/FeatureFlagID.swift") let content = try String(contentsOf: filePath, encoding: .utf8) // Should have added the enum case @@ -496,8 +496,8 @@ struct NimbusTests { #expect(content.contains("nimbus.features.beta.value().enabled")) } - @Test("add command with --qa updates QA settings") - func addCommandWithQaUpdatesQaSettings() throws { + @Test("add command with --debuggable updates debuggable settings") + func addCommandWithDebuggableUpdatesdebuggableSettings() throws { let repoDir = try createValidRepo() defer { cleanup(repoDir) } try setupNimbusStructure(in: repoDir) @@ -507,11 +507,11 @@ struct NimbusTests { FileManager.default.changeCurrentDirectoryPath(repoDir.path) defer { FileManager.default.changeCurrentDirectoryPath(originalDir) } - var command = try Nimbus.Add.parse(["beta", "--qa"]) + var command = try Nimbus.Add.parse(["beta", "--debuggable"]) try command.run() - // Check NimbusFlaggableFeature.swift for debugKey - let flaggablePath = repoDir.appendingPathComponent("firefox-ios/Client/FeatureFlags/NimbusFlaggableFeature.swift") + // Check FeatureFlagID.swift for debugKey + let flaggablePath = repoDir.appendingPathComponent("firefox-ios/Client/FeatureFlags/FeatureFlagID.swift") let flaggableContent = try String(contentsOf: flaggablePath, encoding: .utf8) #expect(flaggableContent.contains(".beta")) @@ -537,7 +537,7 @@ struct NimbusTests { var command = try Nimbus.Add.parse(["beta", "--user-toggleable"]) try command.run() - let filePath = repoDir.appendingPathComponent("firefox-ios/Client/FeatureFlags/NimbusFlaggableFeature.swift") + let filePath = repoDir.appendingPathComponent("firefox-ios/Client/FeatureFlags/FeatureFlagID.swift") let content = try String(contentsOf: filePath, encoding: .utf8) #expect(content.contains("case .beta:")) @@ -698,12 +698,12 @@ struct NimbusTests { FileManager.default.changeCurrentDirectoryPath(repoDir.path) defer { FileManager.default.changeCurrentDirectoryPath(originalDir) } - // First add a feature with --qa - var addCommand = try Nimbus.Add.parse(["beta", "--qa"]) + // First add a feature with --debuggable + var addCommand = try Nimbus.Add.parse(["beta", "--debuggable"]) try addCommand.run() // Verify it was added - let flaggablePath = repoDir.appendingPathComponent("firefox-ios/Client/FeatureFlags/NimbusFlaggableFeature.swift") + let flaggablePath = repoDir.appendingPathComponent("firefox-ios/Client/FeatureFlags/FeatureFlagID.swift") var content = try String(contentsOf: flaggablePath, encoding: .utf8) #expect(content.contains("case beta")) @@ -711,7 +711,7 @@ struct NimbusTests { var removeCommand = try Nimbus.Remove.parse(["beta"]) try removeCommand.run() - // Check NimbusFlaggableFeature.swift + // Check FeatureFlagID.swift content = try String(contentsOf: flaggablePath, encoding: .utf8) #expect(!content.contains("case beta")) @@ -746,7 +746,7 @@ struct NimbusTests { try command.run() // Verify the Swift files weren't modified (feature didn't exist) - let flaggablePath = repoDir.appendingPathComponent("firefox-ios/Client/FeatureFlags/NimbusFlaggableFeature.swift") + let flaggablePath = repoDir.appendingPathComponent("firefox-ios/Client/FeatureFlags/FeatureFlagID.swift") let flaggableContent = try String(contentsOf: flaggablePath, encoding: .utf8) #expect(!flaggableContent.contains("nonexistent")) }