Compare commits
4 Commits
stencil
...
504f006345
Author | SHA1 | Date | |
---|---|---|---|
504f006345 | |||
c9ea8ef9db | |||
950d6ec8a6 | |||
e4ada4b543 |
2
Jenkinsfile
vendored
2
Jenkinsfile
vendored
@ -1,6 +1,6 @@
|
|||||||
library "openiumpipeline"
|
library "openiumpipeline"
|
||||||
|
|
||||||
env.DEVELOPER_DIR="/Applications/Xcode-15.0.1.app/Contents/Developer"
|
env.DEVELOPER_DIR="/Applications/Xcode-15.2.0.app/Contents/Developer"
|
||||||
//env.SIMULATOR_DEVICE_TYPES="iPad--7th-generation-"
|
//env.SIMULATOR_DEVICE_TYPES="iPad--7th-generation-"
|
||||||
env.IS_PACKAGE_SWIFT=1
|
env.IS_PACKAGE_SWIFT=1
|
||||||
env.TARGETS_MACOS=1
|
env.TARGETS_MACOS=1
|
||||||
|
@ -18,15 +18,6 @@
|
|||||||
"version" : "1.8.0"
|
"version" : "1.8.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"identity" : "pathkit",
|
|
||||||
"kind" : "remoteSourceControl",
|
|
||||||
"location" : "https://github.com/kylef/PathKit.git",
|
|
||||||
"state" : {
|
|
||||||
"revision" : "3bfd2737b700b9a36565a8c94f4ad2b050a5e574",
|
|
||||||
"version" : "1.0.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"identity" : "sourcekitten",
|
"identity" : "sourcekitten",
|
||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
@ -36,24 +27,6 @@
|
|||||||
"version" : "0.34.1"
|
"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",
|
"identity" : "swift-argument-parser",
|
||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
|
@ -11,7 +11,6 @@ let package = Package(
|
|||||||
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0"),
|
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0"),
|
||||||
.package(url: "https://github.com/jpsim/Yams.git", from: "5.0.1"),
|
.package(url: "https://github.com/jpsim/Yams.git", from: "5.0.1"),
|
||||||
.package(url: "https://github.com/realm/SwiftLint.git", .upToNextMajor(from: "0.54.0")),
|
.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: [
|
||||||
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
|
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
|
||||||
@ -21,8 +20,7 @@ let package = Package(
|
|||||||
dependencies: [
|
dependencies: [
|
||||||
"ToolCore",
|
"ToolCore",
|
||||||
.product(name: "ArgumentParser", package: "swift-argument-parser"),
|
.product(name: "ArgumentParser", package: "swift-argument-parser"),
|
||||||
"Yams",
|
"Yams"
|
||||||
"Stencil",
|
|
||||||
],
|
],
|
||||||
plugins: [.plugin(name: "SwiftLintPlugin", package: "SwiftLint")]
|
plugins: [.plugin(name: "SwiftLintPlugin", package: "SwiftLint")]
|
||||||
),
|
),
|
||||||
|
35
README.md
35
README.md
@ -131,7 +131,7 @@ swift run -c release ResgenSwift strings tags $FORCE_FLAG "./Tags/tags.txt" \
|
|||||||
6. `--extension-suffix` *(optional)* : additional text which is added to filename (ex: `AppTags+GreatApp.swift`)
|
6. `--extension-suffix` *(optional)* : additional text which is added to filename (ex: `AppTags+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 `Tags`, it will generate the following typaloas `typealias Tags = String`.
|
> ⚠️ If extension name is not set or is `Tags`, it will generate the following typealias `typealias Tags = String`.
|
||||||
|
|
||||||
|
|
||||||
## Analytics
|
## Analytics
|
||||||
@ -139,7 +139,7 @@ swift run -c release ResgenSwift strings tags $FORCE_FLAG "./Tags/tags.txt" \
|
|||||||
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.
|
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
|
```sh
|
||||||
swift run -c release ResgenSwift strings tags $FORCE_FLAG "./Tags/tags.txt" \
|
swift run -c release ResgenSwift analytics $FORCE_FLAG "./Tags/analytics.yml" \
|
||||||
--target "matomo firebase" \
|
--target "matomo firebase" \
|
||||||
--extension-output-path "./Analytics/Generated" \
|
--extension-output-path "./Analytics/Generated" \
|
||||||
--extension-name "AppAnalytics" \
|
--extension-name "AppAnalytics" \
|
||||||
@ -157,7 +157,7 @@ swift run -c release ResgenSwift strings tags $FORCE_FLAG "./Tags/tags.txt" \
|
|||||||
6. `--extension-suffix` *(optional)* : additional text which is added to filename (ex: `AppAnalytics+GreatApp.swift`)
|
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 typaloas `typealias Analytics = String`.
|
> ⚠️ If extension name is not set or is `Analytics`, it will generate the following typealias `typealias Analytics = String`.
|
||||||
|
|
||||||
### YAML
|
### YAML
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ swift run -c release ResgenSwift strings tags $FORCE_FLAG "./Tags/tags.txt" \
|
|||||||
7. `comments` *(optional)*
|
7. `comments` *(optional)*
|
||||||
8. `parameters` *(optional)*
|
8. `parameters` *(optional)*
|
||||||
|
|
||||||
**Parameters**
|
**Parameters**
|
||||||
|
|
||||||
You can use parameters in generate methods.
|
You can use parameters in generate methods.
|
||||||
|
|
||||||
@ -197,6 +197,24 @@ You can use parameters in generate methods.
|
|||||||
This is section is equivalent of `%s | %d | %f | %@`. You can put the content of the parameter in *name*, *path*, *action*, *category*.
|
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)
|
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)
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```
|
||||||
|
events:
|
||||||
|
id: id_of_tag
|
||||||
|
name: _TITLE_
|
||||||
|
tags: ios,droid
|
||||||
|
parameters:
|
||||||
|
- name: title
|
||||||
|
type: String
|
||||||
|
replaceIn: name
|
||||||
|
```
|
||||||
|
|
||||||
|
In this sample, we want to add the parameter `title` in the field `name`. So, we need to place `_TITLE_` in the field `name`.
|
||||||
|
|
||||||
|
The generated method will be:
|
||||||
|
```
|
||||||
|
logIdOfTag(title: String)
|
||||||
|
```
|
||||||
|
|
||||||
## Images
|
## Images
|
||||||
|
|
||||||
@ -284,6 +302,15 @@ tags:
|
|||||||
extensionName: String?
|
extensionName: String?
|
||||||
extensionSuffix: String?
|
extensionSuffix: String?
|
||||||
staticMembers: Bool?
|
staticMembers: Bool?
|
||||||
|
|
||||||
|
analytics:
|
||||||
|
-
|
||||||
|
inputFile: String
|
||||||
|
target: String
|
||||||
|
extensionOutputPath: String
|
||||||
|
extensionName: String?
|
||||||
|
extensionSuffix: String?
|
||||||
|
staticMembers: Bool?
|
||||||
```
|
```
|
||||||
|
|
||||||
### Multiple configurations
|
### Multiple configurations
|
||||||
|
@ -4,25 +4,18 @@ import SwiftUI
|
|||||||
|
|
||||||
extension ColorYolo {
|
extension ColorYolo {
|
||||||
|
|
||||||
|
/// Color red is #FF0000 (light) or #FF0000 (dark)"
|
||||||
/// Color red is #FF0000 #FF0000 or #FF0000 #FF0000"
|
|
||||||
var red: Color {
|
var red: Color {
|
||||||
Color("red")
|
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 {
|
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 #0000FF or #0000AA #0000AA"
|
|
||||||
var blue_light_dark: Color {
|
var blue_light_dark: Color {
|
||||||
Color("blue_light_dark")
|
Color("blue_light_dark")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,25 +4,18 @@ import UIKit
|
|||||||
|
|
||||||
extension UIColorYolo {
|
extension UIColorYolo {
|
||||||
|
|
||||||
|
/// Color red is #FF0000 (light) or #FF0000 (dark)"
|
||||||
/// Color red is #FF0000 #FF0000 or #FF0000 #FF0000"
|
|
||||||
@objc var red: UIColor {
|
@objc 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 #A000FF00 or #A000FF00 #A000FF00"
|
|
||||||
@objc var green_alpha_50: UIColor {
|
@objc 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 #0000FF or #0000AA #0000AA"
|
|
||||||
@objc var blue_light_dark: UIColor {
|
@objc var blue_light_dark: UIColor {
|
||||||
UIColor(named: "blue_light_dark")!
|
UIColor(named: "blue_light_dark")!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
// 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")!
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,6 +1,5 @@
|
|||||||
// Generated by ResgenSwift.Analytics 1.2
|
// Generated by ResgenSwift.Analytics 1.2
|
||||||
|
|
||||||
import MatomoTracker
|
|
||||||
import FirebaseAnalytics
|
import FirebaseAnalytics
|
||||||
|
|
||||||
// MARK: - Protocol
|
// MARK: - Protocol
|
||||||
@ -15,72 +14,11 @@ protocol AnalyticsManagerProtocol {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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) {
|
|
||||||
guard !tracker.isOptedOut else { return }
|
|
||||||
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]?
|
|
||||||
) {
|
|
||||||
guard !tracker.isOptedOut else { return }
|
|
||||||
|
|
||||||
tracker.track(
|
|
||||||
eventWithCategory: category,
|
|
||||||
action: action,
|
|
||||||
name: name,
|
|
||||||
number: nil,
|
|
||||||
url: nil
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - Firebase
|
// MARK: - Firebase
|
||||||
|
|
||||||
class FirebaseAnalyticsManager: AnalyticsManagerProtocol {
|
class FirebaseAnalyticsManager: AnalyticsManagerProtocol {
|
||||||
func logScreen(name: String, path: String) {
|
func logScreen(name: String, path: String) {
|
||||||
var parameters = [
|
let parameters = [
|
||||||
AnalyticsParameterScreenName: name as NSObject
|
AnalyticsParameterScreenName: name as NSObject
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -97,8 +35,9 @@ class FirebaseAnalyticsManager: AnalyticsManagerProtocol {
|
|||||||
params: [String: Any]?
|
params: [String: Any]?
|
||||||
) {
|
) {
|
||||||
var parameters: [String:NSObject] = [
|
var parameters: [String:NSObject] = [
|
||||||
|
AnalyticsParameterItemName: name.replacingOccurrences(of: " ", with: "_") as NSObject,
|
||||||
|
AnalyticsParameterItemCategory: category as NSObject,
|
||||||
"action": action as NSObject,
|
"action": action as NSObject,
|
||||||
"category": category as NSObject,
|
|
||||||
]
|
]
|
||||||
|
|
||||||
if let supplementaryParameters = params {
|
if let supplementaryParameters = params {
|
||||||
@ -114,7 +53,7 @@ class FirebaseAnalyticsManager: AnalyticsManagerProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Analytics.logEvent(
|
Analytics.logEvent(
|
||||||
name.replacingOccurrences(of: [" "], with: "_"),
|
AnalyticsEventSelectContent,
|
||||||
parameters: parameters
|
parameters: parameters
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -137,13 +76,7 @@ class AnalyticsManager {
|
|||||||
isEnabled = enable
|
isEnabled = enable
|
||||||
}
|
}
|
||||||
|
|
||||||
func configure(siteId: String, url: String) {
|
func configure() {
|
||||||
managers.append(
|
|
||||||
MatomoAnalyticsManager(
|
|
||||||
siteId: siteId,
|
|
||||||
url: url
|
|
||||||
)
|
|
||||||
)
|
|
||||||
managers.append(FirebaseAnalyticsManager())
|
managers.append(FirebaseAnalyticsManager())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +111,7 @@ class AnalyticsManager {
|
|||||||
func logScreenS1DefOne(title: String) {
|
func logScreenS1DefOne(title: String) {
|
||||||
logScreen(
|
logScreen(
|
||||||
name: "s1 def one \(title)",
|
name: "s1 def one \(title)",
|
||||||
path: "s1_def_one/\(title)"
|
path: ""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,7 +132,7 @@ class AnalyticsManager {
|
|||||||
func logScreenS2DefOne() {
|
func logScreenS2DefOne() {
|
||||||
logScreen(
|
logScreen(
|
||||||
name: "s2 def one",
|
name: "s2 def one",
|
||||||
path: "s2_def_one/"
|
path: ""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,14 +12,14 @@ FORCE_FLAG="$1"
|
|||||||
#
|
#
|
||||||
#echo "\n-------------------------\n"
|
#echo "\n-------------------------\n"
|
||||||
#
|
#
|
||||||
# Color
|
## Color
|
||||||
swift run -c release ResgenSwift colors $FORCE_FLAG "./Colors/sampleColors1.txt" \
|
#swift run -c release ResgenSwift colors $FORCE_FLAG "./Colors/sampleColors1.txt" \
|
||||||
--style all \
|
# --style all \
|
||||||
--xcassets-path "./Colors/colors.xcassets" \
|
# --xcassets-path "./Colors/colors.xcassets" \
|
||||||
--extension-output-path "./Colors/Generated/" \
|
# --extension-output-path "./Colors/Generated/" \
|
||||||
--extension-name "ColorYolo" \
|
# --extension-name "ColorYolo" \
|
||||||
--extension-name-ui-kit "UIColorYolo" \
|
# --extension-name-ui-kit "UIhkjhkColorYolo" \
|
||||||
--extension-suffix "GenAllScript"
|
# --extension-suffix "GenAllScript"
|
||||||
#
|
#
|
||||||
#echo "\n-------------------------\n"
|
#echo "\n-------------------------\n"
|
||||||
#
|
#
|
||||||
@ -52,12 +52,13 @@ swift run -c release ResgenSwift colors $FORCE_FLAG "./Colors/sampleColors1.txt"
|
|||||||
|
|
||||||
#echo "\n-------------------------\n"
|
#echo "\n-------------------------\n"
|
||||||
|
|
||||||
## Analytics
|
# Analytics
|
||||||
#swift run -c release ResgenSwift analytics $FORCE_FLAG "./Tags/sampleTags.yml" \
|
swift run -c release ResgenSwift analytics $FORCE_FLAG "./Tags/sampleTags.yml" \
|
||||||
# --target "matomo firebase" \
|
--target "firebase" \
|
||||||
# --extension-output-path "./Tags/Generated" \
|
--extension-output-path "./Tags/Generated" \
|
||||||
# --extension-name "Analytics" \
|
--extension-name "Analytics" \
|
||||||
# --extension-suffix "GenAllScript"
|
--extension-suffix "GenAllScript" \
|
||||||
|
--static-members true
|
||||||
|
|
||||||
#echo "\n-------------------------\n"
|
#echo "\n-------------------------\n"
|
||||||
#
|
#
|
||||||
|
@ -32,7 +32,7 @@ enum FirebaseGenerator {
|
|||||||
private static var logScreen: String {
|
private static var logScreen: String {
|
||||||
"""
|
"""
|
||||||
func logScreen(name: String, path: String) {
|
func logScreen(name: String, path: String) {
|
||||||
var parameters = [
|
let parameters = [
|
||||||
AnalyticsParameterScreenName: name as NSObject
|
AnalyticsParameterScreenName: name as NSObject
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -54,8 +54,9 @@ enum FirebaseGenerator {
|
|||||||
params: [String: Any]?
|
params: [String: Any]?
|
||||||
) {
|
) {
|
||||||
var parameters: [String:NSObject] = [
|
var parameters: [String:NSObject] = [
|
||||||
|
AnalyticsParameterItemName: name.replacingOccurrences(of: " ", with: "_") as NSObject,
|
||||||
|
AnalyticsParameterItemCategory: category as NSObject,
|
||||||
"action": action as NSObject,
|
"action": action as NSObject,
|
||||||
"category": category as NSObject,
|
|
||||||
]
|
]
|
||||||
|
|
||||||
if let supplementaryParameters = params {
|
if let supplementaryParameters = params {
|
||||||
@ -71,7 +72,7 @@ enum FirebaseGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Analytics.logEvent(
|
Analytics.logEvent(
|
||||||
name.replacingOccurrences(of: [" "], with: "_"),
|
AnalyticsEventSelectContent,
|
||||||
parameters: parameters
|
parameters: parameters
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ class AnalyticsDefinition {
|
|||||||
replaceIn()
|
replaceIn()
|
||||||
return """
|
return """
|
||||||
static func \(getFuncName())\(getParameters()) {
|
static func \(getFuncName())\(getParameters()) {
|
||||||
\(getlogFunction())
|
AnalyticsManager.shared.\(getlogFunction())
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
@ -139,6 +139,14 @@ class AnalyticsFileParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
definition.action = action
|
definition.action = action
|
||||||
|
} else {
|
||||||
|
if let category = event.category {
|
||||||
|
definition.category = category
|
||||||
|
}
|
||||||
|
|
||||||
|
if let action = event.action {
|
||||||
|
definition.action = action
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return definition
|
return definition
|
||||||
|
@ -41,28 +41,12 @@ struct ColorExtensionGenerator {
|
|||||||
staticVar: Bool,
|
staticVar: Bool,
|
||||||
extensionName: String,
|
extensionName: String,
|
||||||
isSwiftUI: Bool) -> String {
|
isSwiftUI: Bool) -> String {
|
||||||
// [
|
[
|
||||||
// Self.getHeader(extensionClassname: extensionName, isSwiftUI: isSwiftUI),
|
Self.getHeader(extensionClassname: extensionName, isSwiftUI: isSwiftUI),
|
||||||
// Self.getProperties(for: colors, withStaticVar: staticVar, isSwiftUI: isSwiftUI),
|
Self.getProperties(for: colors, withStaticVar: staticVar, isSwiftUI: isSwiftUI),
|
||||||
// Self.getFooter()
|
Self.getFooter()
|
||||||
// ]
|
]
|
||||||
// .joined(separator: "\n")
|
.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 {
|
private static func getHeader(extensionClassname: String, isSwiftUI: Bool) -> String {
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
import ToolCore
|
import ToolCore
|
||||||
import Foundation
|
import Foundation
|
||||||
import ArgumentParser
|
import ArgumentParser
|
||||||
import Stencil
|
|
||||||
import PathKit
|
|
||||||
|
|
||||||
struct ResgenSwift: ParsableCommand {
|
struct ResgenSwift: ParsableCommand {
|
||||||
|
|
||||||
@ -34,20 +32,6 @@ struct ResgenSwift: ParsableCommand {
|
|||||||
// subcommand is not given on the command line.
|
// subcommand is not given on the command line.
|
||||||
//defaultSubcommand: Twine.self
|
//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()
|
ResgenSwift.main()
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
// 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 %}
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
/// Color {{ color.name }} is {{ color.light }} {{ color.light }} or {{ color.dark }} {{ color.dark }}"
|
|
||||||
{% if isStatic %}static {% endif %}var {{ color.name }}: Color {
|
|
||||||
Color("{{ color.name }}")
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
/// 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 }}")!
|
|
||||||
}
|
|
Reference in New Issue
Block a user