Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/fxios/Commands/Nimbus/Nimbus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 6 additions & 6 deletions Sources/fxios/Commands/Nimbus/NimbusAdd.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/fxios/Commands/Nimbus/NimbusRemove.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
34 changes: 17 additions & 17 deletions Tests/fxiosTests/NimbusTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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) }
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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"))

Expand All @@ -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:"))
Expand Down Expand Up @@ -698,20 +698,20 @@ 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"))

// Now remove it
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"))

Expand Down Expand Up @@ -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"))
}
Expand Down
Loading