15 Commits

Author SHA1 Message Date
3f64e9682c Add stencil on color
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
PixeeBox/resgen.swift/pipeline/head There was a failure building this commit
2023-12-15 09:49:11 +01:00
eed20367b9 fix: Edit for NSObject in Firebase
Some checks failed
gitea-openium/resgen.swift/pipeline/pr-master There was a failure building this commit
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
PixeeBox/resgen.swift/pipeline/head There was a failure building this commit
2023-12-13 11:24:21 +01:00
43b5111d79 Actualiser Sources/ResgenSwift/Analytics/Generator/AnalyticsGenerator.swift
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
2023-12-13 10:39:12 +01:00
2983093a9c Add Swiftlint 2023-12-13 10:39:12 +01:00
b4bbaa3bfd Fix Image 2023-12-13 10:39:12 +01:00
498c8fa4ae Fix Font 2023-12-13 10:39:12 +01:00
2957da6233 Fix Color 2023-12-13 10:39:12 +01:00
d79af06c38 docs: Add Analytics section in README
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
2023-12-13 10:27:35 +01:00
d8937f2de6 docs: Add Analytics section in README 2023-12-13 10:23:31 +01:00
9b27f24197 docs: Add Analytics section in README 2023-12-13 10:20:53 +01:00
1d58fd5510 Edit sample file
Some checks failed
gitea-openium/resgen.swift/pipeline/pr-master There was a failure building this commit
2023-12-12 16:58:25 +01:00
f6c49bf626 Add parse error
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
2023-12-11 11:19:19 +01:00
f1b62d83c4 Add missing print error
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
2023-12-11 10:29:19 +01:00
ee5055efa5 Retours sur la structure du code
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
2023-12-11 10:24:42 +01:00
6f8e3b6664 Add error handling
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
2023-12-11 10:09:24 +01:00
59 changed files with 794 additions and 363 deletions

View File

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

View File

@ -1,12 +1,102 @@
{
"pins" : [
{
"identity" : "collectionconcurrencykit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/JohnSundell/CollectionConcurrencyKit.git",
"state" : {
"revision" : "b4f23e24b5a1bff301efc5e70871083ca029ff95",
"version" : "0.2.0"
}
},
{
"identity" : "cryptoswift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/krzyzanowskim/CryptoSwift.git",
"state" : {
"revision" : "db51c407d3be4a051484a141bf0bff36c43d3b1e",
"version" : "1.8.0"
}
},
{
"identity" : "pathkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/kylef/PathKit.git",
"state" : {
"revision" : "3bfd2737b700b9a36565a8c94f4ad2b050a5e574",
"version" : "1.0.1"
}
},
{
"identity" : "sourcekitten",
"kind" : "remoteSourceControl",
"location" : "https://github.com/jpsim/SourceKitten.git",
"state" : {
"revision" : "b6dc09ee51dfb0c66e042d2328c017483a1a5d56",
"version" : "0.34.1"
}
},
{
"identity" : "spectre",
"kind" : "remoteSourceControl",
"location" : "https://github.com/kylef/Spectre.git",
"state" : {
"revision" : "26cc5e9ae0947092c7139ef7ba612e34646086c7",
"version" : "0.10.1"
}
},
{
"identity" : "stencil",
"kind" : "remoteSourceControl",
"location" : "https://github.com/stencilproject/Stencil.git",
"state" : {
"revision" : "4f222ac85d673f35df29962fc4c36ccfdaf9da5b",
"version" : "0.15.1"
}
},
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser",
"state" : {
"revision" : "9f39744e025c7d377987f30b03770805dcb0bcd1",
"version" : "1.1.4"
"revision" : "8f4d2753f0e4778c76d5f05ad16c74f707390531",
"version" : "1.2.3"
}
},
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"state" : {
"revision" : "6ad4ea24b01559dde0773e3d091f1b9e36175036",
"version" : "509.0.2"
}
},
{
"identity" : "swiftlint",
"kind" : "remoteSourceControl",
"location" : "https://github.com/realm/SwiftLint.git",
"state" : {
"revision" : "f17a4f9dfb6a6afb0408426354e4180daaf49cee",
"version" : "0.54.0"
}
},
{
"identity" : "swiftytexttable",
"kind" : "remoteSourceControl",
"location" : "https://github.com/scottrhoyt/SwiftyTextTable.git",
"state" : {
"revision" : "c6df6cf533d120716bff38f8ff9885e1ce2a4ac3",
"version" : "0.9.0"
}
},
{
"identity" : "swxmlhash",
"kind" : "remoteSourceControl",
"location" : "https://github.com/drmohundro/SWXMLHash.git",
"state" : {
"revision" : "a853604c9e9a83ad9954c7e3d2a565273982471f",
"version" : "7.0.2"
}
},
{
@ -14,8 +104,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/jpsim/Yams.git",
"state" : {
"revision" : "01835dc202670b5bb90d07f3eae41867e9ed29f6",
"version" : "5.0.1"
"revision" : "0d9ee7ea8c4ebd4a489ad7a73d5c6cad55d6fed3",
"version" : "5.0.6"
}
}
],

View File

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

View File

@ -16,7 +16,7 @@ iOS required to use the **real name** of the font, this name can be different fr
swift run -c release ResgenSwift fonts $FORCE_FLAG "./Fonts/fonts.txt" \
--extension-output-path "./Fonts/Generated" \
--extension-name "AppFont" \
--extension-name-swift-ui "SUIAppFont" \
--extension-name-ui-kit "UIAppFont" \
--extension-suffix "GreatApp" \
--static-members true \
--info-plist-paths "./path/one/to/Info.plist ./path/two/to/Info.plist"
@ -27,8 +27,8 @@ swift run -c release ResgenSwift fonts $FORCE_FLAG "./Fonts/fonts.txt" \
1. `-f`: force generation
2. Font input folder, it will search for every `.ttf` and `.otf` files specified in `fonts.txt`
3. `--extension-output-path`: path where to generate generated extension
4. `--extension-name` *(optional)* : name of the class to add UIKit getters
5. `--extension-name-swift-ui` *(optional)* : name of the class to add SwiftUI getters
4. `--extension-name` *(optional)* : name of the class to add SwiftUI getters
5. `--extension-name-ui-kit` *(optional)* : name of the class to add UIKit getters
6. `--extension-suffix` *(optional)* : additional text which is added to the filename (ex: `AppFont+GreatApp.swift`)
7. `--static-members` *(optional)*: generate static properties or not
8. `--info-plist-paths` *(optional)*: array of `.plist`, you can specify multiple `Info.plist` for multiple targets
@ -44,7 +44,7 @@ swift run -c release ResgenSwift colors $FORCE_FLAG "./Colors/colors.txt" \
--xcassets-path "./Colors/colors.xcassets" \
--extension-output-path "./Colors/Generated/" \
--extension-name "AppColor" \
--extension-name-swift-ui "SUIAppColor" \
--extension-name-ui-kit "UIAppColor" \
--extension-suffix "GreatApp" \
--static-members true
```
@ -55,8 +55,8 @@ swift run -c release ResgenSwift colors $FORCE_FLAG "./Colors/colors.txt" \
2. Input colors file
3. `--style` can be `all` or `light`
4. `--extension-output-path`: path where to generate generated extension
5. `--extension-name` *(optional)* : name of the class to add UIKit getters
6. `--extension-name-swift-ui` *(optional)* : name of the class to add SwiftUI getters
5. `--extension-name` *(optional)* : name of the class to add SwiftUI getters
6. `--extension-name-ui-kit` *(optional)* : name of the class to add UIKit getters
7. `--extension-suffix` *(optional)* : additional text which is added to filename (ex: `AppColor+GreatApp.swift`)
8. `--static-members` *(optional)*: generate static properties or not
@ -133,6 +133,71 @@ swift run -c release ResgenSwift strings tags $FORCE_FLAG "./Tags/tags.txt" \
> ⚠️ If extension name is not set or is `Tags`, it will generate the following typaloas `typealias Tags = String`.
## Analytics
Analytics will generate all you need to analyze UX with Matomo or Firebase Analytics. Input files are formatted in YAML. This command will generate a manager for each target and an AnalyticsManager. This is this one you will need to use. And it will generate a method for all tags you have declared in the YAML file. Next, you will need to use the `configure()` method of AnalyticsManager and if you want to use matomo to set up the `siteId` and the `url` of the site.
```sh
swift run -c release ResgenSwift strings tags $FORCE_FLAG "./Tags/tags.txt" \
--target "matomo firebase" \
--extension-output-path "./Analytics/Generated" \
--extension-name "AppAnalytics" \
--extension-suffix "GreatApp" \
--static-members true
```
**Parameters**
1. `-f`: force generation
2. Input tags file (must be YAML formatted)
3. `--target`: target with you will log UX
4. `--extension-output-path`: path where to generate generated extension
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
> ⚠️ If extension name is not set or is `Analytics`, it will generate the following typaloas `typealias Analytics = String`.
### YAML
```
- id: s1_def_one
name: s1 def one _TITLE_
path: s1_def_one/_TITLE_
action: Tap
category: User
tags: ios,droid
comments:
parameters:
- name: title
type: String
replaceIn: name,path
```
1. `id`: name of the method (method name will be composed of `log` + `Event|Screen` + `id`)
2. `name`: name of the tag
3. `path` *(optional with firebase)* : needed for matomo but not with firebase (log screen)
4. `action` *(optional with firebase)* : needed for matomo but not with firebase (log event)
5. `category` *(optional with firebase)* : needed for matomo but not with firebase (log event)
6. `tags`: which platform target
7. `comments` *(optional)*
8. `parameters` *(optional)*
**Parameters**
You can use parameters in generate methods.
1. `name`: name of the parameter
2. `type`: type of the parameter (Int, String, Bool, Double)
3. `replaceIn` *(optional)*
**Replace in**
This is section is equivalent of `%s | %d | %f | %@`. You can put the content of the parameter in *name*, *path*, *action*, *category*.
You need to put `_` + `NAME OF THE PARAMETER` + `_` in the target and which target you want in the value of `replaceIn`. (name need to be in uppercase)
## Images
Images generator will generate images assets along with extensions to access those images easily.
@ -142,7 +207,7 @@ swift run -c release ResgenSwift images $FORCE_FLAG "./Images/images.txt" \
--xcassets-path "./Images/app.xcassets" \
--extension-output-path "./Images/Generated" \
--extension-name "AppImage" \
--extension-name-swift-ui "SUIAppImage" \
--extension-name-ui-kit "UIAppImage" \
--extension-suffix "GreatApp" \
--static-members true
```
@ -153,8 +218,8 @@ swift run -c release ResgenSwift images $FORCE_FLAG "./Images/images.txt" \
2. Input images definitions file
3. `--xcassets-path`: xcasset path where to generate imagesets
4. `--extension-output-path`: path where to generate generated extension
5. `--extension-name` *(optional)* : name of the class to add UIKit getters
6. `--extension-name-swift-ui` *(optional)* : name of the class to add SwiftUI getters
5. `--extension-name` *(optional)* : name of the class to add SwiftUI getters
6. `--extension-name-ui-kit` *(optional)* : name of the class to add UIKit getters
6. `--extension-suffix` *(optional)* : additional text which is added to filename (ex: `AppImage+GreatApp.swift`)
7. `--static-members` *(optional)*: generate static properties or not
@ -176,7 +241,7 @@ colors:
xcassetsPath: String
extensionOutputPath: String
extensionName: String?
extensionNameSwiftUI: String?
extensionNameUIKit: String?
extensionSuffix: String?
staticMembers: Bool?
@ -185,7 +250,7 @@ fonts:
inputFile: String
extensionOutputPath: String
extensionName: String?
extensionNameSwiftUI: String?
extensionNameUIKit: String?
extensionSuffix: String?
staticMembers: Bool?
infoPlistPaths: [String]
@ -196,7 +261,7 @@ images:
xcassetsPath: String
extensionOutputPath: String
extensionName: String?
extensionNameSwiftUI: String?
extensionNameUIKit: String?
extensionSuffix: String?
staticMembers: Bool?
@ -236,7 +301,7 @@ colors:
xcassetsPath: String
extensionOutputPath: String
extensionName: String?
extensionNameSwiftUI: String?
extensionNameUIKit: String?
extensionSuffix: String?
staticMembers: Bool?
-
@ -245,7 +310,7 @@ colors:
xcassetsPath: String
extensionOutputPath: String
extensionName: String?
extensionNameSwiftUI: String?
extensionNameUIKit: String?
extensionSuffix: String?
staticMembers: Bool?
...

View File

@ -4,18 +4,25 @@ import SwiftUI
extension ColorYolo {
/// Color red is #FF0000 (light) or #FF0000 (dark)"
/// Color red is #FF0000 #FF0000 or #FF0000 #FF0000"
var red: Color {
Color("red")
}
/// Color green_alpha_50 is #A000FF00 (light) or #A000FF00 (dark)"
/// Color green_alpha_50 is #A000FF00 #A000FF00 or #A000FF00 #A000FF00"
var green_alpha_50: Color {
Color("green_alpha_50")
}
/// Color blue_light_dark is #0000FF (light) or #0000AA (dark)"
/// Color blue_light_dark is #0000FF #0000FF or #0000AA #0000AA"
var blue_light_dark: Color {
Color("blue_light_dark")
}
}

View File

@ -4,18 +4,25 @@ import UIKit
extension UIColorYolo {
/// Color red is #FF0000 (light) or #FF0000 (dark)"
/// Color red is #FF0000 #FF0000 or #FF0000 #FF0000"
@objc var red: UIColor {
UIColor(named: "red")!
}
/// Color green_alpha_50 is #A000FF00 (light) or #A000FF00 (dark)"
/// Color green_alpha_50 is #A000FF00 #A000FF00 or #A000FF00 #A000FF00"
@objc var green_alpha_50: UIColor {
UIColor(named: "green_alpha_50")!
}
/// Color blue_light_dark is #0000FF (light) or #0000AA (dark)"
/// Color blue_light_dark is #0000FF #0000FF or #0000AA #0000AA"
@objc var blue_light_dark: UIColor {
UIColor(named: "blue_light_dark")!
}
}

View File

@ -0,0 +1,32 @@
// Generated by ResgenSwift.Color 1.2
import UIKit
extension UIhkjhkColorYolo {
/// Color red is #FF0000 #FF0000 or #FF0000 #FF0000"
@objc var red: UIColor {
UIColor(named: "red")!
}
/// Color green_alpha_50 is #A000FF00 #A000FF00 or #A000FF00 #A000FF00"
@objc var green_alpha_50: UIColor {
UIColor(named: "green_alpha_50")!
}
/// Color blue_light_dark is #0000FF #0000FF or #0000AA #0000AA"
@objc var blue_light_dark: UIColor {
UIColor(named: "blue_light_dark")!
}
}

View File

@ -1,7 +1,7 @@
// Generated by ResgenSwift.Analytics 1.2
import MatomoTracker
import Firebase
import FirebaseAnalytics
// MARK: - Protocol
@ -81,7 +81,7 @@ class MatomoAnalyticsManager: AnalyticsManagerProtocol {
class FirebaseAnalyticsManager: AnalyticsManagerProtocol {
func logScreen(name: String, path: String) {
var parameters = [
AnalyticsParameterScreenName: name
AnalyticsParameterScreenName: name as NSObject
]
Analytics.logEvent(
@ -96,19 +96,25 @@ class FirebaseAnalyticsManager: AnalyticsManagerProtocol {
category: String,
params: [String: Any]?
) {
var parameters: [String:Any] = [
"action": action,
"category": category,
var parameters: [String:NSObject] = [
"action": action as NSObject,
"category": category as NSObject,
]
if let supplementaryParameters = params {
parameters.merge(supplementaryParameters) { (origin, new) -> Any in
return origin
for (newKey, newValue) in supplementaryParameters {
if parameters.contains(where: { (key: String, value: NSObject) in
key == newKey
}) {
continue
}
parameters[newKey] = newValue as? NSObject
}
}
Analytics.logEvent(
name,
name.replacingOccurrences(of: [" "], with: "_"),
parameters: parameters
)
}
@ -169,19 +175,22 @@ class AnalyticsManager {
// MARK: - section_one
func logScreenS1DefOne() {
func logScreenS1DefOne(title: String) {
logScreen(
name: "s1 def one",
path: "s1_def_one/"
name: "s1 def one \(title)",
path: "s1_def_one/\(title)"
)
}
func logEventS1DefTwo() {
func logEventS1DefTwo(title: String, count: String) {
logEvent(
name: "s1 def two",
action: "test",
category: "test",
params: []
params: [
"title": title,
"count": count
]
)
}

View File

@ -3,9 +3,13 @@ categories:
- id: section_one
screens:
- id: s1_def_one
name: s1 def one
path: s1_def_one/
tags: ios
name: s1 def one _TITLE_
path: s1_def_one/_TITLE_
tags: ios,droid
parameters:
- name: title
type: String
replaceIn: name,path
events:
- id: s1_def_two
@ -13,6 +17,11 @@ categories:
action: test
category: test
tags: ios
parameters:
- name: title
type: String
- name: count
type: String
- id: section_two
screens:

View File

@ -5,21 +5,21 @@ FORCE_FLAG="$1"
## Font
#swift run -c release ResgenSwift fonts $FORCE_FLAG "./Fonts/sampleFontsAll.txt" \
# --extension-output-path "./Fonts/Generated" \
# --extension-name "UIFontYolo" \
# --extension-name-swift-ui "FontYolo" \
# --extension-name "FontYolo" \
# --extension-name-ui-kit "UIFontYolo" \
# --extension-suffix "GenAllScript" \
# --info-plist-paths "./Fonts/Generated/test.plist ./Fonts/Generated/test2.plist"
#
#echo "\n-------------------------\n"
#
## Color
#swift run -c release ResgenSwift colors $FORCE_FLAG "./Colors/sampleColors1.txt" \
# --style all \
# --xcassets-path "./Colors/colors.xcassets" \
# --extension-output-path "./Colors/Generated/" \
# --extension-name "UIColorYolo" \
# --extension-name-swift-ui "ColorYolo" \
# --extension-suffix "GenAllScript"
# Color
swift run -c release ResgenSwift colors $FORCE_FLAG "./Colors/sampleColors1.txt" \
--style all \
--xcassets-path "./Colors/colors.xcassets" \
--extension-output-path "./Colors/Generated/" \
--extension-name "ColorYolo" \
--extension-name-ui-kit "UIColorYolo" \
--extension-suffix "GenAllScript"
#
#echo "\n-------------------------\n"
#
@ -49,22 +49,22 @@ FORCE_FLAG="$1"
# --extension-output-path "./Tags/Generated" \
# --extension-name "Tags" \
# --extension-suffix "GenAllScript"
#
echo "\n-------------------------\n"
# Analytics
swift run -c release ResgenSwift analytics $FORCE_FLAG "./Tags/sampleTags.yml" \
--target "matomo firebase" \
--extension-output-path "./Tags/Generated" \
--extension-name "Analytics" \
--extension-suffix "GenAllScript"
#echo "\n-------------------------\n"
echo "\n-------------------------\n"
## Analytics
#swift run -c release ResgenSwift analytics $FORCE_FLAG "./Tags/sampleTags.yml" \
# --target "matomo firebase" \
# --extension-output-path "./Tags/Generated" \
# --extension-name "Analytics" \
# --extension-suffix "GenAllScript"
#echo "\n-------------------------\n"
#
## Images
#swift run -c release ResgenSwift images $FORCE_FLAG "./Images/sampleImages.txt" \
# --xcassets-path "./Images/imagium.xcassets" \
# --extension-output-path "./Images/Generated" \
# --extension-name "UIImage" \
# --extension-name-swift-ui "ImageYolo" \
# --extension-name "ImageYolo" \
# --extension-name-ui-kit "UIImageYolo" \
# --extension-suffix "GenAllScript"

View File

@ -47,8 +47,8 @@ images:
inputFile: ./Images/sampleImages.txt
xcassetsPath: ./Images/imagium.xcassets
extensionOutputPath: ./Images/Generated
extensionName: UIImage
extensionNameSwiftUI: ImageYolo
extensionName: ImageYolo
extensionNameUIKit: UIImageYolo
extensionSuffix: GenAllScript
@ -61,8 +61,8 @@ colors:
style: all
xcassetsPath: ./Colors/colors.xcassets
extensionOutputPath: ./Colors/Generated/
extensionName: UIColorYolo
extensionNameSwiftUI: ColorYolo
extensionName: ColorYolo
extensionNameUIKit: UIColorYolo
extensionSuffix: GenAllScript
@ -97,7 +97,7 @@ fonts:
-
inputFile: ./Fonts/sampleFontsAll.txt
extensionOutputPath: ./Fonts/Generated
extensionName: UIFontYolo
extensionNameSwiftUI: FontYolo
extensionName: FontYolo
extensionNameUIKit: UIFontYolo
extensionSuffix: GenAllScript
infoPlistPaths: "./Fonts/Generated/test.plist ./Fonts/Generated/test2.plist"

View File

@ -18,7 +18,6 @@ struct Analytics: ParsableCommand {
version: ResgenSwiftVersion
)
// MARK: - Static
static let toolName = "Analytics"
@ -33,8 +32,15 @@ struct Analytics: ParsableCommand {
mutating func run() {
print("[\(Self.toolName)] Starting analytics generation")
print("[\(Self.toolName)] Will use inputFile \(options.inputFile) to generate analytics for target: \(options.target)")
// Check requirements
guard checkRequirements() else { return }
print("[\(Self.toolName)] Will generate analytics")
// Check requirements
guard checkRequirements() else { return }
// Parse input file
let sections = AnalyticsFileParser.parse(options.inputFile, target: options.target)
@ -48,20 +54,33 @@ struct Analytics: ParsableCommand {
print("[\(Self.toolName)] Analytics generated")
}
}
extension Analytics {
enum TargetType: CaseIterable {
case matomo
case firebase
// MARK: - Requirements
private func checkRequirements() -> Bool {
let fileManager = FileManager()
var value: String {
switch self {
case .matomo:
"matomo"
case .firebase:
"firebase"
}
// Input file
guard fileManager.fileExists(atPath: options.inputFile) else {
let error = AnalyticsError.fileNotExists(options.inputFile)
print(error.description)
Analytics.exit(withError: error)
}
guard TrackerType.hasValidTarget(in: options.target) else {
let error = AnalyticsError.noValidTracker(options.target)
print(error.description)
Analytics.exit(withError: error)
}
// Check if needed to regenerate
guard GeneratorChecker.shouldGenerate(force: options.forceGeneration,
inputFilePath: options.inputFile,
extensionFilePath: options.extensionFilePath) else {
print("[\(Self.toolName)] Analytics are already up to date :) ")
return false
}
return true
}
}

View File

@ -0,0 +1,39 @@
//
// AnalyticsError.swift
//
//
// Created by Loris Perret on 11/12/2023.
//
import Foundation
enum AnalyticsError: Error {
case noValidTracker(String)
case fileNotExists(String)
case missingElement(String)
case invalidParameter(String)
case parseFailed(String)
case writeFile(String, String)
var description: String {
switch self {
case .noValidTracker(let inputTargets):
return "error: [\(Analytics.toolName)] '\(inputTargets)' ne contient aucun tracker valid"
case .fileNotExists(let filename):
return "error: [\(Analytics.toolName)] File \(filename) does not exists"
case .missingElement(let element):
return "error: [\(Analytics.toolName)] Missing \(element) for Matomo"
case .invalidParameter(let reason):
return "error: [\(Analytics.toolName)] Invalid parameter \(reason)"
case .parseFailed(let baseError):
return "error: [\(Analytics.toolName)] Parse input file failed: \(baseError)"
case .writeFile(let subErrorDescription, let filename):
return "error: [\(Analytics.toolName)] An error occured while writing content to \(filename): \(subErrorDescription)"
}
}
}

View File

@ -10,13 +10,13 @@ import ToolCore
import CoreVideo
class AnalyticsGenerator {
static var targets: [Analytics.TargetType] = []
static var targets: [TrackerType] = []
static func writeExtensionFiles(sections: [AnalyticsCategory], target: String, tags: [String], staticVar: Bool, extensionName: String, extensionFilePath: String) {
// Get target type from enum
let targetsString: [String] = target.components(separatedBy: " ")
Analytics.TargetType.allCases.forEach { enumTarget in
TrackerType.allCases.forEach { enumTarget in
if targetsString.contains(enumTarget.value) {
targets.append(enumTarget)
}
@ -32,10 +32,10 @@ class AnalyticsGenerator {
let extensionFilePathURL = URL(fileURLWithPath: extensionFilePath)
do {
try extensionFileContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8)
} catch (let error) {
let error = StringiumError.writeFile(extensionFilePath, error.localizedDescription)
} catch let error {
let error = AnalyticsError.writeFile(extensionFilePath, error.localizedDescription)
print(error.description)
Stringium.exit(withError: error)
Analytics.exit(withError: error)
}
}
@ -58,7 +58,7 @@ class AnalyticsGenerator {
\(Self.getImport())
\(Self.getAnalytics())
\(Self.getAnalyticsProtocol())
// MARK: - Manager
class AnalyticsManager {
@ -91,10 +91,10 @@ class AnalyticsGenerator {
private static func getImport() -> String {
var result: [String] = []
if targets.contains(Analytics.TargetType.matomo) {
if targets.contains(TrackerType.matomo) {
result.append("import MatomoTracker")
}
if targets.contains(Analytics.TargetType.firebase) {
if targets.contains(TrackerType.firebase) {
result.append("import FirebaseAnalytics")
}
@ -136,13 +136,13 @@ class AnalyticsGenerator {
var content: [String] = []
let footer = " }"
if targets.contains(Analytics.TargetType.matomo) {
if targets.contains(TrackerType.matomo) {
header = "func configure(siteId: String, url: String) {"
} else if targets.contains(Analytics.TargetType.firebase) {
} else if targets.contains(TrackerType.firebase) {
header = "func configure() {"
}
if targets.contains(Analytics.TargetType.matomo) {
if targets.contains(TrackerType.matomo) {
content.append("""
managers.append(
MatomoAnalyticsManager(
@ -152,7 +152,7 @@ class AnalyticsGenerator {
)
""")
}
if targets.contains(Analytics.TargetType.firebase) {
if targets.contains(TrackerType.firebase) {
content.append(" managers.append(FirebaseAnalyticsManager())")
}
@ -164,7 +164,7 @@ class AnalyticsGenerator {
.joined(separator: "\n")
}
private static func getAnalytics() -> String {
private static func getAnalyticsProtocol() -> String {
let proto = """
// MARK: - Protocol
@ -182,12 +182,12 @@ class AnalyticsGenerator {
var result: [String] = [proto]
if targets.contains(Analytics.TargetType.matomo) {
result.append(MatomoGenerator.service.content)
if targets.contains(TrackerType.matomo) {
result.append(MatomoGenerator.service)
}
if targets.contains(Analytics.TargetType.firebase) {
result.append(FirebaseGenerator.service.content)
if targets.contains(TrackerType.firebase) {
result.append(FirebaseGenerator.service)
}
return result.joined(separator: "\n")

View File

@ -8,19 +8,20 @@
import Foundation
enum FirebaseGenerator {
case service
var content: String {
static var service: String {
[
FirebaseGenerator.service.header,
FirebaseGenerator.service.logScreen,
FirebaseGenerator.service.logEvent,
FirebaseGenerator.service.footer
FirebaseGenerator.header,
FirebaseGenerator.logScreen,
FirebaseGenerator.logEvent,
FirebaseGenerator.footer
]
.joined(separator: "\n")
}
private var header: String {
// MARK: - Private vars
private static var header: String {
"""
// MARK: - Firebase
@ -28,11 +29,11 @@ enum FirebaseGenerator {
"""
}
private var logScreen: String {
private static var logScreen: String {
"""
func logScreen(name: String, path: String) {
var parameters = [
AnalyticsParameterScreenName: name
AnalyticsParameterScreenName: name as NSObject
]
Analytics.logEvent(
@ -44,7 +45,7 @@ enum FirebaseGenerator {
"""
}
private var logEvent: String {
private static var logEvent: String {
"""
func logEvent(
name: String,
@ -52,26 +53,32 @@ enum FirebaseGenerator {
category: String,
params: [String: Any]?
) {
var parameters: [String:Any] = [
"action": action,
"category": category,
var parameters: [String:NSObject] = [
"action": action as NSObject,
"category": category as NSObject,
]
if let supplementaryParameters = params {
parameters.merge(supplementaryParameters) { (origin, new) -> Any in
return origin
for (newKey, newValue) in supplementaryParameters {
if parameters.contains(where: { (key: String, value: NSObject) in
key == newKey
}) {
continue
}
parameters[newKey] = newValue as? NSObject
}
}
Analytics.logEvent(
name,
name.replacingOccurrences(of: [" "], with: "_"),
parameters: parameters
)
}
"""
}
private var footer: String {
private static var footer: String {
"""
}

View File

@ -8,20 +8,21 @@
import Foundation
enum MatomoGenerator {
case service
var content: String {
static var service: String {
[
MatomoGenerator.service.header,
MatomoGenerator.service.setup,
MatomoGenerator.service.logScreen,
MatomoGenerator.service.logEvent,
MatomoGenerator.service.footer
MatomoGenerator.header,
MatomoGenerator.setup,
MatomoGenerator.logScreen,
MatomoGenerator.logEvent,
MatomoGenerator.footer
]
.joined(separator: "\n")
}
private var header: String {
// MARK: - Private vars
private static var header: String {
"""
// MARK: - Matomo
@ -34,7 +35,7 @@ enum MatomoGenerator {
"""
}
private var setup: String {
private static var setup: String {
"""
// MARK: - Init
@ -63,7 +64,7 @@ enum MatomoGenerator {
"""
}
private var logScreen: String {
private static var logScreen: String {
"""
func logScreen(name: String, path: String) {
guard !tracker.isOptedOut else { return }
@ -79,7 +80,7 @@ enum MatomoGenerator {
"""
}
private var logEvent: String {
private static var logEvent: String {
"""
func logEvent(
name: String,
@ -100,7 +101,7 @@ enum MatomoGenerator {
"""
}
private var footer: String {
private static var footer: String {
"""
}

View File

@ -11,10 +11,14 @@ class AnalyticsCategory {
let id: String // OnBoarding
var definitions = [AnalyticsDefinition]()
// MARK: - Init
init(id: String) {
self.id = id
}
// MARK: - Methods
func hasOneOrMoreMatchingTags(tags: [String]) -> Bool {
let allTags = definitions.flatMap { $0.tags }
let allTagsSet = Set(allTags)

View File

@ -6,6 +6,7 @@
//
import Foundation
import ToolCore
class AnalyticsDefinition {
let id: String
@ -18,21 +19,25 @@ class AnalyticsDefinition {
var parameters: [AnalyticsParameter] = []
var type: TagType
// MARK: - Init
init(id: String, name: String, type: TagType) {
self.id = id
self.name = name
self.type = type
}
// MARK: - Methods
func hasOneOrMoreMatchingTags(inputTags: [String]) -> Bool {
if Set(inputTags).intersection(Set(self.tags)).isEmpty {
if Set(inputTags).isDisjoint(with: tags) {
return false
}
return true
}
// MARK: - Methods
// MARK: - Private Methods
private func getFuncName() -> String {
var pascalCaseTitle: String = ""
id.components(separatedBy: "_").forEach { word in
@ -47,7 +52,7 @@ class AnalyticsDefinition {
var result: String
if type == .screen {
params = params.filter{ param in
params = params.filter { param in
!param.replaceIn.isEmpty
}
}
@ -71,7 +76,7 @@ class AnalyticsDefinition {
return result
}
private func replaceIn(){
private func replaceIn() {
for parameter in parameters {
for rep in parameter.replaceIn {
switch rep {
@ -96,7 +101,7 @@ class AnalyticsDefinition {
supplementaryParams.forEach { param in
params.append("\"\(param.name)\": \(param.name)")
}
if params.count > 1 {
result = """
[
@ -150,27 +155,3 @@ class AnalyticsDefinition {
"""
}
}
extension AnalyticsDefinition {
enum TagType {
case screen
case event
}
}
extension String {
func replacingFirstOccurrence(of: String, with: String) -> Self {
if let range = self.range(of: of) {
let tmp = self.replacingOccurrences(
of: of,
with: with,
options: .literal,
range: range
)
return tmp
}
return self
}
}

View File

@ -17,9 +17,7 @@ struct AnalyticsCategoryDTO: Codable {
var events: [AnalyticsDefinitionEventDTO]?
}
protocol AnalyticsDefinitionDTO: Codable {}
struct AnalyticsDefinitionScreenDTO: AnalyticsDefinitionDTO {
struct AnalyticsDefinitionScreenDTO: Codable {
var id: String
var name: String
var tags: String
@ -29,7 +27,7 @@ struct AnalyticsDefinitionScreenDTO: AnalyticsDefinitionDTO {
var path: String?
}
struct AnalyticsDefinitionEventDTO: AnalyticsDefinitionDTO {
struct AnalyticsDefinitionEventDTO: Codable {
var id: String
var name: String
var tags: String

View File

@ -12,6 +12,8 @@ class AnalyticsParameter {
var type: String
var replaceIn: [String] = []
// MARK: - Init
init(name: String, type: String) {
self.name = name
self.type = type

View File

@ -0,0 +1,16 @@
//
// TagType.swift
//
//
// Created by Thibaut Schmitt on 08/12/2023.
//
import Foundation
extension AnalyticsDefinition {
enum TagType {
case screen
case event
}
}

View File

@ -0,0 +1,29 @@
//
// TargetType.swift
//
//
// Created by Thibaut Schmitt on 08/12/2023.
//
import Foundation
enum TrackerType: CaseIterable {
case matomo
case firebase
var value: String {
switch self {
case .matomo:
"matomo"
case .firebase:
"firebase"
}
}
static func hasValidTarget(in targets: String) -> Bool {
for tracker in Self.allCases where targets.contains(tracker.value) {
return true
}
return false
}
}

View File

@ -14,46 +14,49 @@ class AnalyticsFileParser {
private static func parseYaml() -> AnalyticsFile {
guard let data = FileManager().contents(atPath: inputFile) else {
let error = GenerateError.fileNotExists(inputFile)
Generate.exit(withError: error)
let error = AnalyticsError.fileNotExists(inputFile)
print(error.description)
Analytics.exit(withError: error)
}
do {
let tagFile = try YAMLDecoder().decode(AnalyticsFile.self, from: data)
return tagFile
} catch let error {
Generate.exit(withError: error)
} catch {
let error = AnalyticsError.parseFailed(error.localizedDescription)
print(error.description)
Analytics.exit(withError: error)
}
}
private static func getParameters(fromData data: [AnalyticsParameterDTO]) -> [AnalyticsParameter] {
var parameters: [AnalyticsParameter] = []
data.forEach { value in
private static func getParameters(from parameters: [AnalyticsParameterDTO]) -> [AnalyticsParameter] {
parameters.map { dtoParameter in
// Type
let type = value.type.uppercasedFirst()
let type = dtoParameter.type.uppercasedFirst()
guard
type == "String" ||
type == "Int" ||
type == "Double" ||
type == "Bool"
else {
let error = GenerateError.invalidParameter("type of \(value.name)")
Generate.exit(withError: error)
let error = AnalyticsError.invalidParameter("type of \(dtoParameter.name)")
print(error.description)
Analytics.exit(withError: error)
}
let parameter: AnalyticsParameter = AnalyticsParameter(name: value.name, type: type)
if let replaceIn = value.replaceIn {
let parameter = AnalyticsParameter(
name: dtoParameter.name,
type: type
)
if let replaceIn = dtoParameter.replaceIn {
parameter.replaceIn = replaceIn.components(separatedBy: ",")
}
parameters.append(parameter)
return parameter
}
return parameters
}
private static func getTagDefinition(
@ -64,24 +67,24 @@ class AnalyticsFileParser {
comments: String?,
parameters: [AnalyticsParameterDTO]?
) -> AnalyticsDefinition {
let definition: AnalyticsDefinition = AnalyticsDefinition(id: id, name: name, type: type)
definition.tags = tags.components(separatedBy: ",")
let definition = AnalyticsDefinition(id: id, name: name, type: type)
definition.tags = tags
.components(separatedBy: ",")
.map { $0.removeLeadingTrailingWhitespace() }
if let comments = comments {
definition.comments = comments
}
if let parameters = parameters {
definition.parameters = Self.getParameters(fromData: parameters)
definition.parameters = Self.getParameters(from: parameters)
}
return definition
}
private static func getTagDefinitionScreen(fromData screens: [AnalyticsDefinitionScreenDTO]) -> [AnalyticsDefinition] {
var definitions: [AnalyticsDefinition] = []
for screen in screens {
private static func getTagDefinitionScreen(from screens: [AnalyticsDefinitionScreenDTO]) -> [AnalyticsDefinition] {
screens.map { screen in
let definition: AnalyticsDefinition = Self.getTagDefinition(
id: screen.id,
name: screen.name,
@ -90,28 +93,25 @@ class AnalyticsFileParser {
comments: screen.comments,
parameters: screen.parameters
)
if target.contains(Analytics.TargetType.matomo.value) {
if target.contains(TrackerType.matomo.value) {
// Path
guard let path = screen.path else {
let error = GenerateError.missingElement("screen path")
Generate.exit(withError: error)
let error = AnalyticsError.missingElement("screen path")
print(error.description)
Analytics.exit(withError: error)
}
definition.path = path
}
definitions.append(definition)
return definition
}
return definitions
}
private static func getTagDefinitionEvent(fromData events: [AnalyticsDefinitionEventDTO]) -> [AnalyticsDefinition] {
var definitions: [AnalyticsDefinition] = []
for event in events {
private static func getTagDefinitionEvent(from events: [AnalyticsDefinitionEventDTO]) -> [AnalyticsDefinition] {
events.map { event in
let definition: AnalyticsDefinition = Self.getTagDefinition(
id: event.id,
name: event.name,
@ -120,54 +120,59 @@ class AnalyticsFileParser {
comments: event.comments,
parameters: event.parameters
)
if target.contains(Analytics.TargetType.matomo.value) {
if target.contains(TrackerType.matomo.value) {
// Category
guard let category = event.category else {
let error = GenerateError.missingElement("event category")
Generate.exit(withError: error)
let error = AnalyticsError.missingElement("event category")
print(error.description)
Analytics.exit(withError: error)
}
definition.category = category
// Action
guard let action = event.action else {
let error = GenerateError.missingElement("event action")
Generate.exit(withError: error)
let error = AnalyticsError.missingElement("event action")
print(error.description)
Analytics.exit(withError: error)
}
definition.action = action
}
definitions.append(definition)
return definition
}
return definitions
}
static func parse(_ inputFile: String, target: String) -> [AnalyticsCategory] {
self.inputFile = inputFile
self.target = target
let tagFile: AnalyticsFile = Self.parseYaml()
var sections: [AnalyticsCategory] = []
let tagFile = Self.parseYaml()
tagFile.categories.forEach { categorie in
let section: AnalyticsCategory = AnalyticsCategory(id: categorie.id)
if let screens = categorie.screens {
section.definitions.append(contentsOf: Self.getTagDefinitionScreen(fromData: screens))
return tagFile
.categories
.map { categorie in
let section: AnalyticsCategory = AnalyticsCategory(id: categorie.id)
if let screens = categorie.screens {
section
.definitions
.append(
contentsOf: Self.getTagDefinitionScreen(from: screens)
)
}
if let events = categorie.events {
section
.definitions
.append(
contentsOf: Self.getTagDefinitionEvent(from: events)
)
}
return section
}
if let events = categorie.events {
section.definitions.append(contentsOf: Self.getTagDefinitionEvent(fromData: events))
}
sections.append(section)
}
return sections
}
}

View File

@ -21,8 +21,8 @@ struct Colors: ParsableCommand {
// MARK: - Static
static let toolName = "Color"
static let defaultExtensionName = "UIColor"
static let defaultExtensionNameSUI = "Color"
static let defaultExtensionName = "Color"
static let defaultExtensionNameUIKit = "UIColor"
static let assetsColorsFolderName = "Colors"
// MARK: - Command options
@ -57,14 +57,14 @@ struct Colors: ParsableCommand {
staticVar: options.staticMembers,
extensionName: options.extensionName,
extensionFilePath: options.extensionFilePath,
isSwiftUI: false)
isSwiftUI: true)
// Generate extension
ColorExtensionGenerator.writeExtensionFile(colors: parsedColors,
staticVar: options.staticMembers,
extensionName: options.extensionNameSwiftUI,
extensionFilePath: options.extensionFilePathSwiftUI,
isSwiftUI: true)
extensionName: options.extensionNameUIKit,
extensionFilePath: options.extensionFilePathUIKit,
isSwiftUI: false)
print("[\(Self.toolName)] Colors generated")
}
@ -89,7 +89,7 @@ struct Colors: ParsableCommand {
}
// Extension for UIKit and SwiftUI should have different name
guard options.extensionName != options.extensionNameSwiftUI else {
guard options.extensionName != options.extensionNameUIKit else {
let error = ColorsToolError.extensionNamesCollision(options.extensionName)
print(error.description)
Colors.exit(withError: error)

View File

@ -27,11 +27,11 @@ struct ColorsToolOptions: ParsableArguments {
@Option(help: "Tell if it will generate static properties or not")
var staticMembers: Bool = false
@Option(help: "Extension name. If not specified, it will generate an UIColor extension.")
@Option(help: "Extension name. If not specified, it will generate an Color extension.")
var extensionName: String = Colors.defaultExtensionName
@Option(help: "SwiftUI Extension name. If not specified, it will generate an Color extension.")
var extensionNameSwiftUI: String = Colors.defaultExtensionNameSUI
@Option(help: "SwiftUI Extension name. If not specified, it will generate an UIColor extension.")
var extensionNameUIKit: String = Colors.defaultExtensionNameUIKit
@Option(help: "Extension suffix. Ex: MyApp, it will generate {extensionName}+ColorsMyApp.swift")
var extensionSuffix: String?
@ -41,7 +41,7 @@ struct ColorsToolOptions: ParsableArguments {
extension ColorsToolOptions {
// MARK: - UIKit
// MARK: - SwiftUI
var extensionFileName: String {
if let extensionSuffix = extensionSuffix {
@ -54,16 +54,16 @@ extension ColorsToolOptions {
"\(extensionOutputPath)/\(extensionFileName)"
}
// MARK: - SwiftUI
// MARK: - UIKit
var extensionFileNameSwiftUI: String {
var extensionFileNameUIKit: String {
if let extensionSuffix = extensionSuffix {
return "\(extensionNameSwiftUI)+\(extensionSuffix).swift"
return "\(extensionNameUIKit)+\(extensionSuffix).swift"
}
return "\(extensionNameSwiftUI).swift"
return "\(extensionNameUIKit).swift"
}
var extensionFilePathSwiftUI: String {
"\(extensionOutputPath)/\(extensionFileNameSwiftUI)"
var extensionFilePathUIKit: String {
"\(extensionOutputPath)/\(extensionFileNameUIKit)"
}
}

View File

@ -30,7 +30,7 @@ struct ColorExtensionGenerator {
let extensionFilePathURL = URL(fileURLWithPath: extensionFilePath)
do {
try extensionContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8)
} catch (let error) {
} catch let error {
let error = ColorsToolError.writeExtension(extensionFilePath, error.localizedDescription)
print(error.description)
Colors.exit(withError: error)
@ -41,12 +41,28 @@ struct ColorExtensionGenerator {
staticVar: Bool,
extensionName: String,
isSwiftUI: Bool) -> String {
[
Self.getHeader(extensionClassname: extensionName, isSwiftUI: isSwiftUI),
Self.getProperties(for: colors, withStaticVar: staticVar, isSwiftUI: isSwiftUI),
Self.getFooter()
]
.joined(separator: "\n")
// [
// Self.getHeader(extensionClassname: extensionName, isSwiftUI: isSwiftUI),
// Self.getProperties(for: colors, withStaticVar: staticVar, isSwiftUI: isSwiftUI),
// Self.getFooter()
// ]
// .joined(separator: "\n")
do {
let context: [String: Any] = [
"colors": colors,
"isStatic": staticVar,
"isSwiftUI": isSwiftUI,
"toolName": Colors.toolName,
"resgenVersion": ResgenSwiftVersion,
"extensionClassname": extensionName
]
return try ResgenSwift.environment.renderTemplate(name: "Colors/main_template", context: context)
} catch {
// let error = ColorsToolError.writeExtension(extensionFilePath, error.localizedDescription)
// print(error.description)
Colors.exit(withError: error)
}
}
private static func getHeader(extensionClassname: String, isSwiftUI: Bool) -> String {

View File

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

View File

@ -21,11 +21,11 @@ struct FontsOptions: ParsableArguments {
@Option(help: "Tell if it will generate static properties or methods")
var staticMembers: Bool = false
@Option(help: "Extension name. If not specified, it will generate an UIFont extension.")
@Option(help: "Extension name. If not specified, it will generate an Font extension.")
var extensionName: String = Fonts.defaultExtensionName
@Option(help: "Extension name. If not specified, it will generate an Font extension.")
var extensionNameSwiftUI: String = Fonts.defaultExtensionNameSUI
@Option(help: "Extension name. If not specified, it will generate an UIFont extension.")
var extensionNameUIKit: String = Fonts.defaultExtensionNameUIKit
@Option(help: "Extension suffix. Ex: MyApp, it will generate {extensionName}+FontsMyApp.swift")
var extensionSuffix: String = ""
@ -38,7 +38,7 @@ struct FontsOptions: ParsableArguments {
extension FontsOptions {
// MARK: - UIKit
// MARK: - SwiftUI
var extensionFileName: String {
if extensionSuffix.isEmpty == false {
@ -51,17 +51,17 @@ extension FontsOptions {
"\(extensionOutputPath)/\(extensionFileName)"
}
// MARK: - SwiftUI
// MARK: - UIKit
var extensionFileNameSwiftUI: String {
var extensionFileNameUIKit: String {
if extensionSuffix.isEmpty == false {
return "\(extensionNameSwiftUI)+\(extensionSuffix).swift"
return "\(extensionNameUIKit)+\(extensionSuffix).swift"
}
return "\(extensionNameSwiftUI).swift"
return "\(extensionNameUIKit).swift"
}
var extensionFilePathSwiftUI: String {
"\(extensionOutputPath)/\(extensionFileNameSwiftUI)"
var extensionFilePathUIKit: String {
"\(extensionOutputPath)/\(extensionFileNameUIKit)"
}
// MARK: -

View File

@ -21,8 +21,8 @@ struct Fonts: ParsableCommand {
// MARK: - Static
static let toolName = "Fonts"
static let defaultExtensionName = "UIFont"
static let defaultExtensionNameSUI = "Font"
static let defaultExtensionName = "Font"
static let defaultExtensionNameUIKit = "UIFont"
// MARK: - Command Options
@ -52,13 +52,13 @@ struct Fonts: ParsableCommand {
staticVar: options.staticMembers,
extensionName: options.extensionName,
extensionFilePath: options.extensionFilePath,
isSwiftUI: false)
isSwiftUI: true)
FontExtensionGenerator.writeExtensionFile(fontsNames: fontsNames,
staticVar: options.staticMembers,
extensionName: options.extensionNameSwiftUI,
extensionFilePath: options.extensionFilePathSwiftUI,
isSwiftUI: true)
extensionName: options.extensionNameUIKit,
extensionFilePath: options.extensionFilePathUIKit,
isSwiftUI: false)
print("Info.plist has been updated with:")
print("\(FontPlistGenerator.generatePlistUIAppsFontContent(for: fontsNames, infoPlistPaths: options.infoPlistPaths))")
@ -79,7 +79,7 @@ struct Fonts: ParsableCommand {
}
// Extension for UIKit and SwiftUI should have different name
guard options.extensionName != options.extensionNameSwiftUI else {
guard options.extensionName != options.extensionNameUIKit else {
let error = FontsToolError.extensionNamesCollision(options.extensionName)
print(error.description)
Fonts.exit(withError: error)

View File

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

View File

@ -13,11 +13,6 @@ enum GenerateError: Error {
case commandError([String], String)
case writeFile(String, String)
// Analytics
case missingElement(String)
case invalidParameter(String)
var description: String {
switch self {
case .fileNotExists(let filename):
@ -34,12 +29,6 @@ enum GenerateError: Error {
case .writeFile(let filename, let info):
return "error: [\(Generate.toolName)] An error occured while writing file in \(filename): \(info)"
case .missingElement(let element):
return "error: [\(Generate.toolName)] Missing \(element) for Matomo"
case .invalidParameter(let reason):
return "error: [\(Generate.toolName)] Invalid parameter \(reason)"
}
}
}

View File

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

View File

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

View File

@ -127,7 +127,7 @@ struct ColorsConfiguration: Codable, CustomDebugStringConvertible {
let xcassetsPath: String
let extensionOutputPath: String
let extensionName: String?
let extensionNameSwiftUI: String?
let extensionNameUIKit: String?
let extensionSuffix: String?
private let staticMembers: Bool?
@ -143,7 +143,7 @@ struct ColorsConfiguration: Codable, CustomDebugStringConvertible {
xcassetsPath: String,
extensionOutputPath: String,
extensionName: String?,
extensionNameSwiftUI: String?,
extensionNameUIKit: String?,
extensionSuffix: String?,
staticMembers: Bool?) {
self.inputFile = inputFile
@ -151,7 +151,7 @@ struct ColorsConfiguration: Codable, CustomDebugStringConvertible {
self.xcassetsPath = xcassetsPath
self.extensionOutputPath = extensionOutputPath
self.extensionName = extensionName
self.extensionNameSwiftUI = extensionNameSwiftUI
self.extensionNameUIKit = extensionNameUIKit
self.extensionSuffix = extensionSuffix
self.staticMembers = staticMembers
}
@ -164,7 +164,7 @@ struct ColorsConfiguration: Codable, CustomDebugStringConvertible {
- Xcassets path: \(xcassetsPath)
- Extension output path: \(extensionOutputPath)
- Extension name: \(extensionName ?? "-")
- Extension name SwiftUI: \(extensionNameSwiftUI ?? "-")
- Extension name UIKit: \(extensionNameUIKit ?? "-")
- Extension suffix: \(extensionSuffix ?? "-")
"""
}
@ -174,7 +174,7 @@ struct FontsConfiguration: Codable, CustomDebugStringConvertible {
let inputFile: String
let extensionOutputPath: String
let extensionName: String?
let extensionNameSwiftUI: String?
let extensionNameUIKit: String?
let extensionSuffix: String?
let infoPlistPaths: String?
private let staticMembers: Bool?
@ -189,14 +189,14 @@ struct FontsConfiguration: Codable, CustomDebugStringConvertible {
internal init(inputFile: String,
extensionOutputPath: String,
extensionName: String?,
extensionNameSwiftUI: String?,
extensionNameUIKit: String?,
extensionSuffix: String?,
infoPlistPaths: String?,
staticMembers: Bool?) {
self.inputFile = inputFile
self.extensionOutputPath = extensionOutputPath
self.extensionName = extensionName
self.extensionNameSwiftUI = extensionNameSwiftUI
self.extensionNameUIKit = extensionNameUIKit
self.extensionSuffix = extensionSuffix
self.infoPlistPaths = infoPlistPaths
self.staticMembers = staticMembers
@ -208,7 +208,7 @@ struct FontsConfiguration: Codable, CustomDebugStringConvertible {
- Input file: \(inputFile)
- Extension output path: \(extensionOutputPath)
- Extension name: \(extensionName ?? "-")
- Extension name SwiftUI: \(extensionNameSwiftUI ?? "-")
- Extension name UIKit: \(extensionNameUIKit ?? "-")
- Extension suffix: \(extensionSuffix ?? "-")
- InfoPlistPaths: \(infoPlistPaths ?? "-")
"""
@ -220,7 +220,7 @@ struct ImagesConfiguration: Codable, CustomDebugStringConvertible {
let xcassetsPath: String
let extensionOutputPath: String
let extensionName: String?
let extensionNameSwiftUI: String?
let extensionNameUIKit: String?
let extensionSuffix: String?
private let staticMembers: Bool?
@ -235,14 +235,14 @@ struct ImagesConfiguration: Codable, CustomDebugStringConvertible {
xcassetsPath: String,
extensionOutputPath: String,
extensionName: String?,
extensionNameSwiftUI: String?,
extensionNameUIKit: String?,
extensionSuffix: String?,
staticMembers: Bool?) {
self.inputFile = inputFile
self.xcassetsPath = xcassetsPath
self.extensionOutputPath = extensionOutputPath
self.extensionName = extensionName
self.extensionNameSwiftUI = extensionNameSwiftUI
self.extensionNameUIKit = extensionNameUIKit
self.extensionSuffix = extensionSuffix
self.staticMembers = staticMembers
}
@ -254,7 +254,7 @@ struct ImagesConfiguration: Codable, CustomDebugStringConvertible {
- Xcassets path: \(xcassetsPath)
- Extension output path: \(extensionOutputPath)
- Extension name: \(extensionName ?? "-")
- Extension name SwiftUI: \(extensionNameSwiftUI ?? "-")
- Extension name UIKit: \(extensionNameUIKit ?? "-")
- Extension suffix: \(extensionSuffix ?? "-")
"""
}

View File

@ -38,10 +38,10 @@ extension ColorsConfiguration: Runnable {
extensionName
]
}
if let extensionNameSwiftUI = extensionNameSwiftUI {
if let extensionNameUIKit = extensionNameUIKit {
args += [
"--extension-name-swift-ui",
extensionNameSwiftUI
"--extension-name-ui-kit",
extensionNameUIKit
]
}
if let extensionSuffix = extensionSuffix {

View File

@ -34,10 +34,10 @@ extension FontsConfiguration: Runnable {
extensionName
]
}
if let extensionNameSwiftUI = extensionNameSwiftUI {
if let extensionNameUIKit = extensionNameUIKit {
args += [
"--extension-name-swift-ui",
extensionNameSwiftUI
"--extension-name-ui-kit",
extensionNameUIKit
]
}

View File

@ -36,10 +36,10 @@ extension ImagesConfiguration: Runnable {
extensionName
]
}
if let extensionNameSwiftUI = extensionNameSwiftUI {
if let extensionNameUIKit = extensionNameUIKit {
args += [
"--extension-name-swift-ui",
extensionNameSwiftUI
"--extension-name-ui-kit",
extensionNameUIKit
]
}
if let extensionSuffix = extensionSuffix {

View File

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

View File

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

View File

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

View File

@ -21,8 +21,8 @@ struct Images: ParsableCommand {
// MARK: - Static
static let toolName = "Images"
static let defaultExtensionName = "UIImage"
static let defaultExtensionNameSUI = "Image"
static let defaultExtensionName = "Image"
static let defaultExtensionNameUIKit = "UIImage"
// MARK: - Command Options
@ -58,14 +58,14 @@ struct Images: ParsableCommand {
inputFilename: options.inputFilenameWithoutExt,
extensionName: options.extensionName,
extensionFilePath: options.extensionFilePath,
isSwiftUI: false)
isSwiftUI: true)
ImageExtensionGenerator.generateExtensionFile(images: imagesToGenerate,
staticVar: options.staticMembers,
inputFilename: options.inputFilenameWithoutExt,
extensionName: options.extensionNameSwiftUI,
extensionFilePath: options.extensionFilePathSwiftUI,
isSwiftUI: true)
extensionName: options.extensionNameUIKit,
extensionFilePath: options.extensionFilePathUIKit,
isSwiftUI: false)
print("[\(Self.toolName)] Images generated")
}
@ -90,7 +90,7 @@ struct Images: ParsableCommand {
_ = Images.getSvgConverterPath()
// Extension for UIKit and SwiftUI should have different name
guard options.extensionName != options.extensionNameSwiftUI else {
guard options.extensionName != options.extensionNameUIKit else {
let error = ImagesError.extensionNamesCollision(options.extensionName)
print(error.description)
Images.exit(withError: error)

View File

@ -27,11 +27,11 @@ struct ImagesOptions: ParsableArguments {
@Option(help: "Tell if it will generate static properties or not")
var staticMembers: Bool = false
@Option(help: "Extension name. If not specified, it will generate an UIImage extension.")
@Option(help: "Extension name. If not specified, it will generate an Image extension.")
var extensionName: String = Images.defaultExtensionName
@Option(help: "Extension name. If not specified, it will generate an Image extension.")
var extensionNameSwiftUI: String = Images.defaultExtensionNameSUI
@Option(help: "Extension name. If not specified, it will generate an UIImage extension.")
var extensionNameUIKit: String = Images.defaultExtensionNameUIKit
@Option(help: "Extension suffix. Ex: MyApp, it will generate {extensionName}+Image{extensionSuffix}.swift")
var extensionSuffix: String?
@ -41,7 +41,7 @@ struct ImagesOptions: ParsableArguments {
extension ImagesOptions {
// MARK: - UIKit
// MARK: - SwiftUI
var extensionFileName: String {
if let extensionSuffix = extensionSuffix {
@ -54,17 +54,17 @@ extension ImagesOptions {
"\(extensionOutputPath)/\(extensionFileName)"
}
// MARK: - SwiftUI
// MARK: - UIKit
var extensionFileNameSwiftUI: String {
var extensionFileNameUIKit: String {
if let extensionSuffix = extensionSuffix {
return "\(extensionNameSwiftUI)+\(extensionSuffix).swift"
return "\(extensionNameUIKit)+\(extensionSuffix).swift"
}
return "\(extensionNameSwiftUI).swift"
return "\(extensionNameUIKit).swift"
}
var extensionFilePathSwiftUI: String {
"\(extensionOutputPath)/\(extensionFileNameSwiftUI)"
var extensionFilePathUIKit: String {
"\(extensionOutputPath)/\(extensionFileNameUIKit)"
}
// MARK: -

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -8,6 +8,8 @@
import ToolCore
import Foundation
import ArgumentParser
import Stencil
import PathKit
struct ResgenSwift: ParsableCommand {
@ -32,6 +34,20 @@ struct ResgenSwift: ParsableCommand {
// subcommand is not given on the command line.
//defaultSubcommand: Twine.self
)
static let projectDirectory = URL(fileURLWithPath: #file) // ProjectDir/Sources/ResgenSwift/main.swift
.deletingLastPathComponent() // ProjectDir/Sources/ResgenSwift/
.deletingLastPathComponent() // ProjectDir/Sources/
.deletingLastPathComponent() // ProjectDir/
static let environment = Environment(
loader: FileSystemLoader(
paths: [
Path("\(projectDirectory.path)/Templates/")
]
)
)
}
print(ResgenSwift.projectDirectory.path)
ResgenSwift.main()

View File

@ -63,7 +63,7 @@ public extension String {
replacingOccurrences(of: "~", with: "\(FileManager.default.homeDirectoryForCurrentUser.relativePath)")
}
func colorComponent() -> (alpha: String, red: String, green: String, blue: String) {
func colorComponent() -> (alpha: String, red: String, green: String, blue: String) {
var alpha: String = "FF"
var red: String
var green: String
@ -89,4 +89,19 @@ public extension String {
func uppercasedFirst() -> String {
prefix(1).uppercased() + dropFirst()
}
func replacingFirstOccurrence(of: String, with: String) -> Self {
if let range = self.range(of: of) {
let tmp = self.replacingOccurrences(
of: of,
with: with,
options: .literal,
range: range
)
return tmp
}
return self
}
}

View File

View File

@ -0,0 +1,21 @@
// Generated by ResgenSwift.{{ toolName }} {{ resgenVersion }}
{% if isSwiftUI %}
import SwiftUI
{% else %}
import UIKit
{% endif %}
extension {{ extensionClassname }} {
{% for color in colors %}
{% if isSwiftUI %}
/// Color {{ color.name }} is {{ color.light }} {{ color.light }} or {{ color.dark }} {{ color.dark }}"
{% if isStatic %}static {% endif %}var {{ color.name }}: Color {
Color("{{ color.name }}")
}
{% else %}
/// Color {{ color.name }} is {{ color.light }} {{ color.light }} or {{ color.dark }} {{ color.dark }}"
{% if isStatic %}static {% else %}@objc {% endif %}var {{ color.name }}: UIColor {
UIColor(named: "{{ color.name }}")!
}
{% endif %}
{% endfor %}
}

View File

@ -0,0 +1,4 @@
/// Color {{ color.name }} is {{ color.light }} {{ color.light }} or {{ color.dark }} {{ color.dark }}"
{% if isStatic %}static {% endif %}var {{ color.name }}: Color {
Color("{{ color.name }}")
}

View File

@ -0,0 +1,4 @@
/// Color {{ color.name }} is {{ color.light }} {{ color.light }} or {{ color.dark }} {{ color.dark }}"
{% if isStatic %}static {% else %}@objc {% endif %}var {{ color.name }}: UIColor {
UIColor(named: "{{ color.name }}")!
}

View File

@ -51,7 +51,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
]
// When
AnalyticsGenerator.targets = [Analytics.TargetType.firebase]
AnalyticsGenerator.targets = [TrackerType.firebase]
let extensionContent = AnalyticsGenerator.getExtensionContent(sections: [sectionOne, sectionTwo, sectionThree],
tags: ["ios", "iosonly"],
staticVar: false,
@ -216,7 +216,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
]
// When
AnalyticsGenerator.targets = [Analytics.TargetType.matomo]
AnalyticsGenerator.targets = [TrackerType.matomo]
let extensionContent = AnalyticsGenerator.getExtensionContent(sections: [sectionOne, sectionTwo, sectionThree],
tags: ["ios", "iosonly"],
staticVar: false,
@ -409,7 +409,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
]
// When
AnalyticsGenerator.targets = [Analytics.TargetType.matomo, Analytics.TargetType.firebase]
AnalyticsGenerator.targets = [TrackerType.matomo, TrackerType.firebase]
let extensionContent = AnalyticsGenerator.getExtensionContent(sections: [sectionOne, sectionTwo, sectionThree],
tags: ["ios", "iosonly"],
staticVar: false,

View File

@ -1,5 +1,5 @@
//
// File.swift
// DiffString.swift
//
//
// Created by Loris Perret on 06/12/2023.
@ -7,7 +7,6 @@
import Foundation
/// Find first differing character between two strings
///
/// :param: s1 First String

View File

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

View File

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

View File

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

48
script/swiftlint.sh Executable file
View File

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