Skip to content

Commit

Permalink
[Fastlane.swift] Add formatter to Fastlane.swift (#16693)
Browse files Browse the repository at this point in the history
* Add linter to Fastlane.swift

* Formatting
  • Loading branch information
minuscorp committed Jul 6, 2020
1 parent bd12c69 commit f3ed1bb
Show file tree
Hide file tree
Showing 32 changed files with 4,018 additions and 3,951 deletions.
4 changes: 4 additions & 0 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ lane :generate_swift_api do |options|
require "../fastlane/lib/fastlane/swift_fastlane_api_generator.rb"
swift_generator = Fastlane::SwiftFastlaneAPIGenerator.new
generated_files = swift_generator.generate_swift
Dir.chdir("swift/formatting") do
sh("rake")
UI.success("Done linting fastlane.swift API")
end
UI.success("Done generating fastlane.swift API, ensuring it builds")
gym(
project: File.expand_path("swift/FastlaneSwiftRunner/FastlaneSwiftRunner.xcodeproj"),
Expand Down
2 changes: 1 addition & 1 deletion fastlane/lib/fastlane/swift_fastlane_function.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def initialize(action_name: nil, action_description: nil, action_details: nil, k

# rubocop:disable LineLength
# class instance?
@reserved_words = %w[associativity break case catch class continue convenience default deinit didSet do else enum extension fallthrough false final for func get guard if in infix init inout internal lazy let mutating nil operator override postfix precedence prefix private public repeat required return self set static struct subscript super switch throws true try var weak where while willSet].to_set
@reserved_words = %w[associativity break case catch class continue convenience default deinit didSet do else enum extension fallthrough false final for func guard if in infix init inout internal lazy let mutating nil operator override precedence private public repeat required return self static struct subscript super switch throws true try var weak where while willSet].to_set
# rubocop:enable LineLength
end

Expand Down
2 changes: 1 addition & 1 deletion fastlane/swift/Actions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ import Foundation

// Please don't remove the lines below
// They are used to detect outdated files
// FastlaneRunnerAPIVersion [0.9.56]
// FastlaneRunnerAPIVersion [0.9.56]
48 changes: 24 additions & 24 deletions fastlane/swift/ArgumentProcessor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,68 +19,68 @@ struct ArgumentProcessor {
let currentLane: String
let commandTimeout: Int
let port: UInt32
init(args: [String]) {

init(args: [String]) {
// Dump the first arg which is the program name
let fastlaneArgs = stride(from: 1, to: args.count - 1, by: 2).map {
RunnerArgument(name: args[$0], value: args[$0+1])
RunnerArgument(name: args[$0], value: args[$0 + 1])
}
self.args = fastlaneArgs

let fastlaneArgsMinusLanes = fastlaneArgs.filter { arg in
return arg.name.lowercased() != "lane"
arg.name.lowercased() != "lane"
}

let potentialLogMode = fastlaneArgsMinusLanes.filter { arg in
return arg.name.lowercased() == "logmode"
arg.name.lowercased() == "logmode"
}

port = UInt32(fastlaneArgsMinusLanes.first(where: { $0.name == "swiftServerPort" })?.value ?? "") ?? 2000

// Configure logMode since we might need to use it before we finish parsing
if let logModeArg = potentialLogMode.first {
let logModeString = logModeArg.value
Logger.logMode = Logger.LogMode(logMode: logModeString)
}

let lanes = self.args.filter { arg in
return arg.name.lowercased() == "lane"
arg.name.lowercased() == "lane"
}
verbose(message: lanes.description)

guard lanes.count == 1 else {
let message = "You must have exactly one lane specified as an arg, here's what I got: \(lanes)"
log(message: message)
fatalError(message)
}

let lane = lanes.first!
self.currentLane = lane.value
currentLane = lane.value

// User might have configured a timeout for the socket connection
let potentialTimeout = fastlaneArgsMinusLanes.filter { arg in
return arg.name.lowercased() == "timeoutseconds"
arg.name.lowercased() == "timeoutseconds"
}

if let logModeArg = potentialLogMode.first {
let logModeString = logModeArg.value
Logger.logMode = Logger.LogMode(logMode: logModeString)
}

if let timeoutArg = potentialTimeout.first {
let timeoutString = timeoutArg.value
self.commandTimeout = (timeoutString as NSString).integerValue
commandTimeout = (timeoutString as NSString).integerValue
} else {
self.commandTimeout = SocketClient.defaultCommandTimeoutSeconds
commandTimeout = SocketClient.defaultCommandTimeoutSeconds
}
}
func laneParameters() -> [String : String] {
let laneParametersArgs = self.args.filter { arg in

func laneParameters() -> [String: String] {
let laneParametersArgs = args.filter { arg in
let lowercasedName = arg.name.lowercased()
return lowercasedName != "timeoutseconds" && lowercasedName != "lane" && lowercasedName != "logmode"
}
var laneParameters = [String : String]()
var laneParameters = [String: String]()
for arg in laneParametersArgs {
laneParameters[arg.name] = arg.value
}
Expand Down
6 changes: 3 additions & 3 deletions fastlane/swift/ControlCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ struct ControlCommand: RubyCommandable {
let id: String = UUID().uuidString
let shutdownCommandType: ShutdownCommandType
var commandJson: String {
var jsonDictionary: [String: Any] = [ControlCommand.commandKey : self.shutdownCommandType.token]
var jsonDictionary: [String: Any] = [ControlCommand.commandKey: shutdownCommandType.token]

if let message = message {
jsonDictionary[ShutdownCommandType.userMessageKey] = message
}
if case .cancel(let reason) = shutdownCommandType {
if case let .cancel(reason) = shutdownCommandType {
jsonDictionary[ShutdownCommandType.CancelReason.reasonKey] = reason.reasonText
}

Expand All @@ -67,7 +67,7 @@ struct ControlCommand: RubyCommandable {
}

init(commandType: ShutdownCommandType, message: String? = nil) {
self.shutdownCommandType = commandType
shutdownCommandType = commandType
self.message = message
}
}
Expand Down
10 changes: 3 additions & 7 deletions fastlane/swift/Deliverfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@
//

class Deliverfile: DeliverfileProtocol {
// If you want to enable `deliver`, run `fastlane deliver init`
// After, this file will be replaced with a custom implementation that contains values you supplied
// during the `init` process, and you won't see this message
// If you want to enable `deliver`, run `fastlane deliver init`
// After, this file will be replaced with a custom implementation that contains values you supplied
// during the `init` process, and you won't see this message
}





// Generated with fastlane 2.150.3
Loading

0 comments on commit f3ed1bb

Please sign in to comment.