From cd873ca5d9ec26cb23ff32d5cc8dcc990ab7bcd3 Mon Sep 17 00:00:00 2001 From: Loris Perret Date: Fri, 8 Dec 2023 16:15:28 +0100 Subject: [PATCH] Fix Color --- SampleFiles/genAllRessources.sh | 22 +++++++++---------- SampleFiles/resgenConfiguration.yml | 4 ++-- Sources/ResgenSwift/Colors/Colors.swift | 14 ++++++------ .../Colors/ColorsToolOptions.swift | 20 ++++++++--------- .../Generate/Model/ConfigurationFile.swift | 8 +++---- .../ColorsConfiguration+Runnable.swift | 6 ++--- 6 files changed, 37 insertions(+), 37 deletions(-) diff --git a/SampleFiles/genAllRessources.sh b/SampleFiles/genAllRessources.sh index fc001fd..9c3d980 100755 --- a/SampleFiles/genAllRessources.sh +++ b/SampleFiles/genAllRessources.sh @@ -17,8 +17,8 @@ FORCE_FLAG="$1" # --style all \ # --xcassets-path "./Colors/colors.xcassets" \ # --extension-output-path "./Colors/Generated/" \ -# --extension-name "UIColorYolo" \ -# --extension-name-swift-ui "ColorYolo" \ +# --extension-name "ColorYolo" \ +# --extension-name-ui-kit "UIhkjhkColorYolo" \ # --extension-suffix "GenAllScript" # #echo "\n-------------------------\n" @@ -49,17 +49,17 @@ FORCE_FLAG="$1" # --extension-output-path "./Tags/Generated" \ # --extension-name "Tags" \ # --extension-suffix "GenAllScript" -# -echo "\n-------------------------\n" -# Analytics -swift run -c release ResgenSwift analytics $FORCE_FLAG "./Tags/sampleTags.yml" \ - --target "matomo firebase" \ - --extension-output-path "./Tags/Generated" \ - --extension-name "Analytics" \ - --extension-suffix "GenAllScript" +#echo "\n-------------------------\n" -echo "\n-------------------------\n" +## Analytics +#swift run -c release ResgenSwift analytics $FORCE_FLAG "./Tags/sampleTags.yml" \ +# --target "matomo firebase" \ +# --extension-output-path "./Tags/Generated" \ +# --extension-name "Analytics" \ +# --extension-suffix "GenAllScript" + +#echo "\n-------------------------\n" # ## Images #swift run -c release ResgenSwift images $FORCE_FLAG "./Images/sampleImages.txt" \ diff --git a/SampleFiles/resgenConfiguration.yml b/SampleFiles/resgenConfiguration.yml index 512fc67..4ca05d2 100644 --- a/SampleFiles/resgenConfiguration.yml +++ b/SampleFiles/resgenConfiguration.yml @@ -61,8 +61,8 @@ colors: style: all xcassetsPath: ./Colors/colors.xcassets extensionOutputPath: ./Colors/Generated/ - extensionName: UIColorYolo - extensionNameSwiftUI: ColorYolo + extensionName: ColorYolo + extensionNameUIKit: UIColorYolo extensionSuffix: GenAllScript diff --git a/Sources/ResgenSwift/Colors/Colors.swift b/Sources/ResgenSwift/Colors/Colors.swift index 9ee1286..722d08a 100644 --- a/Sources/ResgenSwift/Colors/Colors.swift +++ b/Sources/ResgenSwift/Colors/Colors.swift @@ -21,8 +21,8 @@ struct Colors: ParsableCommand { // MARK: - Static static let toolName = "Color" - static let defaultExtensionName = "UIColor" - static let defaultExtensionNameSUI = "Color" + static let defaultExtensionName = "Color" + static let defaultExtensionNameUIKit = "UIColor" static let assetsColorsFolderName = "Colors" // MARK: - Command options @@ -57,14 +57,14 @@ struct Colors: ParsableCommand { staticVar: options.staticMembers, extensionName: options.extensionName, extensionFilePath: options.extensionFilePath, - isSwiftUI: false) + isSwiftUI: true) // Generate extension ColorExtensionGenerator.writeExtensionFile(colors: parsedColors, staticVar: options.staticMembers, - extensionName: options.extensionNameSwiftUI, - extensionFilePath: options.extensionFilePathSwiftUI, - isSwiftUI: true) + extensionName: options.extensionNameUIKit, + extensionFilePath: options.extensionFilePathUIKit, + isSwiftUI: false) print("[\(Self.toolName)] Colors generated") } @@ -89,7 +89,7 @@ struct Colors: ParsableCommand { } // Extension for UIKit and SwiftUI should have different name - guard options.extensionName != options.extensionNameSwiftUI else { + guard options.extensionName != options.extensionNameUIKit else { let error = ColorsToolError.extensionNamesCollision(options.extensionName) print(error.description) Colors.exit(withError: error) diff --git a/Sources/ResgenSwift/Colors/ColorsToolOptions.swift b/Sources/ResgenSwift/Colors/ColorsToolOptions.swift index 5c9144e..868d753 100644 --- a/Sources/ResgenSwift/Colors/ColorsToolOptions.swift +++ b/Sources/ResgenSwift/Colors/ColorsToolOptions.swift @@ -27,11 +27,11 @@ struct ColorsToolOptions: ParsableArguments { @Option(help: "Tell if it will generate static properties or not") var staticMembers: Bool = false - @Option(help: "Extension name. If not specified, it will generate an UIColor extension.") + @Option(help: "Extension name. If not specified, it will generate an Color extension.") var extensionName: String = Colors.defaultExtensionName - @Option(help: "SwiftUI Extension name. If not specified, it will generate an Color extension.") - var extensionNameSwiftUI: String = Colors.defaultExtensionNameSUI + @Option(help: "SwiftUI Extension name. If not specified, it will generate an UIColor extension.") + var extensionNameUIKit: String = Colors.defaultExtensionNameUIKit @Option(help: "Extension suffix. Ex: MyApp, it will generate {extensionName}+ColorsMyApp.swift") var extensionSuffix: String? @@ -41,7 +41,7 @@ struct ColorsToolOptions: ParsableArguments { extension ColorsToolOptions { - // MARK: - UIKit + // MARK: - SwiftUI var extensionFileName: String { if let extensionSuffix = extensionSuffix { @@ -54,16 +54,16 @@ extension ColorsToolOptions { "\(extensionOutputPath)/\(extensionFileName)" } - // MARK: - SwiftUI + // MARK: - UIKit - var extensionFileNameSwiftUI: String { + var extensionFileNameUIKit: String { if let extensionSuffix = extensionSuffix { - return "\(extensionNameSwiftUI)+\(extensionSuffix).swift" + return "\(extensionNameUIKit)+\(extensionSuffix).swift" } - return "\(extensionNameSwiftUI).swift" + return "\(extensionNameUIKit).swift" } - var extensionFilePathSwiftUI: String { - "\(extensionOutputPath)/\(extensionFileNameSwiftUI)" + var extensionFilePathUIKit: String { + "\(extensionOutputPath)/\(extensionFileNameUIKit)" } } diff --git a/Sources/ResgenSwift/Generate/Model/ConfigurationFile.swift b/Sources/ResgenSwift/Generate/Model/ConfigurationFile.swift index a631426..cb75c38 100644 --- a/Sources/ResgenSwift/Generate/Model/ConfigurationFile.swift +++ b/Sources/ResgenSwift/Generate/Model/ConfigurationFile.swift @@ -127,7 +127,7 @@ struct ColorsConfiguration: Codable, CustomDebugStringConvertible { let xcassetsPath: String let extensionOutputPath: String let extensionName: String? - let extensionNameSwiftUI: String? + let extensionNameUIKit: String? let extensionSuffix: String? private let staticMembers: Bool? @@ -143,7 +143,7 @@ struct ColorsConfiguration: Codable, CustomDebugStringConvertible { xcassetsPath: String, extensionOutputPath: String, extensionName: String?, - extensionNameSwiftUI: String?, + extensionNameUIKit: String?, extensionSuffix: String?, staticMembers: Bool?) { self.inputFile = inputFile @@ -151,7 +151,7 @@ struct ColorsConfiguration: Codable, CustomDebugStringConvertible { self.xcassetsPath = xcassetsPath self.extensionOutputPath = extensionOutputPath self.extensionName = extensionName - self.extensionNameSwiftUI = extensionNameSwiftUI + self.extensionNameUIKit = extensionNameUIKit self.extensionSuffix = extensionSuffix self.staticMembers = staticMembers } @@ -164,7 +164,7 @@ struct ColorsConfiguration: Codable, CustomDebugStringConvertible { - Xcassets path: \(xcassetsPath) - Extension output path: \(extensionOutputPath) - Extension name: \(extensionName ?? "-") - - Extension name SwiftUI: \(extensionNameSwiftUI ?? "-") + - Extension name UIKit: \(extensionNameUIKit ?? "-") - Extension suffix: \(extensionSuffix ?? "-") """ } diff --git a/Sources/ResgenSwift/Generate/Runnable/ColorsConfiguration+Runnable.swift b/Sources/ResgenSwift/Generate/Runnable/ColorsConfiguration+Runnable.swift index 1965373..5c8f735 100644 --- a/Sources/ResgenSwift/Generate/Runnable/ColorsConfiguration+Runnable.swift +++ b/Sources/ResgenSwift/Generate/Runnable/ColorsConfiguration+Runnable.swift @@ -38,10 +38,10 @@ extension ColorsConfiguration: Runnable { extensionName ] } - if let extensionNameSwiftUI = extensionNameSwiftUI { + if let extensionNameUIKit = extensionNameUIKit { args += [ - "--extension-name-swift-ui", - extensionNameSwiftUI + "--extension-name-ui-kit", + extensionNameUIKit ] } if let extensionSuffix = extensionSuffix {