Allow using a period in a CLI product name (#5178)
* Allow using a period in cli product name * PR fixes --------- Co-authored-by: Daniele Formichelli <df@bendingspoons.com>
This commit is contained in:
parent
3769449844
commit
58413d07e3
|
@ -73,14 +73,14 @@ class TargetLinter: TargetLinting {
|
|||
private func lintProductName(target: Target) -> [LintingIssue] {
|
||||
var allowed = CharacterSet(charactersIn: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_")
|
||||
|
||||
if target.product == .app {
|
||||
let allowsDot = target.product == .app || target.product == .commandLineTool
|
||||
if allowsDot {
|
||||
allowed.formUnion(CharacterSet(charactersIn: "."))
|
||||
}
|
||||
|
||||
if target.productName.unicodeScalars.allSatisfy(allowed.contains) == false {
|
||||
let reason = target.product == .app ?
|
||||
"Invalid product name '\(target.productName)'. This string must contain only alphanumeric (A-Z,a-z,0-9), period (.), and underscore (_) characters." :
|
||||
"Invalid product name '\(target.productName)'. This string must contain only alphanumeric (A-Z,a-z,0-9), and underscore (_) characters."
|
||||
let reason =
|
||||
"Invalid product name '\(target.productName)'. This string must contain only alphanumeric (A-Z,a-z,0-9)\(allowsDot ? ", period (.)" : ""), and underscore (_) characters."
|
||||
|
||||
return [LintingIssue(reason: reason, severity: .warning)]
|
||||
}
|
||||
|
|
|
@ -25,9 +25,16 @@ final class TargetLinterTests: TuistUnitTestCase {
|
|||
func test_lint_when_target_has_invalid_product_name() {
|
||||
let XCTAssertInvalidProductNameApp: (Target) -> Void = { target in
|
||||
let got = self.subject.lint(target: target)
|
||||
let reason = target.product == .app ?
|
||||
"Invalid product name '\(target.productName)'. This string must contain only alphanumeric (A-Z,a-z,0-9), period (.), and underscore (_) characters." :
|
||||
"Invalid product name '\(target.productName)'. This string must contain only alphanumeric (A-Z,a-z,0-9), and underscore (_) characters."
|
||||
let reason: String
|
||||
switch target.product {
|
||||
case .app, .commandLineTool:
|
||||
reason =
|
||||
"Invalid product name '\(target.productName)'. This string must contain only alphanumeric (A-Z,a-z,0-9), period (.), and underscore (_) characters."
|
||||
default:
|
||||
reason =
|
||||
"Invalid product name '\(target.productName)'. This string must contain only alphanumeric (A-Z,a-z,0-9), and underscore (_) characters."
|
||||
}
|
||||
|
||||
self.XCTContainsLintingIssue(got, LintingIssue(reason: reason, severity: .warning))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue