-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/4.10.0' into versions
- Loading branch information
Showing
101 changed files
with
3,421 additions
and
2,987 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,3 +48,6 @@ Package.resolved | |
*.xcodeproj | ||
.swiftpm | ||
.build/ | ||
|
||
# Project-specific | ||
secrets.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"lineBreakAroundMultilineExpressionChainComponents": true, | ||
"lineBreakBeforeControlFlowKeywords": true, | ||
"lineBreakBeforeEachArgument": true, | ||
"lineBreakBeforeEachGenericRequirement": true, | ||
"lineLength": 120, | ||
"prioritizeKeepingFunctionOutputTogether": true, | ||
"rules": { | ||
"NeverUseImplicitlyUnwrappedOptionals": true, | ||
"NoLeadingUnderscores": true, | ||
"ValidateDocumentationComments": true, | ||
}, | ||
"tabWidth": 2, | ||
"version": 1, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import Foundation | ||
import MungoHealer | ||
import Toml | ||
|
||
public struct Configuration { | ||
public static let fileName: String = ".bartycrouch.toml" | ||
|
||
public static var configUrl: URL { | ||
return URL(fileURLWithPath: FileManager.default.currentDirectoryPath).appendingPathComponent(Configuration.fileName) | ||
} | ||
|
||
public let updateOptions: UpdateOptions | ||
public let lintOptions: LintOptions | ||
|
||
public static func load() throws -> Configuration { | ||
let configUrl = self.configUrl | ||
|
||
guard FileManager.default.fileExists(atPath: configUrl.path) else { | ||
return try Configuration.make(toml: try Toml(withString: "")) | ||
} | ||
|
||
let toml: Toml = try Toml(contentsOfFile: configUrl.path) | ||
return try Configuration.make(toml: toml) | ||
} | ||
} | ||
|
||
extension Configuration: TomlCodable { | ||
public static func makeDefault() throws -> Configuration { | ||
return try make(toml: Toml(withString: "")) | ||
} | ||
|
||
public static func make(toml: Toml) throws -> Configuration { | ||
let updateOptions = try UpdateOptions.make(toml: toml) | ||
let lintOptions = try LintOptions.make(toml: toml) | ||
|
||
return Configuration(updateOptions: updateOptions, lintOptions: lintOptions) | ||
} | ||
|
||
public func tomlContents() -> String { | ||
let sections: [String] = [ | ||
updateOptions.tomlContents(), | ||
lintOptions.tomlContents(), | ||
] | ||
|
||
return sections.joined(separator: "\n\n") + "\n" | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
Sources/BartyCrouchConfiguration/Extensions/TomlExtension.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Created by Frederick Pietschmann on 15.02.20. | ||
|
||
import Foundation | ||
import Toml | ||
|
||
public extension Toml { | ||
func filePaths(_ path: String..., singularKey: String, pluralKey: String) -> [String] { | ||
return array(path + [pluralKey]) ?? string(path + [singularKey]).map { [$0] } ?? ["."] | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
Sources/BartyCrouchConfiguration/Options/LintOptions.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import BartyCrouchUtility | ||
import Foundation | ||
import MungoHealer | ||
import Toml | ||
|
||
public struct LintOptions { | ||
public let paths: [String] | ||
public let subpathsToIgnore: [String] | ||
public let duplicateKeys: Bool | ||
public let emptyValues: Bool | ||
} | ||
|
||
extension LintOptions: TomlCodable { | ||
static func make(toml: Toml) throws -> LintOptions { | ||
let lint: String = "lint" | ||
|
||
return LintOptions( | ||
paths: toml.filePaths(lint, singularKey: "path", pluralKey: "paths"), | ||
subpathsToIgnore: toml.array(lint, "subpathsToIgnore") ?? Constants.defaultSubpathsToIgnore, | ||
duplicateKeys: toml.bool(lint, "duplicateKeys") ?? true, | ||
emptyValues: toml.bool(lint, "emptyValues") ?? true | ||
) | ||
} | ||
|
||
func tomlContents() -> String { | ||
var lines: [String] = ["[lint]"] | ||
|
||
lines.append("paths = \(paths)") | ||
lines.append("subpathsToIgnore = \(subpathsToIgnore)") | ||
lines.append("duplicateKeys = \(duplicateKeys)") | ||
lines.append("emptyValues = \(emptyValues)") | ||
|
||
return lines.joined(separator: "\n") | ||
} | ||
} |
Oops, something went wrong.