Add Swiftlint
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit

This commit is contained in:
Loris Perret 2023-12-08 17:10:21 +01:00
parent 3d675a5663
commit f0131e0828
24 changed files with 158 additions and 51 deletions

View File

@ -13,7 +13,7 @@
- Update plist `UIAppFonts` when generated fonts (use plistBuddy) - Update plist `UIAppFonts` when generated fonts (use plistBuddy)
- New parameter: `infoPlistPaths` - New parameter: `infoPlistPaths`
- Generate SwiftUI extensions for colors, fonts and images - Generate SwiftUI extensions for colors, fonts and images
- New parameter: `extensionNameSwiftUI` - New parameter: `extensionNameUIKit`
- Adding Makefile to install, unsintall and create man page. - Adding Makefile to install, unsintall and create man page.
## Fixes ## Fixes

View File

@ -1,12 +1,75 @@
{ {
"pins" : [ "pins" : [
{
"identity" : "collectionconcurrencykit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/JohnSundell/CollectionConcurrencyKit.git",
"state" : {
"revision" : "b4f23e24b5a1bff301efc5e70871083ca029ff95",
"version" : "0.2.0"
}
},
{
"identity" : "cryptoswift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/krzyzanowskim/CryptoSwift.git",
"state" : {
"revision" : "db51c407d3be4a051484a141bf0bff36c43d3b1e",
"version" : "1.8.0"
}
},
{
"identity" : "sourcekitten",
"kind" : "remoteSourceControl",
"location" : "https://github.com/jpsim/SourceKitten.git",
"state" : {
"revision" : "b6dc09ee51dfb0c66e042d2328c017483a1a5d56",
"version" : "0.34.1"
}
},
{ {
"identity" : "swift-argument-parser", "identity" : "swift-argument-parser",
"kind" : "remoteSourceControl", "kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser", "location" : "https://github.com/apple/swift-argument-parser",
"state" : { "state" : {
"revision" : "9f39744e025c7d377987f30b03770805dcb0bcd1", "revision" : "8f4d2753f0e4778c76d5f05ad16c74f707390531",
"version" : "1.1.4" "version" : "1.2.3"
}
},
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"state" : {
"revision" : "6ad4ea24b01559dde0773e3d091f1b9e36175036",
"version" : "509.0.2"
}
},
{
"identity" : "swiftlint",
"kind" : "remoteSourceControl",
"location" : "https://github.com/realm/SwiftLint.git",
"state" : {
"revision" : "f17a4f9dfb6a6afb0408426354e4180daaf49cee",
"version" : "0.54.0"
}
},
{
"identity" : "swiftytexttable",
"kind" : "remoteSourceControl",
"location" : "https://github.com/scottrhoyt/SwiftyTextTable.git",
"state" : {
"revision" : "c6df6cf533d120716bff38f8ff9885e1ce2a4ac3",
"version" : "0.9.0"
}
},
{
"identity" : "swxmlhash",
"kind" : "remoteSourceControl",
"location" : "https://github.com/drmohundro/SWXMLHash.git",
"state" : {
"revision" : "a853604c9e9a83ad9954c7e3d2a565273982471f",
"version" : "7.0.2"
} }
}, },
{ {
@ -14,8 +77,8 @@
"kind" : "remoteSourceControl", "kind" : "remoteSourceControl",
"location" : "https://github.com/jpsim/Yams.git", "location" : "https://github.com/jpsim/Yams.git",
"state" : { "state" : {
"revision" : "01835dc202670b5bb90d07f3eae41867e9ed29f6", "revision" : "0d9ee7ea8c4ebd4a489ad7a73d5c6cad55d6fed3",
"version" : "5.0.1" "version" : "5.0.6"
} }
} }
], ],

View File

@ -9,7 +9,8 @@ let package = Package(
dependencies: [ dependencies: [
// Dependencies declare other packages that this package depends on. // Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0"), .package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0"),
.package(url: "https://github.com/jpsim/Yams.git", from: "5.0.1") .package(url: "https://github.com/jpsim/Yams.git", from: "5.0.1"),
.package(url: "https://github.com/realm/SwiftLint.git", .upToNextMajor(from: "0.54.0")),
], ],
targets: [ targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite. // Targets are the basic building blocks of a package. A target can define a module or a test suite.
@ -20,7 +21,8 @@ let package = Package(
"ToolCore", "ToolCore",
.product(name: "ArgumentParser", package: "swift-argument-parser"), .product(name: "ArgumentParser", package: "swift-argument-parser"),
"Yams" "Yams"
] ],
plugins: [.plugin(name: "SwiftLintPlugin", package: "SwiftLint")]
), ),
// Helper targets // Helper targets

View File

@ -16,7 +16,7 @@ iOS required to use the **real name** of the font, this name can be different fr
swift run -c release ResgenSwift fonts $FORCE_FLAG "./Fonts/fonts.txt" \ swift run -c release ResgenSwift fonts $FORCE_FLAG "./Fonts/fonts.txt" \
--extension-output-path "./Fonts/Generated" \ --extension-output-path "./Fonts/Generated" \
--extension-name "AppFont" \ --extension-name "AppFont" \
--extension-name-swift-ui "SUIAppFont" \ --extension-name-ui-kit "UIAppFont" \
--extension-suffix "GreatApp" \ --extension-suffix "GreatApp" \
--static-members true \ --static-members true \
--info-plist-paths "./path/one/to/Info.plist ./path/two/to/Info.plist" --info-plist-paths "./path/one/to/Info.plist ./path/two/to/Info.plist"
@ -27,8 +27,8 @@ swift run -c release ResgenSwift fonts $FORCE_FLAG "./Fonts/fonts.txt" \
1. `-f`: force generation 1. `-f`: force generation
2. Font input folder, it will search for every `.ttf` and `.otf` files specified in `fonts.txt` 2. Font input folder, it will search for every `.ttf` and `.otf` files specified in `fonts.txt`
3. `--extension-output-path`: path where to generate generated extension 3. `--extension-output-path`: path where to generate generated extension
4. `--extension-name` *(optional)* : name of the class to add UIKit getters 4. `--extension-name` *(optional)* : name of the class to add SwiftUI getters
5. `--extension-name-swift-ui` *(optional)* : name of the class to add SwiftUI getters 5. `--extension-name-ui-kit` *(optional)* : name of the class to add UIKit getters
6. `--extension-suffix` *(optional)* : additional text which is added to the filename (ex: `AppFont+GreatApp.swift`) 6. `--extension-suffix` *(optional)* : additional text which is added to the filename (ex: `AppFont+GreatApp.swift`)
7. `--static-members` *(optional)*: generate static properties or not 7. `--static-members` *(optional)*: generate static properties or not
8. `--info-plist-paths` *(optional)*: array of `.plist`, you can specify multiple `Info.plist` for multiple targets 8. `--info-plist-paths` *(optional)*: array of `.plist`, you can specify multiple `Info.plist` for multiple targets
@ -44,7 +44,7 @@ swift run -c release ResgenSwift colors $FORCE_FLAG "./Colors/colors.txt" \
--xcassets-path "./Colors/colors.xcassets" \ --xcassets-path "./Colors/colors.xcassets" \
--extension-output-path "./Colors/Generated/" \ --extension-output-path "./Colors/Generated/" \
--extension-name "AppColor" \ --extension-name "AppColor" \
--extension-name-swift-ui "SUIAppColor" \ --extension-name-ui-kit "UIAppColor" \
--extension-suffix "GreatApp" \ --extension-suffix "GreatApp" \
--static-members true --static-members true
``` ```
@ -55,8 +55,8 @@ swift run -c release ResgenSwift colors $FORCE_FLAG "./Colors/colors.txt" \
2. Input colors file 2. Input colors file
3. `--style` can be `all` or `light` 3. `--style` can be `all` or `light`
4. `--extension-output-path`: path where to generate generated extension 4. `--extension-output-path`: path where to generate generated extension
5. `--extension-name` *(optional)* : name of the class to add UIKit getters 5. `--extension-name` *(optional)* : name of the class to add SwiftUI getters
6. `--extension-name-swift-ui` *(optional)* : name of the class to add SwiftUI getters 6. `--extension-name-ui-kit` *(optional)* : name of the class to add UIKit getters
7. `--extension-suffix` *(optional)* : additional text which is added to filename (ex: `AppColor+GreatApp.swift`) 7. `--extension-suffix` *(optional)* : additional text which is added to filename (ex: `AppColor+GreatApp.swift`)
8. `--static-members` *(optional)*: generate static properties or not 8. `--static-members` *(optional)*: generate static properties or not
@ -142,7 +142,7 @@ swift run -c release ResgenSwift images $FORCE_FLAG "./Images/images.txt" \
--xcassets-path "./Images/app.xcassets" \ --xcassets-path "./Images/app.xcassets" \
--extension-output-path "./Images/Generated" \ --extension-output-path "./Images/Generated" \
--extension-name "AppImage" \ --extension-name "AppImage" \
--extension-name-swift-ui "SUIAppImage" \ --extension-name-ui-kit "UIAppImage" \
--extension-suffix "GreatApp" \ --extension-suffix "GreatApp" \
--static-members true --static-members true
``` ```
@ -153,8 +153,8 @@ swift run -c release ResgenSwift images $FORCE_FLAG "./Images/images.txt" \
2. Input images definitions file 2. Input images definitions file
3. `--xcassets-path`: xcasset path where to generate imagesets 3. `--xcassets-path`: xcasset path where to generate imagesets
4. `--extension-output-path`: path where to generate generated extension 4. `--extension-output-path`: path where to generate generated extension
5. `--extension-name` *(optional)* : name of the class to add UIKit getters 5. `--extension-name` *(optional)* : name of the class to add SwiftUI getters
6. `--extension-name-swift-ui` *(optional)* : name of the class to add SwiftUI getters 6. `--extension-name-ui-kit` *(optional)* : name of the class to add UIKit getters
6. `--extension-suffix` *(optional)* : additional text which is added to filename (ex: `AppImage+GreatApp.swift`) 6. `--extension-suffix` *(optional)* : additional text which is added to filename (ex: `AppImage+GreatApp.swift`)
7. `--static-members` *(optional)*: generate static properties or not 7. `--static-members` *(optional)*: generate static properties or not
@ -176,7 +176,7 @@ colors:
xcassetsPath: String xcassetsPath: String
extensionOutputPath: String extensionOutputPath: String
extensionName: String? extensionName: String?
extensionNameSwiftUI: String? extensionNameUIKit: String?
extensionSuffix: String? extensionSuffix: String?
staticMembers: Bool? staticMembers: Bool?
@ -185,7 +185,7 @@ fonts:
inputFile: String inputFile: String
extensionOutputPath: String extensionOutputPath: String
extensionName: String? extensionName: String?
extensionNameSwiftUI: String? extensionNameUIKit: String?
extensionSuffix: String? extensionSuffix: String?
staticMembers: Bool? staticMembers: Bool?
infoPlistPaths: [String] infoPlistPaths: [String]
@ -196,7 +196,7 @@ images:
xcassetsPath: String xcassetsPath: String
extensionOutputPath: String extensionOutputPath: String
extensionName: String? extensionName: String?
extensionNameSwiftUI: String? extensionNameUIKit: String?
extensionSuffix: String? extensionSuffix: String?
staticMembers: Bool? staticMembers: Bool?
@ -236,7 +236,7 @@ colors:
xcassetsPath: String xcassetsPath: String
extensionOutputPath: String extensionOutputPath: String
extensionName: String? extensionName: String?
extensionNameSwiftUI: String? extensionNameUIKit: String?
extensionSuffix: String? extensionSuffix: String?
staticMembers: Bool? staticMembers: Bool?
- -
@ -245,7 +245,7 @@ colors:
xcassetsPath: String xcassetsPath: String
extensionOutputPath: String extensionOutputPath: String
extensionName: String? extensionName: String?
extensionNameSwiftUI: String? extensionNameUIKit: String?
extensionSuffix: String? extensionSuffix: String?
staticMembers: Bool? staticMembers: Bool?
... ...

View File

@ -18,7 +18,6 @@ struct Analytics: ParsableCommand {
version: ResgenSwiftVersion version: ResgenSwiftVersion
) )
// MARK: - Static // MARK: - Static
static let toolName = "Analytics" static let toolName = "Analytics"

View File

@ -32,7 +32,7 @@ class AnalyticsGenerator {
let extensionFilePathURL = URL(fileURLWithPath: extensionFilePath) let extensionFilePathURL = URL(fileURLWithPath: extensionFilePath)
do { do {
try extensionFileContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8) try extensionFileContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8)
} catch (let error) { } catch let error {
let error = StringiumError.writeFile(extensionFilePath, error.localizedDescription) let error = StringiumError.writeFile(extensionFilePath, error.localizedDescription)
print(error.description) print(error.description)
Stringium.exit(withError: error) Stringium.exit(withError: error)

View File

@ -25,7 +25,7 @@ class AnalyticsDefinition {
} }
func hasOneOrMoreMatchingTags(inputTags: [String]) -> Bool { func hasOneOrMoreMatchingTags(inputTags: [String]) -> Bool {
if Set(inputTags).intersection(Set(self.tags)).isEmpty { if Set(inputTags).isDisjoint(with: tags) {
return false return false
} }
return true return true
@ -47,7 +47,7 @@ class AnalyticsDefinition {
var result: String var result: String
if type == .screen { if type == .screen {
params = params.filter{ param in params = params.filter { param in
!param.replaceIn.isEmpty !param.replaceIn.isEmpty
} }
} }
@ -71,7 +71,7 @@ class AnalyticsDefinition {
return result return result
} }
private func replaceIn(){ private func replaceIn() {
for parameter in parameters { for parameter in parameters {
for rep in parameter.replaceIn { for rep in parameter.replaceIn {
switch rep { switch rep {

View File

@ -30,7 +30,7 @@ struct ColorExtensionGenerator {
let extensionFilePathURL = URL(fileURLWithPath: extensionFilePath) let extensionFilePathURL = URL(fileURLWithPath: extensionFilePath)
do { do {
try extensionContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8) try extensionContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8)
} catch (let error) { } catch let error {
let error = ColorsToolError.writeExtension(extensionFilePath, error.localizedDescription) let error = ColorsToolError.writeExtension(extensionFilePath, error.localizedDescription)
print(error.description) print(error.description)
Colors.exit(withError: error) Colors.exit(withError: error)

View File

@ -38,7 +38,7 @@ struct ColorXcassetHelper {
let contentsJsonPathURL = URL(fileURLWithPath: contentsJsonPath) let contentsJsonPathURL = URL(fileURLWithPath: contentsJsonPath)
do { do {
try color.contentsJSON().write(to: contentsJsonPathURL, atomically: false, encoding: .utf8) try color.contentsJSON().write(to: contentsJsonPathURL, atomically: false, encoding: .utf8)
} catch (let error) { } catch let error {
let error = ColorsToolError.writeAsset(error.localizedDescription) let error = ColorsToolError.writeAsset(error.localizedDescription)
print(error.description) print(error.description)
Colors.exit(withError: error) Colors.exit(withError: error)

View File

@ -36,7 +36,7 @@ class FontExtensionGenerator {
let extensionFilePathURL = URL(fileURLWithPath: extensionFilePath) let extensionFilePathURL = URL(fileURLWithPath: extensionFilePath)
do { do {
try extensionContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8) try extensionContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8)
} catch (let error) { } catch let error {
let error = FontsToolError.writeExtension(extensionFilePath, error.localizedDescription) let error = FontsToolError.writeExtension(extensionFilePath, error.localizedDescription)
print(error.description) print(error.description)
Fonts.exit(withError: error) Fonts.exit(withError: error)

View File

@ -5,8 +5,6 @@
// Created by Thibaut Schmitt on 30/08/2022. // Created by Thibaut Schmitt on 30/08/2022.
// //
import Foundation
import Foundation import Foundation
import ArgumentParser import ArgumentParser

View File

@ -30,7 +30,7 @@ struct ArchitectureGenerator {
let architectureFilePathURL = URL(fileURLWithPath: "\(filePath)/\(filename)") let architectureFilePathURL = URL(fileURLWithPath: "\(filePath)/\(filename)")
do { do {
try architectureContent.write(to: architectureFilePathURL, atomically: false, encoding: .utf8) try architectureContent.write(to: architectureFilePathURL, atomically: false, encoding: .utf8)
} catch (let error) { } catch let error {
let error = GenerateError.writeFile(filename, error.localizedDescription) let error = GenerateError.writeFile(filename, error.localizedDescription)
print(error.description) print(error.description)
Generate.exit(withError: error) Generate.exit(withError: error)

View File

@ -10,4 +10,3 @@ import Foundation
protocol Runnable { protocol Runnable {
func run(projectDirectory: String, force: Bool) func run(projectDirectory: String, force: Bool)
} }

View File

@ -18,7 +18,7 @@ extension FileManager {
for case let fileURL as URL in enumerator { for case let fileURL as URL in enumerator {
do { do {
let fileAttributes = try fileURL.resourceValues(forKeys:[.isRegularFileKey]) let fileAttributes = try fileURL.resourceValues(forKeys: [.isRegularFileKey])
if fileAttributes.isRegularFile! { if fileAttributes.isRegularFile! {
files.append(fileURL.relativePath) files.append(fileURL.relativePath)
} }
@ -41,7 +41,7 @@ extension FileManager {
for case let fileURL as URL in enumerator { for case let fileURL as URL in enumerator {
do { do {
let fileAttributes = try fileURL.resourceValues(forKeys:[.isDirectoryKey]) let fileAttributes = try fileURL.resourceValues(forKeys: [.isDirectoryKey])
if fileAttributes.isDirectory! && fileURL.lastPathComponent.hasSuffix(".imageset") { if fileAttributes.isDirectory! && fileURL.lastPathComponent.hasSuffix(".imageset") {
files.append(fileURL.lastPathComponent) files.append(fileURL.lastPathComponent)
} }

View File

@ -29,7 +29,7 @@ class ImageExtensionGenerator {
let extensionFilePathURL = URL(fileURLWithPath: extensionFilePath) let extensionFilePathURL = URL(fileURLWithPath: extensionFilePath)
do { do {
try extensionContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8) try extensionContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8)
} catch (let error) { } catch let error {
let error = ImagesError.writeFile(extensionFilePath, error.localizedDescription) let error = ImagesError.writeFile(extensionFilePath, error.localizedDescription)
print(error.description) print(error.description)
Images.exit(withError: error) Images.exit(withError: error)

View File

@ -34,7 +34,7 @@ class StringsFileGenerator {
let stringsFilePathURL = URL(fileURLWithPath: stringsFilePath) let stringsFilePathURL = URL(fileURLWithPath: stringsFilePath)
do { do {
try fileContent.write(to: stringsFilePathURL, atomically: false, encoding: .utf8) try fileContent.write(to: stringsFilePathURL, atomically: false, encoding: .utf8)
} catch (let error) { } catch let error {
let error = StringiumError.writeFile(error.localizedDescription, stringsFilePath) let error = StringiumError.writeFile(error.localizedDescription, stringsFilePath)
print(error.description) print(error.description)
Stringium.exit(withError: error) Stringium.exit(withError: error)
@ -115,7 +115,7 @@ class StringsFileGenerator {
let extensionFilePathURL = URL(fileURLWithPath: extensionFilePath) let extensionFilePathURL = URL(fileURLWithPath: extensionFilePath)
do { do {
try extensionFileContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8) try extensionFileContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8)
} catch (let error) { } catch let error {
let error = StringiumError.writeFile(extensionFilePath, error.localizedDescription) let error = StringiumError.writeFile(extensionFilePath, error.localizedDescription)
print(error.description) print(error.description)
Stringium.exit(withError: error) Stringium.exit(withError: error)

View File

@ -22,7 +22,7 @@ class TagsGenerator {
let extensionFilePathURL = URL(fileURLWithPath: extensionFilePath) let extensionFilePathURL = URL(fileURLWithPath: extensionFilePath)
do { do {
try extensionFileContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8) try extensionFileContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8)
} catch (let error) { } catch let error {
let error = StringiumError.writeFile(extensionFilePath, error.localizedDescription) let error = StringiumError.writeFile(extensionFilePath, error.localizedDescription)
print(error.description) print(error.description)
Stringium.exit(withError: error) Stringium.exit(withError: error)

View File

@ -37,7 +37,7 @@ class Definition {
} }
func hasOneOrMoreMatchingTags(inputTags: [String]) -> Bool { func hasOneOrMoreMatchingTags(inputTags: [String]) -> Bool {
if Set(inputTags).intersection(Set(self.tags)).isEmpty { if Set(inputTags).isDisjoint(with: tags) {
return false return false
} }
return true return true

View File

@ -27,4 +27,3 @@ struct Strings: ParsableCommand {
} }
//Strings.main() //Strings.main()

View File

@ -18,7 +18,6 @@ struct Tags: ParsableCommand {
version: ResgenSwiftVersion version: ResgenSwiftVersion
) )
// MARK: - Static // MARK: - Static
static let toolName = "Tags" static let toolName = "Tags"

View File

@ -21,7 +21,7 @@ final class ColorsConfigurationTests: XCTestCase {
xcassetsPath: "path/to/assets.xcassets", xcassetsPath: "path/to/assets.xcassets",
extensionOutputPath: "Colors/Generated", extensionOutputPath: "Colors/Generated",
extensionName: nil, extensionName: nil,
extensionNameSwiftUI: nil, extensionNameUIKit: nil,
extensionSuffix: nil, extensionSuffix: nil,
staticMembers: false) staticMembers: false)
// When // When
@ -50,7 +50,7 @@ final class ColorsConfigurationTests: XCTestCase {
xcassetsPath: "path/to/assets.xcassets", xcassetsPath: "path/to/assets.xcassets",
extensionOutputPath: "Colors/Generated", extensionOutputPath: "Colors/Generated",
extensionName: "AppUIColor", extensionName: "AppUIColor",
extensionNameSwiftUI: "AppColor", extensionNameUIKit: "AppColor",
extensionSuffix: "Testing", extensionSuffix: "Testing",
staticMembers: false) staticMembers: false)
// When // When
@ -70,7 +70,7 @@ final class ColorsConfigurationTests: XCTestCase {
"false", "false",
"--extension-name", "--extension-name",
"AppUIColor", "AppUIColor",
"--extension-name-swift-ui", "--extension-name-ui-kit",
"AppColor", "AppColor",
"--extension-suffix", "--extension-suffix",
"Testing", "Testing",

View File

@ -19,7 +19,7 @@ final class FontsConfigurationTests: XCTestCase {
let testingConfiguration = FontsConfiguration(inputFile: "path/to/fonts.txt", let testingConfiguration = FontsConfiguration(inputFile: "path/to/fonts.txt",
extensionOutputPath: "Fonts/Generated", extensionOutputPath: "Fonts/Generated",
extensionName: nil, extensionName: nil,
extensionNameSwiftUI: nil, extensionNameUIKit: nil,
extensionSuffix: nil, extensionSuffix: nil,
infoPlistPaths: nil, infoPlistPaths: nil,
staticMembers: nil) staticMembers: nil)
@ -43,7 +43,7 @@ final class FontsConfigurationTests: XCTestCase {
let testingConfiguration = FontsConfiguration(inputFile: "path/to/fonts.txt", let testingConfiguration = FontsConfiguration(inputFile: "path/to/fonts.txt",
extensionOutputPath: "Fonts/Generated", extensionOutputPath: "Fonts/Generated",
extensionName: "AppUIFont", extensionName: "AppUIFont",
extensionNameSwiftUI: "AppFont", extensionNameUIKit: "AppFont",
extensionSuffix: "Testing", extensionSuffix: "Testing",
infoPlistPaths: "path/to/plist1.plist path/to/plist2.plist", infoPlistPaths: "path/to/plist1.plist path/to/plist2.plist",
staticMembers: true) staticMembers: true)
@ -60,7 +60,7 @@ final class FontsConfigurationTests: XCTestCase {
"true", "true",
"--extension-name", "--extension-name",
"AppUIFont", "AppUIFont",
"--extension-name-swift-ui", "--extension-name-ui-kit",
"AppFont", "AppFont",
"--extension-suffix", "--extension-suffix",
"Testing", "Testing",

View File

@ -20,7 +20,7 @@ final class ImagesConfigurationTests: XCTestCase {
xcassetsPath: "path/to/assets.xcassets", xcassetsPath: "path/to/assets.xcassets",
extensionOutputPath: "Images/Generated", extensionOutputPath: "Images/Generated",
extensionName: nil, extensionName: nil,
extensionNameSwiftUI: nil, extensionNameUIKit: nil,
extensionSuffix: nil, extensionSuffix: nil,
staticMembers: nil) staticMembers: nil)
@ -47,7 +47,7 @@ final class ImagesConfigurationTests: XCTestCase {
xcassetsPath: "path/to/assets.xcassets", xcassetsPath: "path/to/assets.xcassets",
extensionOutputPath: "Images/Generated", extensionOutputPath: "Images/Generated",
extensionName: "AppUIImage", extensionName: "AppUIImage",
extensionNameSwiftUI: "AppImage", extensionNameUIKit: "AppImage",
extensionSuffix: "Testing", extensionSuffix: "Testing",
staticMembers: true) staticMembers: true)
@ -66,7 +66,7 @@ final class ImagesConfigurationTests: XCTestCase {
"true", "true",
"--extension-name", "--extension-name",
"AppUIImage", "AppUIImage",
"--extension-name-swift-ui", "--extension-name-ui-kit",
"AppImage", "AppImage",
"--extension-suffix", "--extension-suffix",
"Testing", "Testing",

48
script/swiftlint.sh Executable file
View File

@ -0,0 +1,48 @@
#!/bin/sh
# Go to git repo root level
cd $(git rev-parse --show-toplevel)
if [[ "$BUILD_DIR" == *"IBDesignables"* ]] || [[ "$BUILD_DIR" == *"Previews"* ]] ; then
echo "not linting for IBDesignables/SwiftUI Previews builds";
exit 0
fi
SWIFT_LINT=$(which swiftlint)
if [[ -z $SWIFT_LINT ]] ; then
echo "warning: SwiftLint not installed, please download it from https://github.com/realm/SwiftLint"
exit 0
fi
if [[ $RUN_CLANG_STATIC_ANALYZER == "YES" ]] ; then
time $SWIFT_LINT
else
COUNT=0
##### Check for modified git files #####
FILES=$(git diff --name-only | grep -iv "^carthage" | grep -iv "^pods" | grep -iv "^vendor" | grep -v "R2" | grep ".swift$")
if [ ! -z "$FILES" ]; then
while read FILE_PATH; do
export SCRIPT_INPUT_FILE_$COUNT=$FILE_PATH
COUNT=$((COUNT + 1))
done <<< "$FILES"
fi
##### Check for modified files in unstaged/Staged area #####
FILES=$(git diff --name-only --cached --diff-filter=d | grep -iv "^carthage" | grep -iv "^pods" | grep -iv "^vendor" | grep -v "R2" | grep ".swift$")
if [ ! -z "$FILES" ]; then
while read FILE_PATH; do
export SCRIPT_INPUT_FILE_$COUNT=$FILE_PATH
COUNT=$((COUNT + 1))
done <<< "$FILES"
fi
##### Make the count avilable as global variable #####
export SCRIPT_INPUT_FILE_COUNT=$COUNT
env | grep SCRIPT_INPUT_FILE_
if [[ COUNT -ne 0 ]] ; then
time $SWIFT_LINT --use-script-input-files
fi
fi