3 Commits

Author SHA1 Message Date
caa3295dce Fix SwiftLint warning
All checks were successful
gitea-openium/resgen.swift/pipeline/head This commit looks good
gitea-openium/resgen.swift/pipeline/pr-master This commit looks good
2025-07-18 14:09:25 +02:00
352633fddd Add ArgumentParser dependency to ToolCore target
Some checks reported warnings
gitea-openium/resgen.swift/pipeline/head This commit is unstable
2025-07-18 11:58:19 +02:00
7162f13166 Add visibility parameters to control scope of generated extension
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
2025-07-18 11:53:46 +02:00
62 changed files with 1526 additions and 794 deletions

View File

@ -40,7 +40,15 @@ let package = Package(
), ),
// Helper targets // Helper targets
.target(name: "ToolCore"), .target(
name: "ToolCore",
dependencies: [
.product(
name: "ArgumentParser",
package: "swift-argument-parser"
)
]
),
// Test targets // Test targets
.testTarget( .testTarget(

View File

@ -144,9 +144,7 @@ Analytics will generate all you need to analyze UX with Matomo or Firebase Analy
```sh ```sh
swift run -c release ResgenSwift analytics $FORCE_FLAG "./Tags/analytics.yml" \ swift run -c release ResgenSwift analytics $FORCE_FLAG "./Tags/analytics.yml" \
--target "matomo firebase" \ --target "matomo firebase" \
--extension-output-path "./Analytics/Generated" \ --output-file "./Analytics/Generated/AppAnalytics+GreatApp.swift" \
--extension-name "AppAnalytics" \
--extension-suffix "GreatApp" \
--static-members true --static-members true
``` ```
@ -155,9 +153,7 @@ swift run -c release ResgenSwift analytics $FORCE_FLAG "./Tags/analytics.yml" \
1. `-f`: force generation 1. `-f`: force generation
2. Input tags file (must be YAML formatted) 2. Input tags file (must be YAML formatted)
3. `--target`: target with you will log UX 3. `--target`: target with you will log UX
4. `--extension-output-path`: path where to generate generated extension 4. `--output-file`: file where where to generate generated code, must contains path and filename (ex: `./Analytics/Generated/AppAnalytics+GreatApp.swift`)
5. `--extension-name` *(optional)* : name of class to add the extension
6. `--extension-suffix` *(optional)* : additional text which is added to filename (ex: `AppAnalytics+GreatApp.swift`)
7. `--static-members` *(optional)*: generate static properties or not 7. `--static-members` *(optional)*: generate static properties or not
> ⚠️ If extension name is not set or is `Analytics`, it will generate the following typealias `typealias Analytics = String`. > ⚠️ If extension name is not set or is `Analytics`, it will generate the following typealias `typealias Analytics = String`.

View File

@ -1,21 +1,21 @@
// Generated by ResgenSwift.Color 2.1.0 // Generated by ResgenSwift.Color 2.2.0
import SwiftUI import SwiftUI
extension ColorYolo { extension ColorYolo {
/// Color red is #FF0000 (light) or #FF0000 (dark)" /// Color red is #FF0000 (light) or #FF0000 (dark)"
var red: Color { public var red: Color {
Color("red") Color("red")
} }
/// Color green_alpha_50 is #A000FF00 (light) or #A000FF00 (dark)" /// Color green_alpha_50 is #A000FF00 (light) or #A000FF00 (dark)"
var green_alpha_50: Color { public var green_alpha_50: Color {
Color("green_alpha_50") Color("green_alpha_50")
} }
/// Color blue_light_dark is #0000FF (light) or #0000AA (dark)" /// Color blue_light_dark is #0000FF (light) or #0000AA (dark)"
var blue_light_dark: Color { public var blue_light_dark: Color {
Color("blue_light_dark") Color("blue_light_dark")
} }
} }

View File

@ -1,21 +1,21 @@
// Generated by ResgenSwift.Color 2.1.0 // Generated by ResgenSwift.Color 2.2.0
import UIKit import UIKit
extension UIColorYolo { extension UIColorYolo {
/// Color red is #FF0000 (light) or #FF0000 (dark)" /// Color red is #FF0000 (light) or #FF0000 (dark)"
@objc var red: UIColor { @objc public var red: UIColor {
UIColor(named: "red")! UIColor(named: "red")!
} }
/// Color green_alpha_50 is #A000FF00 (light) or #A000FF00 (dark)" /// Color green_alpha_50 is #A000FF00 (light) or #A000FF00 (dark)"
@objc var green_alpha_50: UIColor { @objc public var green_alpha_50: UIColor {
UIColor(named: "green_alpha_50")! UIColor(named: "green_alpha_50")!
} }
/// Color blue_light_dark is #0000FF (light) or #0000AA (dark)" /// Color blue_light_dark is #0000FF (light) or #0000AA (dark)"
@objc var blue_light_dark: UIColor { @objc public var blue_light_dark: UIColor {
UIColor(named: "blue_light_dark")! UIColor(named: "blue_light_dark")!
} }
} }

View File

@ -1,10 +1,10 @@
// Generated by ResgenSwift.Fonts 2.1.0 // Generated by ResgenSwift.Fonts 2.2.0
import SwiftUI import SwiftUI
extension FontYolo { extension FontYolo {
enum FontName: String { public enum FontName: String {
case LatoItalic = "Lato-Italic" case LatoItalic = "Lato-Italic"
case LatoLightItalic = "Lato-LightItalic" case LatoLightItalic = "Lato-LightItalic"
case LatoHairline = "Lato-Hairline" case LatoHairline = "Lato-Hairline"
@ -19,43 +19,43 @@ extension FontYolo {
// MARK: - Getter // MARK: - Getter
func LatoItalic(withSize size: CGFloat) -> Font { public func LatoItalic(withSize size: CGFloat) -> Font {
Font.custom(FontName.LatoItalic.rawValue, size: size) Font.custom(FontName.LatoItalic.rawValue, size: size)
} }
func LatoLightItalic(withSize size: CGFloat) -> Font { public func LatoLightItalic(withSize size: CGFloat) -> Font {
Font.custom(FontName.LatoLightItalic.rawValue, size: size) Font.custom(FontName.LatoLightItalic.rawValue, size: size)
} }
func LatoHairline(withSize size: CGFloat) -> Font { public func LatoHairline(withSize size: CGFloat) -> Font {
Font.custom(FontName.LatoHairline.rawValue, size: size) Font.custom(FontName.LatoHairline.rawValue, size: size)
} }
func LatoBold(withSize size: CGFloat) -> Font { public func LatoBold(withSize size: CGFloat) -> Font {
Font.custom(FontName.LatoBold.rawValue, size: size) Font.custom(FontName.LatoBold.rawValue, size: size)
} }
func LatoBlack(withSize size: CGFloat) -> Font { public func LatoBlack(withSize size: CGFloat) -> Font {
Font.custom(FontName.LatoBlack.rawValue, size: size) Font.custom(FontName.LatoBlack.rawValue, size: size)
} }
func LatoRegular(withSize size: CGFloat) -> Font { public func LatoRegular(withSize size: CGFloat) -> Font {
Font.custom(FontName.LatoRegular.rawValue, size: size) Font.custom(FontName.LatoRegular.rawValue, size: size)
} }
func LatoBlackItalic(withSize size: CGFloat) -> Font { public func LatoBlackItalic(withSize size: CGFloat) -> Font {
Font.custom(FontName.LatoBlackItalic.rawValue, size: size) Font.custom(FontName.LatoBlackItalic.rawValue, size: size)
} }
func LatoBoldItalic(withSize size: CGFloat) -> Font { public func LatoBoldItalic(withSize size: CGFloat) -> Font {
Font.custom(FontName.LatoBoldItalic.rawValue, size: size) Font.custom(FontName.LatoBoldItalic.rawValue, size: size)
} }
func LatoLight(withSize size: CGFloat) -> Font { public func LatoLight(withSize size: CGFloat) -> Font {
Font.custom(FontName.LatoLight.rawValue, size: size) Font.custom(FontName.LatoLight.rawValue, size: size)
} }
func LatoHairlineItalic(withSize size: CGFloat) -> Font { public func LatoHairlineItalic(withSize size: CGFloat) -> Font {
Font.custom(FontName.LatoHairlineItalic.rawValue, size: size) Font.custom(FontName.LatoHairlineItalic.rawValue, size: size)
} }
} }

View File

@ -1,10 +1,10 @@
// Generated by ResgenSwift.Fonts 2.1.0 // Generated by ResgenSwift.Fonts 2.2.0
import UIKit import UIKit
extension UIFontYolo { extension UIFontYolo {
enum FontName: String { public enum FontName: String {
case LatoItalic = "Lato-Italic" case LatoItalic = "Lato-Italic"
case LatoLightItalic = "Lato-LightItalic" case LatoLightItalic = "Lato-LightItalic"
case LatoHairline = "Lato-Hairline" case LatoHairline = "Lato-Hairline"
@ -19,43 +19,43 @@ extension UIFontYolo {
// MARK: - Getter // MARK: - Getter
func LatoItalic(withSize size: CGFloat) -> UIFont { public func LatoItalic(withSize size: CGFloat) -> UIFont {
UIFont(name: FontName.LatoItalic.rawValue, size: size)! UIFont(name: FontName.LatoItalic.rawValue, size: size)!
} }
func LatoLightItalic(withSize size: CGFloat) -> UIFont { public func LatoLightItalic(withSize size: CGFloat) -> UIFont {
UIFont(name: FontName.LatoLightItalic.rawValue, size: size)! UIFont(name: FontName.LatoLightItalic.rawValue, size: size)!
} }
func LatoHairline(withSize size: CGFloat) -> UIFont { public func LatoHairline(withSize size: CGFloat) -> UIFont {
UIFont(name: FontName.LatoHairline.rawValue, size: size)! UIFont(name: FontName.LatoHairline.rawValue, size: size)!
} }
func LatoBold(withSize size: CGFloat) -> UIFont { public func LatoBold(withSize size: CGFloat) -> UIFont {
UIFont(name: FontName.LatoBold.rawValue, size: size)! UIFont(name: FontName.LatoBold.rawValue, size: size)!
} }
func LatoBlack(withSize size: CGFloat) -> UIFont { public func LatoBlack(withSize size: CGFloat) -> UIFont {
UIFont(name: FontName.LatoBlack.rawValue, size: size)! UIFont(name: FontName.LatoBlack.rawValue, size: size)!
} }
func LatoRegular(withSize size: CGFloat) -> UIFont { public func LatoRegular(withSize size: CGFloat) -> UIFont {
UIFont(name: FontName.LatoRegular.rawValue, size: size)! UIFont(name: FontName.LatoRegular.rawValue, size: size)!
} }
func LatoBlackItalic(withSize size: CGFloat) -> UIFont { public func LatoBlackItalic(withSize size: CGFloat) -> UIFont {
UIFont(name: FontName.LatoBlackItalic.rawValue, size: size)! UIFont(name: FontName.LatoBlackItalic.rawValue, size: size)!
} }
func LatoBoldItalic(withSize size: CGFloat) -> UIFont { public func LatoBoldItalic(withSize size: CGFloat) -> UIFont {
UIFont(name: FontName.LatoBoldItalic.rawValue, size: size)! UIFont(name: FontName.LatoBoldItalic.rawValue, size: size)!
} }
func LatoLight(withSize size: CGFloat) -> UIFont { public func LatoLight(withSize size: CGFloat) -> UIFont {
UIFont(name: FontName.LatoLight.rawValue, size: size)! UIFont(name: FontName.LatoLight.rawValue, size: size)!
} }
func LatoHairlineItalic(withSize size: CGFloat) -> UIFont { public func LatoHairlineItalic(withSize size: CGFloat) -> UIFont {
UIFont(name: FontName.LatoHairlineItalic.rawValue, size: size)! UIFont(name: FontName.LatoHairlineItalic.rawValue, size: size)!
} }
} }

View File

@ -1,31 +1,31 @@
// Generated by ResgenSwift.Images 2.1.0 // Generated by ResgenSwift.Images 2.2.0
// Images from sampleImages // Images from sampleImages
import SwiftUI import SwiftUI
extension ImageYolo { extension ImageYolo {
var article_notification_pull_detail: Image { public var article_notification_pull_detail: Image {
Image("article_notification_pull_detail") Image("article_notification_pull_detail")
} }
var article_notification_pull: Image { public var article_notification_pull: Image {
Image("article_notification_pull") Image("article_notification_pull")
} }
var new_article: Image { public var new_article: Image {
Image("new_article") Image("new_article")
} }
var welcome_background: Image { public var welcome_background: Image {
Image("welcome_background") Image("welcome_background")
} }
var article_trash: Image { public var article_trash: Image {
Image("article_trash") Image("article_trash")
} }
var ic_close_article: Image { public var ic_close_article: Image {
Image("ic_close_article") Image("ic_close_article")
} }
} }

View File

@ -1,31 +1,31 @@
// Generated by ResgenSwift.Images 2.1.0 // Generated by ResgenSwift.Images 2.2.0
// Images from sampleImages // Images from sampleImages
import UIKit import UIKit
extension UIImageYolo { extension UIImageYolo {
var article_notification_pull_detail: UIImage { public var article_notification_pull_detail: UIImage {
UIImage(named: "article_notification_pull_detail")! UIImage(named: "article_notification_pull_detail")!
} }
var article_notification_pull: UIImage { public var article_notification_pull: UIImage {
UIImage(named: "article_notification_pull")! UIImage(named: "article_notification_pull")!
} }
var new_article: UIImage { public var new_article: UIImage {
UIImage(named: "new_article")! UIImage(named: "new_article")!
} }
var welcome_background: UIImage { public var welcome_background: UIImage {
UIImage(named: "welcome_background")! UIImage(named: "welcome_background")!
} }
var article_trash: UIImage { public var article_trash: UIImage {
UIImage(named: "article_trash")! UIImage(named: "article_trash")!
} }
var ic_close_article: UIImage { public var ic_close_article: UIImage {
UIImage(named: "ic_close_article")! UIImage(named: "ic_close_article")!
} }
} }

View File

@ -1,4 +1,4 @@
// Generated by ResgenSwift.Strings.Stringium 2.1.0 // Generated by ResgenSwift.Strings.Stringium 2.2.0
import UIKit import UIKit
@ -6,7 +6,7 @@ fileprivate let kStringsFileName = "sampleStrings"
extension String { extension String {
enum KeyGenAllScript: String { public enum KeyGenAllScript: String {
case param_lang = "param_lang" case param_lang = "param_lang"
case generic_back = "generic_back" case generic_back = "generic_back"
case generic_loading_data = "generic_loading_data" case generic_loading_data = "generic_loading_data"
@ -14,7 +14,7 @@ extension String {
case test_equal_symbol = "test_equal_symbol" case test_equal_symbol = "test_equal_symbol"
case placeholders_test_one = "placeholders_test_one" case placeholders_test_one = "placeholders_test_one"
var keyPath: KeyPath<String, String> { public var keyPath: KeyPath<String, String> {
switch self { switch self {
case .param_lang: return \String.param_lang case .param_lang: return \String.param_lang
case .generic_back: return \String.generic_back case .generic_back: return \String.generic_back
@ -33,7 +33,7 @@ extension String {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
var param_lang: String { public var param_lang: String {
NSLocalizedString("param_lang", tableName: kStringsFileName, bundle: Bundle.main, value: "en", comment: "") NSLocalizedString("param_lang", tableName: kStringsFileName, bundle: Bundle.main, value: "en", comment: "")
} }
@ -44,7 +44,7 @@ extension String {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
var generic_back: String { public var generic_back: String {
NSLocalizedString("generic_back", tableName: kStringsFileName, bundle: Bundle.main, value: "Back", comment: "") NSLocalizedString("generic_back", tableName: kStringsFileName, bundle: Bundle.main, value: "Back", comment: "")
} }
@ -53,7 +53,7 @@ extension String {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
var generic_loading_data: String { public var generic_loading_data: String {
NSLocalizedString("generic_loading_data", tableName: kStringsFileName, bundle: Bundle.main, value: "Loading data...", comment: "") NSLocalizedString("generic_loading_data", tableName: kStringsFileName, bundle: Bundle.main, value: "Loading data...", comment: "")
} }
@ -62,7 +62,7 @@ extension String {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
var generic_welcome_firstname_format: String { public var generic_welcome_firstname_format: String {
NSLocalizedString("generic_welcome_firstname_format", tableName: kStringsFileName, bundle: Bundle.main, value: "Welcome \"%@\" !", comment: "") NSLocalizedString("generic_welcome_firstname_format", tableName: kStringsFileName, bundle: Bundle.main, value: "Welcome \"%@\" !", comment: "")
} }
/// Translation in en : /// Translation in en :
@ -70,7 +70,7 @@ extension String {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
func generic_welcome_firstname_format(arg0: String) -> String { public func generic_welcome_firstname_format(arg0: String) -> String {
String(format: self.generic_welcome_firstname_format, arg0) String(format: self.generic_welcome_firstname_format, arg0)
} }
@ -81,7 +81,7 @@ extension String {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
var test_equal_symbol: String { public var test_equal_symbol: String {
NSLocalizedString("test_equal_symbol", tableName: kStringsFileName, bundle: Bundle.main, value: "1€ = 1 point !", comment: "") NSLocalizedString("test_equal_symbol", tableName: kStringsFileName, bundle: Bundle.main, value: "1€ = 1 point !", comment: "")
} }
@ -92,7 +92,7 @@ extension String {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
var placeholders_test_one: String { public var placeholders_test_one: String {
NSLocalizedString("placeholders_test_one", tableName: kStringsFileName, bundle: Bundle.main, value: "You %%: %2$@ %1$@ Age: %3$d", comment: "") NSLocalizedString("placeholders_test_one", tableName: kStringsFileName, bundle: Bundle.main, value: "You %%: %2$@ %1$@ Age: %3$d", comment: "")
} }
/// Translation in en : /// Translation in en :
@ -100,7 +100,7 @@ extension String {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
func placeholders_test_one(arg0: String, arg1: String, arg2: Int) -> String { public func placeholders_test_one(arg0: String, arg1: String, arg2: Int) -> String {
String(format: self.placeholders_test_one, arg0, arg1, arg2) String(format: self.placeholders_test_one, arg0, arg1, arg2)
} }
} }

View File

@ -1,4 +1,4 @@
// Generated by ResgenSwift.Analytics 2.1.0 // Generated by ResgenSwift.Analytics 2.2.0
import Foundation import Foundation
import MatomoTracker import MatomoTracker
@ -6,7 +6,7 @@ import FirebaseAnalytics
// MARK: - Protocol // MARK: - Protocol
protocol AnalyticsManagerProtocol { public protocol AnalyticsManagerProtocol {
func logScreen( func logScreen(
name: String, name: String,
@ -24,6 +24,72 @@ protocol AnalyticsManagerProtocol {
func setEnable(_ enable: Bool) func setEnable(_ enable: Bool)
} }
// MARK: - Matomo
class MatomoAnalyticsManager: AnalyticsManagerProtocol {
// MARK: - Properties
private var tracker: MatomoTracker
// MARK: - Init
init(siteId: String, url: String) {
debugPrint("[Matomo service] Server URL: \(url)")
debugPrint("[Matomo service] Site ID: \(siteId)")
tracker = MatomoTracker(
siteId: siteId,
baseURL: URL(string: url)!
)
#if DEBUG
tracker.dispatchInterval = 5
#endif
#if DEBUG
tracker.logger = DefaultLogger(minLevel: .verbose)
#endif
debugPrint("[Matomo service] Configured with content base: \(tracker.contentBase?.absoluteString ?? "-")")
debugPrint("[Matomo service] Opt out: \(tracker.isOptedOut)")
}
// MARK: - Methods
func logScreen(
name: String,
path: String,
params: [String: Any]?
) {
guard let trackerUrl = tracker.contentBase?.absoluteString else { return }
let urlString = URL(string: "\(trackerUrl)" + "/" + "\(path)" + "iOS")
tracker.track(
view: [name],
url: urlString
)
}
func logEvent(
name: String,
action: String,
category: String,
params: [String: Any]?
) {
tracker.track(
eventWithCategory: category,
action: action,
name: name,
number: nil,
url: nil
)
}
func setEnable(_ enable: Bool) {
tracker.isOptedOut = !enable
}
}
// MARK: - Firebase // MARK: - Firebase
class FirebaseAnalyticsManager: AnalyticsManagerProtocol { class FirebaseAnalyticsManager: AnalyticsManagerProtocol {
@ -50,7 +116,7 @@ class FirebaseAnalyticsManager: AnalyticsManagerProtocol {
}) { }) {
continue continue
} }
parameters[newKey] = newValue as? NSObject parameters[newKey] = newValue as? NSObject
} }
} }
@ -74,11 +140,11 @@ class FirebaseAnalyticsManager: AnalyticsManagerProtocol {
if category.isEmpty == false { if category.isEmpty == false {
parameters["AnalyticsParameterItemCategory"] = category as NSObject parameters["AnalyticsParameterItemCategory"] = category as NSObject
} }
if action.isEmpty == false { if action.isEmpty == false {
parameters["action"] = action as NSObject parameters["action"] = action as NSObject
} }
if let supplementaryParameters = params { if let supplementaryParameters = params {
for (newKey, newValue) in supplementaryParameters { for (newKey, newValue) in supplementaryParameters {
if parameters.contains(where: { (key: String, value: NSObject) in if parameters.contains(where: { (key: String, value: NSObject) in
@ -104,16 +170,17 @@ class FirebaseAnalyticsManager: AnalyticsManagerProtocol {
// MARK: - Traker Type // MARK: - Traker Type
enum TrackerType: CaseIterable { public enum TrackerType: CaseIterable {
case matomo
case firebase case firebase
} }
// MARK: - Manager // MARK: - Manager
class AnalyticsManager { public class AnalyticsManager {
static var shared = AnalyticsManager() public static var shared = AnalyticsManager()
private init() {} private init() {}
@ -141,18 +208,22 @@ class AnalyticsManager {
} }
} }
func enableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) { public func enableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
setAnalytics(enable: true, analytics) setAnalytics(enable: true, analytics)
} }
func disableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) { public func disableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
setAnalytics(enable: false, analytics) setAnalytics(enable: false, analytics)
} }
func configure() { public func configure(siteId: String, url: String) {
managers[TrackerType.matomo] = MatomoAnalyticsManager(
siteId: siteId,
url: url
)
managers[TrackerType.firebase] = FirebaseAnalyticsManager() managers[TrackerType.firebase] = FirebaseAnalyticsManager()
} }
// MARK: - Private Log Methods // MARK: - Private Log Methods
private func logScreen( private func logScreen(
@ -191,15 +262,15 @@ class AnalyticsManager {
// MARK: - section_one // MARK: - section_one
static func logScreenS1DefOne(title: String) { public func logScreenS1DefOne(title: String) {
AnalyticsManager.shared.logScreen( logScreen(
name: "s1 def one \(title)", name: "s1 def one \(title)",
path: "s1_def_one/\(title)", path: "s1_def_one/\(title)",
params: nil params: nil
) )
} }
func logEventS1DefTwo( public func logEventS1DefTwo(
title: String, title: String,
count: String, count: String,
test2: String = "test" test2: String = "test"
@ -219,8 +290,8 @@ class AnalyticsManager {
// MARK: - section_two // MARK: - section_two
static func logScreenS2DefOne() { public func logScreenS2DefOne() {
AnalyticsManager.shared.logScreen( logScreen(
name: "s2 def one", name: "s2 def one",
path: "s2_def_one/", path: "s2_def_one/",
params: nil params: nil

View File

@ -1,4 +1,4 @@
// Generated by ResgenSwift.Strings.Tags 2.1.0 // Generated by ResgenSwift.Strings.Tags 2.2.0
import UIKit import UIKit
@ -11,8 +11,7 @@ extension Tags {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
public var screen_one: String {
var screen_one: String {
"Ecran un" "Ecran un"
} }
@ -21,8 +20,7 @@ extension Tags {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
public var screen_two: String {
var screen_two: String {
"Ecran deux" "Ecran deux"
} }
} }

View File

@ -30,13 +30,14 @@ architecture:
# #
strings: strings:
- -
inputFile: ./Strings/sampleStrings.txt inputFile: ./Strings/sampleStrings.txt
outputPath: ./Strings/Generated outputPath: ./Strings/Generated
langs: "fr en en-us" langs: "fr en en-us"
defaultLang: en defaultLang: en
extensionOutputPath: ./Strings/Generated extensionOutputPath: ./Strings/Generated
extensionName: String extensionName: String
extensionSuffix: GenAllScript extensionSuffix: GenAllScript
visibility: public
# #
@ -50,6 +51,7 @@ images:
extensionName: ImageYolo extensionName: ImageYolo
extensionNameUIKit: UIImageYolo extensionNameUIKit: UIImageYolo
extensionSuffix: GenAllScript extensionSuffix: GenAllScript
visibility: public
# #
@ -57,13 +59,14 @@ images:
# #
colors: colors:
- -
inputFile: ./Colors/sampleColors1.txt inputFile: ./Colors/sampleColors1.txt
style: all style: all
xcassetsPath: ./Colors/colors.xcassets xcassetsPath: ./Colors/colors.xcassets
extensionOutputPath: ./Colors/Generated/ extensionOutputPath: ./Colors/Generated/
extensionName: ColorYolo extensionName: ColorYolo
extensionNameUIKit: UIColorYolo extensionNameUIKit: UIColorYolo
extensionSuffix: GenAllScript extensionSuffix: GenAllScript
visibility: public
# #
@ -76,6 +79,7 @@ tags:
extensionOutputPath: ./Tags/Generated extensionOutputPath: ./Tags/Generated
extensionName: Tags extensionName: Tags
extensionSuffix: GenAllScript extensionSuffix: GenAllScript
visibility: public
# #
@ -85,9 +89,8 @@ analytics:
- -
inputFile: ./Tags/sampleTags.yml inputFile: ./Tags/sampleTags.yml
target: "matomo firebase" target: "matomo firebase"
extensionOutputPath: ./Tags/Generated outputFile: ./Tags/Generated/Analytics+GenAllScript.swift
extensionName: Analytics visibility: public
extensionSuffix: GenAllScript
# #
@ -95,9 +98,10 @@ analytics:
# #
fonts: fonts:
- -
inputFile: ./Fonts/sampleFontsAll.txt inputFile: ./Fonts/sampleFontsAll.txt
extensionOutputPath: ./Fonts/Generated extensionOutputPath: ./Fonts/Generated
extensionName: FontYolo extensionName: FontYolo
extensionNameUIKit: UIFontYolo extensionNameUIKit: UIFontYolo
extensionSuffix: GenAllScript extensionSuffix: GenAllScript
infoPlistPaths: "./Fonts/Generated/test.plist ./Fonts/Generated/test2.plist" infoPlistPaths: "./Fonts/Generated/test.plist ./Fonts/Generated/test2.plist"
visibility: public

View File

@ -50,8 +50,8 @@ struct Analytics: ParsableCommand {
target: options.target, target: options.target,
tags: ["ios", "iosonly"], tags: ["ios", "iosonly"],
staticVar: options.staticMembers, staticVar: options.staticMembers,
extensionName: options.extensionName, outputFile: options.outputFile,
extensionFilePath: options.extensionFilePath visibility: options.extensionVisibility
) )
print("[\(Self.toolName)] Analytics generated") print("[\(Self.toolName)] Analytics generated")
@ -79,7 +79,7 @@ struct Analytics: ParsableCommand {
guard GeneratorChecker.shouldGenerate( guard GeneratorChecker.shouldGenerate(
force: options.forceGeneration, force: options.forceGeneration,
inputFilePath: options.inputFile, inputFilePath: options.inputFile,
extensionFilePath: options.extensionFilePath extensionFilePath: options.outputFile
) else { ) else {
print("[\(Self.toolName)] Analytics are already up to date :) ") print("[\(Self.toolName)] Analytics are already up to date :) ")
return false return false

View File

@ -7,45 +7,41 @@
import ArgumentParser import ArgumentParser
import Foundation import Foundation
import ToolCore
// swiftlint:disable no_grouping_extension
struct AnalyticsOptions: ParsableArguments { struct AnalyticsOptions: ParsableArguments {
@Flag(name: [.customShort("f"), .customShort("F")], help: "Should force generation") @Flag(
name: [.customShort("f"), .customShort("F")],
help: "Should force generation"
)
var forceGeneration = false var forceGeneration = false
@Argument(help: "Input files where tags ared defined.", transform: { $0.replaceTiltWithHomeDirectoryPath() }) @Argument(
help: "Input files where tags ared defined.",
transform: { $0.replaceTiltWithHomeDirectoryPath() }
)
var inputFile: String var inputFile: String
@Option(help: "Target(s) analytics to generate. (\"matomo\" | \"firebase\")") @Option(
help: "Target(s) analytics to generate. (\"matomo\" | \"firebase\")",
completion: .list(["matotmo", "firebase"])
)
var target: String var target: String
@Option(help: "Path where to generate the extension.", transform: { $0.replaceTiltWithHomeDirectoryPath() }) @Option(
var extensionOutputPath: String help: "Where to generate the analytics manager (path with filename)",
transform: { $0.replaceTiltWithHomeDirectoryPath() }
)
var outputFile: String
@Option(help: "Tell if it will generate static properties or not") @Option(help: "Tell if it will generate static properties or not")
var staticMembers: Bool = false var staticMembers: Bool = false
@Option(help: "Extension name. If not specified, it will generate a Analytics extension.") @Option(
var extensionName: String = Analytics.defaultExtensionName name: .customLong("visibility"),
help: "Visibility of extension and properties. Possibles values: public, private, package, internal. Default is internal",
@Option(help: "Extension suffix. Ex: MyApp, it will generate {extensionName}+Analytics{extensionSuffix}.swift") completion: .list(["public", "private", "package", "internal"])
var extensionSuffix: String? )
} var extensionVisibility: ExtensionVisibility = .internal
// MARK: - Computed var
extension AnalyticsOptions {
var extensionFileName: String {
if let extensionSuffix {
return "\(extensionName)+\(extensionSuffix).swift"
}
return "\(extensionName).swift"
}
var extensionFilePath: String {
"\(extensionOutputPath)/\(extensionFileName)"
}
} }

View File

@ -23,8 +23,8 @@ enum AnalyticsGenerator {
target: String, target: String,
tags: [String], tags: [String],
staticVar: Bool, staticVar: Bool,
extensionName: String, outputFile: String,
extensionFilePath: String visibility: ExtensionVisibility
) { ) {
// Get target type from enum // Get target type from enum
let targetsString: [String] = target.components(separatedBy: " ") let targetsString: [String] = target.components(separatedBy: " ")
@ -44,15 +44,15 @@ enum AnalyticsGenerator {
sections: sections, sections: sections,
tags: tags, tags: tags,
staticVar: staticVar, staticVar: staticVar,
extensionName: extensionName visibility: visibility
) )
// Write content // Write content
let extensionFilePathURL = URL(fileURLWithPath: extensionFilePath) let outputFilePathURL = URL(fileURLWithPath: outputFile)
do { do {
try extensionFileContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8) try extensionFileContent.write(to: outputFilePathURL, atomically: false, encoding: .utf8)
} catch { } catch {
let error = AnalyticsError.writeFile(extensionFilePath, error.localizedDescription) let error = AnalyticsError.writeFile(outputFile, error.localizedDescription)
print(error.description) print(error.description)
Analytics.exit(withError: error) Analytics.exit(withError: error)
} }
@ -65,18 +65,19 @@ enum AnalyticsGenerator {
sections: [AnalyticsCategory], sections: [AnalyticsCategory],
tags: [String], tags: [String],
staticVar: Bool, staticVar: Bool,
extensionName: String visibility: ExtensionVisibility
) -> String { ) -> String {
[ [
getHeader( getHeader(
targets: targets, targets: targets,
extensionClassname: extensionName, staticVar: staticVar,
staticVar: staticVar visibility: visibility
), ),
getProperties( getProperties(
sections: sections, sections: sections,
tags: tags, tags: tags,
staticVar: staticVar staticVar: staticVar,
visibility: visibility
), ),
getFooter() getFooter()
] ]
@ -87,23 +88,23 @@ enum AnalyticsGenerator {
private static func getHeader( private static func getHeader(
targets: [TrackerType], targets: [TrackerType],
extensionClassname: String, staticVar: Bool,
staticVar: Bool visibility: ExtensionVisibility
) -> String { ) -> String {
""" """
// Generated by ResgenSwift.\(Analytics.toolName) \(ResgenSwiftVersion) // Generated by ResgenSwift.\(Analytics.toolName) \(ResgenSwiftVersion)
\(Self.getImport(targets: targets)) \(Self.getImport(targets: targets))
\(Self.getAnalyticsProtocol(targets: targets)) \(Self.getAnalyticsProtocol(targets: targets, visibility: visibility))
\(Self.getTrackerTypeEnum(targets: targets)) \(Self.getTrackerTypeEnum(targets: targets, visibility: visibility))
// MARK: - Manager // MARK: - Manager
class AnalyticsManager { \(visibility) class AnalyticsManager {
static var shared = AnalyticsManager() \(visibility) static var shared = AnalyticsManager()
private init() {} private init() {}
@ -111,15 +112,18 @@ enum AnalyticsGenerator {
var managers: [TrackerType: AnalyticsManagerProtocol] = [:] var managers: [TrackerType: AnalyticsManagerProtocol] = [:]
\(Self.getEnabledContent()) \(Self.getEnabledContent(visibility: visibility))
\(Self.getAnalyticsProperties(targets: targets)) \(Self.getAnalyticsProperties(targets: targets, visibility: visibility))
\(Self.getPrivateLogFunction()) \(Self.getPrivateLogFunction())
""" """
} }
private static func getTrackerTypeEnum(targets: [TrackerType]) -> String { private static func getTrackerTypeEnum(
targets: [TrackerType],
visibility: ExtensionVisibility
) -> String {
var result: [String] = [] var result: [String] = []
targets.forEach { type in targets.forEach { type in
result.append(" case \(type)") result.append(" case \(type)")
@ -128,14 +132,16 @@ enum AnalyticsGenerator {
return """ return """
// MARK: - Traker Type // MARK: - Traker Type
enum TrackerType: CaseIterable { \(visibility) enum TrackerType: CaseIterable {
\(result.joined(separator: "\n")) \(result.joined(separator: "\n"))
} }
""" """
} }
private static func getEnabledContent() -> String { private static func getEnabledContent(
visibility: ExtensionVisibility
) -> String {
""" """
private var isEnabled: Bool { private var isEnabled: Bool {
if ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1" { if ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1" {
@ -157,11 +163,11 @@ enum AnalyticsGenerator {
} }
} }
func enableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) { \(visibility) func enableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
setAnalytics(enable: true, analytics) setAnalytics(enable: true, analytics)
} }
func disableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) { \(visibility) func disableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
setAnalytics(enable: false, analytics) setAnalytics(enable: false, analytics)
} }
""" """
@ -223,15 +229,18 @@ enum AnalyticsGenerator {
""" """
} }
private static func getAnalyticsProperties(targets: [TrackerType]) -> String { private static func getAnalyticsProperties(
targets: [TrackerType],
visibility: ExtensionVisibility
) -> String {
var header = "" var header = ""
var content: [String] = [] var content: [String] = []
let footer = " }" let footer = " }"
if targets.contains(TrackerType.matomo) { if targets.contains(TrackerType.matomo) {
header = "func configure(siteId: String, url: String) {" header = "\(visibility) func configure(siteId: String, url: String) {"
} else if targets.contains(TrackerType.firebase) { } else if targets.contains(TrackerType.firebase) {
header = "func configure() {" header = "\(visibility) func configure() {"
} }
if targets.contains(TrackerType.matomo) { if targets.contains(TrackerType.matomo) {
@ -255,11 +264,14 @@ enum AnalyticsGenerator {
.joined(separator: "\n") .joined(separator: "\n")
} }
private static func getAnalyticsProtocol(targets: [TrackerType]) -> String { private static func getAnalyticsProtocol(
targets: [TrackerType],
visibility: ExtensionVisibility
) -> String {
let proto = """ let proto = """
// MARK: - Protocol // MARK: - Protocol
protocol AnalyticsManagerProtocol { \(visibility) protocol AnalyticsManagerProtocol {
func logScreen( func logScreen(
name: String, name: String,
@ -294,7 +306,8 @@ enum AnalyticsGenerator {
private static func getProperties( private static func getProperties(
sections: [AnalyticsCategory], sections: [AnalyticsCategory],
tags: [String], tags: [String],
staticVar: Bool staticVar: Bool,
visibility: ExtensionVisibility
) -> String { ) -> String {
sections sections
.compactMap { section in .compactMap { section in
@ -310,9 +323,9 @@ enum AnalyticsGenerator {
} }
if staticVar { if staticVar {
res += "\n\n\(definition.getStaticProperty())" res += "\n\n\(definition.getStaticProperty(visibility: visibility))"
} else { } else {
res += "\n\n\(definition.getProperty())" res += "\n\n\(definition.getProperty(visibility: visibility))"
} }
} }
return res return res

View File

@ -169,19 +169,19 @@ class AnalyticsDefinition {
// MARK: - Raw strings // MARK: - Raw strings
func getProperty() -> String { func getProperty(visibility: ExtensionVisibility) -> String {
replaceIn() replaceIn()
return """ return """
func \(getFuncName())\(getParameters()) { \(visibility) func \(getFuncName())\(getParameters()) {
\(getlogFunction()) \(getlogFunction())
} }
""" """
} }
func getStaticProperty() -> String { func getStaticProperty(visibility: ExtensionVisibility) -> String {
replaceIn() replaceIn()
return """ return """
static func \(getFuncName())\(getParameters()) { \(visibility) static func \(getFuncName())\(getParameters()) {
AnalyticsManager.shared.\(getlogFunction()) AnalyticsManager.shared.\(getlogFunction())
} }
""" """

View File

@ -62,7 +62,8 @@ struct Colors: ParsableCommand {
staticVar: options.staticMembers, staticVar: options.staticMembers,
extensionName: extensionName, extensionName: extensionName,
extensionFilePath: extensionFilePath, extensionFilePath: extensionFilePath,
isSwiftUI: true isSwiftUI: true,
visibility: options.extensionVisibility
) )
} }
@ -74,7 +75,8 @@ struct Colors: ParsableCommand {
staticVar: options.staticMembers, staticVar: options.staticMembers,
extensionName: extensionNameUIKit, extensionName: extensionNameUIKit,
extensionFilePath: extensionFilePathUIKit, extensionFilePath: extensionFilePathUIKit,
isSwiftUI: false isSwiftUI: false,
visibility: options.extensionVisibility
) )
} }

View File

@ -7,27 +7,47 @@
import ArgumentParser import ArgumentParser
import Foundation import Foundation
import ToolCore
// swiftlint:disable no_grouping_extension // swiftlint:disable no_grouping_extension
struct ColorsToolOptions: ParsableArguments { struct ColorsToolOptions: ParsableArguments {
@Flag(name: [.customShort("f"), .customShort("F")], help: "Should force generation") @Flag(
name: [.customShort("f"), .customShort("F")],
help: "Should force generation"
)
var forceGeneration = false var forceGeneration = false
@Argument(help: "Input files where colors ared defined.", transform: { $0.replaceTiltWithHomeDirectoryPath() }) @Argument(
help: "Input files where colors ared defined.",
transform: { $0.replaceTiltWithHomeDirectoryPath() }
)
var inputFile: String var inputFile: String
@Option(help: "Color style to generate: light for light colors only, or all for dark and light colors") @Option(help: "Color style to generate: light for light colors only, or all for dark and light colors")
var style: ColorStyle var style: ColorStyle
@Option(help: "Path of xcassets where to generate colors", transform: { $0.replaceTiltWithHomeDirectoryPath() }) @Option(
help: "Path of xcassets where to generate colors",
transform: { $0.replaceTiltWithHomeDirectoryPath() }
)
var xcassetsPath: String var xcassetsPath: String
@Option(help: "Tell if it will generate static properties or not") @Option(help: "Tell if it will generate static properties or not")
var staticMembers: Bool = false var staticMembers: Bool = false
@Option(help: "Path where to generate the extension.", transform: { $0.replaceTiltWithHomeDirectoryPath() }) @Option(
name: .customLong("visibility"),
help: "Visibility of extension and properties. Possibles values: public, private, package, internal. Default is internal",
completion: .list(["public", "private", "package", "internal"])
)
var extensionVisibility: ExtensionVisibility = .internal
@Option(
help: "Path where to generate the extension.",
transform: { $0.replaceTiltWithHomeDirectoryPath() }
)
var extensionOutputPath: String? var extensionOutputPath: String?
@Option(help: "SwiftUI extension name. If not specified, no extension will be generated.") @Option(help: "SwiftUI extension name. If not specified, no extension will be generated.")

View File

@ -20,14 +20,16 @@ struct ColorExtensionGenerator {
staticVar: Bool, staticVar: Bool,
extensionName: String, extensionName: String,
extensionFilePath: String, extensionFilePath: String,
isSwiftUI: Bool isSwiftUI: Bool,
visibility: ExtensionVisibility
) { ) {
// Create extension content // Create extension content
let extensionContent = Self.getExtensionContent( let extensionContent = Self.getExtensionContent(
colors: colors, colors: colors,
staticVar: staticVar, staticVar: staticVar,
extensionName: extensionName, extensionName: extensionName,
isSwiftUI: isSwiftUI isSwiftUI: isSwiftUI,
visibility: visibility
) )
// Write content // Write content
@ -45,11 +47,20 @@ struct ColorExtensionGenerator {
colors: [ParsedColor], colors: [ParsedColor],
staticVar: Bool, staticVar: Bool,
extensionName: String, extensionName: String,
isSwiftUI: Bool isSwiftUI: Bool,
visibility: ExtensionVisibility
) -> String { ) -> String {
[ [
Self.getHeader(extensionClassname: extensionName, isSwiftUI: isSwiftUI), Self.getHeader(
Self.getProperties(for: colors, withStaticVar: staticVar, isSwiftUI: isSwiftUI), extensionClassname: extensionName,
isSwiftUI: isSwiftUI
),
Self.getProperties(
for: colors,
withStaticVar: staticVar,
isSwiftUI: isSwiftUI,
visibility: visibility
),
Self.getFooter() Self.getFooter()
] ]
.joined(separator: "\n") .joined(separator: "\n")
@ -75,10 +86,15 @@ struct ColorExtensionGenerator {
private static func getProperties( private static func getProperties(
for colors: [ParsedColor], for colors: [ParsedColor],
withStaticVar staticVar: Bool, withStaticVar staticVar: Bool,
isSwiftUI: Bool isSwiftUI: Bool,
visibility: ExtensionVisibility
) -> String { ) -> String {
colors.map { colors.map {
$0.getColorProperty(isStatic: staticVar, isSwiftUI: isSwiftUI) $0.getColorProperty(
isStatic: staticVar,
isSwiftUI: isSwiftUI,
visibility: visibility
)
} }
.joined(separator: "\n\n") .joined(separator: "\n\n")
} }

View File

@ -6,14 +6,19 @@
// //
import Foundation import Foundation
import ToolCore
struct ParsedColor { struct ParsedColor {
// MARK: - Properties
let name: String let name: String
let light: String let light: String
let dark: String let dark: String
// Generate Contents.json content // MARK: - Contents.json
/// Generate Contents.json content
func contentsJSON() -> String { func contentsJSON() -> String {
let lightARGB = light.colorComponent() let lightARGB = light.colorComponent()
let darkARGB = dark.colorComponent() let darkARGB = dark.colorComponent()
@ -73,20 +78,24 @@ struct ParsedColor {
""" """
} }
// MARK: - UIKit // MARK: - Property
func getColorProperty(isStatic: Bool, isSwiftUI: Bool) -> String { func getColorProperty(
isStatic: Bool,
isSwiftUI: Bool,
visibility: ExtensionVisibility
) -> String {
if isSwiftUI { if isSwiftUI {
return """ return """
/// Color \(name) is \(light) (light) or \(dark) (dark)" /// Color \(name) is \(light) (light) or \(dark) (dark)"
\(isStatic ? "static " : "")var \(name): Color { \(visibility) \(isStatic ? "static " : "")var \(name): Color {
Color("\(name)") Color("\(name)")
} }
""" """
} }
return """ return """
/// Color \(name) is \(light) (light) or \(dark) (dark)" /// Color \(name) is \(light) (light) or \(dark) (dark)"
\(isStatic ? "static " : "@objc ")var \(name): UIColor { \(isStatic ? "" : "@objc ")\(visibility) \(isStatic ? "static " : "")var \(name): UIColor {
UIColor(named: "\(name)")! UIColor(named: "\(name)")!
} }
""" """

View File

@ -7,6 +7,7 @@
import ArgumentParser import ArgumentParser
import Foundation import Foundation
import ToolCore
// swiftlint:disable no_grouping_extension // swiftlint:disable no_grouping_extension
@ -21,6 +22,13 @@ struct FontsOptions: ParsableArguments {
@Option(help: "Tell if it will generate static properties or methods") @Option(help: "Tell if it will generate static properties or methods")
var staticMembers: Bool = false var staticMembers: Bool = false
@Option(
name: .customLong("visibility"),
help: "Visibility of extension and properties. Possibles values: public, private, package, internal. Default is internal",
completion: .list(["public", "private", "package", "internal"])
)
var extensionVisibility: ExtensionVisibility = .internal
@Option(help: "Path where to generate the extension.", transform: { $0.replaceTiltWithHomeDirectoryPath() }) @Option(help: "Path where to generate the extension.", transform: { $0.replaceTiltWithHomeDirectoryPath() })
var extensionOutputPath: String var extensionOutputPath: String

View File

@ -57,7 +57,8 @@ struct Fonts: ParsableCommand {
staticVar: options.staticMembers, staticVar: options.staticMembers,
extensionName: options.extensionName, extensionName: options.extensionName,
extensionFilePath: options.extensionFilePath, extensionFilePath: options.extensionFilePath,
isSwiftUI: true isSwiftUI: true,
visibility: options.extensionVisibility
) )
if let extensionNameUIKit = options.extensionNameUIKit, if let extensionNameUIKit = options.extensionNameUIKit,
@ -67,7 +68,8 @@ struct Fonts: ParsableCommand {
staticVar: options.staticMembers, staticVar: options.staticMembers,
extensionName: extensionNameUIKit, extensionName: extensionNameUIKit,
extensionFilePath: extensionFilePathUIKit, extensionFilePath: extensionFilePathUIKit,
isSwiftUI: false isSwiftUI: false,
visibility: options.extensionVisibility
) )
} }

View File

@ -10,8 +10,11 @@ import ToolCore
enum FontExtensionGenerator { enum FontExtensionGenerator {
private static func getFontNameEnum(fontsNames: [FontName]) -> String { private static func getFontNameEnum(
var enumDefinition = " enum FontName: String {\n" fontsNames: [FontName],
visibility: ExtensionVisibility
) -> String {
var enumDefinition = " \(visibility) enum FontName: String {\n"
fontsNames.forEach { fontsNames.forEach {
enumDefinition += " case \($0.fontNameSanitize) = \"\($0.postscriptName)\"\n" enumDefinition += " case \($0.fontNameSanitize) = \"\($0.postscriptName)\"\n"
@ -26,14 +29,16 @@ enum FontExtensionGenerator {
staticVar: Bool, staticVar: Bool,
extensionName: String, extensionName: String,
extensionFilePath: String, extensionFilePath: String,
isSwiftUI: Bool isSwiftUI: Bool,
visibility: ExtensionVisibility
) { ) {
// Create extension content // Create extension content
let extensionContent = Self.getExtensionContent( let extensionContent = Self.getExtensionContent(
fontsNames: fontsNames, fontsNames: fontsNames,
staticVar: staticVar, staticVar: staticVar,
extensionName: extensionName, extensionName: extensionName,
isSwiftUI: isSwiftUI isSwiftUI: isSwiftUI,
visibility: visibility
) )
// Write content // Write content
@ -51,18 +56,33 @@ enum FontExtensionGenerator {
fontsNames: [FontName], fontsNames: [FontName],
staticVar: Bool, staticVar: Bool,
extensionName: String, extensionName: String,
isSwiftUI: Bool isSwiftUI: Bool,
visibility: ExtensionVisibility
) -> String { ) -> String {
[ [
Self.getHeader(extensionClassname: extensionName, isSwiftUI: isSwiftUI), Self.getHeader(
Self.getFontNameEnum(fontsNames: fontsNames), extensionClassname: extensionName,
Self.getFontMethods(fontsNames: fontsNames, staticVar: staticVar, isSwiftUI: isSwiftUI), isSwiftUI: isSwiftUI
),
Self.getFontNameEnum(
fontsNames: fontsNames,
visibility: visibility
),
Self.getFontMethods(
fontsNames: fontsNames,
staticVar: staticVar,
isSwiftUI: isSwiftUI,
visibility: visibility
),
Self.getFooter() Self.getFooter()
] ]
.joined(separator: "\n") .joined(separator: "\n")
} }
private static func getHeader(extensionClassname: String, isSwiftUI: Bool) -> String { private static func getHeader(
extensionClassname: String,
isSwiftUI: Bool
) -> String {
""" """
// Generated by ResgenSwift.\(Fonts.toolName) \(ResgenSwiftVersion) // Generated by ResgenSwift.\(Fonts.toolName) \(ResgenSwiftVersion)
@ -72,13 +92,22 @@ enum FontExtensionGenerator {
""" """
} }
private static func getFontMethods(fontsNames: [FontName], staticVar: Bool, isSwiftUI: Bool) -> String { private static func getFontMethods(
fontsNames: [FontName],
staticVar: Bool,
isSwiftUI: Bool,
visibility: ExtensionVisibility
) -> String {
let pragma = " // MARK: - Getter" let pragma = " // MARK: - Getter"
var propertiesOrMethods: [String] = fontsNames var propertiesOrMethods: [String] = fontsNames
.unique() .unique()
.map { .map {
$0.getProperty(isStatic: staticVar, isSwiftUI: isSwiftUI) $0.getProperty(
isStatic: staticVar,
isSwiftUI: isSwiftUI,
visibility: visibility
)
} }
propertiesOrMethods.insert(pragma, at: 0) propertiesOrMethods.insert(pragma, at: 0)

View File

@ -6,6 +6,7 @@
// //
import Foundation import Foundation
import ToolCore
// swiftlint:disable no_grouping_extension // swiftlint:disable no_grouping_extension
@ -22,33 +23,43 @@ extension FontName {
postscriptName.removeCharacters(from: "[]+-_") postscriptName.removeCharacters(from: "[]+-_")
} }
func getProperty(isStatic: Bool, isSwiftUI: Bool) -> String { func getProperty(
if isSwiftUI { isStatic: Bool,
if isStatic { isSwiftUI: Bool,
return """ visibility: ExtensionVisibility
static let \(fontNameSanitize): ((_ size: CGFloat) -> Font) = { size in ) -> String {
Font.custom(FontName.\(fontNameSanitize).rawValue, size: size) switch (isSwiftUI, isStatic) {
} case (true, true):
""" // SwiftUI, Static => let
} """
return """ \(visibility) static let \(fontNameSanitize): ((_ size: CGFloat) -> Font) = { size in
func \(fontNameSanitize)(withSize size: CGFloat) -> Font {
Font.custom(FontName.\(fontNameSanitize).rawValue, size: size) Font.custom(FontName.\(fontNameSanitize).rawValue, size: size)
} }
""" """
}
// UIKit case (true, false):
if isStatic { // SwiftUI, Not Static => func
return """ """
static let \(fontNameSanitize): ((_ size: CGFloat) -> UIFont) = { size in \(visibility) func \(fontNameSanitize)(withSize size: CGFloat) -> Font {
Font.custom(FontName.\(fontNameSanitize).rawValue, size: size)
}
"""
case (false, true):
// UIKit, Static => let
"""
\(visibility) static let \(fontNameSanitize): ((_ size: CGFloat) -> UIFont) = { size in
UIFont(name: FontName.\(fontNameSanitize).rawValue, size: size)! UIFont(name: FontName.\(fontNameSanitize).rawValue, size: size)!
} }
""" """
}
return """ case (false, false):
func \(fontNameSanitize)(withSize size: CGFloat) -> UIFont { // UIKit, Not Static => func
"""
\(visibility) func \(fontNameSanitize)(withSize size: CGFloat) -> UIFont {
UIFont(name: FontName.\(fontNameSanitize).rawValue, size: size)! UIFont(name: FontName.\(fontNameSanitize).rawValue, size: size)!
} }
""" """
}
} }
} }

View File

@ -86,31 +86,21 @@ struct AnalyticsConfiguration: Codable, CustomDebugStringConvertible {
let inputFile: String let inputFile: String
let target: String let target: String
let extensionOutputPath: String let outputFile: String
let extensionName: String? let visibility: String?
let extensionSuffix: String? let staticMembers: Bool?
private let staticMembers: Bool?
var staticMembersOptions: Bool {
if let staticMembers {
return staticMembers
}
return false
}
internal init( internal init(
inputFile: String, inputFile: String,
target: String, target: String,
extensionOutputPath: String, outputFile: String,
extensionName: String?, visibility: String?,
extensionSuffix: String?,
staticMembers: Bool? staticMembers: Bool?
) { ) {
self.inputFile = inputFile self.inputFile = inputFile
self.target = target self.target = target
self.extensionOutputPath = extensionOutputPath self.outputFile = outputFile
self.extensionName = extensionName self.visibility = visibility
self.extensionSuffix = extensionSuffix
self.staticMembers = staticMembers self.staticMembers = staticMembers
} }
@ -119,9 +109,9 @@ struct AnalyticsConfiguration: Codable, CustomDebugStringConvertible {
Analytics configuration: Analytics configuration:
- Input file: \(inputFile) - Input file: \(inputFile)
- Target: \(target) - Target: \(target)
- Extension output path: \(extensionOutputPath) - Output file: \(outputFile)
- Extension name: \(extensionName ?? "-") - Visiblity: \(visibility ?? "default")
- Extension suffix: \(extensionSuffix ?? "-") - Static members: \(staticMembers != nil ? "\(String(describing: staticMembers))" : "default")
""" """
} }
} }
@ -135,14 +125,8 @@ struct ColorsConfiguration: Codable, CustomDebugStringConvertible {
let extensionName: String? let extensionName: String?
let extensionNameUIKit: String? let extensionNameUIKit: String?
let extensionSuffix: String? let extensionSuffix: String?
private let staticMembers: Bool? let visibility: String?
let staticMembers: Bool?
var staticMembersOptions: Bool {
if let staticMembers {
return staticMembers
}
return false
}
internal init( internal init(
inputFile: String, inputFile: String,
@ -152,6 +136,7 @@ struct ColorsConfiguration: Codable, CustomDebugStringConvertible {
extensionName: String?, extensionName: String?,
extensionNameUIKit: String?, extensionNameUIKit: String?,
extensionSuffix: String?, extensionSuffix: String?,
visibility: String?,
staticMembers: Bool? staticMembers: Bool?
) { ) {
self.inputFile = inputFile self.inputFile = inputFile
@ -161,6 +146,7 @@ struct ColorsConfiguration: Codable, CustomDebugStringConvertible {
self.extensionName = extensionName self.extensionName = extensionName
self.extensionNameUIKit = extensionNameUIKit self.extensionNameUIKit = extensionNameUIKit
self.extensionSuffix = extensionSuffix self.extensionSuffix = extensionSuffix
self.visibility = visibility
self.staticMembers = staticMembers self.staticMembers = staticMembers
} }
@ -174,6 +160,8 @@ struct ColorsConfiguration: Codable, CustomDebugStringConvertible {
- Extension name: \(extensionName ?? "-") - Extension name: \(extensionName ?? "-")
- Extension name UIKit: \(extensionNameUIKit ?? "-") - Extension name UIKit: \(extensionNameUIKit ?? "-")
- Extension suffix: \(extensionSuffix ?? "-") - Extension suffix: \(extensionSuffix ?? "-")
- Visiblity: \(visibility ?? "default")
- Static members: \(staticMembers != nil ? "\(String(describing: staticMembers))" : "default")
""" """
} }
} }
@ -186,14 +174,8 @@ struct FontsConfiguration: Codable, CustomDebugStringConvertible {
let extensionNameUIKit: String? let extensionNameUIKit: String?
let extensionSuffix: String? let extensionSuffix: String?
let infoPlistPaths: String? let infoPlistPaths: String?
private let staticMembers: Bool? let visibility: String?
let staticMembers: Bool?
var staticMembersOptions: Bool {
if let staticMembers {
return staticMembers
}
return false
}
internal init( internal init(
inputFile: String, inputFile: String,
@ -202,6 +184,7 @@ struct FontsConfiguration: Codable, CustomDebugStringConvertible {
extensionNameUIKit: String?, extensionNameUIKit: String?,
extensionSuffix: String?, extensionSuffix: String?,
infoPlistPaths: String?, infoPlistPaths: String?,
visibility: String?,
staticMembers: Bool? staticMembers: Bool?
) { ) {
self.inputFile = inputFile self.inputFile = inputFile
@ -210,6 +193,7 @@ struct FontsConfiguration: Codable, CustomDebugStringConvertible {
self.extensionNameUIKit = extensionNameUIKit self.extensionNameUIKit = extensionNameUIKit
self.extensionSuffix = extensionSuffix self.extensionSuffix = extensionSuffix
self.infoPlistPaths = infoPlistPaths self.infoPlistPaths = infoPlistPaths
self.visibility = visibility
self.staticMembers = staticMembers self.staticMembers = staticMembers
} }
@ -222,6 +206,8 @@ struct FontsConfiguration: Codable, CustomDebugStringConvertible {
- Extension name UIKit: \(extensionNameUIKit ?? "-") - Extension name UIKit: \(extensionNameUIKit ?? "-")
- Extension suffix: \(extensionSuffix ?? "-") - Extension suffix: \(extensionSuffix ?? "-")
- InfoPlistPaths: \(infoPlistPaths ?? "-") - InfoPlistPaths: \(infoPlistPaths ?? "-")
- Visiblity: \(visibility ?? "default")
- Static members: \(staticMembers != nil ? "\(String(describing: staticMembers))" : "default")
""" """
} }
} }
@ -234,14 +220,8 @@ struct ImagesConfiguration: Codable, CustomDebugStringConvertible {
let extensionName: String? let extensionName: String?
let extensionNameUIKit: String? let extensionNameUIKit: String?
let extensionSuffix: String? let extensionSuffix: String?
private let staticMembers: Bool? let visibility: String?
let staticMembers: Bool?
var staticMembersOptions: Bool {
if let staticMembers {
return staticMembers
}
return false
}
internal init( internal init(
inputFile: String, inputFile: String,
@ -250,6 +230,7 @@ struct ImagesConfiguration: Codable, CustomDebugStringConvertible {
extensionName: String?, extensionName: String?,
extensionNameUIKit: String?, extensionNameUIKit: String?,
extensionSuffix: String?, extensionSuffix: String?,
visibility: String?,
staticMembers: Bool? staticMembers: Bool?
) { ) {
self.inputFile = inputFile self.inputFile = inputFile
@ -258,6 +239,7 @@ struct ImagesConfiguration: Codable, CustomDebugStringConvertible {
self.extensionName = extensionName self.extensionName = extensionName
self.extensionNameUIKit = extensionNameUIKit self.extensionNameUIKit = extensionNameUIKit
self.extensionSuffix = extensionSuffix self.extensionSuffix = extensionSuffix
self.visibility = visibility
self.staticMembers = staticMembers self.staticMembers = staticMembers
} }
@ -270,6 +252,8 @@ struct ImagesConfiguration: Codable, CustomDebugStringConvertible {
- Extension name: \(extensionName ?? "-") - Extension name: \(extensionName ?? "-")
- Extension name UIKit: \(extensionNameUIKit ?? "-") - Extension name UIKit: \(extensionNameUIKit ?? "-")
- Extension suffix: \(extensionSuffix ?? "-") - Extension suffix: \(extensionSuffix ?? "-")
- Visiblity: \(visibility ?? "default")
- Static members: \(staticMembers != nil ? "\(String(describing: staticMembers))" : "default")
""" """
} }
} }
@ -283,22 +267,9 @@ struct StringsConfiguration: Codable, CustomDebugStringConvertible {
let extensionOutputPath: String? let extensionOutputPath: String?
let extensionName: String? let extensionName: String?
let extensionSuffix: String? let extensionSuffix: String?
private let staticMembers: Bool? let visibility: String?
private let xcStrings: Bool? let staticMembers: Bool?
let xcStrings: Bool?
var staticMembersOptions: Bool {
if let staticMembers {
return staticMembers
}
return false
}
var xcStringsOptions: Bool {
if let xcStrings {
return xcStrings
}
return false
}
internal init( internal init(
inputFile: String, inputFile: String,
@ -308,6 +279,7 @@ struct StringsConfiguration: Codable, CustomDebugStringConvertible {
extensionOutputPath: String?, extensionOutputPath: String?,
extensionName: String?, extensionName: String?,
extensionSuffix: String?, extensionSuffix: String?,
visibility: String?,
staticMembers: Bool?, staticMembers: Bool?,
xcStrings: Bool? xcStrings: Bool?
) { ) {
@ -318,6 +290,7 @@ struct StringsConfiguration: Codable, CustomDebugStringConvertible {
self.extensionOutputPath = extensionOutputPath self.extensionOutputPath = extensionOutputPath
self.extensionName = extensionName self.extensionName = extensionName
self.extensionSuffix = extensionSuffix self.extensionSuffix = extensionSuffix
self.visibility = visibility
self.staticMembers = staticMembers self.staticMembers = staticMembers
self.xcStrings = xcStrings self.xcStrings = xcStrings
} }
@ -332,6 +305,9 @@ struct StringsConfiguration: Codable, CustomDebugStringConvertible {
- Extension output path: \(extensionOutputPath ?? "-") - Extension output path: \(extensionOutputPath ?? "-")
- Extension name: \(extensionName ?? "-") - Extension name: \(extensionName ?? "-")
- Extension suffix: \(extensionSuffix ?? "-") - Extension suffix: \(extensionSuffix ?? "-")
- Visiblity: \(visibility ?? "default")
- Static members: \(staticMembers != nil ? "\(String(describing: staticMembers))" : "default")
- XC Strings: \(xcStrings != nil ? "\(String(describing: xcStrings))" : "default")
""" """
} }
} }
@ -343,14 +319,8 @@ struct TagsConfiguration: Codable, CustomDebugStringConvertible {
let extensionOutputPath: String let extensionOutputPath: String
let extensionName: String? let extensionName: String?
let extensionSuffix: String? let extensionSuffix: String?
private let staticMembers: Bool? let visibility: String?
let staticMembers: Bool?
var staticMembersOptions: Bool {
if let staticMembers {
return staticMembers
}
return false
}
internal init( internal init(
inputFile: String, inputFile: String,
@ -358,6 +328,7 @@ struct TagsConfiguration: Codable, CustomDebugStringConvertible {
extensionOutputPath: String, extensionOutputPath: String,
extensionName: String?, extensionName: String?,
extensionSuffix: String?, extensionSuffix: String?,
visibility: String?,
staticMembers: Bool? staticMembers: Bool?
) { ) {
self.inputFile = inputFile self.inputFile = inputFile
@ -365,6 +336,7 @@ struct TagsConfiguration: Codable, CustomDebugStringConvertible {
self.extensionOutputPath = extensionOutputPath self.extensionOutputPath = extensionOutputPath
self.extensionName = extensionName self.extensionName = extensionName
self.extensionSuffix = extensionSuffix self.extensionSuffix = extensionSuffix
self.visibility = visibility
self.staticMembers = staticMembers self.staticMembers = staticMembers
} }
@ -376,6 +348,8 @@ struct TagsConfiguration: Codable, CustomDebugStringConvertible {
- Extension output path: \(extensionOutputPath) - Extension output path: \(extensionOutputPath)
- Extension name: \(extensionName ?? "-") - Extension name: \(extensionName ?? "-")
- Extension suffix: \(extensionSuffix ?? "-") - Extension suffix: \(extensionSuffix ?? "-")
- Visiblity: \(visibility ?? "default")
- Static members: \(staticMembers != nil ? "\(String(describing: staticMembers))" : "default")
""" """
} }
} }

View File

@ -10,6 +10,11 @@ import Foundation
extension AnalyticsConfiguration: Runnable { extension AnalyticsConfiguration: Runnable {
func run(projectDirectory: String, force: Bool) { func run(projectDirectory: String, force: Bool) {
let args = getArguments(projectDirectory: projectDirectory, force: force)
Analytics.main(args)
}
func getArguments(projectDirectory: String, force: Bool) -> [String] {
var args = [String]() var args = [String]()
if force { if force {
@ -20,25 +25,23 @@ extension AnalyticsConfiguration: Runnable {
inputFile.prependIfRelativePath(projectDirectory), inputFile.prependIfRelativePath(projectDirectory),
"--target", "--target",
target, target,
"--extension-output-path", "--output-file",
extensionOutputPath.prependIfRelativePath(projectDirectory), outputFile.prependIfRelativePath(projectDirectory)
"--static-members",
"\(staticMembersOptions)"
] ]
if let extensionName { // Add optional parameters
args += [ [
"--extension-name", ("--visibility", visibility),
extensionName ("--static-members", staticMembers?.description)
] ].forEach { argumentName, argumentValue in
} if let argumentValue {
if let extensionSuffix { args += [
args += [ argumentName,
"--extension-suffix", argumentValue
extensionSuffix ]
] }
} }
Analytics.main(args) return args
} }
} }

View File

@ -26,9 +26,7 @@ extension ColorsConfiguration: Runnable {
"--style", "--style",
style, style,
"--xcassets-path", "--xcassets-path",
xcassetsPath.prependIfRelativePath(projectDirectory), xcassetsPath.prependIfRelativePath(projectDirectory)
"--static-members",
"\(staticMembersOptions)"
] ]
// Add optional parameters // Add optional parameters
@ -36,7 +34,9 @@ extension ColorsConfiguration: Runnable {
("--extension-output-path", extensionOutputPath?.prependIfRelativePath(projectDirectory)), ("--extension-output-path", extensionOutputPath?.prependIfRelativePath(projectDirectory)),
("--extension-name", extensionName), ("--extension-name", extensionName),
("--extension-name-ui-kit", extensionNameUIKit), ("--extension-name-ui-kit", extensionNameUIKit),
("--extension-suffix", extensionSuffix) ("--extension-suffix", extensionSuffix),
("--visibility", visibility),
("--static-members", staticMembers?.description)
].forEach { argumentName, argumentValue in ].forEach { argumentName, argumentValue in
if let argumentValue { if let argumentValue {
args += [ args += [

View File

@ -22,9 +22,7 @@ extension FontsConfiguration: Runnable {
} }
args += [ args += [
inputFile.prependIfRelativePath(projectDirectory), inputFile.prependIfRelativePath(projectDirectory)
"--static-members",
"\(staticMembersOptions)"
] ]
// Add optional parameters // Add optional parameters
@ -32,7 +30,9 @@ extension FontsConfiguration: Runnable {
("--extension-output-path", extensionOutputPath?.prependIfRelativePath(projectDirectory)), ("--extension-output-path", extensionOutputPath?.prependIfRelativePath(projectDirectory)),
("--extension-name", extensionName), ("--extension-name", extensionName),
("--extension-name-ui-kit", extensionNameUIKit), ("--extension-name-ui-kit", extensionNameUIKit),
("--extension-suffix", extensionSuffix) ("--extension-suffix", extensionSuffix),
("--visibility", visibility),
("--static-members", staticMembers?.description)
].forEach { argumentName, argumentValue in ].forEach { argumentName, argumentValue in
if let argumentValue { if let argumentValue {
args += [ args += [

View File

@ -24,9 +24,7 @@ extension ImagesConfiguration: Runnable {
args += [ args += [
inputFile.prependIfRelativePath(projectDirectory), inputFile.prependIfRelativePath(projectDirectory),
"--xcassets-path", "--xcassets-path",
xcassetsPath.prependIfRelativePath(projectDirectory), xcassetsPath.prependIfRelativePath(projectDirectory)
"--static-members",
"\(staticMembersOptions)"
] ]
// Add optional parameters // Add optional parameters
@ -34,7 +32,9 @@ extension ImagesConfiguration: Runnable {
("--extension-output-path", extensionOutputPath?.prependIfRelativePath(projectDirectory)), ("--extension-output-path", extensionOutputPath?.prependIfRelativePath(projectDirectory)),
("--extension-name", extensionName), ("--extension-name", extensionName),
("--extension-name-ui-kit", extensionNameUIKit), ("--extension-name-ui-kit", extensionNameUIKit),
("--extension-suffix", extensionSuffix) ("--extension-suffix", extensionSuffix),
("--visibility", visibility),
("--static-members", staticMembers?.description)
].forEach { argumentName, argumentValue in ].forEach { argumentName, argumentValue in
if let argumentValue { if let argumentValue {
args += [ args += [

View File

@ -10,6 +10,11 @@ import Foundation
extension StringsConfiguration: Runnable { extension StringsConfiguration: Runnable {
func run(projectDirectory: String, force: Bool) { func run(projectDirectory: String, force: Bool) {
let args = getArguments(projectDirectory: projectDirectory, force: force)
Stringium.main(args)
}
func getArguments(projectDirectory: String, force: Bool) -> [String] {
var args = [String]() var args = [String]()
if force { if force {
@ -23,18 +28,17 @@ extension StringsConfiguration: Runnable {
"--langs", "--langs",
langs, langs,
"--default-lang", "--default-lang",
defaultLang, defaultLang
"--static-members",
"\(staticMembersOptions)",
"--xc-strings",
"\(xcStringsOptions)"
] ]
// Add optional parameters // Add optional parameters
[ [
("--extension-output-path", extensionOutputPath?.prependIfRelativePath(projectDirectory)), ("--extension-output-path", extensionOutputPath?.prependIfRelativePath(projectDirectory)),
("--extension-name", extensionName), ("--extension-name", extensionName),
("--extension-suffix", extensionSuffix) ("--extension-suffix", extensionSuffix),
("--visibility", visibility),
("--xc-strings", staticMembers?.description),
("--static-members", xcStrings?.description)
].forEach { argumentName, argumentValue in ].forEach { argumentName, argumentValue in
if let argumentValue { if let argumentValue {
args += [ args += [
@ -44,6 +48,6 @@ extension StringsConfiguration: Runnable {
} }
} }
Stringium.main(args) return args
} }
} }

View File

@ -10,6 +10,11 @@ import Foundation
extension TagsConfiguration: Runnable { extension TagsConfiguration: Runnable {
func run(projectDirectory: String, force: Bool) { func run(projectDirectory: String, force: Bool) {
let args = getArguments(projectDirectory: projectDirectory, force: force)
Tags.main(args)
}
func getArguments(projectDirectory: String, force: Bool) -> [String] {
var args = [String]() var args = [String]()
if force { if force {
@ -21,24 +26,24 @@ extension TagsConfiguration: Runnable {
"--lang", "--lang",
lang, lang,
"--extension-output-path", "--extension-output-path",
extensionOutputPath.prependIfRelativePath(projectDirectory), extensionOutputPath.prependIfRelativePath(projectDirectory)
"--static-members",
"\(staticMembersOptions)"
] ]
if let extensionName { // Add optional parameters
args += [ [
"--extension-name", ("--extension-name", extensionName),
extensionName ("--extension-suffix", extensionSuffix),
] ("--visibility", visibility),
} ("--static-members", staticMembers?.description)
if let extensionSuffix { ].forEach { argumentName, argumentValue in
args += [ if let argumentValue {
"--extension-suffix", args += [
extensionSuffix argumentName,
] argumentValue
]
}
} }
Tags.main(args) return args
} }
} }

View File

@ -18,7 +18,8 @@ enum ImageExtensionGenerator {
inputFilename: String, inputFilename: String,
extensionName: String, extensionName: String,
extensionFilePath: String, extensionFilePath: String,
isSwiftUI: Bool isSwiftUI: Bool,
visibility: ExtensionVisibility
) { ) {
// Create extension conten1t // Create extension conten1t
let extensionContent = Self.getExtensionContent( let extensionContent = Self.getExtensionContent(
@ -26,7 +27,8 @@ enum ImageExtensionGenerator {
staticVar: staticVar, staticVar: staticVar,
extensionName: extensionName, extensionName: extensionName,
inputFilename: inputFilename, inputFilename: inputFilename,
isSwiftUI: isSwiftUI isSwiftUI: isSwiftUI,
visibility: visibility
) )
// Write content // Write content
@ -45,11 +47,21 @@ enum ImageExtensionGenerator {
staticVar: Bool, staticVar: Bool,
extensionName: String, extensionName: String,
inputFilename: String, inputFilename: String,
isSwiftUI: Bool isSwiftUI: Bool,
visibility: ExtensionVisibility
) -> String { ) -> String {
[ [
Self.getHeader(inputFilename: inputFilename, extensionClassname: extensionName, isSwiftUI: isSwiftUI), Self.getHeader(
Self.getProperties(images: images, staticVar: staticVar, isSwiftUI: isSwiftUI), inputFilename: inputFilename,
extensionClassname: extensionName,
isSwiftUI: isSwiftUI
),
Self.getProperties(
images: images,
staticVar: staticVar,
isSwiftUI: isSwiftUI,
visibility: visibility
),
Self.getFooter() Self.getFooter()
] ]
.joined(separator: "\n") .joined(separator: "\n")
@ -73,10 +85,13 @@ enum ImageExtensionGenerator {
private static func getProperties( private static func getProperties(
images: [ParsedImage], images: [ParsedImage],
staticVar: Bool, staticVar: Bool,
isSwiftUI: Bool isSwiftUI: Bool,
visibility: ExtensionVisibility
) -> String { ) -> String {
images images
.map { "\n\($0.getImageProperty(isStatic: staticVar, isSwiftUI: isSwiftUI))" } .map {
"\n\($0.getImageProperty(isStatic: staticVar, isSwiftUI: isSwiftUI, visibility: visibility))"
}
.joined(separator: "\n") .joined(separator: "\n")
} }

View File

@ -61,7 +61,8 @@ struct Images: ParsableCommand {
inputFilename: options.inputFilenameWithoutExt, inputFilename: options.inputFilenameWithoutExt,
extensionName: extensionName, extensionName: extensionName,
extensionFilePath: extensionFilePath, extensionFilePath: extensionFilePath,
isSwiftUI: true isSwiftUI: true,
visibility: options.extensionVisibility
) )
} }
@ -73,7 +74,8 @@ struct Images: ParsableCommand {
inputFilename: options.inputFilenameWithoutExt, inputFilename: options.inputFilenameWithoutExt,
extensionName: extensionNameUIKit, extensionName: extensionNameUIKit,
extensionFilePath: extensionFilePathUIKit, extensionFilePath: extensionFilePathUIKit,
isSwiftUI: false isSwiftUI: false,
visibility: options.extensionVisibility
) )
} }

View File

@ -7,27 +7,54 @@
import ArgumentParser import ArgumentParser
import Foundation import Foundation
import ToolCore
// swiftlint:disable no_grouping_extension // swiftlint:disable no_grouping_extension
struct ImagesOptions: ParsableArguments { struct ImagesOptions: ParsableArguments {
@Flag(name: .customShort("f"), help: "Should force script execution") @Flag(
name: .customShort("f"),
help: "Should force script execution"
)
var forceExecution = false var forceExecution = false
@Flag(name: .customShort("F"), help: "Regenerate all images") @Flag(
name: .customShort("F"),
help: "Regenerate all images"
)
var forceExecutionAndGeneration = false var forceExecutionAndGeneration = false
@Argument(help: "Input files where strings ared defined.", transform: { $0.replaceTiltWithHomeDirectoryPath() }) @Argument(
help: "Input files where strings ared defined.",
completion: .file(),
transform: { $0.replaceTiltWithHomeDirectoryPath() }
)
var inputFile: String var inputFile: String
@Option(help: "Xcassets path where to generate images.", transform: { $0.replaceTiltWithHomeDirectoryPath() }) @Option(
help: "Xcassets path where to generate images.",
transform: { $0.replaceTiltWithHomeDirectoryPath() }
)
var xcassetsPath: String var xcassetsPath: String
@Option(help: "Tell if it will generate static properties or not") @Option(
help: "Tell if it will generate static properties or not",
completion: .list(["true", "false"])
)
var staticMembers: Bool = false var staticMembers: Bool = false
@Option(help: "Path where to generate the extension.", transform: { $0.replaceTiltWithHomeDirectoryPath() }) @Option(
name: .customLong("visibility"),
help: "Visibility of extension and properties. Possibles values: public, private, package, internal. Default is internal",
completion: .list(["public", "private", "package", "internal"])
)
var extensionVisibility: ExtensionVisibility = .internal
@Option(
help: "Path where to generate the extension.",
transform: { $0.replaceTiltWithHomeDirectoryPath() }
)
var extensionOutputPath: String? var extensionOutputPath: String?
@Option(help: "SwiftUI extension name. If not specified, no extension will be generated.") @Option(help: "SwiftUI extension name. If not specified, no extension will be generated.")

View File

@ -6,6 +6,7 @@
// //
import Foundation import Foundation
import ToolCore
enum ImageExtension: String { enum ImageExtension: String {
@ -129,16 +130,16 @@ struct ParsedImage {
// MARK: - Extension property // MARK: - Extension property
func getImageProperty(isStatic: Bool, isSwiftUI: Bool) -> String { func getImageProperty(isStatic: Bool, isSwiftUI: Bool, visibility: ExtensionVisibility) -> String {
if isSwiftUI { if isSwiftUI {
return """ return """
\(isStatic ? "static " : "")var \(name): Image { \(visibility) \(isStatic ? "static " : "")var \(name): Image {
Image("\(name)") Image("\(name)")
} }
""" """
} }
return """ return """
\(isStatic ? "static " : "")var \(name): UIImage { \(visibility) \(isStatic ? "static " : "")var \(name): UIImage {
UIImage(named: "\(name)")! UIImage(named: "\(name)")!
} }
""" """

View File

@ -251,7 +251,8 @@ enum StringsFileGenerator {
inputFilename: String, inputFilename: String,
extensionName: String, extensionName: String,
extensionFilePath: String, extensionFilePath: String,
extensionSuffix: String extensionSuffix: String,
visibility: ExtensionVisibility
) { ) {
// Get extension content // Get extension content
let extensionFileContent = Self.getExtensionContent( let extensionFileContent = Self.getExtensionContent(
@ -261,7 +262,8 @@ enum StringsFileGenerator {
staticVar: staticVar, staticVar: staticVar,
inputFilename: inputFilename, inputFilename: inputFilename,
extensionName: extensionName, extensionName: extensionName,
extensionSuffix: extensionSuffix extensionSuffix: extensionSuffix,
visibility: visibility
) )
// Write content // Write content
@ -284,7 +286,8 @@ enum StringsFileGenerator {
staticVar: Bool, staticVar: Bool,
inputFilename: String, inputFilename: String,
extensionName: String, extensionName: String,
extensionSuffix: String extensionSuffix: String,
visibility: ExtensionVisibility
) -> String { ) -> String {
[ [
Self.getHeader( Self.getHeader(
@ -295,13 +298,15 @@ enum StringsFileGenerator {
sections: sections, sections: sections,
tags: tags, tags: tags,
extensionClassname: extensionName, extensionClassname: extensionName,
extensionSuffix: extensionSuffix extensionSuffix: extensionSuffix,
visibility: visibility
), ),
Self.getProperties( Self.getProperties(
sections: sections, sections: sections,
defaultLang: lang, defaultLang: lang,
tags: tags, tags: tags,
staticVar: staticVar staticVar: staticVar,
visibility: visibility
), ),
Self.getFooter() Self.getFooter()
] ]
@ -326,9 +331,10 @@ enum StringsFileGenerator {
sections: [Section], sections: [Section],
tags: [String], tags: [String],
extensionClassname: String, extensionClassname: String,
extensionSuffix: String extensionSuffix: String,
visibility: ExtensionVisibility
) -> String { ) -> String {
var enumDefinition = "\n enum Key\(extensionSuffix.uppercasedFirst()): String {\n" var enumDefinition = "\n \(visibility) enum Key\(extensionSuffix.uppercasedFirst()): String {\n"
// Enum // Enum
sections.forEach { section in sections.forEach { section in
@ -347,7 +353,7 @@ enum StringsFileGenerator {
// KeyPath accessors // KeyPath accessors
enumDefinition += "\n" enumDefinition += "\n"
enumDefinition += " var keyPath: KeyPath<\(extensionClassname), String> {\n" enumDefinition += " \(visibility) var keyPath: KeyPath<\(extensionClassname), String> {\n"
enumDefinition += " switch self {\n" enumDefinition += " switch self {\n"
sections.forEach { section in sections.forEach { section in
// Check that at least one string will be generated // Check that at least one string will be generated
@ -369,7 +375,13 @@ enum StringsFileGenerator {
return enumDefinition return enumDefinition
} }
private static func getProperties(sections: [Section], defaultLang lang: String, tags: [String], staticVar: Bool) -> String { private static func getProperties(
sections: [Section],
defaultLang lang: String,
tags: [String],
staticVar: Bool,
visibility: ExtensionVisibility
) -> String {
sections.compactMap { section in sections.compactMap { section in
// Check that at least one string will be generated // Check that at least one string will be generated
guard section.hasOneOrMoreMatchingTags(tags: tags) else { guard section.hasOneOrMoreMatchingTags(tags: tags) else {
@ -382,10 +394,21 @@ enum StringsFileGenerator {
return nil // Go to next definition return nil // Go to next definition
} }
if staticVar { let property: String = {
return "\n\(definition.getNSLocalizedStringStaticProperty(forLang: lang))" if staticVar {
} definition.getNSLocalizedStringStaticProperty(
return "\n\(definition.getNSLocalizedStringProperty(forLang: lang))" forLang: lang,
visibility: visibility
)
} else {
definition.getNSLocalizedStringProperty(
forLang: lang,
visibility: visibility
)
}
}()
return "\n\(property)"
} }
.joined(separator: "\n") .joined(separator: "\n")
return res return res

View File

@ -17,7 +17,8 @@ enum TagsGenerator {
tags: [String], tags: [String],
staticVar: Bool, staticVar: Bool,
extensionName: String, extensionName: String,
extensionFilePath: String extensionFilePath: String,
visibility: ExtensionVisibility
) { ) {
// Get extension content // Get extension content
let extensionFileContent = Self.getExtensionContent( let extensionFileContent = Self.getExtensionContent(
@ -25,7 +26,8 @@ enum TagsGenerator {
lang: lang, lang: lang,
tags: tags, tags: tags,
staticVar: staticVar, staticVar: staticVar,
extensionName: extensionName extensionName: extensionName,
visibility: visibility
) )
// Write content // Write content
@ -46,7 +48,8 @@ enum TagsGenerator {
lang: String, lang: String,
tags: [String], tags: [String],
staticVar: Bool, staticVar: Bool,
extensionName: String extensionName: String,
visibility: ExtensionVisibility
) -> String { ) -> String {
[ [
Self.getHeader( Self.getHeader(
@ -57,7 +60,8 @@ enum TagsGenerator {
sections: sections, sections: sections,
lang: lang, lang: lang,
tags: tags, tags: tags,
staticVar: staticVar staticVar: staticVar,
visibility: visibility
), ),
Self.getFooter() Self.getFooter()
] ]
@ -80,7 +84,8 @@ enum TagsGenerator {
sections: [Section], sections: [Section],
lang: String, lang: String,
tags: [String], tags: [String],
staticVar: Bool staticVar: Bool,
visibility: ExtensionVisibility
) -> String { ) -> String {
sections sections
.compactMap { section in .compactMap { section in
@ -96,9 +101,9 @@ enum TagsGenerator {
} }
if staticVar { if staticVar {
res += "\n\n\(definition.getStaticProperty(forLang: lang))" res += "\n\n\(definition.getStaticProperty(forLang: lang, visibility: visibility))"
} else { } else {
res += "\n\n\(definition.getProperty(forLang: lang))" res += "\n\n\(definition.getProperty(forLang: lang, visibility: visibility))"
} }
} }
return res return res

View File

@ -6,6 +6,7 @@
// //
import Foundation import Foundation
import ToolCore
// swiftlint:disable force_unwrapping // swiftlint:disable force_unwrapping
@ -99,14 +100,20 @@ class Definition {
return (inputParameters: inputParameters, translationArguments: translationArguments) return (inputParameters: inputParameters, translationArguments: translationArguments)
} }
private func getBaseProperty(lang: String, translation: String, isStatic: Bool, comment: String?) -> String { private func getBaseProperty(
lang: String,
translation: String,
isStatic: Bool,
comment: String?,
visibility: ExtensionVisibility
) -> String {
""" """
/// Translation in \(lang) : /// Translation in \(lang) :
/// \(translation) /// \(translation)
/// ///
/// Comment : /// Comment :
/// \(comment?.isEmpty == false ? comment! : "No comment") /// \(comment?.isEmpty == false ? comment! : "No comment")
\(isStatic ? "static " : "")var \(name): String { \(visibility) \(isStatic ? "static " : "")var \(name): String {
NSLocalizedString("\(name)", tableName: kStringsFileName, bundle: Bundle.main, value: "\(translation)", comment: "\(comment ?? "")") NSLocalizedString("\(name)", tableName: kStringsFileName, bundle: Bundle.main, value: "\(translation)", comment: "\(comment ?? "")")
} }
""" """
@ -118,7 +125,8 @@ class Definition {
isStatic: Bool, isStatic: Bool,
inputParameters: [String], inputParameters: [String],
translationArguments: [String], translationArguments: [String],
comment: String? comment: String?,
visibility: ExtensionVisibility
) -> String { ) -> String {
""" """
@ -127,13 +135,13 @@ class Definition {
/// ///
/// Comment : /// Comment :
/// \(comment?.isEmpty == false ? comment! : "No comment") /// \(comment?.isEmpty == false ? comment! : "No comment")
\(isStatic ? "static " : "")func \(name)(\(inputParameters.joined(separator: ", "))) -> String { \(visibility) \(isStatic ? "static " : "")func \(name)(\(inputParameters.joined(separator: ", "))) -> String {
String(format: \(isStatic ? "Self" : "self").\(name), \(translationArguments.joined(separator: ", "))) String(format: \(isStatic ? "Self" : "self").\(name), \(translationArguments.joined(separator: ", ")))
} }
""" """
} }
func getNSLocalizedStringProperty(forLang lang: String) -> String { func getNSLocalizedStringProperty(forLang lang: String, visibility: ExtensionVisibility) -> String {
guard let translation = translations[lang] else { guard let translation = translations[lang] else {
let error = StringiumError.langNotDefined(lang, name, reference != nil) let error = StringiumError.langNotDefined(lang, name, reference != nil)
print(error.description) print(error.description)
@ -145,7 +153,8 @@ class Definition {
lang: lang, lang: lang,
translation: translation, translation: translation,
isStatic: false, isStatic: false,
comment: self.comment comment: self.comment,
visibility: visibility
) )
// Generate method // Generate method
@ -157,14 +166,15 @@ class Definition {
isStatic: false, isStatic: false,
inputParameters: parameters.inputParameters, inputParameters: parameters.inputParameters,
translationArguments: parameters.translationArguments, translationArguments: parameters.translationArguments,
comment: self.comment comment: self.comment,
visibility: visibility
) )
} }
return property + method return property + method
} }
func getNSLocalizedStringStaticProperty(forLang lang: String) -> String { func getNSLocalizedStringStaticProperty(forLang lang: String, visibility: ExtensionVisibility) -> String {
guard let translation = translations[lang] else { guard let translation = translations[lang] else {
let error = StringiumError.langNotDefined(lang, name, reference != nil) let error = StringiumError.langNotDefined(lang, name, reference != nil)
print(error.description) print(error.description)
@ -176,7 +186,8 @@ class Definition {
lang: lang, lang: lang,
translation: translation, translation: translation,
isStatic: true, isStatic: true,
comment: self.comment comment: self.comment,
visibility: visibility
) )
// Generate method // Generate method
@ -188,7 +199,8 @@ class Definition {
isStatic: true, isStatic: true,
inputParameters: parameters.inputParameters, inputParameters: parameters.inputParameters,
translationArguments: parameters.translationArguments, translationArguments: parameters.translationArguments,
comment: self.comment comment: self.comment,
visibility: visibility
) )
} }
@ -197,7 +209,7 @@ class Definition {
// MARK: - Raw strings // MARK: - Raw strings
func getProperty(forLang lang: String) -> String { func getProperty(forLang lang: String, visibility: ExtensionVisibility) -> String {
guard let translation = translations[lang] else { guard let translation = translations[lang] else {
let error = StringiumError.langNotDefined(lang, name, reference != nil) let error = StringiumError.langNotDefined(lang, name, reference != nil)
print(error.description) print(error.description)
@ -210,14 +222,13 @@ class Definition {
/// ///
/// Comment : /// Comment :
/// \(comment?.isEmpty == false ? comment! : "No comment") /// \(comment?.isEmpty == false ? comment! : "No comment")
\(visibility) var \(name): String {
var \(name): String {
"\(translation)" "\(translation)"
} }
""" """
} }
func getStaticProperty(forLang lang: String) -> String { func getStaticProperty(forLang lang: String, visibility: ExtensionVisibility) -> String {
guard let translation = translations[lang] else { guard let translation = translations[lang] else {
let error = StringiumError.langNotDefined(lang, name, reference != nil) let error = StringiumError.langNotDefined(lang, name, reference != nil)
print(error.description) print(error.description)
@ -230,7 +241,7 @@ class Definition {
/// ///
/// Comment : /// Comment :
/// \(comment?.isEmpty == false ? comment! : "No comment") /// \(comment?.isEmpty == false ? comment! : "No comment")
static var \(name): String { \(visibility) static var \(name): String {
"\(translation)" "\(translation)"
} }
""" """

View File

@ -72,7 +72,8 @@ struct Stringium: ParsableCommand {
inputFilename: options.inputFilenameWithoutExt, inputFilename: options.inputFilenameWithoutExt,
extensionName: extensionName, extensionName: extensionName,
extensionFilePath: extensionFilePath, extensionFilePath: extensionFilePath,
extensionSuffix: options.extensionSuffix ?? "" extensionSuffix: options.extensionSuffix ?? "",
visibility: options.extensionVisibility
) )
} }

View File

@ -7,6 +7,7 @@
import ArgumentParser import ArgumentParser
import Foundation import Foundation
import ToolCore
// swiftlint:disable no_grouping_extension // swiftlint:disable no_grouping_extension
@ -23,7 +24,7 @@ struct StringiumOptions: ParsableArguments {
@Option( @Option(
name: .customLong("output-path"), name: .customLong("output-path"),
help: "Path where to strings file.", help: "Path where to find the .xcStrings file or the lproj folders.",
transform: { $0.replaceTiltWithHomeDirectoryPath() } transform: { $0.replaceTiltWithHomeDirectoryPath() }
) )
fileprivate var outputPathRaw: String fileprivate var outputPathRaw: String
@ -49,6 +50,13 @@ struct StringiumOptions: ParsableArguments {
@Option(help: "Tell if it will generate xcStrings file or lproj file. True by default") @Option(help: "Tell if it will generate xcStrings file or lproj file. True by default")
var xcStrings: Bool = true var xcStrings: Bool = true
@Option(
name: .customLong("visibility"),
help: "Visibility of extension and properties. Possibles values: public, private, package, internal. Default is internal",
completion: .list(["public", "private", "package", "internal"])
)
var extensionVisibility: ExtensionVisibility = .internal
@Option( @Option(
help: "Path where to generate the extension.", help: "Path where to generate the extension.",
transform: { $0.replaceTiltWithHomeDirectoryPath() } transform: { $0.replaceTiltWithHomeDirectoryPath() }

View File

@ -49,7 +49,8 @@ struct Tags: ParsableCommand {
tags: ["ios", "iosonly", Self.noTranslationTag], tags: ["ios", "iosonly", Self.noTranslationTag],
staticVar: options.staticMembers, staticVar: options.staticMembers,
extensionName: options.extensionName, extensionName: options.extensionName,
extensionFilePath: options.extensionFilePath extensionFilePath: options.extensionFilePath,
visibility: options.extensionVisibility
) )
print("[\(Self.toolName)] Tags generated") print("[\(Self.toolName)] Tags generated")

View File

@ -7,6 +7,7 @@
import ArgumentParser import ArgumentParser
import Foundation import Foundation
import ToolCore
// swiftlint:disable no_grouping_extension // swiftlint:disable no_grouping_extension
@ -21,7 +22,17 @@ struct TagsOptions: ParsableArguments {
@Option(help: "Lang to generate. (\"ium\" by default)") @Option(help: "Lang to generate. (\"ium\" by default)")
var lang: String = "ium" var lang: String = "ium"
@Option(help: "Path where to generate the extension.", transform: { $0.replaceTiltWithHomeDirectoryPath() }) @Option(
name: .customLong("visibility"),
help: "Visibility of extension and properties. Possibles values: public, private, package, internal. Default is internal",
completion: .list(["public", "private", "package", "internal"])
)
var extensionVisibility: ExtensionVisibility = .internal
@Option(
help: "Path where to generate the extension.",
transform: { $0.replaceTiltWithHomeDirectoryPath() }
)
var extensionOutputPath: String var extensionOutputPath: String
@Option(help: "Tell if it will generate static properties or not") @Option(help: "Tell if it will generate static properties or not")

View File

@ -0,0 +1,34 @@
//
// ExtensionVisibility.swift
// ResgenSwift
//
// Created by Thibaut Schmitt on 17/07/2025.
//
import ArgumentParser
package enum ExtensionVisibility: String, CustomStringConvertible, ExpressibleByArgument {
case `public`
case `private`
case `internal`
case `package`
// MARK: - CustomStringConvertible
package var description: String {
switch self {
case .public:
"public"
case .private:
"private"
case .internal:
"internal"
case .package:
"package"
}
}
}

View File

@ -9,4 +9,4 @@ import Foundation
// swiftlint:disable prefixed_toplevel_constant identifier_name // swiftlint:disable prefixed_toplevel_constant identifier_name
public let ResgenSwiftVersion = "2.2g.0" public let ResgenSwiftVersion = "2.2.0"

View File

@ -55,11 +55,11 @@ final class AnalyticsDefinitionTests: XCTestCase {
definition.path = "ecran_un/" definition.path = "ecran_un/"
// When // When
let propertyScreen = definition.getProperty() let propertyScreen = definition.getProperty(visibility: .internal)
// Expect // Expect
let expectScreen = """ let expectScreen = """
func logScreenDefinitionName() { internal func logScreenDefinitionName() {
logScreen( logScreen(
name: "Ecran un", name: "Ecran un",
path: "ecran_un/", path: "ecran_un/",
@ -76,11 +76,11 @@ final class AnalyticsDefinitionTests: XCTestCase {
let definition = AnalyticsDefinition(id: "definition_name", name: "Ecran un", type: .event) let definition = AnalyticsDefinition(id: "definition_name", name: "Ecran un", type: .event)
// When // When
let propertyEvent = definition.getProperty() let propertyEvent = definition.getProperty(visibility: .public)
// Expect // Expect
let expectEvent = """ let expectEvent = """
func logEventDefinitionName() { public func logEventDefinitionName() {
logEvent( logEvent(
name: "Ecran un", name: "Ecran un",
action: "", action: "",
@ -99,11 +99,11 @@ final class AnalyticsDefinitionTests: XCTestCase {
definition.path = "ecran_un/" definition.path = "ecran_un/"
// When // When
let propertyScreen = definition.getStaticProperty() let propertyScreen = definition.getStaticProperty(visibility: .private)
// Expect // Expect
let expectScreen = """ let expectScreen = """
static func logScreenDefinitionName() { private static func logScreenDefinitionName() {
AnalyticsManager.shared.logScreen( AnalyticsManager.shared.logScreen(
name: "Ecran un", name: "Ecran un",
path: "ecran_un/", path: "ecran_un/",
@ -120,11 +120,11 @@ final class AnalyticsDefinitionTests: XCTestCase {
let definition = AnalyticsDefinition(id: "definition_name", name: "Ecran un", type: .event) let definition = AnalyticsDefinition(id: "definition_name", name: "Ecran un", type: .event)
// When // When
let propertyEvent = definition.getStaticProperty() let propertyEvent = definition.getStaticProperty(visibility: .package)
// Expect // Expect
let expectEvent = """ let expectEvent = """
static func logEventDefinitionName() { package static func logEventDefinitionName() {
AnalyticsManager.shared.logEvent( AnalyticsManager.shared.logEvent(
name: "Ecran un", name: "Ecran un",
action: "", action: "",

View File

@ -32,11 +32,11 @@ final class AnalyticsGeneratorTests: XCTestCase {
return definition return definition
} }
private func protocolString() -> String { private func protocolString(visibility: ExtensionVisibility) -> String {
""" """
// MARK: - Protocol // MARK: - Protocol
protocol AnalyticsManagerProtocol { \(visibility) protocol AnalyticsManagerProtocol {
func logScreen( func logScreen(
name: String, name: String,
@ -234,7 +234,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
sections: [sectionOne, sectionTwo, sectionThree], sections: [sectionOne, sectionTwo, sectionThree],
tags: ["ios", "iosonly"], tags: ["ios", "iosonly"],
staticVar: false, staticVar: false,
extensionName: "GenAnalytics" visibility: .public
) )
// Expect Analytics // Expect Analytics
@ -244,22 +244,22 @@ final class AnalyticsGeneratorTests: XCTestCase {
import Foundation import Foundation
import FirebaseAnalytics import FirebaseAnalytics
\(protocolString()) \(protocolString(visibility: .public))
\(firebaseString()) \(firebaseString())
// MARK: - Traker Type // MARK: - Traker Type
enum TrackerType: CaseIterable { public enum TrackerType: CaseIterable {
case firebase case firebase
} }
// MARK: - Manager // MARK: - Manager
class AnalyticsManager { public class AnalyticsManager {
static var shared = AnalyticsManager() public static var shared = AnalyticsManager()
private init() {} private init() {}
@ -287,15 +287,15 @@ final class AnalyticsGeneratorTests: XCTestCase {
} }
} }
func enableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) { public func enableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
setAnalytics(enable: true, analytics) setAnalytics(enable: true, analytics)
} }
func disableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) { public func disableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
setAnalytics(enable: false, analytics) setAnalytics(enable: false, analytics)
} }
func configure() { public func configure() {
managers[TrackerType.firebase] = FirebaseAnalyticsManager() managers[TrackerType.firebase] = FirebaseAnalyticsManager()
} }
@ -337,7 +337,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
// MARK: - section_one // MARK: - section_one
func logScreenS1DefOne() { public func logScreenS1DefOne() {
logScreen( logScreen(
name: "s1 def one", name: "s1 def one",
path: "", path: "",
@ -345,7 +345,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
) )
} }
func logEventS1DefTwo() { public func logEventS1DefTwo() {
logEvent( logEvent(
name: "s1 def two", name: "s1 def two",
action: "", action: "",
@ -356,7 +356,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
// MARK: - section_two // MARK: - section_two
func logScreenS2DefOne() { public func logScreenS2DefOne() {
logScreen( logScreen(
name: "s2 def one", name: "s2 def one",
path: "", path: "",
@ -399,7 +399,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
sections: [sectionOne, sectionTwo, sectionThree], sections: [sectionOne, sectionTwo, sectionThree],
tags: ["ios", "iosonly"], tags: ["ios", "iosonly"],
staticVar: false, staticVar: false,
extensionName: "GenAnalytics" visibility: .package
) )
// Expect Analytics // Expect Analytics
let expect = """ let expect = """
@ -408,22 +408,22 @@ final class AnalyticsGeneratorTests: XCTestCase {
import Foundation import Foundation
import MatomoTracker import MatomoTracker
\(protocolString()) \(protocolString(visibility: .package))
\(matomoString()) \(matomoString())
// MARK: - Traker Type // MARK: - Traker Type
enum TrackerType: CaseIterable { package enum TrackerType: CaseIterable {
case matomo case matomo
} }
// MARK: - Manager // MARK: - Manager
class AnalyticsManager { package class AnalyticsManager {
static var shared = AnalyticsManager() package static var shared = AnalyticsManager()
private init() {} private init() {}
@ -451,15 +451,15 @@ final class AnalyticsGeneratorTests: XCTestCase {
} }
} }
func enableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) { package func enableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
setAnalytics(enable: true, analytics) setAnalytics(enable: true, analytics)
} }
func disableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) { package func disableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
setAnalytics(enable: false, analytics) setAnalytics(enable: false, analytics)
} }
func configure(siteId: String, url: String) { package func configure(siteId: String, url: String) {
managers[TrackerType.matomo] = MatomoAnalyticsManager( managers[TrackerType.matomo] = MatomoAnalyticsManager(
siteId: siteId, siteId: siteId,
url: url url: url
@ -504,7 +504,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
// MARK: - section_one // MARK: - section_one
func logScreenS1DefOne() { package func logScreenS1DefOne() {
logScreen( logScreen(
name: "s1 def one", name: "s1 def one",
path: "s1_def_one/", path: "s1_def_one/",
@ -512,7 +512,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
) )
} }
func logEventS1DefTwo() { package func logEventS1DefTwo() {
logEvent( logEvent(
name: "s1 def two", name: "s1 def two",
action: "test", action: "test",
@ -523,7 +523,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
// MARK: - section_two // MARK: - section_two
func logScreenS2DefOne() { package func logScreenS2DefOne() {
logScreen( logScreen(
name: "s2 def one", name: "s2 def one",
path: "s2_def_one/", path: "s2_def_one/",
@ -566,7 +566,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
sections: [sectionOne, sectionTwo, sectionThree], sections: [sectionOne, sectionTwo, sectionThree],
tags: ["ios", "iosonly"], tags: ["ios", "iosonly"],
staticVar: false, staticVar: false,
extensionName: "GenAnalytics" visibility: .internal
) )
// Expect Analytics // Expect Analytics
@ -577,7 +577,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
import MatomoTracker import MatomoTracker
import FirebaseAnalytics import FirebaseAnalytics
\(protocolString()) \(protocolString(visibility: .internal))
\(matomoString()) \(matomoString())
@ -585,7 +585,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
// MARK: - Traker Type // MARK: - Traker Type
enum TrackerType: CaseIterable { internal enum TrackerType: CaseIterable {
case matomo case matomo
case firebase case firebase
@ -593,9 +593,9 @@ final class AnalyticsGeneratorTests: XCTestCase {
// MARK: - Manager // MARK: - Manager
class AnalyticsManager { internal class AnalyticsManager {
static var shared = AnalyticsManager() internal static var shared = AnalyticsManager()
private init() {} private init() {}
@ -623,15 +623,15 @@ final class AnalyticsGeneratorTests: XCTestCase {
} }
} }
func enableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) { internal func enableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
setAnalytics(enable: true, analytics) setAnalytics(enable: true, analytics)
} }
func disableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) { internal func disableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
setAnalytics(enable: false, analytics) setAnalytics(enable: false, analytics)
} }
func configure(siteId: String, url: String) { internal func configure(siteId: String, url: String) {
managers[TrackerType.matomo] = MatomoAnalyticsManager( managers[TrackerType.matomo] = MatomoAnalyticsManager(
siteId: siteId, siteId: siteId,
url: url url: url
@ -677,7 +677,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
// MARK: - section_one // MARK: - section_one
func logScreenS1DefOne() { internal func logScreenS1DefOne() {
logScreen( logScreen(
name: "s1 def one", name: "s1 def one",
path: "s1_def_one/", path: "s1_def_one/",
@ -685,7 +685,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
) )
} }
func logEventS1DefTwo() { internal func logEventS1DefTwo() {
logEvent( logEvent(
name: "s1 def two", name: "s1 def two",
action: "test", action: "test",
@ -696,7 +696,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
// MARK: - section_two // MARK: - section_two
func logScreenS2DefOne() { internal func logScreenS2DefOne() {
logScreen( logScreen(
name: "s2 def one", name: "s2 def one",
path: "s2_def_one/", path: "s2_def_one/",

View File

@ -21,10 +21,13 @@ final class ColorExtensionGeneratorTests: XCTestCase {
] ]
// When // When
let extensionContent = ColorExtensionGenerator.getExtensionContent(colors: colors, let extensionContent = ColorExtensionGenerator.getExtensionContent(
staticVar: false, colors: colors,
extensionName: "GenColors", staticVar: false,
isSwiftUI: false) extensionName: "GenColors",
isSwiftUI: false,
visibility: .public
)
// Expect // Expect
let expect = """ let expect = """
@ -35,12 +38,12 @@ final class ColorExtensionGeneratorTests: XCTestCase {
extension GenColors { extension GenColors {
/// Color colorOne is #FF00FF (light) or #00FF00 (dark)" /// Color colorOne is #FF00FF (light) or #00FF00 (dark)"
@objc var colorOne: UIColor { @objc public var colorOne: UIColor {
UIColor(named: "colorOne")! UIColor(named: "colorOne")!
} }
/// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)" /// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
@objc var colorTwo: UIColor { @objc public var colorTwo: UIColor {
UIColor(named: "colorTwo")! UIColor(named: "colorTwo")!
} }
} }
@ -57,10 +60,13 @@ final class ColorExtensionGeneratorTests: XCTestCase {
] ]
// When // When
let extensionContent = ColorExtensionGenerator.getExtensionContent(colors: colors, let extensionContent = ColorExtensionGenerator.getExtensionContent(
staticVar: true, colors: colors,
extensionName: "GenColor", staticVar: true,
isSwiftUI: false) extensionName: "GenColor",
isSwiftUI: false,
visibility: .public
)
// Expect // Expect
let expect = """ let expect = """
@ -71,12 +77,12 @@ final class ColorExtensionGeneratorTests: XCTestCase {
extension GenColor { extension GenColor {
/// Color colorOne is #FF00FF (light) or #00FF00 (dark)" /// Color colorOne is #FF00FF (light) or #00FF00 (dark)"
static var colorOne: UIColor { public static var colorOne: UIColor {
UIColor(named: "colorOne")! UIColor(named: "colorOne")!
} }
/// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)" /// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
static var colorTwo: UIColor { public static var colorTwo: UIColor {
UIColor(named: "colorTwo")! UIColor(named: "colorTwo")!
} }
} }
@ -93,10 +99,13 @@ final class ColorExtensionGeneratorTests: XCTestCase {
] ]
// When // When
let extensionContent = ColorExtensionGenerator.getExtensionContent(colors: colors, let extensionContent = ColorExtensionGenerator.getExtensionContent(
staticVar: false, colors: colors,
extensionName: "GenColors", staticVar: false,
isSwiftUI: true) extensionName: "GenColors",
isSwiftUI: true,
visibility: .package
)
// Expect // Expect
let expect = """ let expect = """
@ -107,12 +116,12 @@ final class ColorExtensionGeneratorTests: XCTestCase {
extension GenColors { extension GenColors {
/// Color colorOne is #FF00FF (light) or #00FF00 (dark)" /// Color colorOne is #FF00FF (light) or #00FF00 (dark)"
var colorOne: Color { package var colorOne: Color {
Color("colorOne") Color("colorOne")
} }
/// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)" /// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
var colorTwo: Color { package var colorTwo: Color {
Color("colorTwo") Color("colorTwo")
} }
} }
@ -129,10 +138,13 @@ final class ColorExtensionGeneratorTests: XCTestCase {
] ]
// When // When
let extensionContent = ColorExtensionGenerator.getExtensionContent(colors: colors, let extensionContent = ColorExtensionGenerator.getExtensionContent(
staticVar: true, colors: colors,
extensionName: "GenColor", staticVar: true,
isSwiftUI: true) extensionName: "GenColor",
isSwiftUI: true,
visibility: .internal
)
// Expect // Expect
let expect = """ let expect = """
@ -143,12 +155,12 @@ final class ColorExtensionGeneratorTests: XCTestCase {
extension GenColor { extension GenColor {
/// Color colorOne is #FF00FF (light) or #00FF00 (dark)" /// Color colorOne is #FF00FF (light) or #00FF00 (dark)"
static var colorOne: Color { internal static var colorOne: Color {
Color("colorOne") Color("colorOne")
} }
/// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)" /// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
static var colorTwo: Color { internal static var colorTwo: Color {
Color("colorTwo") Color("colorTwo")
} }
} }

View File

@ -17,12 +17,16 @@ final class ParsedColorTests: XCTestCase {
let color = ParsedColor(name: "red", light: "#FF0000", dark: "#0000FF") let color = ParsedColor(name: "red", light: "#FF0000", dark: "#0000FF")
// When // When
let property = color.getColorProperty(isStatic: false, isSwiftUI: false) let property = color.getColorProperty(
isStatic: false,
isSwiftUI: false,
visibility: .public
)
// Expect // Expect
let expect = """ let expect = """
/// Color red is #FF0000 (light) or #0000FF (dark)" /// Color red is #FF0000 (light) or #0000FF (dark)"
@objc var red: UIColor { @objc public var red: UIColor {
UIColor(named: "red")! UIColor(named: "red")!
} }
""" """
@ -35,12 +39,16 @@ final class ParsedColorTests: XCTestCase {
let color = ParsedColor(name: "red", light: "#FF0000", dark: "#0000FF") let color = ParsedColor(name: "red", light: "#FF0000", dark: "#0000FF")
// When // When
let property = color.getColorProperty(isStatic: true, isSwiftUI: false) let property = color.getColorProperty(
isStatic: true,
isSwiftUI: false,
visibility: .private
)
// Expect // Expect
let expect = """ let expect = """
/// Color red is #FF0000 (light) or #0000FF (dark)" /// Color red is #FF0000 (light) or #0000FF (dark)"
static var red: UIColor { private static var red: UIColor {
UIColor(named: "red")! UIColor(named: "red")!
} }
""" """
@ -53,12 +61,16 @@ final class ParsedColorTests: XCTestCase {
let color = ParsedColor(name: "red", light: "#FF0000", dark: "#0000FF") let color = ParsedColor(name: "red", light: "#FF0000", dark: "#0000FF")
// When // When
let property = color.getColorProperty(isStatic: false, isSwiftUI: true) let property = color.getColorProperty(
isStatic: false,
isSwiftUI: true,
visibility: .package
)
// Expect // Expect
let expect = """ let expect = """
/// Color red is #FF0000 (light) or #0000FF (dark)" /// Color red is #FF0000 (light) or #0000FF (dark)"
var red: Color { package var red: Color {
Color("red") Color("red")
} }
""" """
@ -71,12 +83,16 @@ final class ParsedColorTests: XCTestCase {
let color = ParsedColor(name: "red", light: "#FF0000", dark: "#0000FF") let color = ParsedColor(name: "red", light: "#FF0000", dark: "#0000FF")
// When // When
let property = color.getColorProperty(isStatic: true, isSwiftUI: true) let property = color.getColorProperty(
isStatic: true,
isSwiftUI: true,
visibility: .internal
)
// Expect // Expect
let expect = """ let expect = """
/// Color red is #FF0000 (light) or #0000FF (dark)" /// Color red is #FF0000 (light) or #0000FF (dark)"
static var red: Color { internal static var red: Color {
Color("red") Color("red")
} }
""" """

View File

@ -21,10 +21,13 @@ final class FontExtensionGeneratorTests: XCTestCase {
] ]
// When // When
let extensionContent = FontExtensionGenerator.getExtensionContent(fontsNames: fontNames, let extensionContent = FontExtensionGenerator.getExtensionContent(
staticVar: false, fontsNames: fontNames,
extensionName: "GenFonts", staticVar: false,
isSwiftUI: false) extensionName: "GenFonts",
isSwiftUI: false,
visibility: .public
)
// Expect // Expect
let expect = """ let expect = """
@ -34,18 +37,18 @@ final class FontExtensionGeneratorTests: XCTestCase {
extension GenFonts { extension GenFonts {
enum FontName: String { public enum FontName: String {
case CircularStdRegular = "CircularStd-Regular" case CircularStdRegular = "CircularStd-Regular"
case CircularStdBold = "CircularStd-Bold" case CircularStdBold = "CircularStd-Bold"
} }
// MARK: - Getter // MARK: - Getter
func CircularStdRegular(withSize size: CGFloat) -> UIFont { public func CircularStdRegular(withSize size: CGFloat) -> UIFont {
UIFont(name: FontName.CircularStdRegular.rawValue, size: size)! UIFont(name: FontName.CircularStdRegular.rawValue, size: size)!
} }
func CircularStdBold(withSize size: CGFloat) -> UIFont { public func CircularStdBold(withSize size: CGFloat) -> UIFont {
UIFont(name: FontName.CircularStdBold.rawValue, size: size)! UIFont(name: FontName.CircularStdBold.rawValue, size: size)!
} }
@ -64,10 +67,13 @@ final class FontExtensionGeneratorTests: XCTestCase {
] ]
// When // When
let extensionContent = FontExtensionGenerator.getExtensionContent(fontsNames: fontNames, let extensionContent = FontExtensionGenerator.getExtensionContent(
staticVar: false, fontsNames: fontNames,
extensionName: "GenFonts", staticVar: false,
isSwiftUI: true) extensionName: "GenFonts",
isSwiftUI: true,
visibility: .package
)
// Expect // Expect
let expect = """ let expect = """
@ -77,18 +83,18 @@ final class FontExtensionGeneratorTests: XCTestCase {
extension GenFonts { extension GenFonts {
enum FontName: String { package enum FontName: String {
case CircularStdRegular = "CircularStd-Regular" case CircularStdRegular = "CircularStd-Regular"
case CircularStdBold = "CircularStd-Bold" case CircularStdBold = "CircularStd-Bold"
} }
// MARK: - Getter // MARK: - Getter
func CircularStdRegular(withSize size: CGFloat) -> Font { package func CircularStdRegular(withSize size: CGFloat) -> Font {
Font.custom(FontName.CircularStdRegular.rawValue, size: size) Font.custom(FontName.CircularStdRegular.rawValue, size: size)
} }
func CircularStdBold(withSize size: CGFloat) -> Font { package func CircularStdBold(withSize size: CGFloat) -> Font {
Font.custom(FontName.CircularStdBold.rawValue, size: size) Font.custom(FontName.CircularStdBold.rawValue, size: size)
} }

View File

@ -21,11 +21,15 @@ final class FontNameTests: XCTestCase {
) )
// When // When
let property = fontName.getProperty(isStatic: true, isSwiftUI: false) let property = fontName.getProperty(
isStatic: true,
isSwiftUI: false,
visibility: .internal
)
// Expect // Expect
let expect = """ let expect = """
static let CircularStdBold: ((_ size: CGFloat) -> UIFont) = { size in internal static let CircularStdBold: ((_ size: CGFloat) -> UIFont) = { size in
UIFont(name: FontName.CircularStdBold.rawValue, size: size)! UIFont(name: FontName.CircularStdBold.rawValue, size: size)!
} }
""" """
@ -42,11 +46,15 @@ final class FontNameTests: XCTestCase {
) )
// When // When
let property = fontName.getProperty(isStatic: true, isSwiftUI: false) let property = fontName.getProperty(
isStatic: true,
isSwiftUI: false,
visibility: .package
)
// Expect // Expect
let expect = """ let expect = """
static let CircularStdBoldUnderline: ((_ size: CGFloat) -> UIFont) = { size in package static let CircularStdBoldUnderline: ((_ size: CGFloat) -> UIFont) = { size in
UIFont(name: FontName.CircularStdBoldUnderline.rawValue, size: size)! UIFont(name: FontName.CircularStdBoldUnderline.rawValue, size: size)!
} }
""" """
@ -63,11 +71,15 @@ final class FontNameTests: XCTestCase {
) )
// When // When
let property = fontName.getProperty(isStatic: false, isSwiftUI: false) let property = fontName.getProperty(
isStatic: false,
isSwiftUI: false,
visibility: .private
)
// Expect // Expect
let expect = """ let expect = """
func CircularStdBold(withSize size: CGFloat) -> UIFont { private func CircularStdBold(withSize size: CGFloat) -> UIFont {
UIFont(name: FontName.CircularStdBold.rawValue, size: size)! UIFont(name: FontName.CircularStdBold.rawValue, size: size)!
} }
""" """
@ -84,11 +96,15 @@ final class FontNameTests: XCTestCase {
) )
// When // When
let property = fontName.getProperty(isStatic: false, isSwiftUI: false) let property = fontName.getProperty(
isStatic: false,
isSwiftUI: false,
visibility: .public
)
// Expect // Expect
let expect = """ let expect = """
func CircularStdBoldUnderline(withSize size: CGFloat) -> UIFont { public func CircularStdBoldUnderline(withSize size: CGFloat) -> UIFont {
UIFont(name: FontName.CircularStdBoldUnderline.rawValue, size: size)! UIFont(name: FontName.CircularStdBoldUnderline.rawValue, size: size)!
} }
""" """
@ -105,11 +121,15 @@ final class FontNameTests: XCTestCase {
) )
// When // When
let property = fontName.getProperty(isStatic: true, isSwiftUI: true) let property = fontName.getProperty(
isStatic: true,
isSwiftUI: true,
visibility: .public
)
// Expect // Expect
let expect = """ let expect = """
static let CircularStdBold: ((_ size: CGFloat) -> Font) = { size in public static let CircularStdBold: ((_ size: CGFloat) -> Font) = { size in
Font.custom(FontName.CircularStdBold.rawValue, size: size) Font.custom(FontName.CircularStdBold.rawValue, size: size)
} }
""" """
@ -126,11 +146,15 @@ final class FontNameTests: XCTestCase {
) )
// When // When
let property = fontName.getProperty(isStatic: true, isSwiftUI: true) let property = fontName.getProperty(
isStatic: true,
isSwiftUI: true,
visibility: .package
)
// Expect // Expect
let expect = """ let expect = """
static let CircularStdBoldUnderline: ((_ size: CGFloat) -> Font) = { size in package static let CircularStdBoldUnderline: ((_ size: CGFloat) -> Font) = { size in
Font.custom(FontName.CircularStdBoldUnderline.rawValue, size: size) Font.custom(FontName.CircularStdBoldUnderline.rawValue, size: size)
} }
""" """
@ -147,11 +171,15 @@ final class FontNameTests: XCTestCase {
) )
// When // When
let property = fontName.getProperty(isStatic: false, isSwiftUI: true) let property = fontName.getProperty(
isStatic: false,
isSwiftUI: true,
visibility: .package
)
// Expect // Expect
let expect = """ let expect = """
func CircularStdBold(withSize size: CGFloat) -> Font { package func CircularStdBold(withSize size: CGFloat) -> Font {
Font.custom(FontName.CircularStdBold.rawValue, size: size) Font.custom(FontName.CircularStdBold.rawValue, size: size)
} }
""" """
@ -168,11 +196,15 @@ final class FontNameTests: XCTestCase {
) )
// When // When
let property = fontName.getProperty(isStatic: false, isSwiftUI: true) let property = fontName.getProperty(
isStatic: false,
isSwiftUI: true,
visibility: .internal
)
// Expect // Expect
let expect = """ let expect = """
func CircularStdBoldUnderline(withSize size: CGFloat) -> Font { internal func CircularStdBoldUnderline(withSize size: CGFloat) -> Font {
Font.custom(FontName.CircularStdBoldUnderline.rawValue, size: size) Font.custom(FontName.CircularStdBoldUnderline.rawValue, size: size)
} }
""" """

View File

@ -0,0 +1,76 @@
//
// AnalyticsConfigurationTests.swift
// ResgenSwift
//
// Created by Thibaut Schmitt on 18/07/2025.
//
import Foundation
@testable import ResgenSwift
import XCTest
final class AnalyticsConfigurationTests: XCTestCase {
let projectDirectory = "projectDirectory/"
func test_argsGeneration_requiredArgs() {
// Given
let testingConfiguration = AnalyticsConfiguration(
inputFile: "path/to/tags.yml",
target: "matomo firebase",
outputFile: "Analytics/Generated/AnalyticsManager.swift",
visibility: nil,
staticMembers: nil
)
// When
let arguments = testingConfiguration.getArguments(
projectDirectory: projectDirectory,
force: false
)
// Expect
let expectedArguments = [
"projectDirectory/path/to/tags.yml",
"--target",
"matomo firebase",
"--output-file",
"projectDirectory/Analytics/Generated/AnalyticsManager.swift",
]
XCTAssertEqual(arguments, expectedArguments)
}
func test_argsGeneration_allArguments() {
// Given
let testingConfiguration = AnalyticsConfiguration(
inputFile: "path/to/tags.yml",
target: "matomo firebase",
outputFile: "Analytics/Generated/AnalyticsManager.swift",
visibility: "public",
staticMembers: false
)
// When
let arguments = testingConfiguration.getArguments(
projectDirectory: projectDirectory,
force: true
)
// Expect
let expectedArguments = [
"-f",
"projectDirectory/path/to/tags.yml",
"--target",
"matomo firebase",
"--output-file",
"projectDirectory/Analytics/Generated/AnalyticsManager.swift",
"--visibility",
"public",
"--static-members",
"false"
]
XCTAssertEqual(arguments, expectedArguments)
}
}

View File

@ -16,16 +16,22 @@ final class ColorsConfigurationTests: XCTestCase {
func test_argsGeneration_requiredArgs() { func test_argsGeneration_requiredArgs() {
// Given // Given
let testingConfiguration = ColorsConfiguration(inputFile: "path/to/colors.txt", let testingConfiguration = ColorsConfiguration(
style: ColorStyle.all.rawValue, inputFile: "path/to/colors.txt",
xcassetsPath: "path/to/assets.xcassets", style: ColorStyle.all.rawValue,
extensionOutputPath: nil, xcassetsPath: "path/to/assets.xcassets",
extensionName: nil, extensionOutputPath: nil,
extensionNameUIKit: nil, extensionName: nil,
extensionSuffix: nil, extensionNameUIKit: nil,
staticMembers: false) extensionSuffix: nil,
visibility: nil,
staticMembers: false
)
// When // When
let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: false) let arguments = testingConfiguration.getArguments(
projectDirectory: projectDirectory,
force: false
)
// Expect // Expect
let expectedArguments = [ let expectedArguments = [
@ -43,16 +49,22 @@ final class ColorsConfigurationTests: XCTestCase {
func test_argsGeneration_allArguments() { func test_argsGeneration_allArguments() {
// Given // Given
let testingConfiguration = ColorsConfiguration(inputFile: "path/to/colors.txt", let testingConfiguration = ColorsConfiguration(
style: ColorStyle.all.rawValue, inputFile: "path/to/colors.txt",
xcassetsPath: "path/to/assets.xcassets", style: ColorStyle.all.rawValue,
extensionOutputPath: "Colors/Generated", xcassetsPath: "path/to/assets.xcassets",
extensionName: "AppUIColor", extensionOutputPath: "Colors/Generated",
extensionNameUIKit: "AppColor", extensionName: "AppUIColor",
extensionSuffix: "Testing", extensionNameUIKit: "AppColor",
staticMembers: false) extensionSuffix: "Testing",
visibility: "public",
staticMembers: false
)
// When // When
let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: true) let arguments = testingConfiguration.getArguments(
projectDirectory: projectDirectory,
force: true
)
// Expect // Expect
let expectedArguments = [ let expectedArguments = [
@ -62,8 +74,6 @@ final class ColorsConfigurationTests: XCTestCase {
"all", "all",
"--xcassets-path", "--xcassets-path",
"projectDirectory/path/to/assets.xcassets", "projectDirectory/path/to/assets.xcassets",
"--static-members",
"false",
"--extension-output-path", "--extension-output-path",
"projectDirectory/Colors/Generated", "projectDirectory/Colors/Generated",
"--extension-name", "--extension-name",
@ -72,6 +82,10 @@ final class ColorsConfigurationTests: XCTestCase {
"AppColor", "AppColor",
"--extension-suffix", "--extension-suffix",
"Testing", "Testing",
"--visibility",
"public",
"--static-members",
"false"
] ]
XCTAssertEqual(arguments, expectedArguments) XCTAssertEqual(arguments, expectedArguments)

View File

@ -16,21 +16,25 @@ final class FontsConfigurationTests: XCTestCase {
func test_argsGeneration_requiredArgs() { func test_argsGeneration_requiredArgs() {
// Given // Given
let testingConfiguration = FontsConfiguration(inputFile: "path/to/fonts.txt", let testingConfiguration = FontsConfiguration(
extensionOutputPath: nil, inputFile: "path/to/fonts.txt",
extensionName: nil, extensionOutputPath: nil,
extensionNameUIKit: nil, extensionName: nil,
extensionSuffix: nil, extensionNameUIKit: nil,
infoPlistPaths: nil, extensionSuffix: nil,
staticMembers: nil) infoPlistPaths: nil,
visibility: nil,
staticMembers: nil
)
// When // When
let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: false) let arguments = testingConfiguration.getArguments(
projectDirectory: projectDirectory,
force: false
)
// Expect // Expect
let expectedArguments = [ let expectedArguments = [
"projectDirectory/path/to/fonts.txt", "projectDirectory/path/to/fonts.txt"
"--static-members",
"false"
] ]
XCTAssertEqual(arguments, expectedArguments) XCTAssertEqual(arguments, expectedArguments)
@ -38,22 +42,26 @@ final class FontsConfigurationTests: XCTestCase {
func test_argsGeneration_allArguments() { func test_argsGeneration_allArguments() {
// Given // Given
let testingConfiguration = FontsConfiguration(inputFile: "path/to/fonts.txt", let testingConfiguration = FontsConfiguration(
extensionOutputPath: "Fonts/Generated", inputFile: "path/to/fonts.txt",
extensionName: "AppUIFont", extensionOutputPath: "Fonts/Generated",
extensionNameUIKit: "AppFont", extensionName: "AppUIFont",
extensionSuffix: "Testing", extensionNameUIKit: "AppFont",
infoPlistPaths: "path/to/plist1.plist path/to/plist2.plist", extensionSuffix: "Testing",
staticMembers: true) infoPlistPaths: "path/to/plist1.plist path/to/plist2.plist",
visibility: "package",
staticMembers: true
)
// When // When
let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: true) let arguments = testingConfiguration.getArguments(
projectDirectory: projectDirectory,
force: true
)
// Expect // Expect
let expectedArguments = [ let expectedArguments = [
"-f", "-f",
"projectDirectory/path/to/fonts.txt", "projectDirectory/path/to/fonts.txt",
"--static-members",
"true",
"--extension-output-path", "--extension-output-path",
"projectDirectory/Fonts/Generated", "projectDirectory/Fonts/Generated",
"--extension-name", "--extension-name",
@ -62,6 +70,10 @@ final class FontsConfigurationTests: XCTestCase {
"AppFont", "AppFont",
"--extension-suffix", "--extension-suffix",
"Testing", "Testing",
"--visibility",
"package",
"--static-members",
"true",
"--info-plist-paths", "--info-plist-paths",
"projectDirectory/path/to/plist1.plist projectDirectory/path/to/plist2.plist" "projectDirectory/path/to/plist1.plist projectDirectory/path/to/plist2.plist"
] ]

View File

@ -16,24 +16,28 @@ final class ImagesConfigurationTests: XCTestCase {
func test_argsGeneration_requiredArgs() { func test_argsGeneration_requiredArgs() {
// Given // Given
let testingConfiguration = ImagesConfiguration(inputFile: "path/to/images.txt", let testingConfiguration = ImagesConfiguration(
xcassetsPath: "path/to/assets.xcassets", inputFile: "path/to/images.txt",
extensionOutputPath: nil, xcassetsPath: "path/to/assets.xcassets",
extensionName: nil, extensionOutputPath: nil,
extensionNameUIKit: nil, extensionName: nil,
extensionSuffix: nil, extensionNameUIKit: nil,
staticMembers: nil) extensionSuffix: nil,
visibility: nil,
staticMembers: nil
)
// When // When
let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: false) let arguments = testingConfiguration.getArguments(
projectDirectory: projectDirectory,
force: false
)
// Expect // Expect
let expectedArguments = [ let expectedArguments = [
"projectDirectory/path/to/images.txt", "projectDirectory/path/to/images.txt",
"--xcassets-path", "--xcassets-path",
"projectDirectory/path/to/assets.xcassets", "projectDirectory/path/to/assets.xcassets"
"--static-members",
"false"
] ]
XCTAssertEqual(arguments, expectedArguments) XCTAssertEqual(arguments, expectedArguments)
@ -41,16 +45,22 @@ final class ImagesConfigurationTests: XCTestCase {
func test_argsGeneration_allArguments() { func test_argsGeneration_allArguments() {
// Given // Given
let testingConfiguration = ImagesConfiguration(inputFile: "path/to/images.txt", let testingConfiguration = ImagesConfiguration(
xcassetsPath: "path/to/assets.xcassets", inputFile: "path/to/images.txt",
extensionOutputPath: "Images/Generated", xcassetsPath: "path/to/assets.xcassets",
extensionName: "AppUIImage", extensionOutputPath: "Images/Generated",
extensionNameUIKit: "AppImage", extensionName: "AppUIImage",
extensionSuffix: "Testing", extensionNameUIKit: "AppImage",
staticMembers: true) extensionSuffix: "Testing",
visibility: "private",
staticMembers: true
)
// When // When
let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: true) let arguments = testingConfiguration.getArguments(
projectDirectory: projectDirectory,
force: true
)
// Expect // Expect
let expectedArguments = [ let expectedArguments = [
@ -58,8 +68,6 @@ final class ImagesConfigurationTests: XCTestCase {
"projectDirectory/path/to/images.txt", "projectDirectory/path/to/images.txt",
"--xcassets-path", "--xcassets-path",
"projectDirectory/path/to/assets.xcassets", "projectDirectory/path/to/assets.xcassets",
"--static-members",
"true",
"--extension-output-path", "--extension-output-path",
"projectDirectory/Images/Generated", "projectDirectory/Images/Generated",
"--extension-name", "--extension-name",
@ -68,6 +76,10 @@ final class ImagesConfigurationTests: XCTestCase {
"AppImage", "AppImage",
"--extension-suffix", "--extension-suffix",
"Testing", "Testing",
"--visibility",
"private",
"--static-members",
"true"
] ]
XCTAssertEqual(arguments, expectedArguments) XCTAssertEqual(arguments, expectedArguments)

View File

@ -0,0 +1,98 @@
//
// StringsConfigurationTests.swift
// ResgenSwift
//
// Created by Thibaut Schmitt on 18/07/2025.
//
import Foundation
@testable import ResgenSwift
import XCTest
final class StringsConfigurationTests: XCTestCase {
let projectDirectory = "projectDirectory/"
func test_argsGeneration_requiredArgs() {
// Given
let testingConfiguration = StringsConfiguration(
inputFile: "path/to/strings.txt",
outputPath: "Strings/Generated",
langs: "fr en en-us",
defaultLang: "en",
extensionOutputPath: nil, // Strings/Generated
extensionName: nil, // String
extensionSuffix: nil, // Testing
visibility: nil, // "internal"
staticMembers: nil, // true
xcStrings: nil // true
)
// When
let arguments = testingConfiguration.getArguments(
projectDirectory: projectDirectory,
force: false
)
// Expect
let expectedArguments = [
"projectDirectory/path/to/strings.txt",
"--output-path",
"projectDirectory/Strings/Generated",
"--langs",
"fr en en-us",
"--default-lang",
"en"
]
XCTAssertEqual(arguments, expectedArguments)
}
func test_argsGeneration_allArguments() {
// Given
let testingConfiguration = StringsConfiguration(
inputFile: "path/to/strings.txt",
outputPath: "Strings/Generated",
langs: "fr en en-us",
defaultLang: "en",
extensionOutputPath: "Strings/Generated",
extensionName: "AppString",
extensionSuffix: "Testing",
visibility: "internal",
staticMembers: true,
xcStrings: true
)
// When
let arguments = testingConfiguration.getArguments(
projectDirectory: projectDirectory,
force: true
)
// Expect
let expectedArguments = [
"-f",
"projectDirectory/path/to/strings.txt",
"--output-path",
"projectDirectory/Strings/Generated",
"--langs",
"fr en en-us",
"--default-lang",
"en",
"--extension-output-path",
"projectDirectory/Strings/Generated",
"--extension-name",
"AppString",
"--extension-suffix",
"Testing",
"--visibility",
"internal",
"--xc-strings",
"true",
"--static-members",
"true"
]
XCTAssertEqual(arguments, expectedArguments)
}
}

View File

@ -0,0 +1,84 @@
//
// TagsConfigurationTests.swift
// ResgenSwift
//
// Created by Thibaut Schmitt on 18/07/2025.
//
import Foundation
@testable import ResgenSwift
import XCTest
final class TagsConfigurationTests: XCTestCase {
let projectDirectory = "projectDirectory/"
func test_argsGeneration_requiredArgs() {
// Given
let testingConfiguration = TagsConfiguration(
inputFile: "path/to/tags.txt",
lang: "ium",
extensionOutputPath: "Tags/Generated",
extensionName: nil,
extensionSuffix: nil,
visibility: nil,
staticMembers: nil
)
// When
let arguments = testingConfiguration.getArguments(
projectDirectory: projectDirectory,
force: false
)
// Expect
let expectedArguments = [
"projectDirectory/path/to/tags.txt",
"--lang",
"ium",
"--extension-output-path",
"projectDirectory/Tags/Generated"
]
XCTAssertEqual(arguments, expectedArguments)
}
func test_argsGeneration_allArguments() {
// Given
let testingConfiguration = TagsConfiguration(
inputFile: "path/to/tags.txt",
lang: "ium",
extensionOutputPath: "Tags/Generated",
extensionName: "AppTag",
extensionSuffix: "Testing",
visibility: "private",
staticMembers: true
)
// When
let arguments = testingConfiguration.getArguments(
projectDirectory: projectDirectory,
force: true
)
// Expect
let expectedArguments = [
"-f",
"projectDirectory/path/to/tags.txt",
"--lang",
"ium",
"--extension-output-path",
"projectDirectory/Tags/Generated",
"--extension-name",
"AppTag",
"--extension-suffix",
"Testing",
"--visibility",
"private",
"--static-members",
"true"
]
XCTAssertEqual(arguments, expectedArguments)
}
}

View File

@ -21,11 +21,14 @@ final class ImageExtensionGeneratorTests: XCTestCase {
] ]
// When // When
let extensionContent = ImageExtensionGenerator.getExtensionContent(images: images, let extensionContent = ImageExtensionGenerator.getExtensionContent(
staticVar: false, images: images,
extensionName: "GenImages", staticVar: false,
inputFilename: "myInputFilename", extensionName: "GenImages",
isSwiftUI: false) inputFilename: "myInputFilename",
isSwiftUI: false,
visibility: .public
)
// Expect // Expect
let expect = """ let expect = """
@ -36,11 +39,11 @@ final class ImageExtensionGeneratorTests: XCTestCase {
extension GenImages { extension GenImages {
var image_one: UIImage { public var image_one: UIImage {
UIImage(named: "image_one")! UIImage(named: "image_one")!
} }
var image_two: UIImage { public var image_two: UIImage {
UIImage(named: "image_two")! UIImage(named: "image_two")!
} }
} }
@ -57,11 +60,14 @@ final class ImageExtensionGeneratorTests: XCTestCase {
] ]
// When // When
let extensionContent = ImageExtensionGenerator.getExtensionContent(images: images, let extensionContent = ImageExtensionGenerator.getExtensionContent(
staticVar: true, images: images,
extensionName: "GenImages", staticVar: true,
inputFilename: "myInputFilename", extensionName: "GenImages",
isSwiftUI: false) inputFilename: "myInputFilename",
isSwiftUI: false,
visibility: .internal
)
// Expect // Expect
let expect = """ let expect = """
@ -72,11 +78,11 @@ final class ImageExtensionGeneratorTests: XCTestCase {
extension GenImages { extension GenImages {
static var image_one: UIImage { internal static var image_one: UIImage {
UIImage(named: "image_one")! UIImage(named: "image_one")!
} }
static var image_two: UIImage { internal static var image_two: UIImage {
UIImage(named: "image_two")! UIImage(named: "image_two")!
} }
} }
@ -93,11 +99,14 @@ final class ImageExtensionGeneratorTests: XCTestCase {
] ]
// When // When
let extensionContent = ImageExtensionGenerator.getExtensionContent(images: images, let extensionContent = ImageExtensionGenerator.getExtensionContent(
staticVar: false, images: images,
extensionName: "GenImages", staticVar: false,
inputFilename: "myInputFilename", extensionName: "GenImages",
isSwiftUI: true) inputFilename: "myInputFilename",
isSwiftUI: true,
visibility: .public
)
// Expect // Expect
let expect = """ let expect = """
@ -108,11 +117,11 @@ final class ImageExtensionGeneratorTests: XCTestCase {
extension GenImages { extension GenImages {
var image_one: Image { public var image_one: Image {
Image("image_one") Image("image_one")
} }
var image_two: Image { public var image_two: Image {
Image("image_two") Image("image_two")
} }
} }
@ -129,11 +138,14 @@ final class ImageExtensionGeneratorTests: XCTestCase {
] ]
// When // When
let extensionContent = ImageExtensionGenerator.getExtensionContent(images: images, let extensionContent = ImageExtensionGenerator.getExtensionContent(
staticVar: true, images: images,
extensionName: "GenImages", staticVar: true,
inputFilename: "myInputFilename", extensionName: "GenImages",
isSwiftUI: true) inputFilename: "myInputFilename",
isSwiftUI: true,
visibility: .package
)
// Expect // Expect
let expect = """ let expect = """
@ -144,11 +156,11 @@ final class ImageExtensionGeneratorTests: XCTestCase {
extension GenImages { extension GenImages {
static var image_one: Image { package static var image_one: Image {
Image("image_one") Image("image_one")
} }
static var image_two: Image { package static var image_two: Image {
Image("image_two") Image("image_two")
} }
} }

View File

@ -37,17 +37,23 @@ final class ParsedImageTests: XCTestCase {
func test_uiKit_GeneratedProperty() { func test_uiKit_GeneratedProperty() {
// Given // Given
let imageName = "the_name" let imageName = "the_name"
let parsedImage = ParsedImage(name: imageName, let parsedImage = ParsedImage(
tags: "id", name: imageName,
width: 10, tags: "id",
height: 10) width: 10,
height: 10
)
// When // When
let property = parsedImage.getImageProperty(isStatic: false, isSwiftUI: false) let property = parsedImage.getImageProperty(
isStatic: false,
isSwiftUI: false,
visibility: .public
)
// Expect // Expect
let expect = """ let expect = """
var \(imageName): UIImage { public var \(imageName): UIImage {
UIImage(named: "\(imageName)")! UIImage(named: "\(imageName)")!
} }
""" """
@ -58,17 +64,23 @@ final class ParsedImageTests: XCTestCase {
func test_uiKit_GeneratedStaticProperty() { func test_uiKit_GeneratedStaticProperty() {
// Given // Given
let imageName = "the_name" let imageName = "the_name"
let parsedImage = ParsedImage(name: imageName, let parsedImage = ParsedImage(
tags: "id", name: imageName,
width: 10, tags: "id",
height: 10) width: 10,
height: 10
)
// When // When
let property = parsedImage.getImageProperty(isStatic: true, isSwiftUI: false) let property = parsedImage.getImageProperty(
isStatic: true,
isSwiftUI: false,
visibility: .internal
)
// Expect // Expect
let expect = """ let expect = """
static var \(imageName): UIImage { internal static var \(imageName): UIImage {
UIImage(named: "\(imageName)")! UIImage(named: "\(imageName)")!
} }
""" """
@ -79,17 +91,23 @@ final class ParsedImageTests: XCTestCase {
func test_swiftUI_GeneratedProperty() { func test_swiftUI_GeneratedProperty() {
// Given // Given
let imageName = "the_name" let imageName = "the_name"
let parsedImage = ParsedImage(name: imageName, let parsedImage = ParsedImage(
tags: "id", name: imageName,
width: 10, tags: "id",
height: 10) width: 10,
height: 10
)
// When // When
let property = parsedImage.getImageProperty(isStatic: false, isSwiftUI: true) let property = parsedImage.getImageProperty(
isStatic: false,
isSwiftUI: true,
visibility: .private
)
// Expect // Expect
let expect = """ let expect = """
var \(imageName): Image { private var \(imageName): Image {
Image("\(imageName)") Image("\(imageName)")
} }
""" """
@ -100,17 +118,23 @@ final class ParsedImageTests: XCTestCase {
func test_swiftUI_GeneratedStaticProperty() { func test_swiftUI_GeneratedStaticProperty() {
// Given // Given
let imageName = "the_name" let imageName = "the_name"
let parsedImage = ParsedImage(name: imageName, let parsedImage = ParsedImage(
tags: "id", name: imageName,
width: 10, tags: "id",
height: 10) width: 10,
height: 10
)
// When // When
let property = parsedImage.getImageProperty(isStatic: true, isSwiftUI: true) let property = parsedImage.getImageProperty(
isStatic: true,
isSwiftUI: true,
visibility: .package
)
// Expect // Expect
let expect = """ let expect = """
static var \(imageName): Image { package static var \(imageName): Image {
Image("\(imageName)") Image("\(imageName)")
} }
""" """
@ -121,10 +145,12 @@ final class ParsedImageTests: XCTestCase {
func testAssetContentJson() { func testAssetContentJson() {
// Given // Given
let imageName = "the_name" let imageName = "the_name"
let parsedImage = ParsedImage(name: imageName, let parsedImage = ParsedImage(
tags: "id", name: imageName,
width: 10, tags: "id",
height: 10) width: 10,
height: 10
)
// When // When
let property = parsedImage.generateImageContent(isVector: false) let property = parsedImage.generateImageContent(isVector: false)

View File

@ -8,9 +8,9 @@
// CPD-OFF // CPD-OFF
import Foundation import Foundation
import XCTest
@testable import ResgenSwift @testable import ResgenSwift
import ToolCore
import XCTest
final class DefinitionTests: XCTestCase { final class DefinitionTests: XCTestCase {
@ -94,9 +94,9 @@ final class DefinitionTests: XCTestCase {
] ]
// When // When
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr") let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr", visibility: .public)
let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en") let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en", visibility: .public)
let propertyEnUs = definition.getNSLocalizedStringProperty(forLang: "en-us") let propertyEnUs = definition.getNSLocalizedStringProperty(forLang: "en-us", visibility: .public)
// Expect // Expect
let expectFr = """ let expectFr = """
@ -105,7 +105,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// This is a comment /// This is a comment
var definition_name: String { public var definition_name: String {
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "C'est la traduction francaise", comment: "This is a comment") NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "C'est la traduction francaise", comment: "This is a comment")
} }
""" """
@ -116,7 +116,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// This is a comment /// This is a comment
var definition_name: String { public var definition_name: String {
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english translation", comment: "This is a comment") NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english translation", comment: "This is a comment")
} }
""" """
@ -127,7 +127,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// This is a comment /// This is a comment
var definition_name: String { public var definition_name: String {
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english us translation", comment: "This is a comment") NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english us translation", comment: "This is a comment")
} }
""" """
@ -149,9 +149,9 @@ final class DefinitionTests: XCTestCase {
] ]
// When // When
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr") let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr", visibility: .private)
let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en") let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en", visibility: .private)
let propertyEnUs = definition.getNSLocalizedStringProperty(forLang: "en-us") let propertyEnUs = definition.getNSLocalizedStringProperty(forLang: "en-us", visibility: .private)
// Expect // Expect
let expectFr = """ let expectFr = """
@ -160,7 +160,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
var definition_name: String { private var definition_name: String {
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "C'est la traduction francaise", comment: "") NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "C'est la traduction francaise", comment: "")
} }
""" """
@ -171,7 +171,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
var definition_name: String { private var definition_name: String {
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english translation", comment: "") NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english translation", comment: "")
} }
""" """
@ -182,7 +182,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
var definition_name: String { private var definition_name: String {
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english us translation", comment: "") NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english us translation", comment: "")
} }
""" """
@ -203,9 +203,9 @@ final class DefinitionTests: XCTestCase {
] ]
// When // When
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr") let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr", visibility: .public)
let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en") let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en", visibility: .public)
let propertyEnUs = definition.getNSLocalizedStringProperty(forLang: "en-us") let propertyEnUs = definition.getNSLocalizedStringProperty(forLang: "en-us", visibility: .public)
// Expect // Expect
let expectFr = """ let expectFr = """
@ -214,7 +214,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
var definition_name: String { public var definition_name: String {
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "C'est la traduction francaise", comment: "") NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "C'est la traduction francaise", comment: "")
} }
""" """
@ -225,7 +225,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
var definition_name: String { public var definition_name: String {
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english translation", comment: "") NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english translation", comment: "")
} }
""" """
@ -236,7 +236,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
var definition_name: String { public var definition_name: String {
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english us translation", comment: "") NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english us translation", comment: "")
} }
""" """
@ -260,10 +260,10 @@ final class DefinitionTests: XCTestCase {
] ]
// When // When
let propertyFr = definition.getNSLocalizedStringStaticProperty(forLang: "fr") let propertyFr = definition.getNSLocalizedStringStaticProperty(forLang: "fr", visibility: .public)
let propertyEn = definition.getNSLocalizedStringStaticProperty(forLang: "en") let propertyEn = definition.getNSLocalizedStringStaticProperty(forLang: "en", visibility: .public)
let propertyEnUs = definition.getNSLocalizedStringStaticProperty(forLang: "en-us") let propertyEnUs = definition.getNSLocalizedStringStaticProperty(forLang: "en-us", visibility: .public)
// Expect // Expect
let expectFr = """ let expectFr = """
/// Translation in fr : /// Translation in fr :
@ -271,7 +271,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// This is a comment /// This is a comment
static var definition_name: String { public static var definition_name: String {
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "C'est la traduction francaise", comment: "This is a comment") NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "C'est la traduction francaise", comment: "This is a comment")
} }
""" """
@ -282,7 +282,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// This is a comment /// This is a comment
static var definition_name: String { public static var definition_name: String {
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english translation", comment: "This is a comment") NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english translation", comment: "This is a comment")
} }
""" """
@ -293,7 +293,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// This is a comment /// This is a comment
static var definition_name: String { public static var definition_name: String {
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english us translation", comment: "This is a comment") NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english us translation", comment: "This is a comment")
} }
""" """
@ -315,9 +315,9 @@ final class DefinitionTests: XCTestCase {
] ]
// When // When
let propertyFr = definition.getNSLocalizedStringStaticProperty(forLang: "fr") let propertyFr = definition.getNSLocalizedStringStaticProperty(forLang: "fr", visibility: .internal)
let propertyEn = definition.getNSLocalizedStringStaticProperty(forLang: "en") let propertyEn = definition.getNSLocalizedStringStaticProperty(forLang: "en", visibility: .internal)
let propertyEnUs = definition.getNSLocalizedStringStaticProperty(forLang: "en-us") let propertyEnUs = definition.getNSLocalizedStringStaticProperty(forLang: "en-us", visibility: .internal)
// Expect // Expect
let expectFr = """ let expectFr = """
@ -326,7 +326,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
static var definition_name: String { internal static var definition_name: String {
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "C'est la traduction francaise", comment: "") NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "C'est la traduction francaise", comment: "")
} }
""" """
@ -337,7 +337,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
static var definition_name: String { internal static var definition_name: String {
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english translation", comment: "") NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english translation", comment: "")
} }
""" """
@ -348,7 +348,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
static var definition_name: String { internal static var definition_name: String {
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english us translation", comment: "") NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english us translation", comment: "")
} }
""" """
@ -369,9 +369,9 @@ final class DefinitionTests: XCTestCase {
] ]
// When // When
let propertyFr = definition.getNSLocalizedStringStaticProperty(forLang: "fr") let propertyFr = definition.getNSLocalizedStringStaticProperty(forLang: "fr", visibility: .internal)
let propertyEn = definition.getNSLocalizedStringStaticProperty(forLang: "en") let propertyEn = definition.getNSLocalizedStringStaticProperty(forLang: "en", visibility: .internal)
let propertyEnUs = definition.getNSLocalizedStringStaticProperty(forLang: "en-us") let propertyEnUs = definition.getNSLocalizedStringStaticProperty(forLang: "en-us", visibility: .internal)
// Expect // Expect
let expectFr = """ let expectFr = """
@ -380,7 +380,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
static var definition_name: String { internal static var definition_name: String {
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "C'est la traduction francaise", comment: "") NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "C'est la traduction francaise", comment: "")
} }
""" """
@ -391,7 +391,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
static var definition_name: String { internal static var definition_name: String {
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english translation", comment: "") NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english translation", comment: "")
} }
""" """
@ -402,7 +402,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
static var definition_name: String { internal static var definition_name: String {
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english us translation", comment: "") NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english us translation", comment: "")
} }
""" """
@ -422,8 +422,8 @@ final class DefinitionTests: XCTestCase {
] ]
// When // When
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr") let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr", visibility: .internal)
// Expect // Expect
let expectFr = """ let expectFr = """
/// Translation in fr : /// Translation in fr :
@ -431,7 +431,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// This is a comment /// This is a comment
var definition_name: String { internal var definition_name: String {
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "Welcome \"%@\" !", comment: "This is a comment") NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "Welcome \"%@\" !", comment: "This is a comment")
} }
@ -440,7 +440,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// This is a comment /// This is a comment
func definition_name(arg0: String) -> String { internal func definition_name(arg0: String) -> String {
String(format: self.definition_name, arg0) String(format: self.definition_name, arg0)
} }
""" """
@ -458,8 +458,8 @@ final class DefinitionTests: XCTestCase {
] ]
// When // When
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr") let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr", visibility: .private)
// Expect // Expect
let expectFr = """ let expectFr = """
/// Translation in fr : /// Translation in fr :
@ -467,7 +467,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// This is a comment /// This is a comment
var definition_name: String { private var definition_name: String {
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "Welcome \"%@\" ! Your age is %d :) Your weight is %f ;-)", comment: "This is a comment") NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "Welcome \"%@\" ! Your age is %d :) Your weight is %f ;-)", comment: "This is a comment")
} }
@ -476,7 +476,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// This is a comment /// This is a comment
func definition_name(arg0: String, arg1: Int, arg2: Double) -> String { private func definition_name(arg0: String, arg1: Int, arg2: Double) -> String {
String(format: self.definition_name, arg0, arg1, arg2) String(format: self.definition_name, arg0, arg1, arg2)
} }
""" """
@ -495,16 +495,16 @@ final class DefinitionTests: XCTestCase {
] ]
// When // When
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr") let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr", visibility: .public)
let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en") let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en", visibility: .public)
let expectFr = """ let expectFr = """
/// Translation in fr : /// Translation in fr :
/// Vous %%: %1$@ %2$@ Age: %3$d /// Vous %%: %1$@ %2$@ Age: %3$d
/// ///
/// Comment : /// Comment :
/// This is a comment /// This is a comment
var definition_name: String { public var definition_name: String {
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "Vous %%: %1$@ %2$@ Age: %3$d", comment: "This is a comment") NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "Vous %%: %1$@ %2$@ Age: %3$d", comment: "This is a comment")
} }
@ -513,7 +513,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// This is a comment /// This is a comment
func definition_name(arg0: String, arg1: String, arg2: Int) -> String { public func definition_name(arg0: String, arg1: String, arg2: Int) -> String {
String(format: self.definition_name, arg0, arg1, arg2) String(format: self.definition_name, arg0, arg1, arg2)
} }
""" """
@ -524,7 +524,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// This is a comment /// This is a comment
var definition_name: String { public var definition_name: String {
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "You %%: %2$@ %1$@ Age: %3$d", comment: "This is a comment") NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "You %%: %2$@ %1$@ Age: %3$d", comment: "This is a comment")
} }
@ -533,7 +533,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// This is a comment /// This is a comment
func definition_name(arg0: String, arg1: String, arg2: Int) -> String { public func definition_name(arg0: String, arg1: String, arg2: Int) -> String {
String(format: self.definition_name, arg0, arg1, arg2) String(format: self.definition_name, arg0, arg1, arg2)
} }
""" """
@ -556,10 +556,10 @@ final class DefinitionTests: XCTestCase {
] ]
// When // When
let propertyFr = definition.getProperty(forLang: "fr") let propertyFr = definition.getProperty(forLang: "fr", visibility: .public)
let propertyEn = definition.getProperty(forLang: "en") let propertyEn = definition.getProperty(forLang: "en", visibility: .public)
let propertyEnUs = definition.getProperty(forLang: "en-us") let propertyEnUs = definition.getProperty(forLang: "en-us", visibility: .public)
// Expect // Expect
let expectFr = """ let expectFr = """
/// Translation in fr : /// Translation in fr :
@ -567,7 +567,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// This is a comment /// This is a comment
var definition_name: String { public var definition_name: String {
"C'est la traduction francaise" "C'est la traduction francaise"
} }
""" """
@ -578,7 +578,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// This is a comment /// This is a comment
var definition_name: String { public var definition_name: String {
"This is the english translation" "This is the english translation"
} }
""" """
@ -589,7 +589,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// This is a comment /// This is a comment
var definition_name: String { public var definition_name: String {
"This is the english us translation" "This is the english us translation"
} }
""" """
@ -611,9 +611,9 @@ final class DefinitionTests: XCTestCase {
] ]
// When // When
let propertyFr = definition.getProperty(forLang: "fr") let propertyFr = definition.getProperty(forLang: "fr", visibility: .package)
let propertyEn = definition.getProperty(forLang: "en") let propertyEn = definition.getProperty(forLang: "en", visibility: .package)
let propertyEnUs = definition.getProperty(forLang: "en-us") let propertyEnUs = definition.getProperty(forLang: "en-us", visibility: .package)
// Expect // Expect
let expectFr = """ let expectFr = """
@ -622,7 +622,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
var definition_name: String { package var definition_name: String {
"C'est la traduction francaise" "C'est la traduction francaise"
} }
""" """
@ -633,7 +633,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
var definition_name: String { package var definition_name: String {
"This is the english translation" "This is the english translation"
} }
""" """
@ -644,7 +644,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
var definition_name: String { package var definition_name: String {
"This is the english us translation" "This is the english us translation"
} }
""" """
@ -665,9 +665,9 @@ final class DefinitionTests: XCTestCase {
] ]
// When // When
let propertyFr = definition.getProperty(forLang: "fr") let propertyFr = definition.getProperty(forLang: "fr", visibility: .private)
let propertyEn = definition.getProperty(forLang: "en") let propertyEn = definition.getProperty(forLang: "en", visibility: .private)
let propertyEnUs = definition.getProperty(forLang: "en-us") let propertyEnUs = definition.getProperty(forLang: "en-us", visibility: .private)
// Expect // Expect
let expectFr = """ let expectFr = """
@ -676,7 +676,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
var definition_name: String { private var definition_name: String {
"C'est la traduction francaise" "C'est la traduction francaise"
} }
""" """
@ -687,7 +687,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
var definition_name: String { private var definition_name: String {
"This is the english translation" "This is the english translation"
} }
""" """
@ -698,7 +698,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
var definition_name: String { private var definition_name: String {
"This is the english us translation" "This is the english us translation"
} }
""" """
@ -722,10 +722,10 @@ final class DefinitionTests: XCTestCase {
] ]
// When // When
let propertyFr = definition.getStaticProperty(forLang: "fr") let propertyFr = definition.getStaticProperty(forLang: "fr", visibility: .internal)
let propertyEn = definition.getStaticProperty(forLang: "en") let propertyEn = definition.getStaticProperty(forLang: "en", visibility: .internal)
let propertyEnUs = definition.getStaticProperty(forLang: "en-us") let propertyEnUs = definition.getStaticProperty(forLang: "en-us", visibility: .internal)
// Expect // Expect
let expectFr = """ let expectFr = """
/// Translation in fr : /// Translation in fr :
@ -733,7 +733,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// This is a comment /// This is a comment
static var definition_name: String { internal static var definition_name: String {
"C'est la traduction francaise" "C'est la traduction francaise"
} }
""" """
@ -744,7 +744,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// This is a comment /// This is a comment
static var definition_name: String { internal static var definition_name: String {
"This is the english translation" "This is the english translation"
} }
""" """
@ -755,7 +755,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// This is a comment /// This is a comment
static var definition_name: String { internal static var definition_name: String {
"This is the english us translation" "This is the english us translation"
} }
""" """
@ -777,9 +777,9 @@ final class DefinitionTests: XCTestCase {
] ]
// When // When
let propertyFr = definition.getStaticProperty(forLang: "fr") let propertyFr = definition.getStaticProperty(forLang: "fr", visibility: .internal)
let propertyEn = definition.getStaticProperty(forLang: "en") let propertyEn = definition.getStaticProperty(forLang: "en", visibility: .internal)
let propertyEnUs = definition.getStaticProperty(forLang: "en-us") let propertyEnUs = definition.getStaticProperty(forLang: "en-us", visibility: .internal)
// Expect // Expect
let expectFr = """ let expectFr = """
@ -788,7 +788,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
static var definition_name: String { internal static var definition_name: String {
"C'est la traduction francaise" "C'est la traduction francaise"
} }
""" """
@ -799,7 +799,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
static var definition_name: String { internal static var definition_name: String {
"This is the english translation" "This is the english translation"
} }
""" """
@ -810,7 +810,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
static var definition_name: String { internal static var definition_name: String {
"This is the english us translation" "This is the english us translation"
} }
""" """
@ -831,9 +831,9 @@ final class DefinitionTests: XCTestCase {
] ]
// When // When
let propertyFr = definition.getStaticProperty(forLang: "fr") let propertyFr = definition.getStaticProperty(forLang: "fr", visibility: .internal)
let propertyEn = definition.getStaticProperty(forLang: "en") let propertyEn = definition.getStaticProperty(forLang: "en", visibility: .internal)
let propertyEnUs = definition.getStaticProperty(forLang: "en-us") let propertyEnUs = definition.getStaticProperty(forLang: "en-us", visibility: .internal)
// Expect // Expect
let expectFr = """ let expectFr = """
@ -842,7 +842,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
static var definition_name: String { internal static var definition_name: String {
"C'est la traduction francaise" "C'est la traduction francaise"
} }
""" """
@ -853,7 +853,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
static var definition_name: String { internal static var definition_name: String {
"This is the english translation" "This is the english translation"
} }
""" """
@ -864,7 +864,7 @@ final class DefinitionTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
static var definition_name: String { internal static var definition_name: String {
"This is the english us translation" "This is the english us translation"
} }
""" """

View File

@ -20,6 +20,7 @@ extension StringsFileGeneratorTests {
s2DefOneComment: String = "", s2DefOneComment: String = "",
s2DefTwoFr: String = "Section Deux - Definition Deux", s2DefTwoFr: String = "Section Deux - Definition Deux",
s2DefTwoComment: String = "", s2DefTwoComment: String = "",
visibility: ExtensionVisibility = .internal
) -> String { ) -> String {
""" """
// Generated by ResgenSwift.Strings.Stringium \(ResgenSwiftVersion) // Generated by ResgenSwift.Strings.Stringium \(ResgenSwiftVersion)
@ -30,13 +31,13 @@ extension StringsFileGeneratorTests {
extension GenStrings { extension GenStrings {
enum KeyStrings: String { \(visibility) enum KeyStrings: String {
case s1_def_one = "s1_def_one" case s1_def_one = "s1_def_one"
case s1_def_two = "s1_def_two" case s1_def_two = "s1_def_two"
case s2_def_one = "s2_def_one" case s2_def_one = "s2_def_one"
case s2_def_two = "s2_def_two" case s2_def_two = "s2_def_two"
var keyPath: KeyPath<GenStrings, String> { \(visibility) var keyPath: KeyPath<GenStrings, String> {
switch self { switch self {
case .s1_def_one: return \\GenStrings.s1_def_one case .s1_def_one: return \\GenStrings.s1_def_one
case .s1_def_two: return \\GenStrings.s1_def_two case .s1_def_two: return \\GenStrings.s1_def_two
@ -53,7 +54,7 @@ extension StringsFileGeneratorTests {
/// ///
/// Comment : /// Comment :
/// \(s1DefOneComment.isEmpty ? "No comment" : s1DefOneComment) /// \(s1DefOneComment.isEmpty ? "No comment" : s1DefOneComment)
\(staticVar ? "static " : "")var s1_def_one: String { \(visibility) \(staticVar ? "static " : "")var s1_def_one: String {
NSLocalizedString("s1_def_one", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Un - Definition Un", comment: "\(s1DefOneComment)") NSLocalizedString("s1_def_one", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Un - Definition Un", comment: "\(s1DefOneComment)")
} }
@ -62,7 +63,7 @@ extension StringsFileGeneratorTests {
/// ///
/// Comment : /// Comment :
/// \(s1DefTwoComment.isEmpty ? "No comment" : s1DefTwoComment) /// \(s1DefTwoComment.isEmpty ? "No comment" : s1DefTwoComment)
\(staticVar ? "static " : "")var s1_def_two: String { \(visibility) \(staticVar ? "static " : "")var s1_def_two: String {
NSLocalizedString("s1_def_two", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Un - Definition Deux", comment: "\(s1DefTwoComment)") NSLocalizedString("s1_def_two", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Un - Definition Deux", comment: "\(s1DefTwoComment)")
} }
@ -73,7 +74,7 @@ extension StringsFileGeneratorTests {
/// ///
/// Comment : /// Comment :
/// \(s2DefOneComment.isEmpty ? "No comment" : s2DefOneComment) /// \(s2DefOneComment.isEmpty ? "No comment" : s2DefOneComment)
\(staticVar ? "static " : "")var s2_def_one: String { \(visibility) \(staticVar ? "static " : "")var s2_def_one: String {
NSLocalizedString("s2_def_one", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Deux - Definition Un", comment: "\(s2DefOneComment)") NSLocalizedString("s2_def_one", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Deux - Definition Un", comment: "\(s2DefOneComment)")
} }
@ -82,7 +83,7 @@ extension StringsFileGeneratorTests {
/// ///
/// Comment : /// Comment :
/// \(s2DefTwoComment.isEmpty ? "No comment" : s2DefTwoComment) /// \(s2DefTwoComment.isEmpty ? "No comment" : s2DefTwoComment)
\(staticVar ? "static " : "")var s2_def_two: String { \(visibility) \(staticVar ? "static " : "")var s2_def_two: String {
NSLocalizedString("s2_def_two", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Deux - Definition Deux", comment: "\(s2DefTwoComment)") NSLocalizedString("s2_def_two", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Deux - Definition Deux", comment: "\(s2DefTwoComment)")
} }
} }

View File

@ -373,13 +373,16 @@ final class StringsFileGeneratorTests: XCTestCase {
let sectionTwo = Section.Mock.getSectionTwo() let sectionTwo = Section.Mock.getSectionTwo()
// When // When
let extensionContent = StringsFileGenerator.getExtensionContent(sections: [sectionOne, sectionTwo], let extensionContent = StringsFileGenerator.getExtensionContent(
defaultLang: "fr", sections: [sectionOne, sectionTwo],
tags: ["ios", "iosonly", "notranslation"], defaultLang: "fr",
staticVar: false, tags: ["ios", "iosonly", "notranslation"],
inputFilename: "myInputFilename", staticVar: false,
extensionName: "GenStrings", inputFilename: "myInputFilename",
extensionSuffix: "strings") extensionName: "GenStrings",
extensionSuffix: "strings",
visibility: .internal
)
// Expect // Expect
let expect = Self.getExtensionContentExpectation( let expect = Self.getExtensionContentExpectation(
@ -404,13 +407,16 @@ final class StringsFileGeneratorTests: XCTestCase {
) )
// When // When
let extensionContent = StringsFileGenerator.getExtensionContent(sections: [sectionOne, sectionTwo], let extensionContent = StringsFileGenerator.getExtensionContent(
defaultLang: "fr", sections: [sectionOne, sectionTwo],
tags: ["ios", "iosonly", "notranslation"], defaultLang: "fr",
staticVar: false, tags: ["ios", "iosonly", "notranslation"],
inputFilename: "myInputFilename", staticVar: false,
extensionName: "GenStrings", inputFilename: "myInputFilename",
extensionSuffix: "strings") extensionName: "GenStrings",
extensionSuffix: "strings",
visibility: .public
)
// Expect // Expect
let expect = Self.getExtensionContentExpectation( let expect = Self.getExtensionContentExpectation(
@ -419,6 +425,7 @@ final class StringsFileGeneratorTests: XCTestCase {
s1DefTwoComment: "This is a comment", s1DefTwoComment: "This is a comment",
s2DefOneComment: "This is a comment", s2DefOneComment: "This is a comment",
s2DefTwoComment: "This is a comment", s2DefTwoComment: "This is a comment",
visibility: .public
) )
if extensionContent != expect { if extensionContent != expect {
@ -434,17 +441,21 @@ final class StringsFileGeneratorTests: XCTestCase {
let sectionTwo = Section.Mock.getSectionTwo() let sectionTwo = Section.Mock.getSectionTwo()
// When // When
let extensionContent = StringsFileGenerator.getExtensionContent(sections: [sectionOne, sectionTwo], let extensionContent = StringsFileGenerator.getExtensionContent(
defaultLang: "fr", sections: [sectionOne, sectionTwo],
tags: ["ios", "iosonly", "notranslation"], defaultLang: "fr",
staticVar: true, tags: ["ios", "iosonly", "notranslation"],
inputFilename: "myInputFilename", staticVar: true,
extensionName: "GenStrings", inputFilename: "myInputFilename",
extensionSuffix: "strings") extensionName: "GenStrings",
extensionSuffix: "strings",
visibility: .package
)
// Expect // Expect
let expect = Self.getExtensionContentExpectation( let expect = Self.getExtensionContentExpectation(
staticVar: true staticVar: true,
visibility: .package
) )
if extensionContent != expect { if extensionContent != expect {
@ -465,13 +476,16 @@ final class StringsFileGeneratorTests: XCTestCase {
) )
// When // When
let extensionContent = StringsFileGenerator.getExtensionContent(sections: [sectionOne, sectionTwo], let extensionContent = StringsFileGenerator.getExtensionContent(
defaultLang: "fr", sections: [sectionOne, sectionTwo],
tags: ["ios", "iosonly", "notranslation"], defaultLang: "fr",
staticVar: true, tags: ["ios", "iosonly", "notranslation"],
inputFilename: "myInputFilename", staticVar: true,
extensionName: "GenStrings", inputFilename: "myInputFilename",
extensionSuffix: "strings") extensionName: "GenStrings",
extensionSuffix: "strings",
visibility: .internal
)
// Expect // Expect
let expect = Self.getExtensionContentExpectation( let expect = Self.getExtensionContentExpectation(
@ -480,6 +494,7 @@ final class StringsFileGeneratorTests: XCTestCase {
s1DefTwoComment: "This is a comment", s1DefTwoComment: "This is a comment",
s2DefOneComment: "This is a comment", s2DefOneComment: "This is a comment",
s2DefTwoComment: "This is a comment", s2DefTwoComment: "This is a comment",
visibility: .internal
) )
if extensionContent != expect { if extensionContent != expect {

View File

@ -13,7 +13,11 @@ import ToolCore
final class TagsGeneratorTests: XCTestCase { final class TagsGeneratorTests: XCTestCase {
private func getDefinition(name: String, lang: String, tags: [String]) -> Definition { private func getDefinition(
name: String,
lang: String,
tags: [String]
) -> Definition {
let definition = Definition(name: name) let definition = Definition(name: name)
definition.tags = tags definition.tags = tags
definition.translations = [lang: "Some translation"] definition.translations = [lang: "Some translation"]
@ -41,11 +45,15 @@ final class TagsGeneratorTests: XCTestCase {
] ]
// When // When
let extensionContent = TagsGenerator.getExtensionContent(sections: [sectionOne, sectionTwo, sectionThree], let extensionContent = TagsGenerator.getExtensionContent(
lang: "ium", sections: [sectionOne, sectionTwo, sectionThree],
tags: ["ios", "iosonly"], lang: "ium",
staticVar: false, tags: ["ios", "iosonly"],
extensionName: "GenTags") staticVar: false,
extensionName: "GenTags",
visibility: .public
)
// Expect Tags // Expect Tags
let expect = """ let expect = """
// Generated by ResgenSwift.Strings.Tags \(ResgenSwiftVersion) // Generated by ResgenSwift.Strings.Tags \(ResgenSwiftVersion)
@ -60,7 +68,7 @@ final class TagsGeneratorTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
var s1_def_one: String { public var s1_def_one: String {
"Some translation" "Some translation"
} }
@ -69,7 +77,7 @@ final class TagsGeneratorTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
var s1_def_two: String { public var s1_def_two: String {
"Some translation" "Some translation"
} }
@ -80,7 +88,7 @@ final class TagsGeneratorTests: XCTestCase {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
var s2_def_one: String { public var s2_def_one: String {
"Some translation" "Some translation"
} }
} }