Compare commits
6 Commits
2.2.0
...
087280502e
Author | SHA1 | Date | |
---|---|---|---|
087280502e | |||
9f59b53e35 | |||
d05f18321f | |||
91cc63f942 | |||
187980933e | |||
a64a956254 |
@@ -40,15 +40,7 @@ let package = Package(
|
|||||||
),
|
),
|
||||||
|
|
||||||
// Helper targets
|
// Helper targets
|
||||||
.target(
|
.target(name: "ToolCore"),
|
||||||
name: "ToolCore",
|
|
||||||
dependencies: [
|
|
||||||
.product(
|
|
||||||
name: "ArgumentParser",
|
|
||||||
package: "swift-argument-parser"
|
|
||||||
)
|
|
||||||
]
|
|
||||||
),
|
|
||||||
|
|
||||||
// Test targets
|
// Test targets
|
||||||
.testTarget(
|
.testTarget(
|
||||||
|
434
README.md
434
README.md
@@ -2,122 +2,64 @@
|
|||||||
|
|
||||||
ResgenSwift is a package, fully written in Swift, to help you automatize ressource update and generation.
|
ResgenSwift is a package, fully written in Swift, to help you automatize ressource update and generation.
|
||||||
|
|
||||||
> 🧐 For all commands, see samples files in `SampleFiles` and use `resgen-swift help` and `resgen-swift help <subcommand>` for detailed help.
|
> 🧐 For all commands, see samples files in `SampleFiles`
|
||||||
|
|
||||||
## Fonts
|
## Fonts
|
||||||
|
|
||||||
Font generator generates an extension of `UIFont` and `Font` (or custom classes). It also prints content of `UIAppFonts` from your project `.plist`. If project `.plist` is specified, it will update `UIAppFonts` content of all `.plist`.
|
Font generator generates an extension of `UIFont` and `Font` (or custom classes). It also prints content of `UIAppFonts` from your project `.plist`. If project `.plist` is specified, it will update `UIAppFonts` content of all `.plist`.
|
||||||
|
|
||||||
iOS required to use the **real name** of the font, this name can be different from its filename. To get the **real name**, it uses `fc-scan`. So, be sure that your `$PATH` variable contains path of `fc-scan`.
|
iOS required to use the **real name** of the font, this name can be different from its filename. To get the **real name**, it uses `fc-scan`. So, be sure that the `$PATH` contains path of `fc-scan`.
|
||||||
|
|
||||||
|
|
||||||
```sh
|
|
||||||
USAGE:
|
|
||||||
swift run -c release ResgenSwift fonts [-f] <input-file> --extension-output-path <extension-output-path> \
|
|
||||||
[--static-members <static-members>] \
|
|
||||||
[--visibility <visibility>] \
|
|
||||||
[--extension-name <extension-name>] \
|
|
||||||
[--extension-name-ui-kit <extension-name-ui-kit>] \
|
|
||||||
[--extension-suffix <extension-suffix>] \
|
|
||||||
[--info-plist-paths <info-plist-paths>]
|
|
||||||
|
|
||||||
ARGUMENTS:
|
|
||||||
<input-file> Input files where fonts ared defined.
|
|
||||||
|
|
||||||
OPTIONS:
|
|
||||||
-f, -F Should force generation
|
|
||||||
--static-members <static-members>
|
|
||||||
Tell if it will generate static properties or methods (default: false)
|
|
||||||
--visibility <visibility>
|
|
||||||
Visibility of extension and properties. Possibles values: public, private, package, internal. Default is internal (default: internal)
|
|
||||||
--extension-output-path <extension-output-path>
|
|
||||||
Path where to generate the extension.
|
|
||||||
--extension-name <extension-name>
|
|
||||||
Extension name. If not specified, it will generate an Font extension. (default: Font)
|
|
||||||
--extension-name-ui-kit <extension-name-ui-kit>
|
|
||||||
Extension name. If not specified, no extension will be generated.
|
|
||||||
--extension-suffix <extension-suffix>
|
|
||||||
Extension suffix. Ex: MyApp, it will generate {extensionName}+FontsMyApp.swift
|
|
||||||
--info-plist-paths <info-plist-paths>
|
|
||||||
Info.plist paths (array). Will be used to update UIAppFonts content
|
|
||||||
--version Show the version.
|
|
||||||
-h, --help Show help information.
|
|
||||||
```
|
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
swift run -c release ResgenSwift fonts -f "./Fonts/fonts.txt" \
|
swift run -c release ResgenSwift fonts $FORCE_FLAG "./Fonts/fonts.txt" \
|
||||||
--extension-output-path "./Fonts/Generated" \
|
--extension-output-path "./Fonts/Generated" \
|
||||||
--static-members true \
|
|
||||||
--visibility "public" \
|
|
||||||
--extension-name "AppFont" \
|
--extension-name "AppFont" \
|
||||||
--extension-name-ui-kit "UIAppFont" \
|
--extension-name-ui-kit "UIAppFont" \
|
||||||
--extension-suffix "GreatApp" \
|
--extension-suffix "GreatApp" \
|
||||||
|
--static-members true \
|
||||||
--info-plist-paths "./path/one/to/Info.plist ./path/two/to/Info.plist"
|
--info-plist-paths "./path/one/to/Info.plist ./path/two/to/Info.plist"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Parameters**
|
||||||
|
|
||||||
|
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 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
|
||||||
|
|
||||||
|
|
||||||
## Colors
|
## Colors
|
||||||
|
|
||||||
Colors generator generates colorsets in specified xcassets and an extension of `Color` (or a custom class) associated to those colorsets. If the extension name is not specified, no extension will be generated.
|
Colors generator generates colorsets in specified xcassets and an extension of `Color` (or a custom class) associated to those colorsets. If the extension name is not specified, no extension will be generated.
|
||||||
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
USAGE:
|
swift run -c release ResgenSwift colors $FORCE_FLAG "./Colors/colors.txt" \
|
||||||
swift run -c release ResgenSwift colors [-f] <input-file> \
|
|
||||||
--style <style> \
|
|
||||||
--xcassets-path <xcassets-path> \
|
|
||||||
[--static-members <static-members>] \
|
|
||||||
[--visibility <visibility>] \
|
|
||||||
[--asset-bundle <asset-bundle>] \
|
|
||||||
[--extension-output-path <extension-output-path>] \
|
|
||||||
[--extension-name <extension-name>] \
|
|
||||||
[--extension-name-ui-kit <extension-name-ui-kit>] \
|
|
||||||
[--extension-suffix <extension-suffix>]
|
|
||||||
|
|
||||||
ARGUMENTS:
|
|
||||||
<input-file> Input files where colors ared defined.
|
|
||||||
|
|
||||||
OPTIONS:
|
|
||||||
-f, -F Should force generation
|
|
||||||
--style <style> Color style to generate: light for light colors only, or all for dark and light colors (values: light, all)
|
|
||||||
--xcassets-path <xcassets-path>
|
|
||||||
Path of xcassets where to generate colors
|
|
||||||
--static-members <static-members>
|
|
||||||
Tell if it will generate static properties or not (default: false)
|
|
||||||
--visibility <visibility>
|
|
||||||
Visibility of extension and properties. Possibles values: public, private, package, internal. Default is internal (default: internal)
|
|
||||||
--asset-bundle <asset-bundle>
|
|
||||||
Bundle where the asset are generated (default: main)
|
|
||||||
--extension-output-path <extension-output-path>
|
|
||||||
Path where to generate the extension.
|
|
||||||
--extension-name <extension-name>
|
|
||||||
SwiftUI extension name. If not specified, no extension will be generated.
|
|
||||||
--extension-name-ui-kit <extension-name-ui-kit>
|
|
||||||
UIKit extension name. If not specified, no extension will be generated.
|
|
||||||
--extension-suffix <extension-suffix>
|
|
||||||
Extension suffix. Ex: MyApp, it will generate {extensionName}+ColorsMyApp.swift
|
|
||||||
--version Show the version.
|
|
||||||
-h, --help Show help information.
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
**Example**
|
|
||||||
|
|
||||||
```sh
|
|
||||||
swift run -c release ResgenSwift colors -f "./Colors/colors.txt" \
|
|
||||||
--style all \
|
--style all \
|
||||||
--xcassets-path "./Colors/colors.xcassets" \
|
--xcassets-path "./Colors/colors.xcassets" \
|
||||||
--static-members true \
|
|
||||||
--visibility internal \
|
|
||||||
--asset-bundle "main" \
|
|
||||||
--extension-output-path "./Colors/Generated/" \
|
--extension-output-path "./Colors/Generated/" \
|
||||||
--extension-name "AppColor \
|
--extension-name "AppColor" \
|
||||||
--extension-name-ui-kit "UIAppColor" \
|
--extension-name-ui-kit "UIAppColor" \
|
||||||
--extension-suffix "GreatApp"
|
--extension-suffix "GreatApp" \
|
||||||
|
--static-members true
|
||||||
```
|
```
|
||||||
|
|
||||||
> ⚠️ Option `extensionOutputPath` will require an `extensionName` or `extensionNameUIKit` to generate extension files. Passing an `extensionName` or `extensionNameUIKit` without `extensionOutputPath` will not generate any extension file.
|
**Parameters**
|
||||||
|
|
||||||
|
1. `-f`: force generation
|
||||||
|
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 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
|
||||||
|
|
||||||
|
|
||||||
## Strings
|
## Strings
|
||||||
|
|
||||||
@@ -126,190 +68,98 @@ Strings command allows to generate `strings` files along with extensions to acce
|
|||||||
### Twine (not recommended)
|
### Twine (not recommended)
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
USAGE:
|
swift run -c release ResgenSwift strings twine $FORCE_FLAG "./Twine/strings.txt" \
|
||||||
swift run -c release ResgenSwift strings twine [-f] <input-file> \
|
|
||||||
--output-path <output-path> \
|
|
||||||
--langs <langs> \
|
|
||||||
--default-lang <default-lang> \
|
|
||||||
--extension-output-path <extension-output-path>
|
|
||||||
|
|
||||||
ARGUMENTS:
|
|
||||||
<input-file> Input files where strings ared defined.
|
|
||||||
|
|
||||||
OPTIONS:
|
|
||||||
-f, -F Should force generation
|
|
||||||
--output-path <output-path>
|
|
||||||
Path where to strings file.
|
|
||||||
--langs <langs> Langs to generate.
|
|
||||||
--default-lang <default-lang>
|
|
||||||
Default langs.
|
|
||||||
--extension-output-path <extension-output-path>
|
|
||||||
Path where to generate the extension.
|
|
||||||
--version Show the version.
|
|
||||||
-h, --help Show help information.
|
|
||||||
```
|
|
||||||
|
|
||||||
**Example**
|
|
||||||
|
|
||||||
```sh
|
|
||||||
swift run -c release ResgenSwift strings twine -f "./Twine/strings.txt" \
|
|
||||||
--output-path "./Twine/Generated" \
|
--output-path "./Twine/Generated" \
|
||||||
--langs "fr en en-us" \
|
--langs "fr en en-us" \
|
||||||
--default-lang "en" \
|
--default-lang "en" \
|
||||||
--extension-output-path "./Twine/Generated"
|
--extension-output-path "./Twine/Generated"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Parameters**
|
||||||
|
|
||||||
|
1. `-f`: force generation
|
||||||
|
2. Input translations file (must be Twine formatted)
|
||||||
|
3. `--langs`: langs to generate (string with space between each lang)
|
||||||
|
4. `--default-lang`: default lang that will be in `Base.lproj`. It must be in `langs` as well
|
||||||
|
5. `--extension-output-path`: path where to generate generated extension
|
||||||
|
|
||||||
### Stringium (recommended)
|
### Stringium (recommended)
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
USAGE:
|
swift run -c release ResgenSwift strings stringium $FORCE_FLAG "./Strings/strings.txt" \
|
||||||
swift run -c release ResgenSwift strings stringium [-f] <input-file> \
|
|
||||||
--output-path <output-path> \
|
|
||||||
--langs <langs> \
|
|
||||||
--default-lang <default-lang> \
|
|
||||||
[--tags <tags>] \
|
|
||||||
[--static-members <static-members>] \
|
|
||||||
[--xc-strings <xc-strings>] \
|
|
||||||
[--visibility <visibility>] \
|
|
||||||
[--asset-bundle <asset-bundle>] \
|
|
||||||
[--extension-output-path <extension-output-path>] \
|
|
||||||
[--extension-name <extension-name>] \
|
|
||||||
[--extension-suffix <extension-suffix>]
|
|
||||||
|
|
||||||
ARGUMENTS:
|
|
||||||
<input-file> Input files where strings are defined.
|
|
||||||
|
|
||||||
OPTIONS:
|
|
||||||
-f, -F Should force generation
|
|
||||||
--output-path <output-path>
|
|
||||||
Path where to find the .xcStrings file or the lproj folders.
|
|
||||||
--langs <langs> Langs to generate.
|
|
||||||
--default-lang <default-lang>
|
|
||||||
Default langs.
|
|
||||||
--tags <tags> Tags to generate. (default: ios iosonly iosOnly notranslation)
|
|
||||||
--static-members <static-members>
|
|
||||||
Generate static properties. False by default (default: false)
|
|
||||||
--xc-strings <xc-strings>
|
|
||||||
Tell if it will generate xcStrings file or lproj file. True by default (default: true)
|
|
||||||
--visibility <visibility>
|
|
||||||
Visibility of extension and properties. Possibles values: public, private, package, internal. Default is internal (default: internal)
|
|
||||||
--asset-bundle <asset-bundle>
|
|
||||||
Bundle where the asset are generated (default: main)
|
|
||||||
--extension-output-path <extension-output-path>
|
|
||||||
Path where to generate the extension.
|
|
||||||
--extension-name <extension-name>
|
|
||||||
Extension name. If not specified, no extension will be generated.
|
|
||||||
--extension-suffix <extension-suffix>
|
|
||||||
Extension suffix: {extensionName}+{extensionSuffix}.swift
|
|
||||||
--version Show the version.
|
|
||||||
-h, --help Show help information.
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
**Example**
|
|
||||||
|
|
||||||
```sh
|
|
||||||
swift run -c release ResgenSwift strings stringium -f "./Strings/strings.txt" \
|
|
||||||
--output-path "./Strings/Generated" \
|
--output-path "./Strings/Generated" \
|
||||||
--langs "fr en en-us" \
|
--langs "fr en en-us" \
|
||||||
--default-lang "en \
|
--default-lang "en" \
|
||||||
--tags "ios iosonly iosOnly notranslation" \
|
|
||||||
--static-members true \
|
|
||||||
--xc-strings true \
|
|
||||||
--visibility "package" \
|
|
||||||
--asset-bundle "module" \
|
|
||||||
--extension-output-path "./Strings/Generated" \
|
--extension-output-path "./Strings/Generated" \
|
||||||
--extension-name "AppString \
|
--extension-name "AppString" \
|
||||||
--extension-suffix "GreatApp"
|
--extension-suffix "GreatApp" \
|
||||||
|
--xcStrings true
|
||||||
|
--static-members true
|
||||||
```
|
```
|
||||||
|
|
||||||
> ⚠️ Option `extensionOutputPath` will require an `extensionName` or `extensionNameUIKit` to generate extension files. Passing an `extensionName` or `extensionNameUIKit` without `extensionOutputPath` will not generate any extension file.
|
**Parameters**
|
||||||
|
|
||||||
|
1. `-f`: force generation
|
||||||
|
2. Input translations file (must be Twine formatted)
|
||||||
|
3. `--langs`: langs to generate (string with space between each lang)
|
||||||
|
4. `--default-lang`: default lang that will be in `Base.lproj`. It must be in `langs` as well
|
||||||
|
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: `AppString+GreatApp.swift`)
|
||||||
|
6. `--xcStrings`*(optional)* : generate string catalog
|
||||||
|
7. `--static-members` *(optional)*: generate static properties or not
|
||||||
|
|
||||||
|
|
||||||
## Tags
|
## Tags
|
||||||
|
|
||||||
Tags is also a subcommand of `Strings`. Input files are formatted the same way. Tags will generate properties which return exactly what is specified in the input file. It was designed to be used for analytics purpose and to be shared with any other platform to have the same analytics keys.
|
Tags is also a subcommand of `Strings`. Input files are formatted the same way. Tags will generate properties which return exactly what is specified in the input file. It was designed to be used for analytics purpose and to be shared with any other platform to have the same analytics keys.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
USAGE:
|
swift run -c release ResgenSwift strings tags $FORCE_FLAG "./Tags/tags.txt" \
|
||||||
swift run -c release ResgenSwift strings tags [-f] <input-file> \
|
|
||||||
--extension-output-path <extension-output-path> \
|
|
||||||
[--lang <lang>] \
|
|
||||||
[--visibility <visibility>] \
|
|
||||||
[--static-members <static-members>] \
|
|
||||||
[--extension-name <extension-name>] \
|
|
||||||
[--extension-suffix <extension-suffix>]
|
|
||||||
|
|
||||||
ARGUMENTS:
|
|
||||||
<input-file> Input files where tags ared defined.
|
|
||||||
|
|
||||||
OPTIONS:
|
|
||||||
-f, -F Should force generation
|
|
||||||
--lang <lang> Lang to generate. ("ium" by default) (default: ium)
|
|
||||||
--visibility <visibility>
|
|
||||||
Visibility of extension and properties. Possibles values: public, private, package, internal. Default is internal (default: internal)
|
|
||||||
--extension-output-path <extension-output-path>
|
|
||||||
Path where to generate the extension.
|
|
||||||
--static-members <static-members>
|
|
||||||
Tell if it will generate static properties or not (default: false)
|
|
||||||
--extension-name <extension-name>
|
|
||||||
Extension name. If not specified, it will generate a Tag extension. (default: Tags)
|
|
||||||
--extension-suffix <extension-suffix>
|
|
||||||
Extension suffix. Ex: MyApp, it will generate {extensionName}+Tag{extensionSuffix}.swift
|
|
||||||
--version Show the version.
|
|
||||||
-h, --help Show help information.
|
|
||||||
```
|
|
||||||
|
|
||||||
**Example**
|
|
||||||
|
|
||||||
```sh
|
|
||||||
swift run -c release ResgenSwift strings tags -f "./Tags/tags.txt" \
|
|
||||||
--extension-output-path "./Tags/Generated" \
|
|
||||||
--lang "ium" \
|
--lang "ium" \
|
||||||
--visibility "public" \
|
--extension-output-path "./Tags/Generated" \
|
||||||
--static-members true \
|
|
||||||
--extension-name "AppTags" \
|
--extension-name "AppTags" \
|
||||||
--extension-suffix "GreatApp"
|
--extension-suffix "GreatApp" \
|
||||||
|
--static-members true
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Parameters**
|
||||||
|
|
||||||
|
1. `-f`: force generation
|
||||||
|
2. Input tags file (must be Twine formatted)
|
||||||
|
3. `--lang`: langs to look at in input file
|
||||||
|
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: `AppTags+GreatApp.swift`)
|
||||||
|
7. `--static-members` *(optional)*: generate static properties or not
|
||||||
|
|
||||||
> ⚠️ If extension name is not set or is `Tags`, it will generate the following typealias `typealias Tags = String`.
|
> ⚠️ If extension name is not set or is `Tags`, it will generate the following typealias `typealias Tags = String`.
|
||||||
|
|
||||||
|
|
||||||
## Analytics
|
## 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.
|
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
|
||||||
USAGE:
|
swift run -c release ResgenSwift analytics $FORCE_FLAG "./Tags/analytics.yml" \
|
||||||
swift run -c release ResgenSwift analytics [-f] <input-file> \
|
--target "matomo firebase" \
|
||||||
--target <target> \
|
--extension-output-path "./Analytics/Generated" \
|
||||||
--output-file <output-file> \
|
--extension-name "AppAnalytics" \
|
||||||
[--static-members <static-members>] \
|
--extension-suffix "GreatApp" \
|
||||||
[--visibility <visibility>]
|
--static-members true
|
||||||
|
|
||||||
ARGUMENTS:
|
|
||||||
<input-file> Input files where tags ared defined.
|
|
||||||
|
|
||||||
OPTIONS:
|
|
||||||
-f, -F Should force generation
|
|
||||||
--target <target> Target(s) analytics to generate. ("matomo" | "firebase")
|
|
||||||
--output-file <output-file>
|
|
||||||
Where to generate the analytics manager (path with filename)
|
|
||||||
--static-members <static-members>
|
|
||||||
Tell if it will generate static properties or not (default: false)
|
|
||||||
--visibility <visibility>
|
|
||||||
Visibility of extension and properties. Possibles values: public, private, package, internal. Default is internal (default: internal)
|
|
||||||
--version Show the version.
|
|
||||||
-h, --help Show help information.
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**Example**
|
**Parameters**
|
||||||
|
|
||||||
```sh
|
1. `-f`: force generation
|
||||||
swift run -c release ResgenSwift analytics -f "./Tags/analytics.yml" \
|
2. Input tags file (must be YAML formatted)
|
||||||
--target "matomo firebase" \
|
3. `--target`: target with you will log UX
|
||||||
--output-file "./Analytics/Generated/AppAnalytics+GreatApp.swift" \
|
4. `--extension-output-path`: path where to generate generated extension
|
||||||
--static-members false \
|
5. `--extension-name` *(optional)* : name of class to add the extension
|
||||||
--visibility "public"
|
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 typealias `typealias Analytics = String`.
|
||||||
|
|
||||||
### YAML
|
### YAML
|
||||||
|
|
||||||
@@ -416,61 +266,28 @@ events:
|
|||||||
|
|
||||||
## Images
|
## Images
|
||||||
|
|
||||||
Images generator will generate images assets along with extensions to access those images easily. If the extension name is not specified, no extension will be generated.
|
Images generator will generate images assets along with extensions to access those images easily.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
USAGE:
|
swift run -c release ResgenSwift images $FORCE_FLAG "./Images/images.txt" \
|
||||||
resgen-swift images [-f] [-F] <input-file> \
|
|
||||||
--xcassets-path <xcassets-path> \
|
|
||||||
[--static-members <static-members>] \
|
|
||||||
[--visibility <visibility>] \
|
|
||||||
[--asset-bundle <asset-bundle>] \
|
|
||||||
[--extension-output-path <extension-output-path>] \
|
|
||||||
[--extension-name <extension-name>] \
|
|
||||||
[--extension-name-ui-kit <extension-name-ui-kit>] \
|
|
||||||
[--extension-suffix <extension-suffix>]
|
|
||||||
|
|
||||||
ARGUMENTS:
|
|
||||||
<input-file> Input files where strings ared defined.
|
|
||||||
|
|
||||||
OPTIONS:
|
|
||||||
-f Should force script execution
|
|
||||||
-F Regenerate all images
|
|
||||||
--xcassets-path <xcassets-path>
|
|
||||||
Xcassets path where to generate images.
|
|
||||||
--static-members <static-members>
|
|
||||||
Tell if it will generate static properties or not (default: false)
|
|
||||||
--visibility <visibility>
|
|
||||||
Visibility of extension and properties. Possibles values: public, private, package, internal. Default is internal (default: internal)
|
|
||||||
--asset-bundle <asset-bundle>
|
|
||||||
Bundle where the asset are generated (default: main)
|
|
||||||
--extension-output-path <extension-output-path>
|
|
||||||
Path where to generate the extension.
|
|
||||||
--extension-name <extension-name>
|
|
||||||
SwiftUI extension name. If not specified, no extension will be generated.
|
|
||||||
--extension-name-ui-kit <extension-name-ui-kit>
|
|
||||||
UIKit extension name. If not specified, no extension will be generated.
|
|
||||||
--extension-suffix <extension-suffix>
|
|
||||||
Extension suffix. Ex: MyApp, it will generate {extensionName}+Image{extensionSuffix}.swift
|
|
||||||
--version Show the version.
|
|
||||||
-h, --help Show help information.
|
|
||||||
```
|
|
||||||
|
|
||||||
**Example**
|
|
||||||
|
|
||||||
```sh
|
|
||||||
swift run -c release ResgenSwift images -F "./Images/images.txt" \
|
|
||||||
--xcassets-path "./Images/app.xcassets" \
|
--xcassets-path "./Images/app.xcassets" \
|
||||||
--static-members false \
|
|
||||||
--visibility "public" \
|
|
||||||
--asset-bundle "module" \
|
|
||||||
--extension-output-path "./Images/Generated" \
|
--extension-output-path "./Images/Generated" \
|
||||||
--extension-name "AppImage" \
|
--extension-name "AppImage" \
|
||||||
--extension-name-ui-kit "UIAppImage" \
|
--extension-name-ui-kit "UIAppImage" \
|
||||||
--extension-suffix "GreatApp"
|
--extension-suffix "GreatApp" \
|
||||||
|
--static-members true
|
||||||
```
|
```
|
||||||
|
|
||||||
> ⚠️ Option `extensionOutputPath` will require an `extensionName` or `extensionNameUIKit` to generate extension files. Passing an `extensionName` or `extensionNameUIKit` without `extensionOutputPath` will not generate any extension file.
|
**Parameters**
|
||||||
|
|
||||||
|
1. `-f`: force generation
|
||||||
|
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 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
|
||||||
|
|
||||||
> ⚠️ Svg images will be copied in the assets and rendered as "Original", however if those images are not rendered correctly you can force the png generation by adding the key word "png" like this: id arrow_back 15 ? png
|
> ⚠️ Svg images will be copied in the assets and rendered as "Original", however if those images are not rendered correctly you can force the png generation by adding the key word "png" like this: id arrow_back 15 ? png
|
||||||
|
|
||||||
@@ -487,15 +304,13 @@ All parameters can be specified in a configuration file in `Yaml`:
|
|||||||
colors:
|
colors:
|
||||||
-
|
-
|
||||||
inputFile: String
|
inputFile: String
|
||||||
style: String
|
style: [light/all]
|
||||||
xcassetsPath: String
|
xcassetsPath: String
|
||||||
extensionOutputPath: String
|
extensionOutputPath: String
|
||||||
extensionName: String?
|
extensionName: String?
|
||||||
extensionNameUIKit: String?
|
extensionNameUIKit: String?
|
||||||
extensionSuffix: String?
|
extensionSuffix: String?
|
||||||
staticMembers: Bool?
|
staticMembers: Bool?
|
||||||
visiblity: String?
|
|
||||||
assetBundle: String?
|
|
||||||
|
|
||||||
fonts:
|
fonts:
|
||||||
-
|
-
|
||||||
@@ -505,7 +320,6 @@ fonts:
|
|||||||
extensionNameUIKit: String?
|
extensionNameUIKit: String?
|
||||||
extensionSuffix: String?
|
extensionSuffix: String?
|
||||||
staticMembers: Bool?
|
staticMembers: Bool?
|
||||||
visiblity: String?
|
|
||||||
infoPlistPaths: [String]
|
infoPlistPaths: [String]
|
||||||
|
|
||||||
images:
|
images:
|
||||||
@@ -517,8 +331,6 @@ images:
|
|||||||
extensionNameUIKit: String?
|
extensionNameUIKit: String?
|
||||||
extensionSuffix: String?
|
extensionSuffix: String?
|
||||||
staticMembers: Bool?
|
staticMembers: Bool?
|
||||||
visiblity: String?
|
|
||||||
assetBundle: String?
|
|
||||||
|
|
||||||
strings:
|
strings:
|
||||||
-
|
-
|
||||||
@@ -530,9 +342,6 @@ strings:
|
|||||||
extensionName: String?
|
extensionName: String?
|
||||||
extensionSuffix: String?
|
extensionSuffix: String?
|
||||||
staticMembers: Bool?
|
staticMembers: Bool?
|
||||||
visiblity: String?
|
|
||||||
assetBundle: String?
|
|
||||||
xcStrings: Bool?
|
|
||||||
|
|
||||||
tags:
|
tags:
|
||||||
-
|
-
|
||||||
@@ -542,14 +351,14 @@ tags:
|
|||||||
extensionName: String?
|
extensionName: String?
|
||||||
extensionSuffix: String?
|
extensionSuffix: String?
|
||||||
staticMembers: Bool?
|
staticMembers: Bool?
|
||||||
visiblity: String?
|
|
||||||
|
|
||||||
analytics:
|
analytics:
|
||||||
-
|
-
|
||||||
inputFile: String
|
inputFile: String
|
||||||
target: String
|
target: String
|
||||||
outputFile: String
|
extensionOutputPath: String
|
||||||
visibility: String?
|
extensionName: String?
|
||||||
|
extensionSuffix: String?
|
||||||
staticMembers: Bool?
|
staticMembers: Bool?
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -564,26 +373,22 @@ Sample for 2 colors configurations:
|
|||||||
colors:
|
colors:
|
||||||
-
|
-
|
||||||
inputFile: String
|
inputFile: String
|
||||||
style: String
|
style: [light/all]
|
||||||
xcassetsPath: String
|
xcassetsPath: String
|
||||||
extensionOutputPath: String
|
extensionOutputPath: String
|
||||||
extensionName: String?
|
extensionName: String?
|
||||||
extensionNameUIKit: String?
|
extensionNameUIKit: String?
|
||||||
extensionSuffix: String?
|
extensionSuffix: String?
|
||||||
staticMembers: Bool?
|
staticMembers: Bool?
|
||||||
visiblity: String?
|
|
||||||
assetBundle: String?
|
|
||||||
-
|
-
|
||||||
inputFile: String
|
inputFile: String
|
||||||
style: String
|
style: [light/all]
|
||||||
xcassetsPath: String
|
xcassetsPath: String
|
||||||
extensionOutputPath: String
|
extensionOutputPath: String
|
||||||
extensionName: String?
|
extensionName: String?
|
||||||
extensionNameUIKit: String?
|
extensionNameUIKit: String?
|
||||||
extensionSuffix: String?
|
extensionSuffix: String?
|
||||||
staticMembers: Bool?
|
staticMembers: Bool?
|
||||||
visiblity: String?
|
|
||||||
assetBundle: String?
|
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -627,9 +432,8 @@ architecture:
|
|||||||
```
|
```
|
||||||
|
|
||||||
This will generate a file named as the architecture classname: `R.swift`. Based on the previous architecture, it will generate:
|
This will generate a file named as the architecture classname: `R.swift`. Based on the previous architecture, it will generate:
|
||||||
|
```
|
||||||
```swift
|
class R {
|
||||||
class R: Sendable {
|
|
||||||
static let images = R2Image()
|
static let images = R2Image()
|
||||||
static let strings = R2String()
|
static let strings = R2String()
|
||||||
static let fonts = R2Font()
|
static let fonts = R2Font()
|
||||||
@@ -637,25 +441,25 @@ class R: Sendable {
|
|||||||
static let uikit = R2UI()
|
static let uikit = R2UI()
|
||||||
}
|
}
|
||||||
|
|
||||||
class R2Image: Sendable {}
|
class R2Image {}
|
||||||
|
|
||||||
class R2String: Sendable {}
|
class R2String {}
|
||||||
|
|
||||||
class R2Font: Sendable {}
|
class R2Font {}
|
||||||
|
|
||||||
class R2Image: Sendable {}
|
class R2Image {}
|
||||||
|
|
||||||
class R2UI: Sendable {
|
class R2UI {
|
||||||
let images = R2UIImage()
|
let images = R2UIImage()
|
||||||
let fonts = R2UIFont()
|
let fonts = R2UIFont()
|
||||||
let images = R2UIImage()
|
let images = R2UIImage()
|
||||||
}
|
}
|
||||||
|
|
||||||
class R2UIImage: Sendable {}
|
class R2UIImage {}
|
||||||
|
|
||||||
class R2UIFont: Sendable {}
|
class R2UIFont {}
|
||||||
|
|
||||||
class R2UIImage: Sendable {}
|
class R2UIImage {}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,21 +1,21 @@
|
|||||||
// Generated by ResgenSwift.Color 2.2.0
|
// Generated by ResgenSwift.Color 2.1.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)"
|
||||||
public 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 (light) or #A000FF00 (dark)"
|
||||||
public 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 (light) or #0000AA (dark)"
|
||||||
public var blue_light_dark: Color {
|
var blue_light_dark: Color {
|
||||||
Color("blue_light_dark")
|
Color("blue_light_dark")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,21 +1,21 @@
|
|||||||
// Generated by ResgenSwift.Color 2.2.0
|
// Generated by ResgenSwift.Color 1.2
|
||||||
|
|
||||||
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 public 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 (light) or #A000FF00 (dark)"
|
||||||
@objc public 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 (light) or #0000AA (dark)"
|
||||||
@objc public var blue_light_dark: UIColor {
|
@objc var blue_light_dark: UIColor {
|
||||||
UIColor(named: "blue_light_dark")!
|
UIColor(named: "blue_light_dark")!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
6
SampleFiles/Colors/colors.xcassets/Colors/Contents.json
Normal file
6
SampleFiles/Colors/colors.xcassets/Colors/Contents.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
@@ -1,10 +1,10 @@
|
|||||||
// Generated by ResgenSwift.Fonts 2.2.0
|
// Generated by ResgenSwift.Fonts 2.1.0
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
extension FontYolo {
|
extension FontYolo {
|
||||||
|
|
||||||
public enum FontName: String {
|
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
|
||||||
|
|
||||||
public func LatoItalic(withSize size: CGFloat) -> Font {
|
func LatoItalic(withSize size: CGFloat) -> Font {
|
||||||
Font.custom(FontName.LatoItalic.rawValue, size: size)
|
Font.custom(FontName.LatoItalic.rawValue, size: size)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func LatoLightItalic(withSize size: CGFloat) -> Font {
|
func LatoLightItalic(withSize size: CGFloat) -> Font {
|
||||||
Font.custom(FontName.LatoLightItalic.rawValue, size: size)
|
Font.custom(FontName.LatoLightItalic.rawValue, size: size)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func LatoHairline(withSize size: CGFloat) -> Font {
|
func LatoHairline(withSize size: CGFloat) -> Font {
|
||||||
Font.custom(FontName.LatoHairline.rawValue, size: size)
|
Font.custom(FontName.LatoHairline.rawValue, size: size)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func LatoBold(withSize size: CGFloat) -> Font {
|
func LatoBold(withSize size: CGFloat) -> Font {
|
||||||
Font.custom(FontName.LatoBold.rawValue, size: size)
|
Font.custom(FontName.LatoBold.rawValue, size: size)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func LatoBlack(withSize size: CGFloat) -> Font {
|
func LatoBlack(withSize size: CGFloat) -> Font {
|
||||||
Font.custom(FontName.LatoBlack.rawValue, size: size)
|
Font.custom(FontName.LatoBlack.rawValue, size: size)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func LatoRegular(withSize size: CGFloat) -> Font {
|
func LatoRegular(withSize size: CGFloat) -> Font {
|
||||||
Font.custom(FontName.LatoRegular.rawValue, size: size)
|
Font.custom(FontName.LatoRegular.rawValue, size: size)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func LatoBlackItalic(withSize size: CGFloat) -> Font {
|
func LatoBlackItalic(withSize size: CGFloat) -> Font {
|
||||||
Font.custom(FontName.LatoBlackItalic.rawValue, size: size)
|
Font.custom(FontName.LatoBlackItalic.rawValue, size: size)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func LatoBoldItalic(withSize size: CGFloat) -> Font {
|
func LatoBoldItalic(withSize size: CGFloat) -> Font {
|
||||||
Font.custom(FontName.LatoBoldItalic.rawValue, size: size)
|
Font.custom(FontName.LatoBoldItalic.rawValue, size: size)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func LatoLight(withSize size: CGFloat) -> Font {
|
func LatoLight(withSize size: CGFloat) -> Font {
|
||||||
Font.custom(FontName.LatoLight.rawValue, size: size)
|
Font.custom(FontName.LatoLight.rawValue, size: size)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func LatoHairlineItalic(withSize size: CGFloat) -> Font {
|
func LatoHairlineItalic(withSize size: CGFloat) -> Font {
|
||||||
Font.custom(FontName.LatoHairlineItalic.rawValue, size: size)
|
Font.custom(FontName.LatoHairlineItalic.rawValue, size: size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
// Generated by ResgenSwift.Fonts 2.2.0
|
// Generated by ResgenSwift.Fonts 2.1.0
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
extension UIFontYolo {
|
extension UIFontYolo {
|
||||||
|
|
||||||
public enum FontName: String {
|
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
|
||||||
|
|
||||||
public func LatoItalic(withSize size: CGFloat) -> UIFont {
|
func LatoItalic(withSize size: CGFloat) -> UIFont {
|
||||||
UIFont(name: FontName.LatoItalic.rawValue, size: size)!
|
UIFont(name: FontName.LatoItalic.rawValue, size: size)!
|
||||||
}
|
}
|
||||||
|
|
||||||
public func LatoLightItalic(withSize size: CGFloat) -> UIFont {
|
func LatoLightItalic(withSize size: CGFloat) -> UIFont {
|
||||||
UIFont(name: FontName.LatoLightItalic.rawValue, size: size)!
|
UIFont(name: FontName.LatoLightItalic.rawValue, size: size)!
|
||||||
}
|
}
|
||||||
|
|
||||||
public func LatoHairline(withSize size: CGFloat) -> UIFont {
|
func LatoHairline(withSize size: CGFloat) -> UIFont {
|
||||||
UIFont(name: FontName.LatoHairline.rawValue, size: size)!
|
UIFont(name: FontName.LatoHairline.rawValue, size: size)!
|
||||||
}
|
}
|
||||||
|
|
||||||
public func LatoBold(withSize size: CGFloat) -> UIFont {
|
func LatoBold(withSize size: CGFloat) -> UIFont {
|
||||||
UIFont(name: FontName.LatoBold.rawValue, size: size)!
|
UIFont(name: FontName.LatoBold.rawValue, size: size)!
|
||||||
}
|
}
|
||||||
|
|
||||||
public func LatoBlack(withSize size: CGFloat) -> UIFont {
|
func LatoBlack(withSize size: CGFloat) -> UIFont {
|
||||||
UIFont(name: FontName.LatoBlack.rawValue, size: size)!
|
UIFont(name: FontName.LatoBlack.rawValue, size: size)!
|
||||||
}
|
}
|
||||||
|
|
||||||
public func LatoRegular(withSize size: CGFloat) -> UIFont {
|
func LatoRegular(withSize size: CGFloat) -> UIFont {
|
||||||
UIFont(name: FontName.LatoRegular.rawValue, size: size)!
|
UIFont(name: FontName.LatoRegular.rawValue, size: size)!
|
||||||
}
|
}
|
||||||
|
|
||||||
public func LatoBlackItalic(withSize size: CGFloat) -> UIFont {
|
func LatoBlackItalic(withSize size: CGFloat) -> UIFont {
|
||||||
UIFont(name: FontName.LatoBlackItalic.rawValue, size: size)!
|
UIFont(name: FontName.LatoBlackItalic.rawValue, size: size)!
|
||||||
}
|
}
|
||||||
|
|
||||||
public func LatoBoldItalic(withSize size: CGFloat) -> UIFont {
|
func LatoBoldItalic(withSize size: CGFloat) -> UIFont {
|
||||||
UIFont(name: FontName.LatoBoldItalic.rawValue, size: size)!
|
UIFont(name: FontName.LatoBoldItalic.rawValue, size: size)!
|
||||||
}
|
}
|
||||||
|
|
||||||
public func LatoLight(withSize size: CGFloat) -> UIFont {
|
func LatoLight(withSize size: CGFloat) -> UIFont {
|
||||||
UIFont(name: FontName.LatoLight.rawValue, size: size)!
|
UIFont(name: FontName.LatoLight.rawValue, size: size)!
|
||||||
}
|
}
|
||||||
|
|
||||||
public func LatoHairlineItalic(withSize size: CGFloat) -> UIFont {
|
func LatoHairlineItalic(withSize size: CGFloat) -> UIFont {
|
||||||
UIFont(name: FontName.LatoHairlineItalic.rawValue, size: size)!
|
UIFont(name: FontName.LatoHairlineItalic.rawValue, size: size)!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,31 +1,31 @@
|
|||||||
// Generated by ResgenSwift.Images 2.2.0
|
// Generated by ResgenSwift.Images 2.1.0
|
||||||
// Images from sampleImages
|
// Images from sampleImages
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
extension ImageYolo {
|
extension ImageYolo {
|
||||||
|
|
||||||
public var article_notification_pull_detail: Image {
|
var article_notification_pull_detail: Image {
|
||||||
Image("article_notification_pull_detail")
|
Image("article_notification_pull_detail")
|
||||||
}
|
}
|
||||||
|
|
||||||
public var article_notification_pull: Image {
|
var article_notification_pull: Image {
|
||||||
Image("article_notification_pull")
|
Image("article_notification_pull")
|
||||||
}
|
}
|
||||||
|
|
||||||
public var new_article: Image {
|
var new_article: Image {
|
||||||
Image("new_article")
|
Image("new_article")
|
||||||
}
|
}
|
||||||
|
|
||||||
public var welcome_background: Image {
|
var welcome_background: Image {
|
||||||
Image("welcome_background")
|
Image("welcome_background")
|
||||||
}
|
}
|
||||||
|
|
||||||
public var article_trash: Image {
|
var article_trash: Image {
|
||||||
Image("article_trash")
|
Image("article_trash")
|
||||||
}
|
}
|
||||||
|
|
||||||
public var ic_close_article: Image {
|
var ic_close_article: Image {
|
||||||
Image("ic_close_article")
|
Image("ic_close_article")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,31 +1,31 @@
|
|||||||
// Generated by ResgenSwift.Images 2.2.0
|
// Generated by ResgenSwift.Images 2.1.0
|
||||||
// Images from sampleImages
|
// Images from sampleImages
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
extension UIImageYolo {
|
extension UIImageYolo {
|
||||||
|
|
||||||
public var article_notification_pull_detail: UIImage {
|
var article_notification_pull_detail: UIImage {
|
||||||
UIImage(named: "article_notification_pull_detail")!
|
UIImage(named: "article_notification_pull_detail")!
|
||||||
}
|
}
|
||||||
|
|
||||||
public var article_notification_pull: UIImage {
|
var article_notification_pull: UIImage {
|
||||||
UIImage(named: "article_notification_pull")!
|
UIImage(named: "article_notification_pull")!
|
||||||
}
|
}
|
||||||
|
|
||||||
public var new_article: UIImage {
|
var new_article: UIImage {
|
||||||
UIImage(named: "new_article")!
|
UIImage(named: "new_article")!
|
||||||
}
|
}
|
||||||
|
|
||||||
public var welcome_background: UIImage {
|
var welcome_background: UIImage {
|
||||||
UIImage(named: "welcome_background")!
|
UIImage(named: "welcome_background")!
|
||||||
}
|
}
|
||||||
|
|
||||||
public var article_trash: UIImage {
|
var article_trash: UIImage {
|
||||||
UIImage(named: "article_trash")!
|
UIImage(named: "article_trash")!
|
||||||
}
|
}
|
||||||
|
|
||||||
public var ic_close_article: UIImage {
|
var ic_close_article: UIImage {
|
||||||
UIImage(named: "ic_close_article")!
|
UIImage(named: "ic_close_article")!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
// Generated by ResgenSwift.Strings.Stringium 2.2.0
|
// Generated by ResgenSwift.Strings.Stringium 2.1.0
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@ fileprivate let kStringsFileName = "sampleStrings"
|
|||||||
|
|
||||||
extension String {
|
extension String {
|
||||||
|
|
||||||
public enum KeyGenAllScript: String {
|
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"
|
||||||
|
|
||||||
public var keyPath: KeyPath<String, String> {
|
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
|
||||||
public var param_lang: String {
|
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
|
||||||
public var generic_back: String {
|
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
|
||||||
public var generic_loading_data: String {
|
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
|
||||||
public var generic_welcome_firstname_format: String {
|
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
|
||||||
public func generic_welcome_firstname_format(arg0: String) -> String {
|
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
|
||||||
public var test_equal_symbol: String {
|
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
|
||||||
public var placeholders_test_one: String {
|
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
|
||||||
public func placeholders_test_one(arg0: String, arg1: String, arg2: Int) -> String {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,150 +0,0 @@
|
|||||||
{
|
|
||||||
"sourceLanguage" : "en",
|
|
||||||
"strings" : {
|
|
||||||
"generic_back" : {
|
|
||||||
"comment" : "",
|
|
||||||
"extractionState" : "manual",
|
|
||||||
"localizations" : {
|
|
||||||
"en" : {
|
|
||||||
"stringUnit" : {
|
|
||||||
"state" : "translated",
|
|
||||||
"value" : "Back"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"en-us" : {
|
|
||||||
"stringUnit" : {
|
|
||||||
"state" : "translated",
|
|
||||||
"value" : "Back"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fr" : {
|
|
||||||
"stringUnit" : {
|
|
||||||
"state" : "translated",
|
|
||||||
"value" : "Retour"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"generic_loading_data" : {
|
|
||||||
"comment" : "",
|
|
||||||
"extractionState" : "manual",
|
|
||||||
"localizations" : {
|
|
||||||
"en" : {
|
|
||||||
"stringUnit" : {
|
|
||||||
"state" : "translated",
|
|
||||||
"value" : "Loading data..."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"en-us" : {
|
|
||||||
"stringUnit" : {
|
|
||||||
"state" : "translated",
|
|
||||||
"value" : "Loading data..."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fr" : {
|
|
||||||
"stringUnit" : {
|
|
||||||
"state" : "translated",
|
|
||||||
"value" : "Chargement des données..."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"generic_welcome_firstname_format" : {
|
|
||||||
"comment" : "",
|
|
||||||
"extractionState" : "manual",
|
|
||||||
"localizations" : {
|
|
||||||
"en" : {
|
|
||||||
"stringUnit" : {
|
|
||||||
"state" : "translated",
|
|
||||||
"value" : "Welcome \\\"%@\\\" !"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"en-us" : {
|
|
||||||
"stringUnit" : {
|
|
||||||
"state" : "translated",
|
|
||||||
"value" : "Welcome \\\"%@\\\" !"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fr" : {
|
|
||||||
"stringUnit" : {
|
|
||||||
"state" : "translated",
|
|
||||||
"value" : "Bienvenue \\\"%@\\\" !"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"param_lang" : {
|
|
||||||
"comment" : "",
|
|
||||||
"extractionState" : "manual",
|
|
||||||
"localizations" : {
|
|
||||||
"en" : {
|
|
||||||
"stringUnit" : {
|
|
||||||
"state" : "translated",
|
|
||||||
"value" : "en"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"en-us" : {
|
|
||||||
"stringUnit" : {
|
|
||||||
"state" : "translated",
|
|
||||||
"value" : "en-us"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fr" : {
|
|
||||||
"stringUnit" : {
|
|
||||||
"state" : "translated",
|
|
||||||
"value" : "fr"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"placeholders_test_one" : {
|
|
||||||
"comment" : "",
|
|
||||||
"extractionState" : "manual",
|
|
||||||
"localizations" : {
|
|
||||||
"en" : {
|
|
||||||
"stringUnit" : {
|
|
||||||
"state" : "translated",
|
|
||||||
"value" : "You %%: %2$@ %1$@ Age: %3$d"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"en-us" : {
|
|
||||||
"stringUnit" : {
|
|
||||||
"state" : "translated",
|
|
||||||
"value" : "You %%: %2$@ %1$@ Age: %3$d"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fr" : {
|
|
||||||
"stringUnit" : {
|
|
||||||
"state" : "translated",
|
|
||||||
"value" : "Vous %%: %1$@ %2$@ Age: %3$d"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"test_equal_symbol" : {
|
|
||||||
"comment" : "",
|
|
||||||
"extractionState" : "manual",
|
|
||||||
"localizations" : {
|
|
||||||
"en" : {
|
|
||||||
"stringUnit" : {
|
|
||||||
"state" : "translated",
|
|
||||||
"value" : "1€ = 1 point !"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"en-us" : {
|
|
||||||
"stringUnit" : {
|
|
||||||
"state" : "translated",
|
|
||||||
"value" : "1€ = 1 point !"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fr" : {
|
|
||||||
"stringUnit" : {
|
|
||||||
"state" : "translated",
|
|
||||||
"value" : "1€ = 1 point !"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"version" : "1.0"
|
|
||||||
}
|
|
@@ -1,4 +1,4 @@
|
|||||||
// Generated by ResgenSwift.Analytics 2.2.0
|
// Generated by ResgenSwift.Analytics 2.1.0
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import MatomoTracker
|
import MatomoTracker
|
||||||
@@ -6,7 +6,7 @@ import FirebaseAnalytics
|
|||||||
|
|
||||||
// MARK: - Protocol
|
// MARK: - Protocol
|
||||||
|
|
||||||
public protocol AnalyticsManagerProtocol {
|
protocol AnalyticsManagerProtocol {
|
||||||
|
|
||||||
func logScreen(
|
func logScreen(
|
||||||
name: String,
|
name: String,
|
||||||
@@ -24,72 +24,6 @@ public 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 {
|
||||||
@@ -170,17 +104,16 @@ class FirebaseAnalyticsManager: AnalyticsManagerProtocol {
|
|||||||
|
|
||||||
// MARK: - Traker Type
|
// MARK: - Traker Type
|
||||||
|
|
||||||
public enum TrackerType: CaseIterable {
|
enum TrackerType: CaseIterable {
|
||||||
|
|
||||||
case matomo
|
|
||||||
case firebase
|
case firebase
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Manager
|
// MARK: - Manager
|
||||||
|
|
||||||
public class AnalyticsManager {
|
class AnalyticsManager {
|
||||||
|
|
||||||
public static var shared = AnalyticsManager()
|
static var shared = AnalyticsManager()
|
||||||
|
|
||||||
private init() {}
|
private init() {}
|
||||||
|
|
||||||
@@ -208,19 +141,15 @@ public class AnalyticsManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func enableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
func enableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
||||||
setAnalytics(enable: true, analytics)
|
setAnalytics(enable: true, analytics)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func disableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
func disableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
||||||
setAnalytics(enable: false, analytics)
|
setAnalytics(enable: false, analytics)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func configure(siteId: String, url: String) {
|
func configure() {
|
||||||
managers[TrackerType.matomo] = MatomoAnalyticsManager(
|
|
||||||
siteId: siteId,
|
|
||||||
url: url
|
|
||||||
)
|
|
||||||
managers[TrackerType.firebase] = FirebaseAnalyticsManager()
|
managers[TrackerType.firebase] = FirebaseAnalyticsManager()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,15 +191,15 @@ public class AnalyticsManager {
|
|||||||
|
|
||||||
// MARK: - section_one
|
// MARK: - section_one
|
||||||
|
|
||||||
public func logScreenS1DefOne(title: String) {
|
static func logScreenS1DefOne(title: String) {
|
||||||
logScreen(
|
AnalyticsManager.shared.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
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func logEventS1DefTwo(
|
func logEventS1DefTwo(
|
||||||
title: String,
|
title: String,
|
||||||
count: String,
|
count: String,
|
||||||
test2: String = "test"
|
test2: String = "test"
|
||||||
@@ -290,8 +219,8 @@ public class AnalyticsManager {
|
|||||||
|
|
||||||
// MARK: - section_two
|
// MARK: - section_two
|
||||||
|
|
||||||
public func logScreenS2DefOne() {
|
static func logScreenS2DefOne() {
|
||||||
logScreen(
|
AnalyticsManager.shared.logScreen(
|
||||||
name: "s2 def one",
|
name: "s2 def one",
|
||||||
path: "s2_def_one/",
|
path: "s2_def_one/",
|
||||||
params: nil
|
params: nil
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
// Generated by ResgenSwift.Strings.Tags 2.2.0
|
// Generated by ResgenSwift.Strings.Tags 2.1.0
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
@@ -11,7 +11,8 @@ extension Tags {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
public var screen_one: String {
|
|
||||||
|
var screen_one: String {
|
||||||
"Ecran un"
|
"Ecran un"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,7 +21,8 @@ extension Tags {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
public var screen_two: String {
|
|
||||||
|
var screen_two: String {
|
||||||
"Ecran deux"
|
"Ecran deux"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,6 @@ strings:
|
|||||||
extensionOutputPath: ./Strings/Generated
|
extensionOutputPath: ./Strings/Generated
|
||||||
extensionName: String
|
extensionName: String
|
||||||
extensionSuffix: GenAllScript
|
extensionSuffix: GenAllScript
|
||||||
visibility: public
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -51,7 +50,6 @@ images:
|
|||||||
extensionName: ImageYolo
|
extensionName: ImageYolo
|
||||||
extensionNameUIKit: UIImageYolo
|
extensionNameUIKit: UIImageYolo
|
||||||
extensionSuffix: GenAllScript
|
extensionSuffix: GenAllScript
|
||||||
visibility: public
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -66,7 +64,6 @@ colors:
|
|||||||
extensionName: ColorYolo
|
extensionName: ColorYolo
|
||||||
extensionNameUIKit: UIColorYolo
|
extensionNameUIKit: UIColorYolo
|
||||||
extensionSuffix: GenAllScript
|
extensionSuffix: GenAllScript
|
||||||
visibility: public
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -79,7 +76,6 @@ tags:
|
|||||||
extensionOutputPath: ./Tags/Generated
|
extensionOutputPath: ./Tags/Generated
|
||||||
extensionName: Tags
|
extensionName: Tags
|
||||||
extensionSuffix: GenAllScript
|
extensionSuffix: GenAllScript
|
||||||
visibility: public
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -89,8 +85,9 @@ analytics:
|
|||||||
-
|
-
|
||||||
inputFile: ./Tags/sampleTags.yml
|
inputFile: ./Tags/sampleTags.yml
|
||||||
target: "matomo firebase"
|
target: "matomo firebase"
|
||||||
outputFile: ./Tags/Generated/Analytics+GenAllScript.swift
|
extensionOutputPath: ./Tags/Generated
|
||||||
visibility: public
|
extensionName: Analytics
|
||||||
|
extensionSuffix: GenAllScript
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -104,4 +101,3 @@ fonts:
|
|||||||
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
|
|
||||||
|
@@ -49,9 +49,9 @@ struct Analytics: ParsableCommand {
|
|||||||
sections: sections,
|
sections: sections,
|
||||||
target: options.target,
|
target: options.target,
|
||||||
tags: ["ios", "iosonly"],
|
tags: ["ios", "iosonly"],
|
||||||
isStatic: options.staticMembers,
|
staticVar: options.staticMembers,
|
||||||
outputFile: options.outputFile,
|
extensionName: options.extensionName,
|
||||||
visibility: options.extensionVisibility
|
extensionFilePath: options.extensionFilePath
|
||||||
)
|
)
|
||||||
|
|
||||||
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.outputFile
|
extensionFilePath: options.extensionFilePath
|
||||||
) else {
|
) else {
|
||||||
print("[\(Self.toolName)] Analytics are already up to date :) ")
|
print("[\(Self.toolName)] Analytics are already up to date :) ")
|
||||||
return false
|
return false
|
||||||
|
@@ -7,41 +7,45 @@
|
|||||||
|
|
||||||
import ArgumentParser
|
import ArgumentParser
|
||||||
import Foundation
|
import Foundation
|
||||||
import ToolCore
|
|
||||||
|
// swiftlint:disable no_grouping_extension
|
||||||
|
|
||||||
struct AnalyticsOptions: ParsableArguments {
|
struct AnalyticsOptions: ParsableArguments {
|
||||||
|
|
||||||
@Flag(
|
@Flag(name: [.customShort("f"), .customShort("F")], help: "Should force generation")
|
||||||
name: [.customShort("f"), .customShort("F")],
|
|
||||||
help: "Should force generation"
|
|
||||||
)
|
|
||||||
var forceGeneration = false
|
var forceGeneration = false
|
||||||
|
|
||||||
@Argument(
|
@Argument(help: "Input files where tags ared defined.", transform: { $0.replaceTiltWithHomeDirectoryPath() })
|
||||||
help: "Input files where tags ared defined.",
|
|
||||||
transform: { $0.replaceTiltWithHomeDirectoryPath() }
|
|
||||||
)
|
|
||||||
var inputFile: String
|
var inputFile: String
|
||||||
|
|
||||||
@Option(
|
@Option(help: "Target(s) analytics to generate. (\"matomo\" | \"firebase\")")
|
||||||
help: "Target(s) analytics to generate. (\"matomo\" | \"firebase\")",
|
|
||||||
completion: .list(["matotmo", "firebase"])
|
|
||||||
)
|
|
||||||
var target: String
|
var target: String
|
||||||
|
|
||||||
@Option(
|
@Option(help: "Path where to generate the extension.", transform: { $0.replaceTiltWithHomeDirectoryPath() })
|
||||||
help: "Where to generate the analytics manager (path with filename)",
|
var extensionOutputPath: String
|
||||||
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(
|
@Option(help: "Extension name. If not specified, it will generate a Analytics extension.")
|
||||||
name: .customLong("visibility"),
|
var extensionName: String = Analytics.defaultExtensionName
|
||||||
help: "Visibility of extension and properties. Possibles values: public, private, package, internal. Default is internal",
|
|
||||||
completion: .list(["public", "private", "package", "internal"])
|
@Option(help: "Extension suffix. Ex: MyApp, it will generate {extensionName}+Analytics{extensionSuffix}.swift")
|
||||||
)
|
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)"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -5,14 +5,11 @@
|
|||||||
// Created by Loris Perret on 08/12/2023.
|
// Created by Loris Perret on 08/12/2023.
|
||||||
//
|
//
|
||||||
|
|
||||||
// CPD-OFF
|
|
||||||
|
|
||||||
import CoreVideo
|
import CoreVideo
|
||||||
import Foundation
|
import Foundation
|
||||||
import ToolCore
|
import ToolCore
|
||||||
|
|
||||||
// Disabled cause it's a pain to handle in generated string
|
// Disabled cause it's a pain to handle in generated string
|
||||||
// swiftlint:disable type_body_length
|
|
||||||
|
|
||||||
enum AnalyticsGenerator {
|
enum AnalyticsGenerator {
|
||||||
|
|
||||||
@@ -22,9 +19,9 @@ enum AnalyticsGenerator {
|
|||||||
sections: [AnalyticsCategory],
|
sections: [AnalyticsCategory],
|
||||||
target: String,
|
target: String,
|
||||||
tags: [String],
|
tags: [String],
|
||||||
isStatic: Bool,
|
staticVar: Bool,
|
||||||
outputFile: String,
|
extensionName: String,
|
||||||
visibility: ExtensionVisibility
|
extensionFilePath: String
|
||||||
) {
|
) {
|
||||||
// Get target type from enum
|
// Get target type from enum
|
||||||
let targetsString: [String] = target.components(separatedBy: " ")
|
let targetsString: [String] = target.components(separatedBy: " ")
|
||||||
@@ -43,16 +40,16 @@ enum AnalyticsGenerator {
|
|||||||
targets: targets,
|
targets: targets,
|
||||||
sections: sections,
|
sections: sections,
|
||||||
tags: tags,
|
tags: tags,
|
||||||
isStatic: isStatic,
|
staticVar: staticVar,
|
||||||
visibility: visibility
|
extensionName: extensionName
|
||||||
)
|
)
|
||||||
|
|
||||||
// Write content
|
// Write content
|
||||||
let outputFilePathURL = URL(fileURLWithPath: outputFile)
|
let extensionFilePathURL = URL(fileURLWithPath: extensionFilePath)
|
||||||
do {
|
do {
|
||||||
try extensionFileContent.write(to: outputFilePathURL, atomically: false, encoding: .utf8)
|
try extensionFileContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8)
|
||||||
} catch {
|
} catch {
|
||||||
let error = AnalyticsError.writeFile(outputFile, error.localizedDescription)
|
let error = AnalyticsError.writeFile(extensionFilePath, error.localizedDescription)
|
||||||
print(error.description)
|
print(error.description)
|
||||||
Analytics.exit(withError: error)
|
Analytics.exit(withError: error)
|
||||||
}
|
}
|
||||||
@@ -64,20 +61,19 @@ enum AnalyticsGenerator {
|
|||||||
targets: [TrackerType],
|
targets: [TrackerType],
|
||||||
sections: [AnalyticsCategory],
|
sections: [AnalyticsCategory],
|
||||||
tags: [String],
|
tags: [String],
|
||||||
isStatic: Bool,
|
staticVar: Bool,
|
||||||
visibility: ExtensionVisibility
|
extensionName: String
|
||||||
) -> String {
|
) -> String {
|
||||||
[
|
[
|
||||||
getHeader(
|
getHeader(
|
||||||
targets: targets,
|
targets: targets,
|
||||||
isStatic: isStatic,
|
extensionClassname: extensionName,
|
||||||
visibility: visibility
|
staticVar: staticVar
|
||||||
),
|
),
|
||||||
getProperties(
|
getProperties(
|
||||||
sections: sections,
|
sections: sections,
|
||||||
tags: tags,
|
tags: tags,
|
||||||
isStatic: isStatic,
|
staticVar: staticVar
|
||||||
visibility: visibility
|
|
||||||
),
|
),
|
||||||
getFooter()
|
getFooter()
|
||||||
]
|
]
|
||||||
@@ -88,23 +84,23 @@ enum AnalyticsGenerator {
|
|||||||
|
|
||||||
private static func getHeader(
|
private static func getHeader(
|
||||||
targets: [TrackerType],
|
targets: [TrackerType],
|
||||||
isStatic: Bool,
|
extensionClassname: String,
|
||||||
visibility: ExtensionVisibility
|
staticVar: Bool
|
||||||
) -> 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, visibility: visibility))
|
\(Self.getAnalyticsProtocol(targets: targets))
|
||||||
|
|
||||||
\(Self.getTrackerTypeEnum(targets: targets, visibility: visibility))
|
\(Self.getTrackerTypeEnum(targets: targets))
|
||||||
|
|
||||||
// MARK: - Manager
|
// MARK: - Manager
|
||||||
|
|
||||||
\(visibility) class AnalyticsManager {
|
class AnalyticsManager {
|
||||||
|
|
||||||
\(visibility) static var shared = AnalyticsManager()
|
static var shared = AnalyticsManager()
|
||||||
|
|
||||||
private init() {}
|
private init() {}
|
||||||
|
|
||||||
@@ -112,18 +108,15 @@ enum AnalyticsGenerator {
|
|||||||
|
|
||||||
var managers: [TrackerType: AnalyticsManagerProtocol] = [:]
|
var managers: [TrackerType: AnalyticsManagerProtocol] = [:]
|
||||||
|
|
||||||
\(Self.getEnabledContent(visibility: visibility))
|
\(Self.getEnabledContent())
|
||||||
|
|
||||||
\(Self.getAnalyticsProperties(targets: targets, visibility: visibility))
|
\(Self.getAnalyticsProperties(targets: targets))
|
||||||
|
|
||||||
\(Self.getPrivateLogFunction())
|
\(Self.getPrivateLogFunction())
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func getTrackerTypeEnum(
|
private static func getTrackerTypeEnum(targets: [TrackerType]) -> String {
|
||||||
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)")
|
||||||
@@ -132,16 +125,14 @@ enum AnalyticsGenerator {
|
|||||||
return """
|
return """
|
||||||
// MARK: - Traker Type
|
// MARK: - Traker Type
|
||||||
|
|
||||||
\(visibility) enum TrackerType: CaseIterable {
|
enum TrackerType: CaseIterable {
|
||||||
|
|
||||||
\(result.joined(separator: "\n"))
|
\(result.joined(separator: "\n"))
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func getEnabledContent(
|
private static func getEnabledContent() -> String {
|
||||||
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" {
|
||||||
@@ -163,11 +154,11 @@ enum AnalyticsGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
\(visibility) func enableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
func enableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
||||||
setAnalytics(enable: true, analytics)
|
setAnalytics(enable: true, analytics)
|
||||||
}
|
}
|
||||||
|
|
||||||
\(visibility) func disableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
func disableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
||||||
setAnalytics(enable: false, analytics)
|
setAnalytics(enable: false, analytics)
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -181,7 +172,6 @@ enum AnalyticsGenerator {
|
|||||||
if targets.contains(TrackerType.matomo) {
|
if targets.contains(TrackerType.matomo) {
|
||||||
result.append("import MatomoTracker")
|
result.append("import MatomoTracker")
|
||||||
}
|
}
|
||||||
|
|
||||||
if targets.contains(TrackerType.firebase) {
|
if targets.contains(TrackerType.firebase) {
|
||||||
result.append("import FirebaseAnalytics")
|
result.append("import FirebaseAnalytics")
|
||||||
}
|
}
|
||||||
@@ -229,18 +219,15 @@ enum AnalyticsGenerator {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func getAnalyticsProperties(
|
private static func getAnalyticsProperties(targets: [TrackerType]) -> String {
|
||||||
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 = "\(visibility) func configure(siteId: String, url: String) {"
|
header = "func configure(siteId: String, url: String) {"
|
||||||
} else if targets.contains(TrackerType.firebase) {
|
} else if targets.contains(TrackerType.firebase) {
|
||||||
header = "\(visibility) func configure() {"
|
header = "func configure() {"
|
||||||
}
|
}
|
||||||
|
|
||||||
if targets.contains(TrackerType.matomo) {
|
if targets.contains(TrackerType.matomo) {
|
||||||
@@ -251,7 +238,6 @@ enum AnalyticsGenerator {
|
|||||||
)
|
)
|
||||||
""")
|
""")
|
||||||
}
|
}
|
||||||
|
|
||||||
if targets.contains(TrackerType.firebase) {
|
if targets.contains(TrackerType.firebase) {
|
||||||
content.append(" managers[TrackerType.firebase] = FirebaseAnalyticsManager()")
|
content.append(" managers[TrackerType.firebase] = FirebaseAnalyticsManager()")
|
||||||
}
|
}
|
||||||
@@ -264,14 +250,11 @@ enum AnalyticsGenerator {
|
|||||||
.joined(separator: "\n")
|
.joined(separator: "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func getAnalyticsProtocol(
|
private static func getAnalyticsProtocol(targets: [TrackerType]) -> String {
|
||||||
targets: [TrackerType],
|
|
||||||
visibility: ExtensionVisibility
|
|
||||||
) -> String {
|
|
||||||
let proto = """
|
let proto = """
|
||||||
// MARK: - Protocol
|
// MARK: - Protocol
|
||||||
|
|
||||||
\(visibility) protocol AnalyticsManagerProtocol {
|
protocol AnalyticsManagerProtocol {
|
||||||
|
|
||||||
func logScreen(
|
func logScreen(
|
||||||
name: String,
|
name: String,
|
||||||
@@ -306,8 +289,7 @@ enum AnalyticsGenerator {
|
|||||||
private static func getProperties(
|
private static func getProperties(
|
||||||
sections: [AnalyticsCategory],
|
sections: [AnalyticsCategory],
|
||||||
tags: [String],
|
tags: [String],
|
||||||
isStatic: Bool,
|
staticVar: Bool
|
||||||
visibility: ExtensionVisibility
|
|
||||||
) -> String {
|
) -> String {
|
||||||
sections
|
sections
|
||||||
.compactMap { section in
|
.compactMap { section in
|
||||||
@@ -322,10 +304,10 @@ enum AnalyticsGenerator {
|
|||||||
return // Go to next definition
|
return // Go to next definition
|
||||||
}
|
}
|
||||||
|
|
||||||
if isStatic {
|
if staticVar {
|
||||||
res += "\n\n\(definition.getStaticProperty(visibility: visibility))"
|
res += "\n\n\(definition.getStaticProperty())"
|
||||||
} else {
|
} else {
|
||||||
res += "\n\n\(definition.getProperty(visibility: visibility))"
|
res += "\n\n\(definition.getProperty())"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
@@ -340,5 +322,3 @@ enum AnalyticsGenerator {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CPD-ON
|
|
||||||
|
@@ -13,11 +13,11 @@ enum FirebaseGenerator {
|
|||||||
|
|
||||||
static var service: String {
|
static var service: String {
|
||||||
[
|
[
|
||||||
Self.header,
|
FirebaseGenerator.header,
|
||||||
Self.logScreen,
|
FirebaseGenerator.logScreen,
|
||||||
Self.logEvent,
|
FirebaseGenerator.logEvent,
|
||||||
Self.enable,
|
FirebaseGenerator.enable,
|
||||||
Self.footer
|
FirebaseGenerator.footer
|
||||||
]
|
]
|
||||||
.joined(separator: "\n")
|
.joined(separator: "\n")
|
||||||
}
|
}
|
||||||
|
@@ -5,20 +5,18 @@
|
|||||||
// Created by Loris Perret on 05/12/2023.
|
// Created by Loris Perret on 05/12/2023.
|
||||||
//
|
//
|
||||||
|
|
||||||
// CPD-OFF
|
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
enum MatomoGenerator {
|
enum MatomoGenerator {
|
||||||
|
|
||||||
static var service: String {
|
static var service: String {
|
||||||
[
|
[
|
||||||
Self.header,
|
MatomoGenerator.header,
|
||||||
Self.setup,
|
MatomoGenerator.setup,
|
||||||
Self.logScreen,
|
MatomoGenerator.logScreen,
|
||||||
Self.logEvent,
|
MatomoGenerator.logEvent,
|
||||||
Self.enable,
|
MatomoGenerator.enable,
|
||||||
Self.footer
|
MatomoGenerator.footer
|
||||||
]
|
]
|
||||||
.joined(separator: "\n")
|
.joined(separator: "\n")
|
||||||
}
|
}
|
||||||
@@ -120,5 +118,3 @@ enum MatomoGenerator {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CPD-ON
|
|
||||||
|
@@ -60,10 +60,8 @@ class AnalyticsDefinition {
|
|||||||
switch parameter.type {
|
switch parameter.type {
|
||||||
case .bool:
|
case .bool:
|
||||||
defaultValue = "\(parameter.defaultValue.lowercased())"
|
defaultValue = "\(parameter.defaultValue.lowercased())"
|
||||||
|
|
||||||
case .int, .double:
|
case .int, .double:
|
||||||
defaultValue = "\(parameter.defaultValue)"
|
defaultValue = "\(parameter.defaultValue)"
|
||||||
|
|
||||||
case .string:
|
case .string:
|
||||||
defaultValue = "\"\(parameter.defaultValue)\""
|
defaultValue = "\"\(parameter.defaultValue)\""
|
||||||
}
|
}
|
||||||
@@ -92,13 +90,9 @@ class AnalyticsDefinition {
|
|||||||
for rep in parameter.replaceIn {
|
for rep in parameter.replaceIn {
|
||||||
switch rep {
|
switch rep {
|
||||||
case "name": name = name.replacingFirstOccurrence(of: "_\(parameter.name.uppercased())_", with: "\\(\(parameter.name))")
|
case "name": name = name.replacingFirstOccurrence(of: "_\(parameter.name.uppercased())_", with: "\\(\(parameter.name))")
|
||||||
|
|
||||||
case "path": path = path.replacingFirstOccurrence(of: "_\(parameter.name.uppercased())_", with: "\\(\(parameter.name))")
|
case "path": path = path.replacingFirstOccurrence(of: "_\(parameter.name.uppercased())_", with: "\\(\(parameter.name))")
|
||||||
|
|
||||||
case "category": category = category.replacingFirstOccurrence(of: "_\(parameter.name.uppercased())_", with: "\\(\(parameter.name))")
|
case "category": category = category.replacingFirstOccurrence(of: "_\(parameter.name.uppercased())_", with: "\\(\(parameter.name))")
|
||||||
|
|
||||||
case "action": action = action.replacingFirstOccurrence(of: "_\(parameter.name.uppercased())_", with: "\\(\(parameter.name))")
|
case "action": action = action.replacingFirstOccurrence(of: "_\(parameter.name.uppercased())_", with: "\\(\(parameter.name))")
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if let param = parameters.first(where: { $0.name == rep }), param.value.isEmpty == false {
|
if let param = parameters.first(where: { $0.name == rep }), param.value.isEmpty == false {
|
||||||
param.value = param.value.replacingFirstOccurrence(of: "_\(parameter.name.uppercased())_", with: "\\(\(parameter.name))")
|
param.value = param.value.replacingFirstOccurrence(of: "_\(parameter.name.uppercased())_", with: "\\(\(parameter.name))")
|
||||||
@@ -123,10 +117,8 @@ class AnalyticsDefinition {
|
|||||||
switch param.type {
|
switch param.type {
|
||||||
case .bool:
|
case .bool:
|
||||||
params.append("\"\(param.name)\": \(param.value.lowercased())")
|
params.append("\"\(param.name)\": \(param.value.lowercased())")
|
||||||
|
|
||||||
case .int, .double:
|
case .int, .double:
|
||||||
params.append("\"\(param.name)\": \(param.value)")
|
params.append("\"\(param.name)\": \(param.value)")
|
||||||
|
|
||||||
case .string:
|
case .string:
|
||||||
params.append("\"\(param.name)\": \"\(param.value)\"")
|
params.append("\"\(param.name)\": \"\(param.value)\"")
|
||||||
}
|
}
|
||||||
@@ -169,19 +161,19 @@ class AnalyticsDefinition {
|
|||||||
|
|
||||||
// MARK: - Raw strings
|
// MARK: - Raw strings
|
||||||
|
|
||||||
func getProperty(visibility: ExtensionVisibility) -> String {
|
func getProperty() -> String {
|
||||||
replaceIn()
|
replaceIn()
|
||||||
return """
|
return """
|
||||||
\(visibility) func \(getFuncName())\(getParameters()) {
|
func \(getFuncName())\(getParameters()) {
|
||||||
\(getlogFunction())
|
\(getlogFunction())
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
func getStaticProperty(visibility: ExtensionVisibility) -> String {
|
func getStaticProperty() -> String {
|
||||||
replaceIn()
|
replaceIn()
|
||||||
return """
|
return """
|
||||||
\(visibility) static func \(getFuncName())\(getParameters()) {
|
static func \(getFuncName())\(getParameters()) {
|
||||||
AnalyticsManager.shared.\(getlogFunction())
|
AnalyticsManager.shared.\(getlogFunction())
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
@@ -8,7 +8,6 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
enum ParameterType: String {
|
enum ParameterType: String {
|
||||||
|
|
||||||
case string = "String"
|
case string = "String"
|
||||||
case int = "Int"
|
case int = "Int"
|
||||||
case double = "Double"
|
case double = "Double"
|
||||||
|
@@ -78,21 +78,18 @@ class AnalyticsFileParser {
|
|||||||
print(error.description)
|
print(error.description)
|
||||||
Analytics.exit(withError: error)
|
Analytics.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
case .bool:
|
case .bool:
|
||||||
if Bool(value.lowercased()) == nil {
|
if Bool(value.lowercased()) == nil {
|
||||||
let error = AnalyticsError.invalidParameter("type of \(value) is not \(type)")
|
let error = AnalyticsError.invalidParameter("type of \(value) is not \(type)")
|
||||||
print(error.description)
|
print(error.description)
|
||||||
Analytics.exit(withError: error)
|
Analytics.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
case .double:
|
case .double:
|
||||||
if Double(value) == nil {
|
if Double(value) == nil {
|
||||||
let error = AnalyticsError.invalidParameter("type of \(value) is not \(type)")
|
let error = AnalyticsError.invalidParameter("type of \(value) is not \(type)")
|
||||||
print(error.description)
|
print(error.description)
|
||||||
Analytics.exit(withError: error)
|
Analytics.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
case .string:
|
case .string:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -150,7 +147,7 @@ class AnalyticsFileParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let parameters {
|
if let parameters {
|
||||||
definition.parameters = Self.getParameters(from: parameters)
|
definition.parameters = AnalyticsFileParser.getParameters(from: parameters)
|
||||||
}
|
}
|
||||||
|
|
||||||
return definition
|
return definition
|
||||||
|
@@ -59,12 +59,10 @@ struct Colors: ParsableCommand {
|
|||||||
let extensionFilePath = options.extensionFilePath {
|
let extensionFilePath = options.extensionFilePath {
|
||||||
ColorExtensionGenerator.writeExtensionFile(
|
ColorExtensionGenerator.writeExtensionFile(
|
||||||
colors: parsedColors,
|
colors: parsedColors,
|
||||||
isStatic: options.staticMembers,
|
staticVar: options.staticMembers,
|
||||||
extensionName: extensionName,
|
extensionName: extensionName,
|
||||||
extensionFilePath: extensionFilePath,
|
extensionFilePath: extensionFilePath,
|
||||||
isSwiftUI: true,
|
isSwiftUI: true
|
||||||
visibility: options.extensionVisibility,
|
|
||||||
assetBundle: options.assetBundle
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,12 +71,10 @@ struct Colors: ParsableCommand {
|
|||||||
let extensionFilePathUIKit = options.extensionFilePathUIKit {
|
let extensionFilePathUIKit = options.extensionFilePathUIKit {
|
||||||
ColorExtensionGenerator.writeExtensionFile(
|
ColorExtensionGenerator.writeExtensionFile(
|
||||||
colors: parsedColors,
|
colors: parsedColors,
|
||||||
isStatic: options.staticMembers,
|
staticVar: options.staticMembers,
|
||||||
extensionName: extensionNameUIKit,
|
extensionName: extensionNameUIKit,
|
||||||
extensionFilePath: extensionFilePathUIKit,
|
extensionFilePath: extensionFilePathUIKit,
|
||||||
isSwiftUI: false,
|
isSwiftUI: false
|
||||||
visibility: options.extensionVisibility,
|
|
||||||
assetBundle: options.assetBundle
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,17 +110,6 @@ struct Colors: ParsableCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If an extension need to be generated, ensure extensionOutputPath is defined
|
|
||||||
if options.extensionName != nil ||
|
|
||||||
options.extensionNameUIKit != nil {
|
|
||||||
guard let extensionOutputPath = options.extensionOutputPath,
|
|
||||||
extensionOutputPath.isEmpty == false else {
|
|
||||||
let error = ColorsToolError.missingExtensionPath
|
|
||||||
print(error.description)
|
|
||||||
Self.exit(withError: error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if needed to regenerate
|
// Check if needed to regenerate
|
||||||
let fileToCompareToInput: String = {
|
let fileToCompareToInput: String = {
|
||||||
// If there is no extension file to compare
|
// If there is no extension file to compare
|
||||||
|
@@ -17,12 +17,11 @@ enum ColorsToolError: Error {
|
|||||||
case fileNotExists(String)
|
case fileNotExists(String)
|
||||||
case badColorDefinition(String, String)
|
case badColorDefinition(String, String)
|
||||||
case deleteExistingColors(String)
|
case deleteExistingColors(String)
|
||||||
case missingExtensionPath
|
|
||||||
|
|
||||||
var description: String {
|
var description: String {
|
||||||
switch self {
|
switch self {
|
||||||
case .extensionNamesCollision(let extensionName):
|
case .extensionNamesCollision(let extensionName):
|
||||||
return "error: [\(Colors.toolName)] Error on extension names, extension name and SwiftUI extension name should be different (\(extensionName) is used on both)"
|
return "error: [\(Fonts.toolName)] Error on extension names, extension name and SwiftUI extension name should be different (\(extensionName) is used on both)"
|
||||||
|
|
||||||
case .badFormat(let info):
|
case .badFormat(let info):
|
||||||
return "error: [\(Colors.toolName)] Bad line format: \(info). Accepted format are: colorName=\"#RGB/#ARGB\"; colorName \"#RGB/#ARGB\"; colorName \"#RGB/#ARGB\" \"#RGB/#ARGB\""
|
return "error: [\(Colors.toolName)] Bad line format: \(info). Accepted format are: colorName=\"#RGB/#ARGB\"; colorName \"#RGB/#ARGB\"; colorName \"#RGB/#ARGB\" \"#RGB/#ARGB\""
|
||||||
@@ -44,9 +43,6 @@ enum ColorsToolError: Error {
|
|||||||
|
|
||||||
case .deleteExistingColors(let assetsFolder):
|
case .deleteExistingColors(let assetsFolder):
|
||||||
return "error: [\(Colors.toolName)] An error occured while deleting colors folder `\(assetsFolder)`"
|
return "error: [\(Colors.toolName)] An error occured while deleting colors folder `\(assetsFolder)`"
|
||||||
|
|
||||||
case .missingExtensionPath:
|
|
||||||
return "error: [\(Colors.toolName)] Extension need to be generated but no `extensionOutputPath` is provided"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -5,62 +5,35 @@
|
|||||||
// Created by Thibaut Schmitt on 17/01/2022.
|
// Created by Thibaut Schmitt on 17/01/2022.
|
||||||
//
|
//
|
||||||
|
|
||||||
// CPD-OFF
|
|
||||||
|
|
||||||
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(
|
@Flag(name: [.customShort("f"), .customShort("F")], help: "Should force generation")
|
||||||
name: [.customShort("f"), .customShort("F")],
|
|
||||||
help: "Should force generation"
|
|
||||||
)
|
|
||||||
var forceGeneration = false
|
var forceGeneration = false
|
||||||
|
|
||||||
@Argument(
|
@Argument(help: "Input files where colors ared defined.", transform: { $0.replaceTiltWithHomeDirectoryPath() })
|
||||||
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(
|
@Option(help: "Path of xcassets where to generate colors", transform: { $0.replaceTiltWithHomeDirectoryPath() })
|
||||||
help: "Path of xcassets where to generate colors",
|
|
||||||
transform: { $0.replaceTiltWithHomeDirectoryPath() }
|
|
||||||
)
|
|
||||||
var xcassetsPath: String
|
var xcassetsPath: String
|
||||||
|
|
||||||
|
@Option(help: "Path where to generate the extension.", transform: { $0.replaceTiltWithHomeDirectoryPath() })
|
||||||
|
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")
|
||||||
var staticMembers: Bool = false
|
var staticMembers: Bool = false
|
||||||
|
|
||||||
@Option(
|
@Option(help: "Extension name. If not specified, no extension will be generated.")
|
||||||
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: "Bundle where the asset are generated"
|
|
||||||
)
|
|
||||||
var assetBundle: AssetBundle = .main
|
|
||||||
|
|
||||||
@Option(
|
|
||||||
help: "Path where to generate the extension.",
|
|
||||||
transform: { $0.replaceTiltWithHomeDirectoryPath() }
|
|
||||||
)
|
|
||||||
var extensionOutputPath: String?
|
|
||||||
|
|
||||||
@Option(help: "SwiftUI extension name. If not specified, no extension will be generated.")
|
|
||||||
var extensionName: String?
|
var extensionName: String?
|
||||||
|
|
||||||
@Option(help: "UIKit extension name. If not specified, no extension will be generated.")
|
@Option(help: "SwiftUI Extension name. If not specified, no extension will be generated.")
|
||||||
var extensionNameUIKit: String?
|
var extensionNameUIKit: String?
|
||||||
|
|
||||||
@Option(help: "Extension suffix. Ex: MyApp, it will generate {extensionName}+ColorsMyApp.swift")
|
@Option(help: "Extension suffix. Ex: MyApp, it will generate {extensionName}+ColorsMyApp.swift")
|
||||||
@@ -83,7 +56,7 @@ extension ColorsToolOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var extensionFilePath: String? {
|
var extensionFilePath: String? {
|
||||||
guard let extensionOutputPath, let extensionFileName else { return nil }
|
guard let extensionFileName else { return nil }
|
||||||
|
|
||||||
return "\(extensionOutputPath)/\(extensionFileName)"
|
return "\(extensionOutputPath)/\(extensionFileName)"
|
||||||
}
|
}
|
||||||
@@ -100,8 +73,8 @@ extension ColorsToolOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var extensionFilePathUIKit: String? {
|
var extensionFilePathUIKit: String? {
|
||||||
guard let extensionOutputPath, let extensionFileNameUIKit else { return nil }
|
guard let extensionFileNameUIKit else { return nil }
|
||||||
|
|
||||||
return "\(extensionOutputPath)/\(extensionFileNameUIKit)"
|
return "\(extensionOutputPath)/\(extensionFileNameUIKit)"
|
||||||
}
|
}
|
||||||
}// CPD-ON
|
}
|
||||||
|
@@ -17,21 +17,17 @@ struct ColorExtensionGenerator {
|
|||||||
|
|
||||||
static func writeExtensionFile(
|
static func writeExtensionFile(
|
||||||
colors: [ParsedColor],
|
colors: [ParsedColor],
|
||||||
isStatic: Bool,
|
staticVar: Bool,
|
||||||
extensionName: String,
|
extensionName: String,
|
||||||
extensionFilePath: String,
|
extensionFilePath: String,
|
||||||
isSwiftUI: Bool,
|
isSwiftUI: Bool
|
||||||
visibility: ExtensionVisibility,
|
|
||||||
assetBundle: AssetBundle
|
|
||||||
) {
|
) {
|
||||||
// Create extension content
|
// Create extension content
|
||||||
let extensionContent = Self.getExtensionContent(
|
let extensionContent = Self.getExtensionContent(
|
||||||
colors: colors,
|
colors: colors,
|
||||||
isStatic: isStatic,
|
staticVar: staticVar,
|
||||||
extensionName: extensionName,
|
extensionName: extensionName,
|
||||||
isSwiftUI: isSwiftUI,
|
isSwiftUI: isSwiftUI
|
||||||
visibility: visibility,
|
|
||||||
assetBundle: assetBundle
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Write content
|
// Write content
|
||||||
@@ -47,24 +43,13 @@ struct ColorExtensionGenerator {
|
|||||||
|
|
||||||
static func getExtensionContent(
|
static func getExtensionContent(
|
||||||
colors: [ParsedColor],
|
colors: [ParsedColor],
|
||||||
isStatic: Bool,
|
staticVar: Bool,
|
||||||
extensionName: String,
|
extensionName: String,
|
||||||
isSwiftUI: Bool,
|
isSwiftUI: Bool
|
||||||
visibility: ExtensionVisibility,
|
|
||||||
assetBundle: AssetBundle
|
|
||||||
) -> String {
|
) -> String {
|
||||||
[
|
[
|
||||||
Self.getHeader(
|
Self.getHeader(extensionClassname: extensionName, isSwiftUI: isSwiftUI),
|
||||||
extensionClassname: extensionName,
|
Self.getProperties(for: colors, withStaticVar: staticVar, isSwiftUI: isSwiftUI),
|
||||||
isSwiftUI: isSwiftUI
|
|
||||||
),
|
|
||||||
Self.getProperties(
|
|
||||||
for: colors,
|
|
||||||
withIsStatic: isStatic,
|
|
||||||
isSwiftUI: isSwiftUI,
|
|
||||||
visibility: visibility,
|
|
||||||
assetBundle: assetBundle
|
|
||||||
),
|
|
||||||
Self.getFooter()
|
Self.getFooter()
|
||||||
]
|
]
|
||||||
.joined(separator: "\n")
|
.joined(separator: "\n")
|
||||||
@@ -89,18 +74,11 @@ struct ColorExtensionGenerator {
|
|||||||
|
|
||||||
private static func getProperties(
|
private static func getProperties(
|
||||||
for colors: [ParsedColor],
|
for colors: [ParsedColor],
|
||||||
withIsStatic isStatic: Bool,
|
withStaticVar staticVar: Bool,
|
||||||
isSwiftUI: Bool,
|
isSwiftUI: Bool
|
||||||
visibility: ExtensionVisibility,
|
|
||||||
assetBundle: AssetBundle
|
|
||||||
) -> String {
|
) -> String {
|
||||||
colors.map {
|
colors.map {
|
||||||
$0.getColorProperty(
|
$0.getColorProperty(isStatic: staticVar, isSwiftUI: isSwiftUI)
|
||||||
isStatic: isStatic,
|
|
||||||
isSwiftUI: isSwiftUI,
|
|
||||||
visibility: visibility,
|
|
||||||
assetBundle: assetBundle
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
.joined(separator: "\n\n")
|
.joined(separator: "\n\n")
|
||||||
}
|
}
|
||||||
|
@@ -6,19 +6,14 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
// MARK: - Contents.json
|
// Generate Contents.json content
|
||||||
|
|
||||||
/// 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()
|
||||||
@@ -78,26 +73,21 @@ struct ParsedColor {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Property
|
// MARK: - UIKit
|
||||||
|
|
||||||
func getColorProperty(
|
func getColorProperty(isStatic: Bool, isSwiftUI: Bool) -> String {
|
||||||
isStatic: Bool,
|
|
||||||
isSwiftUI: Bool,
|
|
||||||
visibility: ExtensionVisibility,
|
|
||||||
assetBundle: AssetBundle
|
|
||||||
) -> String {
|
|
||||||
if isSwiftUI {
|
if isSwiftUI {
|
||||||
return """
|
return """
|
||||||
/// Color \(name) is \(light) (light) or \(dark) (dark)"
|
/// Color \(name) is \(light) (light) or \(dark) (dark)"
|
||||||
\(visibility) \(isStatic ? "static " : "")var \(name): Color {
|
\(isStatic ? "static " : "")var \(name): Color {
|
||||||
Color("\(name)", bundle: Bundle.\(assetBundle))
|
Color("\(name)")
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
return """
|
return """
|
||||||
/// Color \(name) is \(light) (light) or \(dark) (dark)"
|
/// Color \(name) is \(light) (light) or \(dark) (dark)"
|
||||||
\(isStatic ? "" : "@objc ")\(visibility) \(isStatic ? "static " : "")var \(name): UIColor {
|
\(isStatic ? "static " : "@objc ")var \(name): UIColor {
|
||||||
UIColor(named: "\(name)", in: Bundle.\(assetBundle), compatibleWith: nil)!
|
UIColor(named: "\(name)")!
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
import ArgumentParser
|
import ArgumentParser
|
||||||
import Foundation
|
import Foundation
|
||||||
import ToolCore
|
|
||||||
|
|
||||||
// swiftlint:disable no_grouping_extension
|
// swiftlint:disable no_grouping_extension
|
||||||
|
|
||||||
@@ -19,27 +18,20 @@ struct FontsOptions: ParsableArguments {
|
|||||||
@Argument(help: "Input files where fonts ared defined.", transform: { $0.replaceTiltWithHomeDirectoryPath() })
|
@Argument(help: "Input files where fonts ared defined.", transform: { $0.replaceTiltWithHomeDirectoryPath() })
|
||||||
var inputFile: String
|
var inputFile: String
|
||||||
|
|
||||||
@Option(help: "Tell if it will generate static properties or methods")
|
|
||||||
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
|
||||||
|
|
||||||
|
@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 Font extension.")
|
@Option(help: "Extension name. If not specified, it will generate an Font extension.")
|
||||||
var extensionName: String = Fonts.defaultExtensionName
|
var extensionName: String = Fonts.defaultExtensionName
|
||||||
|
|
||||||
@Option(help: "Extension name. If not specified, no extension will be generated.")
|
@Option(help: "Extension name. If not specified, it will generate an UIFont extension.")
|
||||||
var extensionNameUIKit: String?
|
var extensionNameUIKit: String = Fonts.defaultExtensionNameUIKit
|
||||||
|
|
||||||
@Option(help: "Extension suffix. Ex: MyApp, it will generate {extensionName}+FontsMyApp.swift")
|
@Option(help: "Extension suffix. Ex: MyApp, it will generate {extensionName}+FontsMyApp.swift")
|
||||||
var extensionSuffix: String?
|
var extensionSuffix: String = ""
|
||||||
|
|
||||||
@Option(name: .customLong("info-plist-paths"), help: "Info.plist paths (array). Will be used to update UIAppFonts content")
|
@Option(name: .customLong("info-plist-paths"), help: "Info.plist paths (array). Will be used to update UIAppFonts content")
|
||||||
fileprivate var infoPlistPathsRaw: String = ""
|
fileprivate var infoPlistPathsRaw: String = ""
|
||||||
@@ -52,7 +44,7 @@ extension FontsOptions {
|
|||||||
// MARK: - SwiftUI
|
// MARK: - SwiftUI
|
||||||
|
|
||||||
var extensionFileName: String {
|
var extensionFileName: String {
|
||||||
if let extensionSuffix {
|
if extensionSuffix.isEmpty == false {
|
||||||
return "\(extensionName)+\(extensionSuffix).swift"
|
return "\(extensionName)+\(extensionSuffix).swift"
|
||||||
}
|
}
|
||||||
return "\(extensionName).swift"
|
return "\(extensionName).swift"
|
||||||
@@ -64,19 +56,15 @@ extension FontsOptions {
|
|||||||
|
|
||||||
// MARK: - UIKit
|
// MARK: - UIKit
|
||||||
|
|
||||||
var extensionFileNameUIKit: String? {
|
var extensionFileNameUIKit: String {
|
||||||
guard let extensionNameUIKit else { return nil }
|
if extensionSuffix.isEmpty == false {
|
||||||
|
|
||||||
if let extensionSuffix {
|
|
||||||
return "\(extensionNameUIKit)+\(extensionSuffix).swift"
|
return "\(extensionNameUIKit)+\(extensionSuffix).swift"
|
||||||
}
|
}
|
||||||
return "\(extensionNameUIKit).swift"
|
return "\(extensionNameUIKit).swift"
|
||||||
}
|
}
|
||||||
|
|
||||||
var extensionFilePathUIKit: String? {
|
var extensionFilePathUIKit: String {
|
||||||
guard let extensionFileNameUIKit else { return nil }
|
"\(extensionOutputPath)/\(extensionFileNameUIKit)"
|
||||||
|
|
||||||
return "\(extensionOutputPath)/\(extensionFileNameUIKit)"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: -
|
// MARK: -
|
||||||
|
@@ -22,6 +22,7 @@ struct Fonts: ParsableCommand {
|
|||||||
|
|
||||||
static let toolName = "Fonts"
|
static let toolName = "Fonts"
|
||||||
static let defaultExtensionName = "Font"
|
static let defaultExtensionName = "Font"
|
||||||
|
static let defaultExtensionNameUIKit = "UIFont"
|
||||||
|
|
||||||
// MARK: - Command Options
|
// MARK: - Command Options
|
||||||
|
|
||||||
@@ -54,33 +55,22 @@ struct Fonts: ParsableCommand {
|
|||||||
// Generate extension
|
// Generate extension
|
||||||
FontExtensionGenerator.writeExtensionFile(
|
FontExtensionGenerator.writeExtensionFile(
|
||||||
fontsNames: fontsNames,
|
fontsNames: fontsNames,
|
||||||
isStatic: 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,
|
|
||||||
let extensionFilePathUIKit = options.extensionFilePathUIKit {
|
|
||||||
FontExtensionGenerator.writeExtensionFile(
|
FontExtensionGenerator.writeExtensionFile(
|
||||||
fontsNames: fontsNames,
|
fontsNames: fontsNames,
|
||||||
isStatic: options.staticMembers,
|
staticVar: options.staticMembers,
|
||||||
extensionName: extensionNameUIKit,
|
extensionName: options.extensionNameUIKit,
|
||||||
extensionFilePath: extensionFilePathUIKit,
|
extensionFilePath: options.extensionFilePathUIKit,
|
||||||
isSwiftUI: false,
|
isSwiftUI: false
|
||||||
visibility: options.extensionVisibility
|
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
if options.infoPlistPaths.isEmpty == false {
|
|
||||||
let plistUpdateFontsData = FontPlistGenerator.generatePlistUIAppsFontContent(
|
|
||||||
for: fontsNames,
|
|
||||||
infoPlistPaths: options.infoPlistPaths
|
|
||||||
)
|
|
||||||
print("Info.plist has been updated with:")
|
print("Info.plist has been updated with:")
|
||||||
print(plistUpdateFontsData)
|
print("\(FontPlistGenerator.generatePlistUIAppsFontContent(for: fontsNames, infoPlistPaths: options.infoPlistPaths))")
|
||||||
}
|
|
||||||
|
|
||||||
print("[\(Self.toolName)] Fonts generated")
|
print("[\(Self.toolName)] Fonts generated")
|
||||||
}
|
}
|
||||||
|
@@ -14,7 +14,6 @@ enum FontsToolError: Error {
|
|||||||
case inputFolderNotFound(String)
|
case inputFolderNotFound(String)
|
||||||
case fileNotExists(String)
|
case fileNotExists(String)
|
||||||
case writeExtension(String, String)
|
case writeExtension(String, String)
|
||||||
case missingExtensionPath
|
|
||||||
|
|
||||||
var description: String {
|
var description: String {
|
||||||
switch self {
|
switch self {
|
||||||
@@ -32,9 +31,6 @@ enum FontsToolError: Error {
|
|||||||
|
|
||||||
case let .writeExtension(filename, info):
|
case let .writeExtension(filename, info):
|
||||||
return "error: [\(Fonts.toolName)] An error occured while writing extension in \(filename): \(info)"
|
return "error: [\(Fonts.toolName)] An error occured while writing extension in \(filename): \(info)"
|
||||||
|
|
||||||
case .missingExtensionPath:
|
|
||||||
return "error: [\(Fonts.toolName)] Extension need to be generated but no `extensionOutputPath` is provided"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,11 +10,8 @@ import ToolCore
|
|||||||
|
|
||||||
enum FontExtensionGenerator {
|
enum FontExtensionGenerator {
|
||||||
|
|
||||||
private static func getFontNameEnum(
|
private static func getFontNameEnum(fontsNames: [FontName]) -> String {
|
||||||
fontsNames: [FontName],
|
var enumDefinition = " enum FontName: String {\n"
|
||||||
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,19 +23,17 @@ enum FontExtensionGenerator {
|
|||||||
|
|
||||||
static func writeExtensionFile(
|
static func writeExtensionFile(
|
||||||
fontsNames: [FontName],
|
fontsNames: [FontName],
|
||||||
isStatic: 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,
|
||||||
isStatic: isStatic,
|
staticVar: staticVar,
|
||||||
extensionName: extensionName,
|
extensionName: extensionName,
|
||||||
isSwiftUI: isSwiftUI,
|
isSwiftUI: isSwiftUI
|
||||||
visibility: visibility
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Write content
|
// Write content
|
||||||
@@ -54,35 +49,20 @@ enum FontExtensionGenerator {
|
|||||||
|
|
||||||
static func getExtensionContent(
|
static func getExtensionContent(
|
||||||
fontsNames: [FontName],
|
fontsNames: [FontName],
|
||||||
isStatic: Bool,
|
staticVar: Bool,
|
||||||
extensionName: String,
|
extensionName: String,
|
||||||
isSwiftUI: Bool,
|
isSwiftUI: Bool
|
||||||
visibility: ExtensionVisibility
|
|
||||||
) -> String {
|
) -> String {
|
||||||
[
|
[
|
||||||
Self.getHeader(
|
Self.getHeader(extensionClassname: extensionName, isSwiftUI: isSwiftUI),
|
||||||
extensionClassname: extensionName,
|
Self.getFontNameEnum(fontsNames: fontsNames),
|
||||||
isSwiftUI: isSwiftUI
|
Self.getFontMethods(fontsNames: fontsNames, staticVar: staticVar, isSwiftUI: isSwiftUI),
|
||||||
),
|
|
||||||
Self.getFontNameEnum(
|
|
||||||
fontsNames: fontsNames,
|
|
||||||
visibility: visibility
|
|
||||||
),
|
|
||||||
Self.getFontMethods(
|
|
||||||
fontsNames: fontsNames,
|
|
||||||
isStatic: isStatic,
|
|
||||||
isSwiftUI: isSwiftUI,
|
|
||||||
visibility: visibility
|
|
||||||
),
|
|
||||||
Self.getFooter()
|
Self.getFooter()
|
||||||
]
|
]
|
||||||
.joined(separator: "\n")
|
.joined(separator: "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func getHeader(
|
private static func getHeader(extensionClassname: String, isSwiftUI: Bool) -> String {
|
||||||
extensionClassname: String,
|
|
||||||
isSwiftUI: Bool
|
|
||||||
) -> String {
|
|
||||||
"""
|
"""
|
||||||
// Generated by ResgenSwift.\(Fonts.toolName) \(ResgenSwiftVersion)
|
// Generated by ResgenSwift.\(Fonts.toolName) \(ResgenSwiftVersion)
|
||||||
|
|
||||||
@@ -92,22 +72,13 @@ enum FontExtensionGenerator {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func getFontMethods(
|
private static func getFontMethods(fontsNames: [FontName], staticVar: Bool, isSwiftUI: Bool) -> String {
|
||||||
fontsNames: [FontName],
|
|
||||||
isStatic: 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(
|
$0.getProperty(isStatic: staticVar, isSwiftUI: isSwiftUI)
|
||||||
isStatic: isStatic,
|
|
||||||
isSwiftUI: isSwiftUI,
|
|
||||||
visibility: visibility
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
propertiesOrMethods.insert(pragma, at: 0)
|
propertiesOrMethods.insert(pragma, at: 0)
|
||||||
|
@@ -6,7 +6,6 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import ToolCore
|
|
||||||
|
|
||||||
// swiftlint:disable no_grouping_extension
|
// swiftlint:disable no_grouping_extension
|
||||||
|
|
||||||
@@ -23,43 +22,33 @@ extension FontName {
|
|||||||
postscriptName.removeCharacters(from: "[]+-_")
|
postscriptName.removeCharacters(from: "[]+-_")
|
||||||
}
|
}
|
||||||
|
|
||||||
func getProperty(
|
func getProperty(isStatic: Bool, isSwiftUI: Bool) -> String {
|
||||||
isStatic: Bool,
|
if isSwiftUI {
|
||||||
isSwiftUI: Bool,
|
if isStatic {
|
||||||
visibility: ExtensionVisibility
|
return """
|
||||||
) -> String {
|
static let \(fontNameSanitize): ((_ size: CGFloat) -> Font) = { size in
|
||||||
switch (isSwiftUI, isStatic) {
|
|
||||||
case (true, true):
|
|
||||||
// SwiftUI, Static => let
|
|
||||||
"""
|
|
||||||
\(visibility) static let \(fontNameSanitize): ((_ size: CGFloat) -> Font) = { size in
|
|
||||||
Font.custom(FontName.\(fontNameSanitize).rawValue, size: size)
|
Font.custom(FontName.\(fontNameSanitize).rawValue, size: size)
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
}
|
||||||
case (true, false):
|
return """
|
||||||
// SwiftUI, Not Static => func
|
func \(fontNameSanitize)(withSize size: CGFloat) -> Font {
|
||||||
"""
|
|
||||||
\(visibility) func \(fontNameSanitize)(withSize size: CGFloat) -> Font {
|
|
||||||
Font.custom(FontName.\(fontNameSanitize).rawValue, size: size)
|
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)!
|
|
||||||
}
|
}
|
||||||
"""
|
// UIKit
|
||||||
|
if isStatic {
|
||||||
case (false, false):
|
return """
|
||||||
// UIKit, Not Static => func
|
static let \(fontNameSanitize): ((_ size: CGFloat) -> UIFont) = { size in
|
||||||
"""
|
|
||||||
\(visibility) func \(fontNameSanitize)(withSize size: CGFloat) -> UIFont {
|
|
||||||
UIFont(name: FontName.\(fontNameSanitize).rawValue, size: size)!
|
UIFont(name: FontName.\(fontNameSanitize).rawValue, size: size)!
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
return """
|
||||||
|
func \(fontNameSanitize)(withSize size: CGFloat) -> UIFont {
|
||||||
|
UIFont(name: FontName.\(fontNameSanitize).rawValue, size: size)!
|
||||||
|
}
|
||||||
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -86,21 +86,31 @@ struct AnalyticsConfiguration: Codable, CustomDebugStringConvertible {
|
|||||||
|
|
||||||
let inputFile: String
|
let inputFile: String
|
||||||
let target: String
|
let target: String
|
||||||
let outputFile: String
|
let extensionOutputPath: String
|
||||||
let visibility: String?
|
let extensionName: String?
|
||||||
let staticMembers: Bool?
|
let extensionSuffix: String?
|
||||||
|
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,
|
||||||
outputFile: String,
|
extensionOutputPath: String,
|
||||||
visibility: String?,
|
extensionName: String?,
|
||||||
|
extensionSuffix: String?,
|
||||||
staticMembers: Bool?
|
staticMembers: Bool?
|
||||||
) {
|
) {
|
||||||
self.inputFile = inputFile
|
self.inputFile = inputFile
|
||||||
self.target = target
|
self.target = target
|
||||||
self.outputFile = outputFile
|
self.extensionOutputPath = extensionOutputPath
|
||||||
self.visibility = visibility
|
self.extensionName = extensionName
|
||||||
|
self.extensionSuffix = extensionSuffix
|
||||||
self.staticMembers = staticMembers
|
self.staticMembers = staticMembers
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,9 +119,9 @@ struct AnalyticsConfiguration: Codable, CustomDebugStringConvertible {
|
|||||||
Analytics configuration:
|
Analytics configuration:
|
||||||
- Input file: \(inputFile)
|
- Input file: \(inputFile)
|
||||||
- Target: \(target)
|
- Target: \(target)
|
||||||
- Output file: \(outputFile)
|
- Extension output path: \(extensionOutputPath)
|
||||||
- Visiblity: \(visibility ?? "default")
|
- Extension name: \(extensionName ?? "-")
|
||||||
- Static members: \(staticMembers != nil ? "\(String(describing: staticMembers))" : "default")
|
- Extension suffix: \(extensionSuffix ?? "-")
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,24 +131,27 @@ struct ColorsConfiguration: Codable, CustomDebugStringConvertible {
|
|||||||
let inputFile: String
|
let inputFile: String
|
||||||
let style: String
|
let style: String
|
||||||
let xcassetsPath: String
|
let xcassetsPath: String
|
||||||
let extensionOutputPath: String?
|
let extensionOutputPath: String
|
||||||
let extensionName: String?
|
let extensionName: String?
|
||||||
let extensionNameUIKit: String?
|
let extensionNameUIKit: String?
|
||||||
let extensionSuffix: String?
|
let extensionSuffix: String?
|
||||||
let visibility: String?
|
private let staticMembers: Bool?
|
||||||
let assetBundle: String?
|
|
||||||
let staticMembers: Bool?
|
var staticMembersOptions: Bool {
|
||||||
|
if let staticMembers {
|
||||||
|
return staticMembers
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
internal init(
|
internal init(
|
||||||
inputFile: String,
|
inputFile: String,
|
||||||
style: String,
|
style: String,
|
||||||
xcassetsPath: String,
|
xcassetsPath: String,
|
||||||
extensionOutputPath: String?,
|
extensionOutputPath: String,
|
||||||
extensionName: String?,
|
extensionName: String?,
|
||||||
extensionNameUIKit: String?,
|
extensionNameUIKit: String?,
|
||||||
extensionSuffix: String?,
|
extensionSuffix: String?,
|
||||||
visibility: String?,
|
|
||||||
assetBundle: String?,
|
|
||||||
staticMembers: Bool?
|
staticMembers: Bool?
|
||||||
) {
|
) {
|
||||||
self.inputFile = inputFile
|
self.inputFile = inputFile
|
||||||
@@ -148,8 +161,6 @@ 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.assetBundle = assetBundle
|
|
||||||
self.staticMembers = staticMembers
|
self.staticMembers = staticMembers
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,13 +170,10 @@ struct ColorsConfiguration: Codable, CustomDebugStringConvertible {
|
|||||||
- Input file: \(inputFile)
|
- Input file: \(inputFile)
|
||||||
- Style: \(style)
|
- Style: \(style)
|
||||||
- Xcassets path: \(xcassetsPath)
|
- Xcassets path: \(xcassetsPath)
|
||||||
- Extension output path: \(extensionOutputPath ?? "-")
|
- Extension output path: \(extensionOutputPath)
|
||||||
- Extension name: \(extensionName ?? "-")
|
- Extension name: \(extensionName ?? "-")
|
||||||
- Extension name UIKit: \(extensionNameUIKit ?? "-")
|
- Extension name UIKit: \(extensionNameUIKit ?? "-")
|
||||||
- Extension suffix: \(extensionSuffix ?? "-")
|
- Extension suffix: \(extensionSuffix ?? "-")
|
||||||
- Visiblity: \(visibility ?? "default")
|
|
||||||
- Asset Bundle: \(assetBundle ?? "default")
|
|
||||||
- Static members: \(staticMembers != nil ? "\(String(describing: staticMembers))" : "default")
|
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -173,22 +181,27 @@ struct ColorsConfiguration: Codable, CustomDebugStringConvertible {
|
|||||||
struct FontsConfiguration: Codable, CustomDebugStringConvertible {
|
struct FontsConfiguration: Codable, CustomDebugStringConvertible {
|
||||||
|
|
||||||
let inputFile: String
|
let inputFile: String
|
||||||
let extensionOutputPath: String?
|
let extensionOutputPath: String
|
||||||
let extensionName: String?
|
let extensionName: String?
|
||||||
let extensionNameUIKit: String?
|
let extensionNameUIKit: String?
|
||||||
let extensionSuffix: String?
|
let extensionSuffix: String?
|
||||||
let infoPlistPaths: String?
|
let infoPlistPaths: String?
|
||||||
let visibility: String?
|
private let staticMembers: Bool?
|
||||||
let staticMembers: Bool?
|
|
||||||
|
var staticMembersOptions: Bool {
|
||||||
|
if let staticMembers {
|
||||||
|
return staticMembers
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
internal init(
|
internal init(
|
||||||
inputFile: String,
|
inputFile: String,
|
||||||
extensionOutputPath: String?,
|
extensionOutputPath: String,
|
||||||
extensionName: String?,
|
extensionName: String?,
|
||||||
extensionNameUIKit: String?,
|
extensionNameUIKit: String?,
|
||||||
extensionSuffix: String?,
|
extensionSuffix: String?,
|
||||||
infoPlistPaths: String?,
|
infoPlistPaths: String?,
|
||||||
visibility: String?,
|
|
||||||
staticMembers: Bool?
|
staticMembers: Bool?
|
||||||
) {
|
) {
|
||||||
self.inputFile = inputFile
|
self.inputFile = inputFile
|
||||||
@@ -197,7 +210,6 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,13 +217,11 @@ struct FontsConfiguration: Codable, CustomDebugStringConvertible {
|
|||||||
"""
|
"""
|
||||||
Fonts configuration:
|
Fonts configuration:
|
||||||
- Input file: \(inputFile)
|
- Input file: \(inputFile)
|
||||||
- Extension output path: \(extensionOutputPath ?? "-")
|
- Extension output path: \(extensionOutputPath)
|
||||||
- Extension name: \(extensionName ?? "-")
|
- Extension name: \(extensionName ?? "-")
|
||||||
- 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")
|
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,23 +230,26 @@ struct ImagesConfiguration: Codable, CustomDebugStringConvertible {
|
|||||||
|
|
||||||
let inputFile: String
|
let inputFile: String
|
||||||
let xcassetsPath: String
|
let xcassetsPath: String
|
||||||
let extensionOutputPath: String?
|
let extensionOutputPath: String
|
||||||
let extensionName: String?
|
let extensionName: String?
|
||||||
let extensionNameUIKit: String?
|
let extensionNameUIKit: String?
|
||||||
let extensionSuffix: String?
|
let extensionSuffix: String?
|
||||||
let visibility: String?
|
private let staticMembers: Bool?
|
||||||
let assetBundle: String?
|
|
||||||
let staticMembers: Bool?
|
var staticMembersOptions: Bool {
|
||||||
|
if let staticMembers {
|
||||||
|
return staticMembers
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
internal init(
|
internal init(
|
||||||
inputFile: String,
|
inputFile: String,
|
||||||
xcassetsPath: String,
|
xcassetsPath: String,
|
||||||
extensionOutputPath: String?,
|
extensionOutputPath: String,
|
||||||
extensionName: String?,
|
extensionName: String?,
|
||||||
extensionNameUIKit: String?,
|
extensionNameUIKit: String?,
|
||||||
extensionSuffix: String?,
|
extensionSuffix: String?,
|
||||||
visibility: String?,
|
|
||||||
assetBundle: String?,
|
|
||||||
staticMembers: Bool?
|
staticMembers: Bool?
|
||||||
) {
|
) {
|
||||||
self.inputFile = inputFile
|
self.inputFile = inputFile
|
||||||
@@ -245,8 +258,6 @@ 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.assetBundle = assetBundle
|
|
||||||
self.staticMembers = staticMembers
|
self.staticMembers = staticMembers
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,13 +266,10 @@ struct ImagesConfiguration: Codable, CustomDebugStringConvertible {
|
|||||||
Images configuration:
|
Images configuration:
|
||||||
- Input file: \(inputFile)
|
- Input file: \(inputFile)
|
||||||
- Xcassets path: \(xcassetsPath)
|
- Xcassets path: \(xcassetsPath)
|
||||||
- Extension output path: \(extensionOutputPath ?? "-")
|
- Extension output path: \(extensionOutputPath)
|
||||||
- Extension name: \(extensionName ?? "-")
|
- Extension name: \(extensionName ?? "-")
|
||||||
- Extension name UIKit: \(extensionNameUIKit ?? "-")
|
- Extension name UIKit: \(extensionNameUIKit ?? "-")
|
||||||
- Extension suffix: \(extensionSuffix ?? "-")
|
- Extension suffix: \(extensionSuffix ?? "-")
|
||||||
- Visiblity: \(visibility ?? "default")
|
|
||||||
- Asset Bundle: \(assetBundle ?? "default")
|
|
||||||
- Static members: \(staticMembers != nil ? "\(String(describing: staticMembers))" : "default")
|
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -272,24 +280,34 @@ struct StringsConfiguration: Codable, CustomDebugStringConvertible {
|
|||||||
let outputPath: String
|
let outputPath: String
|
||||||
let langs: String
|
let langs: String
|
||||||
let defaultLang: String
|
let defaultLang: String
|
||||||
let extensionOutputPath: String?
|
let extensionOutputPath: String
|
||||||
let extensionName: String?
|
let extensionName: String?
|
||||||
let extensionSuffix: String?
|
let extensionSuffix: String?
|
||||||
let visibility: String?
|
private let staticMembers: Bool?
|
||||||
let assetBundle: 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,
|
||||||
outputPath: String,
|
outputPath: String,
|
||||||
langs: String,
|
langs: String,
|
||||||
defaultLang: String,
|
defaultLang: String,
|
||||||
extensionOutputPath: String?,
|
extensionOutputPath: String,
|
||||||
extensionName: String?,
|
extensionName: String?,
|
||||||
extensionSuffix: String?,
|
extensionSuffix: String?,
|
||||||
visibility: String?,
|
|
||||||
assetBundle: String?,
|
|
||||||
staticMembers: Bool?,
|
staticMembers: Bool?,
|
||||||
xcStrings: Bool?
|
xcStrings: Bool?
|
||||||
) {
|
) {
|
||||||
@@ -300,8 +318,6 @@ 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.assetBundle = assetBundle
|
|
||||||
self.staticMembers = staticMembers
|
self.staticMembers = staticMembers
|
||||||
self.xcStrings = xcStrings
|
self.xcStrings = xcStrings
|
||||||
}
|
}
|
||||||
@@ -313,13 +329,9 @@ struct StringsConfiguration: Codable, CustomDebugStringConvertible {
|
|||||||
- Output path: \(outputPath)
|
- Output path: \(outputPath)
|
||||||
- Langs: \(langs)
|
- Langs: \(langs)
|
||||||
- Default lang: \(defaultLang)
|
- Default lang: \(defaultLang)
|
||||||
- Extension output path: \(extensionOutputPath ?? "-")
|
- Extension output path: \(extensionOutputPath)
|
||||||
- Extension name: \(extensionName ?? "-")
|
- Extension name: \(extensionName ?? "-")
|
||||||
- Extension suffix: \(extensionSuffix ?? "-")
|
- Extension suffix: \(extensionSuffix ?? "-")
|
||||||
- Visiblity: \(visibility ?? "default")
|
|
||||||
- Asset Bundle: \(assetBundle ?? "default")
|
|
||||||
- Static members: \(staticMembers != nil ? "\(String(describing: staticMembers))" : "default")
|
|
||||||
- XC Strings: \(xcStrings != nil ? "\(String(describing: xcStrings))" : "default")
|
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -331,8 +343,14 @@ struct TagsConfiguration: Codable, CustomDebugStringConvertible {
|
|||||||
let extensionOutputPath: String
|
let extensionOutputPath: String
|
||||||
let extensionName: String?
|
let extensionName: String?
|
||||||
let extensionSuffix: String?
|
let extensionSuffix: String?
|
||||||
let visibility: String?
|
private let staticMembers: Bool?
|
||||||
let staticMembers: Bool?
|
|
||||||
|
var staticMembersOptions: Bool {
|
||||||
|
if let staticMembers {
|
||||||
|
return staticMembers
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
internal init(
|
internal init(
|
||||||
inputFile: String,
|
inputFile: String,
|
||||||
@@ -340,7 +358,6 @@ 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
|
||||||
@@ -348,7 +365,6 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,8 +376,6 @@ 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")
|
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,11 +10,6 @@ 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 {
|
||||||
@@ -25,23 +20,25 @@ extension AnalyticsConfiguration: Runnable {
|
|||||||
inputFile.prependIfRelativePath(projectDirectory),
|
inputFile.prependIfRelativePath(projectDirectory),
|
||||||
"--target",
|
"--target",
|
||||||
target,
|
target,
|
||||||
"--output-file",
|
"--extension-output-path",
|
||||||
outputFile.prependIfRelativePath(projectDirectory)
|
extensionOutputPath.prependIfRelativePath(projectDirectory),
|
||||||
|
"--static-members",
|
||||||
|
"\(staticMembersOptions)"
|
||||||
]
|
]
|
||||||
|
|
||||||
// Add optional parameters
|
if let extensionName {
|
||||||
[
|
|
||||||
("--visibility", visibility),
|
|
||||||
("--static-members", staticMembers?.description)
|
|
||||||
].forEach { argumentName, argumentValue in
|
|
||||||
if let argumentValue {
|
|
||||||
args += [
|
args += [
|
||||||
argumentName,
|
"--extension-name",
|
||||||
argumentValue
|
extensionName
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
if let extensionSuffix {
|
||||||
|
args += [
|
||||||
|
"--extension-suffix",
|
||||||
|
extensionSuffix
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
return args
|
Analytics.main(args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,25 +26,30 @@ extension ColorsConfiguration: Runnable {
|
|||||||
"--style",
|
"--style",
|
||||||
style,
|
style,
|
||||||
"--xcassets-path",
|
"--xcassets-path",
|
||||||
xcassetsPath.prependIfRelativePath(projectDirectory)
|
xcassetsPath.prependIfRelativePath(projectDirectory),
|
||||||
|
"--extension-output-path",
|
||||||
|
extensionOutputPath.prependIfRelativePath(projectDirectory),
|
||||||
|
"--static-members",
|
||||||
|
"\(staticMembersOptions)"
|
||||||
]
|
]
|
||||||
|
|
||||||
// Add optional parameters
|
if let extensionName {
|
||||||
[
|
|
||||||
("--extension-output-path", extensionOutputPath?.prependIfRelativePath(projectDirectory)),
|
|
||||||
("--extension-name", extensionName),
|
|
||||||
("--extension-name-ui-kit", extensionNameUIKit),
|
|
||||||
("--extension-suffix", extensionSuffix),
|
|
||||||
("--visibility", visibility),
|
|
||||||
("--asset-bundle", assetBundle),
|
|
||||||
("--static-members", staticMembers?.description)
|
|
||||||
].forEach { argumentName, argumentValue in
|
|
||||||
if let argumentValue {
|
|
||||||
args += [
|
args += [
|
||||||
argumentName,
|
"--extension-name",
|
||||||
argumentValue
|
extensionName
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
if let extensionNameUIKit {
|
||||||
|
args += [
|
||||||
|
"--extension-name-ui-kit",
|
||||||
|
extensionNameUIKit
|
||||||
|
]
|
||||||
|
}
|
||||||
|
if let extensionSuffix {
|
||||||
|
args += [
|
||||||
|
"--extension-suffix",
|
||||||
|
extensionSuffix
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
return args
|
return args
|
||||||
|
@@ -22,27 +22,33 @@ extension FontsConfiguration: Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
args += [
|
args += [
|
||||||
inputFile.prependIfRelativePath(projectDirectory)
|
inputFile.prependIfRelativePath(projectDirectory),
|
||||||
|
"--extension-output-path",
|
||||||
|
extensionOutputPath.prependIfRelativePath(projectDirectory),
|
||||||
|
"--static-members",
|
||||||
|
"\(staticMembersOptions)"
|
||||||
]
|
]
|
||||||
|
|
||||||
// Add optional parameters
|
if let extensionName {
|
||||||
[
|
|
||||||
("--extension-output-path", extensionOutputPath?.prependIfRelativePath(projectDirectory)),
|
|
||||||
("--extension-name", extensionName),
|
|
||||||
("--extension-name-ui-kit", extensionNameUIKit),
|
|
||||||
("--extension-suffix", extensionSuffix),
|
|
||||||
("--visibility", visibility),
|
|
||||||
("--static-members", staticMembers?.description)
|
|
||||||
].forEach { argumentName, argumentValue in
|
|
||||||
if let argumentValue {
|
|
||||||
args += [
|
args += [
|
||||||
argumentName,
|
"--extension-name",
|
||||||
argumentValue
|
extensionName
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
if let extensionNameUIKit {
|
||||||
|
args += [
|
||||||
|
"--extension-name-ui-kit",
|
||||||
|
extensionNameUIKit
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
if let extensionSuffix {
|
||||||
|
args += [
|
||||||
|
"--extension-suffix",
|
||||||
|
extensionSuffix
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add infoPlist paths
|
|
||||||
if let infoPlistPaths {
|
if let infoPlistPaths {
|
||||||
let adjustedPlistPaths = infoPlistPaths
|
let adjustedPlistPaths = infoPlistPaths
|
||||||
.split(separator: " ")
|
.split(separator: " ")
|
||||||
|
@@ -24,25 +24,32 @@ extension ImagesConfiguration: Runnable {
|
|||||||
args += [
|
args += [
|
||||||
inputFile.prependIfRelativePath(projectDirectory),
|
inputFile.prependIfRelativePath(projectDirectory),
|
||||||
"--xcassets-path",
|
"--xcassets-path",
|
||||||
xcassetsPath.prependIfRelativePath(projectDirectory)
|
xcassetsPath.prependIfRelativePath(projectDirectory),
|
||||||
|
"--extension-output-path",
|
||||||
|
extensionOutputPath.prependIfRelativePath(projectDirectory),
|
||||||
|
"--static-members",
|
||||||
|
"\(staticMembersOptions)"
|
||||||
]
|
]
|
||||||
|
|
||||||
// Add optional parameters
|
if let extensionName {
|
||||||
[
|
|
||||||
("--extension-output-path", extensionOutputPath?.prependIfRelativePath(projectDirectory)),
|
|
||||||
("--extension-name", extensionName),
|
|
||||||
("--extension-name-ui-kit", extensionNameUIKit),
|
|
||||||
("--extension-suffix", extensionSuffix),
|
|
||||||
("--visibility", visibility),
|
|
||||||
("--asset-bundle", assetBundle),
|
|
||||||
("--static-members", staticMembers?.description)
|
|
||||||
].forEach { argumentName, argumentValue in
|
|
||||||
if let argumentValue {
|
|
||||||
args += [
|
args += [
|
||||||
argumentName,
|
"--extension-name",
|
||||||
argumentValue
|
extensionName
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let extensionNameUIKit {
|
||||||
|
args += [
|
||||||
|
"--extension-name-ui-kit",
|
||||||
|
extensionNameUIKit
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
if let extensionSuffix {
|
||||||
|
args += [
|
||||||
|
"--extension-suffix",
|
||||||
|
extensionSuffix
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
return args
|
return args
|
||||||
|
@@ -10,11 +10,6 @@ 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 {
|
||||||
@@ -28,27 +23,29 @@ extension StringsConfiguration: Runnable {
|
|||||||
"--langs",
|
"--langs",
|
||||||
langs,
|
langs,
|
||||||
"--default-lang",
|
"--default-lang",
|
||||||
defaultLang
|
defaultLang,
|
||||||
|
"--extension-output-path",
|
||||||
|
extensionOutputPath.prependIfRelativePath(projectDirectory),
|
||||||
|
"--static-members",
|
||||||
|
"\(staticMembersOptions)",
|
||||||
|
"--xc-strings",
|
||||||
|
"\(xcStringsOptions)"
|
||||||
]
|
]
|
||||||
|
|
||||||
// Add optional parameters
|
if let extensionName {
|
||||||
[
|
|
||||||
("--extension-output-path", extensionOutputPath?.prependIfRelativePath(projectDirectory)),
|
|
||||||
("--extension-name", extensionName),
|
|
||||||
("--extension-suffix", extensionSuffix),
|
|
||||||
("--visibility", visibility),
|
|
||||||
("--asset-bundle", assetBundle),
|
|
||||||
("--xc-strings", staticMembers?.description),
|
|
||||||
("--static-members", xcStrings?.description)
|
|
||||||
].forEach { argumentName, argumentValue in
|
|
||||||
if let argumentValue {
|
|
||||||
args += [
|
args += [
|
||||||
argumentName,
|
"--extension-name",
|
||||||
argumentValue
|
extensionName
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let extensionSuffix {
|
||||||
|
args += [
|
||||||
|
"--extension-suffix",
|
||||||
|
extensionSuffix
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
return args
|
Stringium.main(args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,11 +10,6 @@ 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 {
|
||||||
@@ -26,24 +21,24 @@ extension TagsConfiguration: Runnable {
|
|||||||
"--lang",
|
"--lang",
|
||||||
lang,
|
lang,
|
||||||
"--extension-output-path",
|
"--extension-output-path",
|
||||||
extensionOutputPath.prependIfRelativePath(projectDirectory)
|
extensionOutputPath.prependIfRelativePath(projectDirectory),
|
||||||
|
"--static-members",
|
||||||
|
"\(staticMembersOptions)"
|
||||||
]
|
]
|
||||||
|
|
||||||
// Add optional parameters
|
if let extensionName {
|
||||||
[
|
|
||||||
("--extension-name", extensionName),
|
|
||||||
("--extension-suffix", extensionSuffix),
|
|
||||||
("--visibility", visibility),
|
|
||||||
("--static-members", staticMembers?.description)
|
|
||||||
].forEach { argumentName, argumentValue in
|
|
||||||
if let argumentValue {
|
|
||||||
args += [
|
args += [
|
||||||
argumentName,
|
"--extension-name",
|
||||||
argumentValue
|
extensionName
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
if let extensionSuffix {
|
||||||
|
args += [
|
||||||
|
"--extension-suffix",
|
||||||
|
extensionSuffix
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
return args
|
Tags.main(args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -14,23 +14,19 @@ enum ImageExtensionGenerator {
|
|||||||
|
|
||||||
static func generateExtensionFile(
|
static func generateExtensionFile(
|
||||||
images: [ParsedImage],
|
images: [ParsedImage],
|
||||||
isStatic: Bool,
|
staticVar: Bool,
|
||||||
inputFilename: String,
|
inputFilename: String,
|
||||||
extensionName: String,
|
extensionName: String,
|
||||||
extensionFilePath: String,
|
extensionFilePath: String,
|
||||||
isSwiftUI: Bool,
|
isSwiftUI: Bool
|
||||||
visibility: ExtensionVisibility,
|
|
||||||
assetBundle: AssetBundle
|
|
||||||
) {
|
) {
|
||||||
// Create extension conten1t
|
// Create extension conten1t
|
||||||
let extensionContent = Self.getExtensionContent(
|
let extensionContent = Self.getExtensionContent(
|
||||||
images: images,
|
images: images,
|
||||||
isStatic: isStatic,
|
staticVar: staticVar,
|
||||||
extensionName: extensionName,
|
extensionName: extensionName,
|
||||||
inputFilename: inputFilename,
|
inputFilename: inputFilename,
|
||||||
isSwiftUI: isSwiftUI,
|
isSwiftUI: isSwiftUI
|
||||||
visibility: visibility,
|
|
||||||
assetBundle: assetBundle
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Write content
|
// Write content
|
||||||
@@ -46,26 +42,14 @@ enum ImageExtensionGenerator {
|
|||||||
|
|
||||||
static func getExtensionContent(
|
static func getExtensionContent(
|
||||||
images: [ParsedImage],
|
images: [ParsedImage],
|
||||||
isStatic: Bool,
|
staticVar: Bool,
|
||||||
extensionName: String,
|
extensionName: String,
|
||||||
inputFilename: String,
|
inputFilename: String,
|
||||||
isSwiftUI: Bool,
|
isSwiftUI: Bool
|
||||||
visibility: ExtensionVisibility,
|
|
||||||
assetBundle: AssetBundle
|
|
||||||
) -> String {
|
) -> String {
|
||||||
[
|
[
|
||||||
Self.getHeader(
|
Self.getHeader(inputFilename: inputFilename, extensionClassname: extensionName, isSwiftUI: isSwiftUI),
|
||||||
inputFilename: inputFilename,
|
Self.getProperties(images: images, staticVar: staticVar, isSwiftUI: isSwiftUI),
|
||||||
extensionClassname: extensionName,
|
|
||||||
isSwiftUI: isSwiftUI
|
|
||||||
),
|
|
||||||
Self.getProperties(
|
|
||||||
images: images,
|
|
||||||
isStatic: isStatic,
|
|
||||||
isSwiftUI: isSwiftUI,
|
|
||||||
visibility: visibility,
|
|
||||||
assetBundle: assetBundle
|
|
||||||
),
|
|
||||||
Self.getFooter()
|
Self.getFooter()
|
||||||
]
|
]
|
||||||
.joined(separator: "\n")
|
.joined(separator: "\n")
|
||||||
@@ -88,21 +72,11 @@ enum ImageExtensionGenerator {
|
|||||||
|
|
||||||
private static func getProperties(
|
private static func getProperties(
|
||||||
images: [ParsedImage],
|
images: [ParsedImage],
|
||||||
isStatic: Bool,
|
staticVar: Bool,
|
||||||
isSwiftUI: Bool,
|
isSwiftUI: Bool
|
||||||
visibility: ExtensionVisibility,
|
|
||||||
assetBundle: AssetBundle
|
|
||||||
) -> String {
|
) -> String {
|
||||||
images
|
images
|
||||||
.map { parsedImage in
|
.map { "\n\($0.getImageProperty(isStatic: staticVar, isSwiftUI: isSwiftUI))" }
|
||||||
let property = parsedImage.getImageProperty(
|
|
||||||
isStatic: isStatic,
|
|
||||||
isSwiftUI: isSwiftUI,
|
|
||||||
visibility: visibility,
|
|
||||||
assetBundle: assetBundle
|
|
||||||
)
|
|
||||||
return "\n\(property)"
|
|
||||||
}
|
|
||||||
.joined(separator: "\n")
|
.joined(separator: "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,6 +21,8 @@ struct Images: ParsableCommand {
|
|||||||
// MARK: - Static
|
// MARK: - Static
|
||||||
|
|
||||||
static let toolName = "Images"
|
static let toolName = "Images"
|
||||||
|
static let defaultExtensionName = "Image"
|
||||||
|
static let defaultExtensionNameUIKit = "UIImage"
|
||||||
|
|
||||||
// MARK: - Command Options
|
// MARK: - Command Options
|
||||||
|
|
||||||
@@ -53,33 +55,23 @@ struct Images: ParsableCommand {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Generate extension
|
// Generate extension
|
||||||
if let extensionName = options.extensionName,
|
|
||||||
let extensionFilePath = options.extensionFilePath {
|
|
||||||
ImageExtensionGenerator.generateExtensionFile(
|
ImageExtensionGenerator.generateExtensionFile(
|
||||||
images: imagesToGenerate,
|
images: imagesToGenerate,
|
||||||
isStatic: options.staticMembers,
|
staticVar: options.staticMembers,
|
||||||
inputFilename: options.inputFilenameWithoutExt,
|
inputFilename: options.inputFilenameWithoutExt,
|
||||||
extensionName: extensionName,
|
extensionName: options.extensionName,
|
||||||
extensionFilePath: extensionFilePath,
|
extensionFilePath: options.extensionFilePath,
|
||||||
isSwiftUI: true,
|
isSwiftUI: true
|
||||||
visibility: options.extensionVisibility,
|
|
||||||
assetBundle: options.assetBundle
|
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
if let extensionNameUIKit = options.extensionNameUIKit,
|
|
||||||
let extensionFilePathUIKit = options.extensionFilePathUIKit {
|
|
||||||
ImageExtensionGenerator.generateExtensionFile(
|
ImageExtensionGenerator.generateExtensionFile(
|
||||||
images: imagesToGenerate,
|
images: imagesToGenerate,
|
||||||
isStatic: options.staticMembers,
|
staticVar: options.staticMembers,
|
||||||
inputFilename: options.inputFilenameWithoutExt,
|
inputFilename: options.inputFilenameWithoutExt,
|
||||||
extensionName: extensionNameUIKit,
|
extensionName: options.extensionNameUIKit,
|
||||||
extensionFilePath: extensionFilePathUIKit,
|
extensionFilePath: options.extensionFilePathUIKit,
|
||||||
isSwiftUI: false,
|
isSwiftUI: false
|
||||||
visibility: options.extensionVisibility,
|
|
||||||
assetBundle: options.assetBundle
|
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
print("[\(Self.toolName)] Images generated")
|
print("[\(Self.toolName)] Images generated")
|
||||||
}
|
}
|
||||||
@@ -104,39 +96,17 @@ struct Images: ParsableCommand {
|
|||||||
_ = Self.getSvgConverterPath()
|
_ = Self.getSvgConverterPath()
|
||||||
|
|
||||||
// Extension for UIKit and SwiftUI should have different name
|
// Extension for UIKit and SwiftUI should have different name
|
||||||
if let extensionName = options.extensionName,
|
guard options.extensionName != options.extensionNameUIKit else {
|
||||||
let extensionNameUIKit = options.extensionNameUIKit {
|
let error = ImagesError.extensionNamesCollision(options.extensionName)
|
||||||
guard extensionName != extensionNameUIKit else {
|
|
||||||
let error = ImagesError.extensionNamesCollision(extensionName)
|
|
||||||
print(error.description)
|
print(error.description)
|
||||||
Self.exit(withError: error)
|
Self.exit(withError: error)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// If an extension need to be generated, ensure extensionOutputPath is defined
|
|
||||||
if options.extensionName != nil ||
|
|
||||||
options.extensionNameUIKit != nil {
|
|
||||||
guard let extensionOutputPath = options.extensionOutputPath,
|
|
||||||
extensionOutputPath.isEmpty == false else {
|
|
||||||
let error = ImagesError.missingExtensionPath
|
|
||||||
print(error.description)
|
|
||||||
Self.exit(withError: error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if needed to regenerate
|
// Check if needed to regenerate
|
||||||
let fileToCompareToInput: String = {
|
|
||||||
// If there is no extension file to compare
|
|
||||||
// Then check the xcassets file instead
|
|
||||||
if let extensionFilePath = options.extensionFilePath {
|
|
||||||
return extensionFilePath
|
|
||||||
}
|
|
||||||
return options.xcassetsPath
|
|
||||||
}()
|
|
||||||
guard GeneratorChecker.shouldGenerate(
|
guard GeneratorChecker.shouldGenerate(
|
||||||
force: options.forceExecution,
|
force: options.forceExecution,
|
||||||
inputFilePath: options.inputFile,
|
inputFilePath: options.inputFile,
|
||||||
extensionFilePath: fileToCompareToInput
|
extensionFilePath: options.extensionFilePath
|
||||||
) else {
|
) else {
|
||||||
print("[\(Self.toolName)] Images are already up to date :) ")
|
print("[\(Self.toolName)] Images are already up to date :) ")
|
||||||
return false
|
return false
|
||||||
|
@@ -18,13 +18,12 @@ enum ImagesError: Error {
|
|||||||
case magickConvertNotFound
|
case magickConvertNotFound
|
||||||
case writeFile(String, String)
|
case writeFile(String, String)
|
||||||
case createAssetFolder(String)
|
case createAssetFolder(String)
|
||||||
case missingExtensionPath
|
|
||||||
case unknown(String)
|
case unknown(String)
|
||||||
|
|
||||||
var description: String {
|
var description: String {
|
||||||
switch self {
|
switch self {
|
||||||
case .extensionNamesCollision(let extensionName):
|
case .extensionNamesCollision(let extensionName):
|
||||||
return "error: [\(Images.toolName)] Error on extension names, extension name and SwiftUI extension name should be different (\(extensionName) is used on both)"
|
return "error: [\(Fonts.toolName)] Error on extension names, extension name and SwiftUI extension name should be different (\(extensionName) is used on both)"
|
||||||
|
|
||||||
case .inputFolderNotFound(let inputFolder):
|
case .inputFolderNotFound(let inputFolder):
|
||||||
return "error: [\(Images.toolName)] Input folder not found: \(inputFolder)"
|
return "error: [\(Images.toolName)] Input folder not found: \(inputFolder)"
|
||||||
@@ -48,10 +47,7 @@ enum ImagesError: Error {
|
|||||||
return "error: [\(Images.toolName)] An error occured while writing content to \(filename): \(subErrorDescription)"
|
return "error: [\(Images.toolName)] An error occured while writing content to \(filename): \(subErrorDescription)"
|
||||||
|
|
||||||
case .createAssetFolder(let folder):
|
case .createAssetFolder(let folder):
|
||||||
return "error: [\(Images.toolName)] An error occured while creating folder `\(folder)`"
|
return "error: [\(Colors.toolName)] An error occured while creating folder `\(folder)`"
|
||||||
|
|
||||||
case .missingExtensionPath:
|
|
||||||
return "error: [\(Images.toolName)] Extension need to be generated but no `extensionOutputPath` is provided"
|
|
||||||
|
|
||||||
case .unknown(let errorDescription):
|
case .unknown(let errorDescription):
|
||||||
return "error: [\(Images.toolName)] Unknown error: \(errorDescription)"
|
return "error: [\(Images.toolName)] Unknown error: \(errorDescription)"
|
||||||
|
@@ -5,70 +5,36 @@
|
|||||||
// Created by Thibaut Schmitt on 24/01/2022.
|
// Created by Thibaut Schmitt on 24/01/2022.
|
||||||
//
|
//
|
||||||
|
|
||||||
// CPD-OFF
|
|
||||||
|
|
||||||
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(
|
@Flag(name: .customShort("f"), help: "Should force script execution")
|
||||||
name: .customShort("f"),
|
|
||||||
help: "Should force script execution"
|
|
||||||
)
|
|
||||||
var forceExecution = false
|
var forceExecution = false
|
||||||
|
|
||||||
@Flag(
|
@Flag(name: .customShort("F"), help: "Regenerate all images")
|
||||||
name: .customShort("F"),
|
|
||||||
help: "Regenerate all images"
|
|
||||||
)
|
|
||||||
var forceExecutionAndGeneration = false
|
var forceExecutionAndGeneration = false
|
||||||
|
|
||||||
@Argument(
|
@Argument(help: "Input files where strings ared defined.", transform: { $0.replaceTiltWithHomeDirectoryPath() })
|
||||||
help: "Input files where strings ared defined.",
|
|
||||||
completion: .file(),
|
|
||||||
transform: { $0.replaceTiltWithHomeDirectoryPath() }
|
|
||||||
)
|
|
||||||
var inputFile: String
|
var inputFile: String
|
||||||
|
|
||||||
@Option(
|
@Option(help: "Xcassets path where to generate images.", transform: { $0.replaceTiltWithHomeDirectoryPath() })
|
||||||
help: "Xcassets path where to generate images.",
|
|
||||||
transform: { $0.replaceTiltWithHomeDirectoryPath() }
|
|
||||||
)
|
|
||||||
var xcassetsPath: String
|
var xcassetsPath: String
|
||||||
|
|
||||||
@Option(
|
@Option(help: "Path where to generate the extension.", transform: { $0.replaceTiltWithHomeDirectoryPath() })
|
||||||
help: "Tell if it will generate static properties or not",
|
var extensionOutputPath: String
|
||||||
completion: .list(["true", "false"])
|
|
||||||
)
|
@Option(help: "Tell if it will generate static properties or not")
|
||||||
var staticMembers: Bool = false
|
var staticMembers: Bool = false
|
||||||
|
|
||||||
@Option(
|
@Option(help: "Extension name. If not specified, it will generate an Image extension.")
|
||||||
name: .customLong("visibility"),
|
var extensionName: String = Images.defaultExtensionName
|
||||||
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: "Extension name. If not specified, it will generate an UIImage extension.")
|
||||||
help: "Bundle where the asset are generated"
|
var extensionNameUIKit: String = Images.defaultExtensionNameUIKit
|
||||||
)
|
|
||||||
var assetBundle: AssetBundle = .main
|
|
||||||
|
|
||||||
@Option(
|
|
||||||
help: "Path where to generate the extension.",
|
|
||||||
transform: { $0.replaceTiltWithHomeDirectoryPath() }
|
|
||||||
)
|
|
||||||
var extensionOutputPath: String?
|
|
||||||
|
|
||||||
@Option(help: "SwiftUI extension name. If not specified, no extension will be generated.")
|
|
||||||
var extensionName: String?
|
|
||||||
|
|
||||||
@Option(help: "UIKit extension name. If not specified, no extension will be generated.")
|
|
||||||
var extensionNameUIKit: String?
|
|
||||||
|
|
||||||
@Option(help: "Extension suffix. Ex: MyApp, it will generate {extensionName}+Image{extensionSuffix}.swift")
|
@Option(help: "Extension suffix. Ex: MyApp, it will generate {extensionName}+Image{extensionSuffix}.swift")
|
||||||
var extensionSuffix: String?
|
var extensionSuffix: String?
|
||||||
@@ -80,36 +46,28 @@ extension ImagesOptions {
|
|||||||
|
|
||||||
// MARK: - SwiftUI
|
// MARK: - SwiftUI
|
||||||
|
|
||||||
var extensionFileName: String? {
|
var extensionFileName: String {
|
||||||
guard let extensionName else { return nil }
|
|
||||||
|
|
||||||
if let extensionSuffix {
|
if let extensionSuffix {
|
||||||
return "\(extensionName)+\(extensionSuffix).swift"
|
return "\(extensionName)+\(extensionSuffix).swift"
|
||||||
}
|
}
|
||||||
return "\(extensionName).swift"
|
return "\(extensionName).swift"
|
||||||
}
|
}
|
||||||
|
|
||||||
var extensionFilePath: String? {
|
var extensionFilePath: String {
|
||||||
guard let extensionOutputPath, let extensionFileName else { return nil }
|
"\(extensionOutputPath)/\(extensionFileName)"
|
||||||
|
|
||||||
return "\(extensionOutputPath)/\(extensionFileName)"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - UIKit
|
// MARK: - UIKit
|
||||||
|
|
||||||
var extensionFileNameUIKit: String? {
|
var extensionFileNameUIKit: String {
|
||||||
guard let extensionNameUIKit else { return nil }
|
|
||||||
|
|
||||||
if let extensionSuffix {
|
if let extensionSuffix {
|
||||||
return "\(extensionNameUIKit)+\(extensionSuffix).swift"
|
return "\(extensionNameUIKit)+\(extensionSuffix).swift"
|
||||||
}
|
}
|
||||||
return "\(extensionNameUIKit).swift"
|
return "\(extensionNameUIKit).swift"
|
||||||
}
|
}
|
||||||
|
|
||||||
var extensionFilePathUIKit: String? {
|
var extensionFilePathUIKit: String {
|
||||||
guard let extensionOutputPath, let extensionFileNameUIKit else { return nil }
|
"\(extensionOutputPath)/\(extensionFileNameUIKit)"
|
||||||
|
|
||||||
return "\(extensionOutputPath)/\(extensionFileNameUIKit)"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: -
|
// MARK: -
|
||||||
@@ -120,5 +78,3 @@ extension ImagesOptions {
|
|||||||
.lastPathComponent
|
.lastPathComponent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CPD-ON
|
|
||||||
|
@@ -6,7 +6,6 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import ToolCore
|
|
||||||
|
|
||||||
enum ImageExtension: String {
|
enum ImageExtension: String {
|
||||||
|
|
||||||
@@ -130,22 +129,17 @@ struct ParsedImage {
|
|||||||
|
|
||||||
// MARK: - Extension property
|
// MARK: - Extension property
|
||||||
|
|
||||||
func getImageProperty(
|
func getImageProperty(isStatic: Bool, isSwiftUI: Bool) -> String {
|
||||||
isStatic: Bool,
|
|
||||||
isSwiftUI: Bool,
|
|
||||||
visibility: ExtensionVisibility,
|
|
||||||
assetBundle: AssetBundle
|
|
||||||
) -> String {
|
|
||||||
if isSwiftUI {
|
if isSwiftUI {
|
||||||
return """
|
return """
|
||||||
\(visibility) \(isStatic ? "static " : "")var \(name): Image {
|
\(isStatic ? "static " : "")var \(name): Image {
|
||||||
Image("\(name)", bundle: Bundle.\(assetBundle))
|
Image("\(name)")
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
return """
|
return """
|
||||||
\(visibility) \(isStatic ? "static " : "")var \(name): UIImage {
|
\(isStatic ? "static " : "")var \(name): UIImage {
|
||||||
UIImage(named: "\(name)", in: Bundle.\(assetBundle), with: nil)!
|
UIImage(named: "\(name)")!
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
@@ -19,7 +19,8 @@ enum StringsFileGenerator {
|
|||||||
langs: [String],
|
langs: [String],
|
||||||
defaultLang: String,
|
defaultLang: String,
|
||||||
tags: [String],
|
tags: [String],
|
||||||
lprojPathFormat: String
|
outputPath: String,
|
||||||
|
inputFilenameWithoutExt: String
|
||||||
) {
|
) {
|
||||||
|
|
||||||
var stringsFilesContent = [String: String]()
|
var stringsFilesContent = [String: String]()
|
||||||
@@ -36,7 +37,7 @@ enum StringsFileGenerator {
|
|||||||
langs.forEach { lang in
|
langs.forEach { lang in
|
||||||
guard let fileContent = stringsFilesContent[lang] else { return }
|
guard let fileContent = stringsFilesContent[lang] else { return }
|
||||||
|
|
||||||
let stringsFilePath = String(format: lprojPathFormat, lang)
|
let stringsFilePath = "\(outputPath)/\(lang).lproj/\(inputFilenameWithoutExt).strings"
|
||||||
let stringsFilePathURL = URL(fileURLWithPath: stringsFilePath)
|
let stringsFilePathURL = URL(fileURLWithPath: stringsFilePath)
|
||||||
do {
|
do {
|
||||||
try fileContent.write(to: stringsFilePathURL, atomically: false, encoding: .utf8)
|
try fileContent.write(to: stringsFilePathURL, atomically: false, encoding: .utf8)
|
||||||
@@ -53,7 +54,8 @@ enum StringsFileGenerator {
|
|||||||
langs: [String],
|
langs: [String],
|
||||||
defaultLang: String,
|
defaultLang: String,
|
||||||
tags: [String],
|
tags: [String],
|
||||||
xcStringsFilePath: String
|
outputPath: String,
|
||||||
|
inputFilenameWithoutExt: String
|
||||||
) {
|
) {
|
||||||
|
|
||||||
let fileContent: String = Self.generateXcStringsFileContent(
|
let fileContent: String = Self.generateXcStringsFileContent(
|
||||||
@@ -63,11 +65,12 @@ enum StringsFileGenerator {
|
|||||||
sections: sections
|
sections: sections
|
||||||
)
|
)
|
||||||
|
|
||||||
let stringsFilePathURL = URL(fileURLWithPath: xcStringsFilePath)
|
let stringsFilePath = "\(outputPath)/\(inputFilenameWithoutExt).xcstrings"
|
||||||
|
let stringsFilePathURL = URL(fileURLWithPath: stringsFilePath)
|
||||||
do {
|
do {
|
||||||
try fileContent.write(to: stringsFilePathURL, atomically: false, encoding: .utf8)
|
try fileContent.write(to: stringsFilePathURL, atomically: false, encoding: .utf8)
|
||||||
} catch {
|
} catch {
|
||||||
let error = StringiumError.writeFile(error.localizedDescription, xcStringsFilePath)
|
let error = StringiumError.writeFile(error.localizedDescription, stringsFilePath)
|
||||||
print(error.description)
|
print(error.description)
|
||||||
Stringium.exit(withError: error)
|
Stringium.exit(withError: error)
|
||||||
}
|
}
|
||||||
@@ -247,25 +250,21 @@ enum StringsFileGenerator {
|
|||||||
sections: [Section],
|
sections: [Section],
|
||||||
defaultLang lang: String,
|
defaultLang lang: String,
|
||||||
tags: [String],
|
tags: [String],
|
||||||
isStatic: Bool,
|
staticVar: Bool,
|
||||||
inputFilename: String,
|
inputFilename: String,
|
||||||
extensionName: String,
|
extensionName: String,
|
||||||
extensionFilePath: String,
|
extensionFilePath: String,
|
||||||
extensionSuffix: String,
|
extensionSuffix: String
|
||||||
visibility: ExtensionVisibility,
|
|
||||||
assetBundle: AssetBundle
|
|
||||||
) {
|
) {
|
||||||
// Get extension content
|
// Get extension content
|
||||||
let extensionFileContent = Self.getExtensionContent(
|
let extensionFileContent = Self.getExtensionContent(
|
||||||
sections: sections,
|
sections: sections,
|
||||||
defaultLang: lang,
|
defaultLang: lang,
|
||||||
tags: tags,
|
tags: tags,
|
||||||
isStatic: isStatic,
|
staticVar: staticVar,
|
||||||
inputFilename: inputFilename,
|
inputFilename: inputFilename,
|
||||||
extensionName: extensionName,
|
extensionName: extensionName,
|
||||||
extensionSuffix: extensionSuffix,
|
extensionSuffix: extensionSuffix
|
||||||
visibility: visibility,
|
|
||||||
assetBundle: assetBundle
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Write content
|
// Write content
|
||||||
@@ -285,12 +284,10 @@ enum StringsFileGenerator {
|
|||||||
sections: [Section],
|
sections: [Section],
|
||||||
defaultLang lang: String,
|
defaultLang lang: String,
|
||||||
tags: [String],
|
tags: [String],
|
||||||
isStatic: Bool,
|
staticVar: Bool,
|
||||||
inputFilename: String,
|
inputFilename: String,
|
||||||
extensionName: String,
|
extensionName: String,
|
||||||
extensionSuffix: String,
|
extensionSuffix: String
|
||||||
visibility: ExtensionVisibility,
|
|
||||||
assetBundle: AssetBundle
|
|
||||||
) -> String {
|
) -> String {
|
||||||
[
|
[
|
||||||
Self.getHeader(
|
Self.getHeader(
|
||||||
@@ -301,16 +298,13 @@ 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,
|
||||||
isStatic: isStatic,
|
staticVar: staticVar
|
||||||
visibility: visibility,
|
|
||||||
assetBundle: assetBundle
|
|
||||||
),
|
),
|
||||||
Self.getFooter()
|
Self.getFooter()
|
||||||
]
|
]
|
||||||
@@ -335,10 +329,9 @@ 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 \(visibility) enum Key\(extensionSuffix.uppercasedFirst()): String {\n"
|
var enumDefinition = "\n enum Key\(extensionSuffix.uppercasedFirst()): String {\n"
|
||||||
|
|
||||||
// Enum
|
// Enum
|
||||||
sections.forEach { section in
|
sections.forEach { section in
|
||||||
@@ -357,7 +350,7 @@ enum StringsFileGenerator {
|
|||||||
|
|
||||||
// KeyPath accessors
|
// KeyPath accessors
|
||||||
enumDefinition += "\n"
|
enumDefinition += "\n"
|
||||||
enumDefinition += " \(visibility) var keyPath: KeyPath<\(extensionClassname), String> {\n"
|
enumDefinition += " 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
|
||||||
@@ -379,14 +372,7 @@ enum StringsFileGenerator {
|
|||||||
return enumDefinition
|
return enumDefinition
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func getProperties(
|
private static func getProperties(sections: [Section], defaultLang lang: String, tags: [String], staticVar: Bool) -> String {
|
||||||
sections: [Section],
|
|
||||||
defaultLang lang: String,
|
|
||||||
tags: [String],
|
|
||||||
isStatic: Bool,
|
|
||||||
visibility: ExtensionVisibility,
|
|
||||||
assetBundle: AssetBundle
|
|
||||||
) -> 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 {
|
||||||
@@ -399,14 +385,10 @@ enum StringsFileGenerator {
|
|||||||
return nil // Go to next definition
|
return nil // Go to next definition
|
||||||
}
|
}
|
||||||
|
|
||||||
let property = definition.getNSLocalizedStringProperty(
|
if staticVar {
|
||||||
forLang: lang,
|
return "\n\(definition.getNSLocalizedStringStaticProperty(forLang: lang))"
|
||||||
isStatic: isStatic,
|
}
|
||||||
visibility: visibility,
|
return "\n\(definition.getNSLocalizedStringProperty(forLang: lang))"
|
||||||
assetBundle: assetBundle
|
|
||||||
)
|
|
||||||
|
|
||||||
return "\n\(property)"
|
|
||||||
}
|
}
|
||||||
.joined(separator: "\n")
|
.joined(separator: "\n")
|
||||||
return res
|
return res
|
||||||
|
@@ -15,19 +15,17 @@ enum TagsGenerator {
|
|||||||
sections: [Section],
|
sections: [Section],
|
||||||
lang: String,
|
lang: String,
|
||||||
tags: [String],
|
tags: [String],
|
||||||
isStatic: 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(
|
||||||
sections: sections,
|
sections: sections,
|
||||||
lang: lang,
|
lang: lang,
|
||||||
tags: tags,
|
tags: tags,
|
||||||
isStatic: isStatic,
|
staticVar: staticVar,
|
||||||
extensionName: extensionName,
|
extensionName: extensionName
|
||||||
visibility: visibility
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Write content
|
// Write content
|
||||||
@@ -47,21 +45,19 @@ enum TagsGenerator {
|
|||||||
sections: [Section],
|
sections: [Section],
|
||||||
lang: String,
|
lang: String,
|
||||||
tags: [String],
|
tags: [String],
|
||||||
isStatic: Bool,
|
staticVar: Bool,
|
||||||
extensionName: String,
|
extensionName: String
|
||||||
visibility: ExtensionVisibility
|
|
||||||
) -> String {
|
) -> String {
|
||||||
[
|
[
|
||||||
Self.getHeader(
|
Self.getHeader(
|
||||||
extensionClassname: extensionName,
|
extensionClassname: extensionName,
|
||||||
isStatic: isStatic
|
staticVar: staticVar
|
||||||
),
|
),
|
||||||
Self.getProperties(
|
Self.getProperties(
|
||||||
sections: sections,
|
sections: sections,
|
||||||
lang: lang,
|
lang: lang,
|
||||||
tags: tags,
|
tags: tags,
|
||||||
isStatic: isStatic,
|
staticVar: staticVar
|
||||||
visibility: visibility
|
|
||||||
),
|
),
|
||||||
Self.getFooter()
|
Self.getFooter()
|
||||||
]
|
]
|
||||||
@@ -70,11 +66,11 @@ enum TagsGenerator {
|
|||||||
|
|
||||||
// MARK: - Extension part
|
// MARK: - Extension part
|
||||||
|
|
||||||
private static func getHeader(extensionClassname: String, isStatic: Bool) -> String {
|
private static func getHeader(extensionClassname: String, staticVar: Bool) -> String {
|
||||||
"""
|
"""
|
||||||
// Generated by ResgenSwift.Strings.\(Tags.toolName) \(ResgenSwiftVersion)
|
// Generated by ResgenSwift.Strings.\(Tags.toolName) \(ResgenSwiftVersion)
|
||||||
|
|
||||||
\(isStatic ? "typelias Tags = String\n\n" : "")import UIKit
|
\(staticVar ? "typelias Tags = String\n\n" : "")import UIKit
|
||||||
|
|
||||||
extension \(extensionClassname) {
|
extension \(extensionClassname) {
|
||||||
"""
|
"""
|
||||||
@@ -84,8 +80,7 @@ enum TagsGenerator {
|
|||||||
sections: [Section],
|
sections: [Section],
|
||||||
lang: String,
|
lang: String,
|
||||||
tags: [String],
|
tags: [String],
|
||||||
isStatic: Bool,
|
staticVar: Bool
|
||||||
visibility: ExtensionVisibility
|
|
||||||
) -> String {
|
) -> String {
|
||||||
sections
|
sections
|
||||||
.compactMap { section in
|
.compactMap { section in
|
||||||
@@ -100,12 +95,11 @@ enum TagsGenerator {
|
|||||||
return // Go to next definition
|
return // Go to next definition
|
||||||
}
|
}
|
||||||
|
|
||||||
let property = definition.getProperty(
|
if staticVar {
|
||||||
forLang: lang,
|
res += "\n\n\(definition.getStaticProperty(forLang: lang))"
|
||||||
visibility: visibility,
|
} else {
|
||||||
isStatic: isStatic
|
res += "\n\n\(definition.getProperty(forLang: lang))"
|
||||||
)
|
}
|
||||||
res += "\n\n\(property)"
|
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,6 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import ToolCore
|
|
||||||
|
|
||||||
// swiftlint:disable force_unwrapping
|
// swiftlint:disable force_unwrapping
|
||||||
|
|
||||||
@@ -100,22 +99,15 @@ class Definition {
|
|||||||
return (inputParameters: inputParameters, translationArguments: translationArguments)
|
return (inputParameters: inputParameters, translationArguments: translationArguments)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func getBaseProperty(
|
private func getBaseProperty(lang: String, translation: String, isStatic: Bool, comment: String?) -> String {
|
||||||
lang: String,
|
|
||||||
translation: String,
|
|
||||||
isStatic: Bool,
|
|
||||||
comment: String?,
|
|
||||||
visibility: ExtensionVisibility,
|
|
||||||
assetBundle: AssetBundle
|
|
||||||
) -> String {
|
|
||||||
"""
|
"""
|
||||||
/// Translation in \(lang) :
|
/// Translation in \(lang) :
|
||||||
/// \(translation)
|
/// \(translation)
|
||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// \(comment?.isEmpty == false ? comment! : "No comment")
|
/// \(comment?.isEmpty == false ? comment! : "No comment")
|
||||||
\(visibility) \(isStatic ? "static " : "")var \(name): String {
|
\(isStatic ? "static " : "")var \(name): String {
|
||||||
NSLocalizedString("\(name)", tableName: kStringsFileName, bundle: Bundle.\(assetBundle), value: "\(translation)", comment: "\(comment ?? "")")
|
NSLocalizedString("\(name)", tableName: kStringsFileName, bundle: Bundle.main, value: "\(translation)", comment: "\(comment ?? "")")
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
@@ -126,8 +118,7 @@ class Definition {
|
|||||||
isStatic: Bool,
|
isStatic: Bool,
|
||||||
inputParameters: [String],
|
inputParameters: [String],
|
||||||
translationArguments: [String],
|
translationArguments: [String],
|
||||||
comment: String?,
|
comment: String?
|
||||||
visibility: ExtensionVisibility
|
|
||||||
) -> String {
|
) -> String {
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -136,18 +127,13 @@ class Definition {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// \(comment?.isEmpty == false ? comment! : "No comment")
|
/// \(comment?.isEmpty == false ? comment! : "No comment")
|
||||||
\(visibility) \(isStatic ? "static " : "")func \(name)(\(inputParameters.joined(separator: ", "))) -> String {
|
\(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(
|
func getNSLocalizedStringProperty(forLang lang: String) -> String {
|
||||||
forLang lang: String,
|
|
||||||
isStatic: Bool,
|
|
||||||
visibility: ExtensionVisibility,
|
|
||||||
assetBundle: AssetBundle
|
|
||||||
) -> 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)
|
||||||
@@ -158,10 +144,8 @@ class Definition {
|
|||||||
let property = getBaseProperty(
|
let property = getBaseProperty(
|
||||||
lang: lang,
|
lang: lang,
|
||||||
translation: translation,
|
translation: translation,
|
||||||
isStatic: isStatic,
|
isStatic: false,
|
||||||
comment: self.comment,
|
comment: self.comment
|
||||||
visibility: visibility,
|
|
||||||
assetBundle: assetBundle
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Generate method
|
// Generate method
|
||||||
@@ -170,11 +154,41 @@ class Definition {
|
|||||||
method = getBaseMethod(
|
method = getBaseMethod(
|
||||||
lang: lang,
|
lang: lang,
|
||||||
translation: translation,
|
translation: translation,
|
||||||
isStatic: isStatic,
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func getNSLocalizedStringStaticProperty(forLang lang: String) -> String {
|
||||||
|
guard let translation = translations[lang] else {
|
||||||
|
let error = StringiumError.langNotDefined(lang, name, reference != nil)
|
||||||
|
print(error.description)
|
||||||
|
Stringium.exit(withError: error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate property
|
||||||
|
let property = getBaseProperty(
|
||||||
|
lang: lang,
|
||||||
|
translation: translation,
|
||||||
|
isStatic: true,
|
||||||
|
comment: self.comment
|
||||||
|
)
|
||||||
|
|
||||||
|
// Generate method
|
||||||
|
var method = ""
|
||||||
|
if let parameters = self.getStringParameters(input: translation) {
|
||||||
|
method = getBaseMethod(
|
||||||
|
lang: lang,
|
||||||
|
translation: translation,
|
||||||
|
isStatic: true,
|
||||||
|
inputParameters: parameters.inputParameters,
|
||||||
|
translationArguments: parameters.translationArguments,
|
||||||
|
comment: self.comment
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,11 +197,7 @@ class Definition {
|
|||||||
|
|
||||||
// MARK: - Raw strings
|
// MARK: - Raw strings
|
||||||
|
|
||||||
func getProperty(
|
func getProperty(forLang lang: String) -> String {
|
||||||
forLang lang: String,
|
|
||||||
visibility: ExtensionVisibility,
|
|
||||||
isStatic: Bool
|
|
||||||
) -> 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)
|
||||||
@@ -200,7 +210,27 @@ class Definition {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// \(comment?.isEmpty == false ? comment! : "No comment")
|
/// \(comment?.isEmpty == false ? comment! : "No comment")
|
||||||
\(visibility) \(isStatic ? "static " : "")var \(name): String {
|
|
||||||
|
var \(name): String {
|
||||||
|
"\(translation)"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
|
||||||
|
func getStaticProperty(forLang lang: String) -> String {
|
||||||
|
guard let translation = translations[lang] else {
|
||||||
|
let error = StringiumError.langNotDefined(lang, name, reference != nil)
|
||||||
|
print(error.description)
|
||||||
|
Stringium.exit(withError: error)
|
||||||
|
}
|
||||||
|
|
||||||
|
return """
|
||||||
|
/// Translation in \(lang) :
|
||||||
|
/// \(translation)
|
||||||
|
///
|
||||||
|
/// Comment :
|
||||||
|
/// \(comment?.isEmpty == false ? comment! : "No comment")
|
||||||
|
static var \(name): String {
|
||||||
"\(translation)"
|
"\(translation)"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
@@ -21,6 +21,7 @@ struct Stringium: ParsableCommand {
|
|||||||
// MARK: - Static
|
// MARK: - Static
|
||||||
|
|
||||||
static let toolName = "Stringium"
|
static let toolName = "Stringium"
|
||||||
|
static let defaultExtensionName = "String"
|
||||||
static let noTranslationTag: String = "notranslation"
|
static let noTranslationTag: String = "notranslation"
|
||||||
|
|
||||||
// MARK: - Command options
|
// MARK: - Command options
|
||||||
@@ -48,7 +49,8 @@ struct Stringium: ParsableCommand {
|
|||||||
langs: options.langs,
|
langs: options.langs,
|
||||||
defaultLang: options.defaultLang,
|
defaultLang: options.defaultLang,
|
||||||
tags: options.tags,
|
tags: options.tags,
|
||||||
lprojPathFormat: options.lprojPathFormat
|
outputPath: options.stringsFileOutputPath,
|
||||||
|
inputFilenameWithoutExt: options.inputFilenameWithoutExt
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
StringsFileGenerator.writeXcStringsFiles(
|
StringsFileGenerator.writeXcStringsFiles(
|
||||||
@@ -56,27 +58,22 @@ struct Stringium: ParsableCommand {
|
|||||||
langs: options.langs,
|
langs: options.langs,
|
||||||
defaultLang: options.defaultLang,
|
defaultLang: options.defaultLang,
|
||||||
tags: options.tags,
|
tags: options.tags,
|
||||||
xcStringsFilePath: options.xcStringsFilePath
|
outputPath: options.stringsFileOutputPath,
|
||||||
|
inputFilenameWithoutExt: options.inputFilenameWithoutExt
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate extension
|
// Generate extension
|
||||||
if let extensionName = options.extensionName,
|
|
||||||
let extensionFilePath = options.extensionFilePath {
|
|
||||||
print("Will generate extensions")
|
|
||||||
StringsFileGenerator.writeExtensionFiles(
|
StringsFileGenerator.writeExtensionFiles(
|
||||||
sections: sections,
|
sections: sections,
|
||||||
defaultLang: options.defaultLang,
|
defaultLang: options.defaultLang,
|
||||||
tags: options.tags,
|
tags: options.tags,
|
||||||
isStatic: options.staticMembers,
|
staticVar: options.staticMembers,
|
||||||
inputFilename: options.inputFilenameWithoutExt,
|
inputFilename: options.inputFilenameWithoutExt,
|
||||||
extensionName: extensionName,
|
extensionName: options.extensionName,
|
||||||
extensionFilePath: extensionFilePath,
|
extensionFilePath: options.extensionFilePath,
|
||||||
extensionSuffix: options.extensionSuffix ?? "",
|
extensionSuffix: options.extensionSuffix
|
||||||
visibility: options.extensionVisibility,
|
|
||||||
assetBundle: options.assetBundle
|
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
print("[\(Self.toolName)] Strings generated")
|
print("[\(Self.toolName)] Strings generated")
|
||||||
}
|
}
|
||||||
@@ -107,18 +104,10 @@ struct Stringium: ParsableCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if needed to regenerate
|
// Check if needed to regenerate
|
||||||
let fileToCompareToInput: String = {
|
|
||||||
// If there is no extension file to compare
|
|
||||||
// Then check the xcassets file instead
|
|
||||||
if options.xcStrings {
|
|
||||||
return options.xcStringsFilePath
|
|
||||||
}
|
|
||||||
return String(format: options.lprojPathFormat, options.defaultLang)
|
|
||||||
}()
|
|
||||||
guard GeneratorChecker.shouldGenerate(
|
guard GeneratorChecker.shouldGenerate(
|
||||||
force: options.forceGeneration,
|
force: options.forceGeneration,
|
||||||
inputFilePath: options.inputFile,
|
inputFilePath: options.inputFile,
|
||||||
extensionFilePath: fileToCompareToInput
|
extensionFilePath: options.extensionFilePath
|
||||||
) else {
|
) else {
|
||||||
print("[\(Self.toolName)] Strings are already up to date :) ")
|
print("[\(Self.toolName)] Strings are already up to date :) ")
|
||||||
return false
|
return false
|
||||||
|
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
import ArgumentParser
|
import ArgumentParser
|
||||||
import Foundation
|
import Foundation
|
||||||
import ToolCore
|
|
||||||
|
|
||||||
// swiftlint:disable no_grouping_extension
|
// swiftlint:disable no_grouping_extension
|
||||||
|
|
||||||
@@ -16,63 +15,35 @@ struct StringiumOptions: 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(
|
@Argument(help: "Input files where strings are defined.", transform: { $0.replaceTiltWithHomeDirectoryPath() })
|
||||||
help: "Input files where strings are defined.",
|
|
||||||
transform: { $0.replaceTiltWithHomeDirectoryPath() }
|
|
||||||
)
|
|
||||||
var inputFile: String
|
var inputFile: String
|
||||||
|
|
||||||
@Option(
|
@Option(name: .customLong("output-path"), help: "Path where to strings file.", transform: { $0.replaceTiltWithHomeDirectoryPath() })
|
||||||
name: .customLong("output-path"),
|
|
||||||
help: "Path where to find the .xcStrings file or the lproj folders.",
|
|
||||||
transform: { $0.replaceTiltWithHomeDirectoryPath() }
|
|
||||||
)
|
|
||||||
fileprivate var outputPathRaw: String
|
fileprivate var outputPathRaw: String
|
||||||
|
|
||||||
@Option(
|
@Option(name: .customLong("langs"), help: "Langs to generate.")
|
||||||
name: .customLong("langs"),
|
|
||||||
help: "Langs to generate."
|
|
||||||
)
|
|
||||||
fileprivate var langsRaw: String
|
fileprivate var langsRaw: String
|
||||||
|
|
||||||
@Option(help: "Default langs.")
|
@Option(help: "Default langs.")
|
||||||
var defaultLang: String
|
var defaultLang: String
|
||||||
|
|
||||||
@Option(
|
@Option(name: .customLong("tags"), help: "Tags to generate.")
|
||||||
name: .customLong("tags"),
|
|
||||||
help: "Tags to generate."
|
|
||||||
)
|
|
||||||
fileprivate var tagsRaw: String = "ios iosonly iosOnly notranslation"
|
fileprivate var tagsRaw: String = "ios iosonly iosOnly notranslation"
|
||||||
|
|
||||||
@Option(help: "Generate static properties. False by default")
|
@Option(help: "Path where to generate the extension.", transform: { $0.replaceTiltWithHomeDirectoryPath() })
|
||||||
|
var extensionOutputPath: String
|
||||||
|
|
||||||
|
@Option(help: "Tell if it will generate static properties or not")
|
||||||
var staticMembers: Bool = false
|
var staticMembers: Bool = false
|
||||||
|
|
||||||
@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 not")
|
||||||
var xcStrings: Bool = true
|
var xcStrings: Bool = false
|
||||||
|
|
||||||
@Option(
|
@Option(help: "Extension name. If not specified, it will generate an String extension.")
|
||||||
name: .customLong("visibility"),
|
var extensionName: String = Stringium.defaultExtensionName
|
||||||
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: "Bundle where the asset are generated"
|
|
||||||
)
|
|
||||||
var assetBundle: AssetBundle = .main
|
|
||||||
|
|
||||||
@Option(
|
|
||||||
help: "Path where to generate the extension.",
|
|
||||||
transform: { $0.replaceTiltWithHomeDirectoryPath() }
|
|
||||||
)
|
|
||||||
var extensionOutputPath: String?
|
|
||||||
|
|
||||||
@Option(help: "Extension name. If not specified, no extension will be generated.")
|
|
||||||
var extensionName: String?
|
|
||||||
|
|
||||||
@Option(help: "Extension suffix: {extensionName}+{extensionSuffix}.swift")
|
@Option(help: "Extension suffix: {extensionName}+{extensionSuffix}.swift")
|
||||||
var extensionSuffix: String?
|
var extensionSuffix: String
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Private var getter
|
// MARK: - Private var getter
|
||||||
@@ -104,21 +75,12 @@ extension StringiumOptions {
|
|||||||
|
|
||||||
extension StringiumOptions {
|
extension StringiumOptions {
|
||||||
|
|
||||||
private var extensionFileName: String? {
|
var extensionFileName: String {
|
||||||
if let extensionName {
|
"\(extensionName)+\(extensionSuffix).swift"
|
||||||
if let extensionSuffix {
|
|
||||||
return "\(extensionName)+\(extensionSuffix).swift"
|
|
||||||
}
|
|
||||||
return "\(extensionName).swift"
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var extensionFilePath: String? {
|
var extensionFilePath: String {
|
||||||
if let extensionOutputPath, let extensionFileName {
|
"\(extensionOutputPath)/\(extensionFileName)"
|
||||||
return "\(extensionOutputPath)/\(extensionFileName)"
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var inputFilenameWithoutExt: String {
|
var inputFilenameWithoutExt: String {
|
||||||
@@ -126,12 +88,4 @@ extension StringiumOptions {
|
|||||||
.deletingPathExtension()
|
.deletingPathExtension()
|
||||||
.lastPathComponent
|
.lastPathComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
var xcStringsFilePath: String {
|
|
||||||
"\(stringsFileOutputPath)/\(inputFilenameWithoutExt).xcstrings"
|
|
||||||
}
|
|
||||||
|
|
||||||
var lprojPathFormat: String {
|
|
||||||
"\(stringsFileOutputPath)/%@.lproj/\(inputFilenameWithoutExt).strings"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -47,10 +47,9 @@ struct Tags: ParsableCommand {
|
|||||||
sections: sections,
|
sections: sections,
|
||||||
lang: options.lang,
|
lang: options.lang,
|
||||||
tags: ["ios", "iosonly", Self.noTranslationTag],
|
tags: ["ios", "iosonly", Self.noTranslationTag],
|
||||||
isStatic: 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")
|
||||||
|
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
import ArgumentParser
|
import ArgumentParser
|
||||||
import Foundation
|
import Foundation
|
||||||
import ToolCore
|
|
||||||
|
|
||||||
// swiftlint:disable no_grouping_extension
|
// swiftlint:disable no_grouping_extension
|
||||||
|
|
||||||
@@ -22,17 +21,7 @@ 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(
|
@Option(help: "Path where to generate the extension.", transform: { $0.replaceTiltWithHomeDirectoryPath() })
|
||||||
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")
|
||||||
|
@@ -1,26 +0,0 @@
|
|||||||
//
|
|
||||||
// AssetBundle.swift
|
|
||||||
// ResgenSwift
|
|
||||||
//
|
|
||||||
// Created by Thibaut Schmitt on 21/07/2025.
|
|
||||||
//
|
|
||||||
|
|
||||||
import ArgumentParser
|
|
||||||
|
|
||||||
package enum AssetBundle: String, CustomStringConvertible, ExpressibleByArgument {
|
|
||||||
|
|
||||||
case main
|
|
||||||
case module
|
|
||||||
|
|
||||||
// MARK: - CustomStringConvertible
|
|
||||||
|
|
||||||
package var description: String {
|
|
||||||
switch self {
|
|
||||||
case .main:
|
|
||||||
"main"
|
|
||||||
|
|
||||||
case .module:
|
|
||||||
"module"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,34 +0,0 @@
|
|||||||
//
|
|
||||||
// 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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -9,4 +9,4 @@ import Foundation
|
|||||||
|
|
||||||
// swiftlint:disable prefixed_toplevel_constant identifier_name
|
// swiftlint:disable prefixed_toplevel_constant identifier_name
|
||||||
|
|
||||||
public let ResgenSwiftVersion = "2.2.0"
|
public let ResgenSwiftVersion = "2.1.0"
|
||||||
|
@@ -55,11 +55,11 @@ final class AnalyticsDefinitionTests: XCTestCase {
|
|||||||
definition.path = "ecran_un/"
|
definition.path = "ecran_un/"
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyScreen = definition.getProperty(visibility: .internal)
|
let propertyScreen = definition.getProperty()
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectScreen = """
|
let expectScreen = """
|
||||||
internal func logScreenDefinitionName() {
|
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(visibility: .public)
|
let propertyEvent = definition.getProperty()
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectEvent = """
|
let expectEvent = """
|
||||||
public func logEventDefinitionName() {
|
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(visibility: .private)
|
let propertyScreen = definition.getStaticProperty()
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectScreen = """
|
let expectScreen = """
|
||||||
private static func logScreenDefinitionName() {
|
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(visibility: .package)
|
let propertyEvent = definition.getStaticProperty()
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectEvent = """
|
let expectEvent = """
|
||||||
package static func logEventDefinitionName() {
|
static func logEventDefinitionName() {
|
||||||
AnalyticsManager.shared.logEvent(
|
AnalyticsManager.shared.logEvent(
|
||||||
name: "Ecran un",
|
name: "Ecran un",
|
||||||
action: "",
|
action: "",
|
||||||
|
@@ -32,11 +32,11 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
|||||||
return definition
|
return definition
|
||||||
}
|
}
|
||||||
|
|
||||||
private func protocolString(visibility: ExtensionVisibility) -> String {
|
private func protocolString() -> String {
|
||||||
"""
|
"""
|
||||||
// MARK: - Protocol
|
// MARK: - Protocol
|
||||||
|
|
||||||
\(visibility) protocol AnalyticsManagerProtocol {
|
protocol AnalyticsManagerProtocol {
|
||||||
|
|
||||||
func logScreen(
|
func logScreen(
|
||||||
name: String,
|
name: String,
|
||||||
@@ -233,8 +233,8 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
|||||||
targets: [TrackerType.firebase],
|
targets: [TrackerType.firebase],
|
||||||
sections: [sectionOne, sectionTwo, sectionThree],
|
sections: [sectionOne, sectionTwo, sectionThree],
|
||||||
tags: ["ios", "iosonly"],
|
tags: ["ios", "iosonly"],
|
||||||
isStatic: false,
|
staticVar: false,
|
||||||
visibility: .public
|
extensionName: "GenAnalytics"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Expect Analytics
|
// Expect Analytics
|
||||||
@@ -244,22 +244,22 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
|||||||
import Foundation
|
import Foundation
|
||||||
import FirebaseAnalytics
|
import FirebaseAnalytics
|
||||||
|
|
||||||
\(protocolString(visibility: .public))
|
\(protocolString())
|
||||||
|
|
||||||
\(firebaseString())
|
\(firebaseString())
|
||||||
|
|
||||||
// MARK: - Traker Type
|
// MARK: - Traker Type
|
||||||
|
|
||||||
public enum TrackerType: CaseIterable {
|
enum TrackerType: CaseIterable {
|
||||||
|
|
||||||
case firebase
|
case firebase
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Manager
|
// MARK: - Manager
|
||||||
|
|
||||||
public class AnalyticsManager {
|
class AnalyticsManager {
|
||||||
|
|
||||||
public static var shared = AnalyticsManager()
|
static var shared = AnalyticsManager()
|
||||||
|
|
||||||
private init() {}
|
private init() {}
|
||||||
|
|
||||||
@@ -287,15 +287,15 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func enableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
func enableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
||||||
setAnalytics(enable: true, analytics)
|
setAnalytics(enable: true, analytics)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func disableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
func disableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
||||||
setAnalytics(enable: false, analytics)
|
setAnalytics(enable: false, analytics)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func configure() {
|
func configure() {
|
||||||
managers[TrackerType.firebase] = FirebaseAnalyticsManager()
|
managers[TrackerType.firebase] = FirebaseAnalyticsManager()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,7 +337,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
|||||||
|
|
||||||
// MARK: - section_one
|
// MARK: - section_one
|
||||||
|
|
||||||
public func logScreenS1DefOne() {
|
func logScreenS1DefOne() {
|
||||||
logScreen(
|
logScreen(
|
||||||
name: "s1 def one",
|
name: "s1 def one",
|
||||||
path: "",
|
path: "",
|
||||||
@@ -345,7 +345,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func logEventS1DefTwo() {
|
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
|
||||||
|
|
||||||
public func logScreenS2DefOne() {
|
func logScreenS2DefOne() {
|
||||||
logScreen(
|
logScreen(
|
||||||
name: "s2 def one",
|
name: "s2 def one",
|
||||||
path: "",
|
path: "",
|
||||||
@@ -398,8 +398,8 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
|||||||
targets: [TrackerType.matomo],
|
targets: [TrackerType.matomo],
|
||||||
sections: [sectionOne, sectionTwo, sectionThree],
|
sections: [sectionOne, sectionTwo, sectionThree],
|
||||||
tags: ["ios", "iosonly"],
|
tags: ["ios", "iosonly"],
|
||||||
isStatic: false,
|
staticVar: false,
|
||||||
visibility: .package
|
extensionName: "GenAnalytics"
|
||||||
)
|
)
|
||||||
// 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(visibility: .package))
|
\(protocolString())
|
||||||
|
|
||||||
\(matomoString())
|
\(matomoString())
|
||||||
|
|
||||||
// MARK: - Traker Type
|
// MARK: - Traker Type
|
||||||
|
|
||||||
package enum TrackerType: CaseIterable {
|
enum TrackerType: CaseIterable {
|
||||||
|
|
||||||
case matomo
|
case matomo
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Manager
|
// MARK: - Manager
|
||||||
|
|
||||||
package class AnalyticsManager {
|
class AnalyticsManager {
|
||||||
|
|
||||||
package static var shared = AnalyticsManager()
|
static var shared = AnalyticsManager()
|
||||||
|
|
||||||
private init() {}
|
private init() {}
|
||||||
|
|
||||||
@@ -451,15 +451,15 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
package func enableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
func enableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
||||||
setAnalytics(enable: true, analytics)
|
setAnalytics(enable: true, analytics)
|
||||||
}
|
}
|
||||||
|
|
||||||
package func disableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
func disableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
||||||
setAnalytics(enable: false, analytics)
|
setAnalytics(enable: false, analytics)
|
||||||
}
|
}
|
||||||
|
|
||||||
package func configure(siteId: String, url: String) {
|
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
|
||||||
|
|
||||||
package func logScreenS1DefOne() {
|
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 {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
package func logEventS1DefTwo() {
|
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
|
||||||
|
|
||||||
package func logScreenS2DefOne() {
|
func logScreenS2DefOne() {
|
||||||
logScreen(
|
logScreen(
|
||||||
name: "s2 def one",
|
name: "s2 def one",
|
||||||
path: "s2_def_one/",
|
path: "s2_def_one/",
|
||||||
@@ -565,8 +565,8 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
|||||||
targets: [TrackerType.matomo, TrackerType.firebase],
|
targets: [TrackerType.matomo, TrackerType.firebase],
|
||||||
sections: [sectionOne, sectionTwo, sectionThree],
|
sections: [sectionOne, sectionTwo, sectionThree],
|
||||||
tags: ["ios", "iosonly"],
|
tags: ["ios", "iosonly"],
|
||||||
isStatic: false,
|
staticVar: false,
|
||||||
visibility: .internal
|
extensionName: "GenAnalytics"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Expect Analytics
|
// Expect Analytics
|
||||||
@@ -577,7 +577,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
|||||||
import MatomoTracker
|
import MatomoTracker
|
||||||
import FirebaseAnalytics
|
import FirebaseAnalytics
|
||||||
|
|
||||||
\(protocolString(visibility: .internal))
|
\(protocolString())
|
||||||
|
|
||||||
\(matomoString())
|
\(matomoString())
|
||||||
|
|
||||||
@@ -585,7 +585,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
|||||||
|
|
||||||
// MARK: - Traker Type
|
// MARK: - Traker Type
|
||||||
|
|
||||||
internal enum TrackerType: CaseIterable {
|
enum TrackerType: CaseIterable {
|
||||||
|
|
||||||
case matomo
|
case matomo
|
||||||
case firebase
|
case firebase
|
||||||
@@ -593,9 +593,9 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
|||||||
|
|
||||||
// MARK: - Manager
|
// MARK: - Manager
|
||||||
|
|
||||||
internal class AnalyticsManager {
|
class AnalyticsManager {
|
||||||
|
|
||||||
internal static var shared = AnalyticsManager()
|
static var shared = AnalyticsManager()
|
||||||
|
|
||||||
private init() {}
|
private init() {}
|
||||||
|
|
||||||
@@ -623,15 +623,15 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func enableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
func enableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
||||||
setAnalytics(enable: true, analytics)
|
setAnalytics(enable: true, analytics)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func disableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
func disableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
||||||
setAnalytics(enable: false, analytics)
|
setAnalytics(enable: false, analytics)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func configure(siteId: String, url: String) {
|
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
|
||||||
|
|
||||||
internal func logScreenS1DefOne() {
|
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 {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func logEventS1DefTwo() {
|
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
|
||||||
|
|
||||||
internal func logScreenS2DefOne() {
|
func logScreenS2DefOne() {
|
||||||
logScreen(
|
logScreen(
|
||||||
name: "s2 def one",
|
name: "s2 def one",
|
||||||
path: "s2_def_one/",
|
path: "s2_def_one/",
|
||||||
|
@@ -21,14 +21,10 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let extensionContent = ColorExtensionGenerator.getExtensionContent(
|
let extensionContent = ColorExtensionGenerator.getExtensionContent(colors: colors,
|
||||||
colors: colors,
|
staticVar: false,
|
||||||
isStatic: false,
|
|
||||||
extensionName: "GenColors",
|
extensionName: "GenColors",
|
||||||
isSwiftUI: false,
|
isSwiftUI: false)
|
||||||
visibility: .public,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
@@ -39,13 +35,13 @@ 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 public var colorOne: UIColor {
|
@objc var colorOne: UIColor {
|
||||||
UIColor(named: "colorOne", in: Bundle.main, compatibleWith: nil)!
|
UIColor(named: "colorOne")!
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
|
/// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
|
||||||
@objc public var colorTwo: UIColor {
|
@objc var colorTwo: UIColor {
|
||||||
UIColor(named: "colorTwo", in: Bundle.main, compatibleWith: nil)!
|
UIColor(named: "colorTwo")!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -53,7 +49,7 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
|||||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
}
|
}
|
||||||
|
|
||||||
func test_uiKit_GeneratedExtensionContentForIsStatic() {
|
func test_uiKit_GeneratedExtensionContentForStaticVar() {
|
||||||
// Given
|
// Given
|
||||||
let colors = [
|
let colors = [
|
||||||
ParsedColor(name: "colorOne", light: "#FF00FF", dark: "#00FF00"),
|
ParsedColor(name: "colorOne", light: "#FF00FF", dark: "#00FF00"),
|
||||||
@@ -61,14 +57,10 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let extensionContent = ColorExtensionGenerator.getExtensionContent(
|
let extensionContent = ColorExtensionGenerator.getExtensionContent(colors: colors,
|
||||||
colors: colors,
|
staticVar: true,
|
||||||
isStatic: true,
|
|
||||||
extensionName: "GenColor",
|
extensionName: "GenColor",
|
||||||
isSwiftUI: false,
|
isSwiftUI: false)
|
||||||
visibility: .public,
|
|
||||||
assetBundle: .module
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
@@ -79,13 +71,13 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
|||||||
extension GenColor {
|
extension GenColor {
|
||||||
|
|
||||||
/// Color colorOne is #FF00FF (light) or #00FF00 (dark)"
|
/// Color colorOne is #FF00FF (light) or #00FF00 (dark)"
|
||||||
public static var colorOne: UIColor {
|
static var colorOne: UIColor {
|
||||||
UIColor(named: "colorOne", in: Bundle.module, compatibleWith: nil)!
|
UIColor(named: "colorOne")!
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
|
/// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
|
||||||
public static var colorTwo: UIColor {
|
static var colorTwo: UIColor {
|
||||||
UIColor(named: "colorTwo", in: Bundle.module, compatibleWith: nil)!
|
UIColor(named: "colorTwo")!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -101,14 +93,10 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let extensionContent = ColorExtensionGenerator.getExtensionContent(
|
let extensionContent = ColorExtensionGenerator.getExtensionContent(colors: colors,
|
||||||
colors: colors,
|
staticVar: false,
|
||||||
isStatic: false,
|
|
||||||
extensionName: "GenColors",
|
extensionName: "GenColors",
|
||||||
isSwiftUI: true,
|
isSwiftUI: true)
|
||||||
visibility: .package,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
@@ -119,13 +107,13 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
|||||||
extension GenColors {
|
extension GenColors {
|
||||||
|
|
||||||
/// Color colorOne is #FF00FF (light) or #00FF00 (dark)"
|
/// Color colorOne is #FF00FF (light) or #00FF00 (dark)"
|
||||||
package var colorOne: Color {
|
var colorOne: Color {
|
||||||
Color("colorOne", bundle: Bundle.main)
|
Color("colorOne")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
|
/// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
|
||||||
package var colorTwo: Color {
|
var colorTwo: Color {
|
||||||
Color("colorTwo", bundle: Bundle.main)
|
Color("colorTwo")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -133,7 +121,7 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
|||||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
}
|
}
|
||||||
|
|
||||||
func test_swiftUI_GeneratedExtensionContentForIsStatic() {
|
func test_swiftUI_GeneratedExtensionContentForStaticVar() {
|
||||||
// Given
|
// Given
|
||||||
let colors = [
|
let colors = [
|
||||||
ParsedColor(name: "colorOne", light: "#FF00FF", dark: "#00FF00"),
|
ParsedColor(name: "colorOne", light: "#FF00FF", dark: "#00FF00"),
|
||||||
@@ -141,14 +129,10 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let extensionContent = ColorExtensionGenerator.getExtensionContent(
|
let extensionContent = ColorExtensionGenerator.getExtensionContent(colors: colors,
|
||||||
colors: colors,
|
staticVar: true,
|
||||||
isStatic: true,
|
|
||||||
extensionName: "GenColor",
|
extensionName: "GenColor",
|
||||||
isSwiftUI: true,
|
isSwiftUI: true)
|
||||||
visibility: .internal,
|
|
||||||
assetBundle: .module
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
@@ -159,13 +143,13 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
|||||||
extension GenColor {
|
extension GenColor {
|
||||||
|
|
||||||
/// Color colorOne is #FF00FF (light) or #00FF00 (dark)"
|
/// Color colorOne is #FF00FF (light) or #00FF00 (dark)"
|
||||||
internal static var colorOne: Color {
|
static var colorOne: Color {
|
||||||
Color("colorOne", bundle: Bundle.module)
|
Color("colorOne")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
|
/// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
|
||||||
internal static var colorTwo: Color {
|
static var colorTwo: Color {
|
||||||
Color("colorTwo", bundle: Bundle.module)
|
Color("colorTwo")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
@@ -17,18 +17,13 @@ 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(
|
let property = color.getColorProperty(isStatic: false, isSwiftUI: false)
|
||||||
isStatic: false,
|
|
||||||
isSwiftUI: false,
|
|
||||||
visibility: .public,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
/// Color red is #FF0000 (light) or #0000FF (dark)"
|
/// Color red is #FF0000 (light) or #0000FF (dark)"
|
||||||
@objc public var red: UIColor {
|
@objc var red: UIColor {
|
||||||
UIColor(named: "red", in: Bundle.main, compatibleWith: nil)!
|
UIColor(named: "red")!
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -40,18 +35,13 @@ 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(
|
let property = color.getColorProperty(isStatic: true, isSwiftUI: false)
|
||||||
isStatic: true,
|
|
||||||
isSwiftUI: false,
|
|
||||||
visibility: .private,
|
|
||||||
assetBundle: .module
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
/// Color red is #FF0000 (light) or #0000FF (dark)"
|
/// Color red is #FF0000 (light) or #0000FF (dark)"
|
||||||
private static var red: UIColor {
|
static var red: UIColor {
|
||||||
UIColor(named: "red", in: Bundle.module, compatibleWith: nil)!
|
UIColor(named: "red")!
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -63,18 +53,13 @@ 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(
|
let property = color.getColorProperty(isStatic: false, isSwiftUI: true)
|
||||||
isStatic: false,
|
|
||||||
isSwiftUI: true,
|
|
||||||
visibility: .package,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
/// Color red is #FF0000 (light) or #0000FF (dark)"
|
/// Color red is #FF0000 (light) or #0000FF (dark)"
|
||||||
package var red: Color {
|
var red: Color {
|
||||||
Color("red", bundle: Bundle.main)
|
Color("red")
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -86,18 +71,13 @@ 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(
|
let property = color.getColorProperty(isStatic: true, isSwiftUI: true)
|
||||||
isStatic: true,
|
|
||||||
isSwiftUI: true,
|
|
||||||
visibility: .internal,
|
|
||||||
assetBundle: .module
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
/// Color red is #FF0000 (light) or #0000FF (dark)"
|
/// Color red is #FF0000 (light) or #0000FF (dark)"
|
||||||
internal static var red: Color {
|
static var red: Color {
|
||||||
Color("red", bundle: Bundle.module)
|
Color("red")
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@@ -21,13 +21,10 @@ final class FontExtensionGeneratorTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let extensionContent = FontExtensionGenerator.getExtensionContent(
|
let extensionContent = FontExtensionGenerator.getExtensionContent(fontsNames: fontNames,
|
||||||
fontsNames: fontNames,
|
staticVar: false,
|
||||||
isStatic: false,
|
|
||||||
extensionName: "GenFonts",
|
extensionName: "GenFonts",
|
||||||
isSwiftUI: false,
|
isSwiftUI: false)
|
||||||
visibility: .public
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
@@ -37,18 +34,18 @@ final class FontExtensionGeneratorTests: XCTestCase {
|
|||||||
|
|
||||||
extension GenFonts {
|
extension GenFonts {
|
||||||
|
|
||||||
public enum FontName: String {
|
enum FontName: String {
|
||||||
case CircularStdRegular = "CircularStd-Regular"
|
case CircularStdRegular = "CircularStd-Regular"
|
||||||
case CircularStdBold = "CircularStd-Bold"
|
case CircularStdBold = "CircularStd-Bold"
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Getter
|
// MARK: - Getter
|
||||||
|
|
||||||
public func CircularStdRegular(withSize size: CGFloat) -> UIFont {
|
func CircularStdRegular(withSize size: CGFloat) -> UIFont {
|
||||||
UIFont(name: FontName.CircularStdRegular.rawValue, size: size)!
|
UIFont(name: FontName.CircularStdRegular.rawValue, size: size)!
|
||||||
}
|
}
|
||||||
|
|
||||||
public func CircularStdBold(withSize size: CGFloat) -> UIFont {
|
func CircularStdBold(withSize size: CGFloat) -> UIFont {
|
||||||
UIFont(name: FontName.CircularStdBold.rawValue, size: size)!
|
UIFont(name: FontName.CircularStdBold.rawValue, size: size)!
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,13 +64,10 @@ final class FontExtensionGeneratorTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let extensionContent = FontExtensionGenerator.getExtensionContent(
|
let extensionContent = FontExtensionGenerator.getExtensionContent(fontsNames: fontNames,
|
||||||
fontsNames: fontNames,
|
staticVar: false,
|
||||||
isStatic: false,
|
|
||||||
extensionName: "GenFonts",
|
extensionName: "GenFonts",
|
||||||
isSwiftUI: true,
|
isSwiftUI: true)
|
||||||
visibility: .package
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
@@ -83,18 +77,18 @@ final class FontExtensionGeneratorTests: XCTestCase {
|
|||||||
|
|
||||||
extension GenFonts {
|
extension GenFonts {
|
||||||
|
|
||||||
package enum FontName: String {
|
enum FontName: String {
|
||||||
case CircularStdRegular = "CircularStd-Regular"
|
case CircularStdRegular = "CircularStd-Regular"
|
||||||
case CircularStdBold = "CircularStd-Bold"
|
case CircularStdBold = "CircularStd-Bold"
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Getter
|
// MARK: - Getter
|
||||||
|
|
||||||
package func CircularStdRegular(withSize size: CGFloat) -> Font {
|
func CircularStdRegular(withSize size: CGFloat) -> Font {
|
||||||
Font.custom(FontName.CircularStdRegular.rawValue, size: size)
|
Font.custom(FontName.CircularStdRegular.rawValue, size: size)
|
||||||
}
|
}
|
||||||
|
|
||||||
package func CircularStdBold(withSize size: CGFloat) -> Font {
|
func CircularStdBold(withSize size: CGFloat) -> Font {
|
||||||
Font.custom(FontName.CircularStdBold.rawValue, size: size)
|
Font.custom(FontName.CircularStdBold.rawValue, size: size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,15 +21,11 @@ final class FontNameTests: XCTestCase {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let property = fontName.getProperty(
|
let property = fontName.getProperty(isStatic: true, isSwiftUI: false)
|
||||||
isStatic: true,
|
|
||||||
isSwiftUI: false,
|
|
||||||
visibility: .internal
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
internal static let CircularStdBold: ((_ size: CGFloat) -> UIFont) = { size in
|
static let CircularStdBold: ((_ size: CGFloat) -> UIFont) = { size in
|
||||||
UIFont(name: FontName.CircularStdBold.rawValue, size: size)!
|
UIFont(name: FontName.CircularStdBold.rawValue, size: size)!
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -46,15 +42,11 @@ final class FontNameTests: XCTestCase {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let property = fontName.getProperty(
|
let property = fontName.getProperty(isStatic: true, isSwiftUI: false)
|
||||||
isStatic: true,
|
|
||||||
isSwiftUI: false,
|
|
||||||
visibility: .package
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
package static let CircularStdBoldUnderline: ((_ size: CGFloat) -> UIFont) = { size in
|
static let CircularStdBoldUnderline: ((_ size: CGFloat) -> UIFont) = { size in
|
||||||
UIFont(name: FontName.CircularStdBoldUnderline.rawValue, size: size)!
|
UIFont(name: FontName.CircularStdBoldUnderline.rawValue, size: size)!
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -71,15 +63,11 @@ final class FontNameTests: XCTestCase {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let property = fontName.getProperty(
|
let property = fontName.getProperty(isStatic: false, isSwiftUI: false)
|
||||||
isStatic: false,
|
|
||||||
isSwiftUI: false,
|
|
||||||
visibility: .private
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
private func CircularStdBold(withSize size: CGFloat) -> UIFont {
|
func CircularStdBold(withSize size: CGFloat) -> UIFont {
|
||||||
UIFont(name: FontName.CircularStdBold.rawValue, size: size)!
|
UIFont(name: FontName.CircularStdBold.rawValue, size: size)!
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -96,15 +84,11 @@ final class FontNameTests: XCTestCase {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let property = fontName.getProperty(
|
let property = fontName.getProperty(isStatic: false, isSwiftUI: false)
|
||||||
isStatic: false,
|
|
||||||
isSwiftUI: false,
|
|
||||||
visibility: .public
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
public func CircularStdBoldUnderline(withSize size: CGFloat) -> UIFont {
|
func CircularStdBoldUnderline(withSize size: CGFloat) -> UIFont {
|
||||||
UIFont(name: FontName.CircularStdBoldUnderline.rawValue, size: size)!
|
UIFont(name: FontName.CircularStdBoldUnderline.rawValue, size: size)!
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -121,15 +105,11 @@ final class FontNameTests: XCTestCase {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let property = fontName.getProperty(
|
let property = fontName.getProperty(isStatic: true, isSwiftUI: true)
|
||||||
isStatic: true,
|
|
||||||
isSwiftUI: true,
|
|
||||||
visibility: .public
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
public static let CircularStdBold: ((_ size: CGFloat) -> Font) = { size in
|
static let CircularStdBold: ((_ size: CGFloat) -> Font) = { size in
|
||||||
Font.custom(FontName.CircularStdBold.rawValue, size: size)
|
Font.custom(FontName.CircularStdBold.rawValue, size: size)
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -146,15 +126,11 @@ final class FontNameTests: XCTestCase {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let property = fontName.getProperty(
|
let property = fontName.getProperty(isStatic: true, isSwiftUI: true)
|
||||||
isStatic: true,
|
|
||||||
isSwiftUI: true,
|
|
||||||
visibility: .package
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
package static let CircularStdBoldUnderline: ((_ size: CGFloat) -> Font) = { size in
|
static let CircularStdBoldUnderline: ((_ size: CGFloat) -> Font) = { size in
|
||||||
Font.custom(FontName.CircularStdBoldUnderline.rawValue, size: size)
|
Font.custom(FontName.CircularStdBoldUnderline.rawValue, size: size)
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -171,15 +147,11 @@ final class FontNameTests: XCTestCase {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let property = fontName.getProperty(
|
let property = fontName.getProperty(isStatic: false, isSwiftUI: true)
|
||||||
isStatic: false,
|
|
||||||
isSwiftUI: true,
|
|
||||||
visibility: .package
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
package func CircularStdBold(withSize size: CGFloat) -> Font {
|
func CircularStdBold(withSize size: CGFloat) -> Font {
|
||||||
Font.custom(FontName.CircularStdBold.rawValue, size: size)
|
Font.custom(FontName.CircularStdBold.rawValue, size: size)
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -196,15 +168,11 @@ final class FontNameTests: XCTestCase {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let property = fontName.getProperty(
|
let property = fontName.getProperty(isStatic: false, isSwiftUI: true)
|
||||||
isStatic: false,
|
|
||||||
isSwiftUI: true,
|
|
||||||
visibility: .internal
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
internal func CircularStdBoldUnderline(withSize size: CGFloat) -> Font {
|
func CircularStdBoldUnderline(withSize size: CGFloat) -> Font {
|
||||||
Font.custom(FontName.CircularStdBoldUnderline.rawValue, size: size)
|
Font.custom(FontName.CircularStdBoldUnderline.rawValue, size: size)
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
@@ -1,76 +0,0 @@
|
|||||||
//
|
|
||||||
// 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)
|
|
||||||
}
|
|
||||||
}
|
|
@@ -16,23 +16,16 @@ final class ColorsConfigurationTests: XCTestCase {
|
|||||||
|
|
||||||
func test_argsGeneration_requiredArgs() {
|
func test_argsGeneration_requiredArgs() {
|
||||||
// Given
|
// Given
|
||||||
let testingConfiguration = ColorsConfiguration(
|
let testingConfiguration = ColorsConfiguration(inputFile: "path/to/colors.txt",
|
||||||
inputFile: "path/to/colors.txt",
|
|
||||||
style: ColorStyle.all.rawValue,
|
style: ColorStyle.all.rawValue,
|
||||||
xcassetsPath: "path/to/assets.xcassets",
|
xcassetsPath: "path/to/assets.xcassets",
|
||||||
extensionOutputPath: nil,
|
extensionOutputPath: "Colors/Generated",
|
||||||
extensionName: nil,
|
extensionName: nil,
|
||||||
extensionNameUIKit: nil,
|
extensionNameUIKit: nil,
|
||||||
extensionSuffix: nil,
|
extensionSuffix: nil,
|
||||||
visibility: nil,
|
staticMembers: false)
|
||||||
assetBundle: nil,
|
|
||||||
staticMembers: false
|
|
||||||
)
|
|
||||||
// When
|
// When
|
||||||
let arguments = testingConfiguration.getArguments(
|
let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: false)
|
||||||
projectDirectory: projectDirectory,
|
|
||||||
force: false
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectedArguments = [
|
let expectedArguments = [
|
||||||
@@ -41,6 +34,8 @@ final class ColorsConfigurationTests: XCTestCase {
|
|||||||
"all",
|
"all",
|
||||||
"--xcassets-path",
|
"--xcassets-path",
|
||||||
"projectDirectory/path/to/assets.xcassets",
|
"projectDirectory/path/to/assets.xcassets",
|
||||||
|
"--extension-output-path",
|
||||||
|
"projectDirectory/Colors/Generated",
|
||||||
"--static-members",
|
"--static-members",
|
||||||
"false"
|
"false"
|
||||||
]
|
]
|
||||||
@@ -50,23 +45,16 @@ final class ColorsConfigurationTests: XCTestCase {
|
|||||||
|
|
||||||
func test_argsGeneration_allArguments() {
|
func test_argsGeneration_allArguments() {
|
||||||
// Given
|
// Given
|
||||||
let testingConfiguration = ColorsConfiguration(
|
let testingConfiguration = ColorsConfiguration(inputFile: "path/to/colors.txt",
|
||||||
inputFile: "path/to/colors.txt",
|
|
||||||
style: ColorStyle.all.rawValue,
|
style: ColorStyle.all.rawValue,
|
||||||
xcassetsPath: "path/to/assets.xcassets",
|
xcassetsPath: "path/to/assets.xcassets",
|
||||||
extensionOutputPath: "Colors/Generated",
|
extensionOutputPath: "Colors/Generated",
|
||||||
extensionName: "AppUIColor",
|
extensionName: "AppUIColor",
|
||||||
extensionNameUIKit: "AppColor",
|
extensionNameUIKit: "AppColor",
|
||||||
extensionSuffix: "Testing",
|
extensionSuffix: "Testing",
|
||||||
visibility: "public",
|
staticMembers: false)
|
||||||
assetBundle: "module",
|
|
||||||
staticMembers: false
|
|
||||||
)
|
|
||||||
// When
|
// When
|
||||||
let arguments = testingConfiguration.getArguments(
|
let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: true)
|
||||||
projectDirectory: projectDirectory,
|
|
||||||
force: true
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectedArguments = [
|
let expectedArguments = [
|
||||||
@@ -78,18 +66,14 @@ final class ColorsConfigurationTests: XCTestCase {
|
|||||||
"projectDirectory/path/to/assets.xcassets",
|
"projectDirectory/path/to/assets.xcassets",
|
||||||
"--extension-output-path",
|
"--extension-output-path",
|
||||||
"projectDirectory/Colors/Generated",
|
"projectDirectory/Colors/Generated",
|
||||||
|
"--static-members",
|
||||||
|
"false",
|
||||||
"--extension-name",
|
"--extension-name",
|
||||||
"AppUIColor",
|
"AppUIColor",
|
||||||
"--extension-name-ui-kit",
|
"--extension-name-ui-kit",
|
||||||
"AppColor",
|
"AppColor",
|
||||||
"--extension-suffix",
|
"--extension-suffix",
|
||||||
"Testing",
|
"Testing",
|
||||||
"--visibility",
|
|
||||||
"public",
|
|
||||||
"--asset-bundle",
|
|
||||||
"module",
|
|
||||||
"--static-members",
|
|
||||||
"false"
|
|
||||||
]
|
]
|
||||||
|
|
||||||
XCTAssertEqual(arguments, expectedArguments)
|
XCTAssertEqual(arguments, expectedArguments)
|
||||||
|
@@ -16,25 +16,23 @@ final class FontsConfigurationTests: XCTestCase {
|
|||||||
|
|
||||||
func test_argsGeneration_requiredArgs() {
|
func test_argsGeneration_requiredArgs() {
|
||||||
// Given
|
// Given
|
||||||
let testingConfiguration = FontsConfiguration(
|
let testingConfiguration = FontsConfiguration(inputFile: "path/to/fonts.txt",
|
||||||
inputFile: "path/to/fonts.txt",
|
extensionOutputPath: "Fonts/Generated",
|
||||||
extensionOutputPath: nil,
|
|
||||||
extensionName: nil,
|
extensionName: nil,
|
||||||
extensionNameUIKit: nil,
|
extensionNameUIKit: nil,
|
||||||
extensionSuffix: nil,
|
extensionSuffix: nil,
|
||||||
infoPlistPaths: nil,
|
infoPlistPaths: nil,
|
||||||
visibility: nil,
|
staticMembers: nil)
|
||||||
staticMembers: nil
|
|
||||||
)
|
|
||||||
// When
|
// When
|
||||||
let arguments = testingConfiguration.getArguments(
|
let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: false)
|
||||||
projectDirectory: projectDirectory,
|
|
||||||
force: false
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectedArguments = [
|
let expectedArguments = [
|
||||||
"projectDirectory/path/to/fonts.txt"
|
"projectDirectory/path/to/fonts.txt",
|
||||||
|
"--extension-output-path",
|
||||||
|
"projectDirectory/Fonts/Generated",
|
||||||
|
"--static-members",
|
||||||
|
"false"
|
||||||
]
|
]
|
||||||
|
|
||||||
XCTAssertEqual(arguments, expectedArguments)
|
XCTAssertEqual(arguments, expectedArguments)
|
||||||
@@ -42,21 +40,15 @@ final class FontsConfigurationTests: XCTestCase {
|
|||||||
|
|
||||||
func test_argsGeneration_allArguments() {
|
func test_argsGeneration_allArguments() {
|
||||||
// Given
|
// Given
|
||||||
let testingConfiguration = FontsConfiguration(
|
let testingConfiguration = FontsConfiguration(inputFile: "path/to/fonts.txt",
|
||||||
inputFile: "path/to/fonts.txt",
|
|
||||||
extensionOutputPath: "Fonts/Generated",
|
extensionOutputPath: "Fonts/Generated",
|
||||||
extensionName: "AppUIFont",
|
extensionName: "AppUIFont",
|
||||||
extensionNameUIKit: "AppFont",
|
extensionNameUIKit: "AppFont",
|
||||||
extensionSuffix: "Testing",
|
extensionSuffix: "Testing",
|
||||||
infoPlistPaths: "path/to/plist1.plist path/to/plist2.plist",
|
infoPlistPaths: "path/to/plist1.plist path/to/plist2.plist",
|
||||||
visibility: "package",
|
staticMembers: true)
|
||||||
staticMembers: true
|
|
||||||
)
|
|
||||||
// When
|
// When
|
||||||
let arguments = testingConfiguration.getArguments(
|
let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: true)
|
||||||
projectDirectory: projectDirectory,
|
|
||||||
force: true
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectedArguments = [
|
let expectedArguments = [
|
||||||
@@ -64,16 +56,14 @@ final class FontsConfigurationTests: XCTestCase {
|
|||||||
"projectDirectory/path/to/fonts.txt",
|
"projectDirectory/path/to/fonts.txt",
|
||||||
"--extension-output-path",
|
"--extension-output-path",
|
||||||
"projectDirectory/Fonts/Generated",
|
"projectDirectory/Fonts/Generated",
|
||||||
|
"--static-members",
|
||||||
|
"true",
|
||||||
"--extension-name",
|
"--extension-name",
|
||||||
"AppUIFont",
|
"AppUIFont",
|
||||||
"--extension-name-ui-kit",
|
"--extension-name-ui-kit",
|
||||||
"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"
|
||||||
]
|
]
|
||||||
|
@@ -16,29 +16,26 @@ final class ImagesConfigurationTests: XCTestCase {
|
|||||||
|
|
||||||
func test_argsGeneration_requiredArgs() {
|
func test_argsGeneration_requiredArgs() {
|
||||||
// Given
|
// Given
|
||||||
let testingConfiguration = ImagesConfiguration(
|
let testingConfiguration = ImagesConfiguration(inputFile: "path/to/images.txt",
|
||||||
inputFile: "path/to/images.txt",
|
|
||||||
xcassetsPath: "path/to/assets.xcassets",
|
xcassetsPath: "path/to/assets.xcassets",
|
||||||
extensionOutputPath: nil,
|
extensionOutputPath: "Images/Generated",
|
||||||
extensionName: nil,
|
extensionName: nil,
|
||||||
extensionNameUIKit: nil,
|
extensionNameUIKit: nil,
|
||||||
extensionSuffix: nil,
|
extensionSuffix: nil,
|
||||||
visibility: nil,
|
staticMembers: nil)
|
||||||
assetBundle: nil,
|
|
||||||
staticMembers: nil
|
|
||||||
)
|
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let arguments = testingConfiguration.getArguments(
|
let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: false)
|
||||||
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",
|
||||||
|
"--extension-output-path",
|
||||||
|
"projectDirectory/Images/Generated",
|
||||||
|
"--static-members",
|
||||||
|
"false"
|
||||||
]
|
]
|
||||||
|
|
||||||
XCTAssertEqual(arguments, expectedArguments)
|
XCTAssertEqual(arguments, expectedArguments)
|
||||||
@@ -46,23 +43,16 @@ final class ImagesConfigurationTests: XCTestCase {
|
|||||||
|
|
||||||
func test_argsGeneration_allArguments() {
|
func test_argsGeneration_allArguments() {
|
||||||
// Given
|
// Given
|
||||||
let testingConfiguration = ImagesConfiguration(
|
let testingConfiguration = ImagesConfiguration(inputFile: "path/to/images.txt",
|
||||||
inputFile: "path/to/images.txt",
|
|
||||||
xcassetsPath: "path/to/assets.xcassets",
|
xcassetsPath: "path/to/assets.xcassets",
|
||||||
extensionOutputPath: "Images/Generated",
|
extensionOutputPath: "Images/Generated",
|
||||||
extensionName: "AppUIImage",
|
extensionName: "AppUIImage",
|
||||||
extensionNameUIKit: "AppImage",
|
extensionNameUIKit: "AppImage",
|
||||||
extensionSuffix: "Testing",
|
extensionSuffix: "Testing",
|
||||||
visibility: "private",
|
staticMembers: true)
|
||||||
assetBundle: "module",
|
|
||||||
staticMembers: true
|
|
||||||
)
|
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let arguments = testingConfiguration.getArguments(
|
let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: true)
|
||||||
projectDirectory: projectDirectory,
|
|
||||||
force: true
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectedArguments = [
|
let expectedArguments = [
|
||||||
@@ -72,18 +62,14 @@ final class ImagesConfigurationTests: XCTestCase {
|
|||||||
"projectDirectory/path/to/assets.xcassets",
|
"projectDirectory/path/to/assets.xcassets",
|
||||||
"--extension-output-path",
|
"--extension-output-path",
|
||||||
"projectDirectory/Images/Generated",
|
"projectDirectory/Images/Generated",
|
||||||
|
"--static-members",
|
||||||
|
"true",
|
||||||
"--extension-name",
|
"--extension-name",
|
||||||
"AppUIImage",
|
"AppUIImage",
|
||||||
"--extension-name-ui-kit",
|
"--extension-name-ui-kit",
|
||||||
"AppImage",
|
"AppImage",
|
||||||
"--extension-suffix",
|
"--extension-suffix",
|
||||||
"Testing",
|
"Testing",
|
||||||
"--visibility",
|
|
||||||
"private",
|
|
||||||
"--asset-bundle",
|
|
||||||
"module",
|
|
||||||
"--static-members",
|
|
||||||
"true"
|
|
||||||
]
|
]
|
||||||
|
|
||||||
XCTAssertEqual(arguments, expectedArguments)
|
XCTAssertEqual(arguments, expectedArguments)
|
||||||
|
@@ -1,102 +0,0 @@
|
|||||||
//
|
|
||||||
// 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"
|
|
||||||
assetBundle: nil, // .main
|
|
||||||
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",
|
|
||||||
assetBundle: "module",
|
|
||||||
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",
|
|
||||||
"--asset-bundle",
|
|
||||||
"module",
|
|
||||||
"--xc-strings",
|
|
||||||
"true",
|
|
||||||
"--static-members",
|
|
||||||
"true"
|
|
||||||
]
|
|
||||||
|
|
||||||
XCTAssertEqual(arguments, expectedArguments)
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,84 +0,0 @@
|
|||||||
//
|
|
||||||
// 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)
|
|
||||||
}
|
|
||||||
}
|
|
@@ -21,15 +21,11 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let extensionContent = ImageExtensionGenerator.getExtensionContent(
|
let extensionContent = ImageExtensionGenerator.getExtensionContent(images: images,
|
||||||
images: images,
|
staticVar: false,
|
||||||
isStatic: false,
|
|
||||||
extensionName: "GenImages",
|
extensionName: "GenImages",
|
||||||
inputFilename: "myInputFilename",
|
inputFilename: "myInputFilename",
|
||||||
isSwiftUI: false,
|
isSwiftUI: false)
|
||||||
visibility: .public,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
@@ -40,12 +36,12 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
|||||||
|
|
||||||
extension GenImages {
|
extension GenImages {
|
||||||
|
|
||||||
public var image_one: UIImage {
|
var image_one: UIImage {
|
||||||
UIImage(named: "image_one", in: Bundle.main, with: nil)!
|
UIImage(named: "image_one")!
|
||||||
}
|
}
|
||||||
|
|
||||||
public var image_two: UIImage {
|
var image_two: UIImage {
|
||||||
UIImage(named: "image_two", in: Bundle.main, with: nil)!
|
UIImage(named: "image_two")!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -53,7 +49,7 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
|||||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
}
|
}
|
||||||
|
|
||||||
func test_uiKit_GeneratedExtensionContentForIsStatic() {
|
func test_uiKit_GeneratedExtensionContentForStaticVar() {
|
||||||
// Given
|
// Given
|
||||||
let images = [
|
let images = [
|
||||||
ParsedImage(name: "image_one", tags: "id", width: 10, height: 10),
|
ParsedImage(name: "image_one", tags: "id", width: 10, height: 10),
|
||||||
@@ -61,15 +57,11 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let extensionContent = ImageExtensionGenerator.getExtensionContent(
|
let extensionContent = ImageExtensionGenerator.getExtensionContent(images: images,
|
||||||
images: images,
|
staticVar: true,
|
||||||
isStatic: true,
|
|
||||||
extensionName: "GenImages",
|
extensionName: "GenImages",
|
||||||
inputFilename: "myInputFilename",
|
inputFilename: "myInputFilename",
|
||||||
isSwiftUI: false,
|
isSwiftUI: false)
|
||||||
visibility: .internal,
|
|
||||||
assetBundle: .module
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
@@ -80,12 +72,12 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
|||||||
|
|
||||||
extension GenImages {
|
extension GenImages {
|
||||||
|
|
||||||
internal static var image_one: UIImage {
|
static var image_one: UIImage {
|
||||||
UIImage(named: "image_one", in: Bundle.module, with: nil)!
|
UIImage(named: "image_one")!
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static var image_two: UIImage {
|
static var image_two: UIImage {
|
||||||
UIImage(named: "image_two", in: Bundle.module, with: nil)!
|
UIImage(named: "image_two")!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -101,15 +93,11 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let extensionContent = ImageExtensionGenerator.getExtensionContent(
|
let extensionContent = ImageExtensionGenerator.getExtensionContent(images: images,
|
||||||
images: images,
|
staticVar: false,
|
||||||
isStatic: false,
|
|
||||||
extensionName: "GenImages",
|
extensionName: "GenImages",
|
||||||
inputFilename: "myInputFilename",
|
inputFilename: "myInputFilename",
|
||||||
isSwiftUI: true,
|
isSwiftUI: true)
|
||||||
visibility: .public,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
@@ -120,12 +108,12 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
|||||||
|
|
||||||
extension GenImages {
|
extension GenImages {
|
||||||
|
|
||||||
public var image_one: Image {
|
var image_one: Image {
|
||||||
Image("image_one", bundle: Bundle.main)
|
Image("image_one")
|
||||||
}
|
}
|
||||||
|
|
||||||
public var image_two: Image {
|
var image_two: Image {
|
||||||
Image("image_two", bundle: Bundle.main)
|
Image("image_two")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -133,7 +121,7 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
|||||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
}
|
}
|
||||||
|
|
||||||
func test_swiftUI_GeneratedExtensionContentForIsStatic() {
|
func test_swiftUI_GeneratedExtensionContentForStaticVar() {
|
||||||
// Given
|
// Given
|
||||||
let images = [
|
let images = [
|
||||||
ParsedImage(name: "image_one", tags: "id", width: 10, height: 10),
|
ParsedImage(name: "image_one", tags: "id", width: 10, height: 10),
|
||||||
@@ -141,15 +129,11 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let extensionContent = ImageExtensionGenerator.getExtensionContent(
|
let extensionContent = ImageExtensionGenerator.getExtensionContent(images: images,
|
||||||
images: images,
|
staticVar: true,
|
||||||
isStatic: true,
|
|
||||||
extensionName: "GenImages",
|
extensionName: "GenImages",
|
||||||
inputFilename: "myInputFilename",
|
inputFilename: "myInputFilename",
|
||||||
isSwiftUI: true,
|
isSwiftUI: true)
|
||||||
visibility: .package,
|
|
||||||
assetBundle: .module
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
@@ -160,12 +144,12 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
|||||||
|
|
||||||
extension GenImages {
|
extension GenImages {
|
||||||
|
|
||||||
package static var image_one: Image {
|
static var image_one: Image {
|
||||||
Image("image_one", bundle: Bundle.module)
|
Image("image_one")
|
||||||
}
|
}
|
||||||
|
|
||||||
package static var image_two: Image {
|
static var image_two: Image {
|
||||||
Image("image_two", bundle: Bundle.module)
|
Image("image_two")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
@@ -37,25 +37,18 @@ 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(
|
let parsedImage = ParsedImage(name: imageName,
|
||||||
name: imageName,
|
|
||||||
tags: "id",
|
tags: "id",
|
||||||
width: 10,
|
width: 10,
|
||||||
height: 10
|
height: 10)
|
||||||
)
|
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let property = parsedImage.getImageProperty(
|
let property = parsedImage.getImageProperty(isStatic: false, isSwiftUI: false)
|
||||||
isStatic: false,
|
|
||||||
isSwiftUI: false,
|
|
||||||
visibility: .public,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
public var \(imageName): UIImage {
|
var \(imageName): UIImage {
|
||||||
UIImage(named: "\(imageName)", in: Bundle.main, with: nil)!
|
UIImage(named: "\(imageName)")!
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -65,25 +58,18 @@ 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(
|
let parsedImage = ParsedImage(name: imageName,
|
||||||
name: imageName,
|
|
||||||
tags: "id",
|
tags: "id",
|
||||||
width: 10,
|
width: 10,
|
||||||
height: 10
|
height: 10)
|
||||||
)
|
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let property = parsedImage.getImageProperty(
|
let property = parsedImage.getImageProperty(isStatic: true, isSwiftUI: false)
|
||||||
isStatic: true,
|
|
||||||
isSwiftUI: false,
|
|
||||||
visibility: .internal,
|
|
||||||
assetBundle: .module
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
internal static var \(imageName): UIImage {
|
static var \(imageName): UIImage {
|
||||||
UIImage(named: "\(imageName)", in: Bundle.module, with: nil)!
|
UIImage(named: "\(imageName)")!
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -93,25 +79,18 @@ 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(
|
let parsedImage = ParsedImage(name: imageName,
|
||||||
name: imageName,
|
|
||||||
tags: "id",
|
tags: "id",
|
||||||
width: 10,
|
width: 10,
|
||||||
height: 10
|
height: 10)
|
||||||
)
|
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let property = parsedImage.getImageProperty(
|
let property = parsedImage.getImageProperty(isStatic: false, isSwiftUI: true)
|
||||||
isStatic: false,
|
|
||||||
isSwiftUI: true,
|
|
||||||
visibility: .private,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
private var \(imageName): Image {
|
var \(imageName): Image {
|
||||||
Image("\(imageName)", bundle: Bundle.main)
|
Image("\(imageName)")
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -121,25 +100,18 @@ 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(
|
let parsedImage = ParsedImage(name: imageName,
|
||||||
name: imageName,
|
|
||||||
tags: "id",
|
tags: "id",
|
||||||
width: 10,
|
width: 10,
|
||||||
height: 10
|
height: 10)
|
||||||
)
|
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let property = parsedImage.getImageProperty(
|
let property = parsedImage.getImageProperty(isStatic: true, isSwiftUI: true)
|
||||||
isStatic: true,
|
|
||||||
isSwiftUI: true,
|
|
||||||
visibility: .package,
|
|
||||||
assetBundle: .module
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
package static var \(imageName): Image {
|
static var \(imageName): Image {
|
||||||
Image("\(imageName)", bundle: Bundle.module)
|
Image("\(imageName)")
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -149,12 +121,10 @@ final class ParsedImageTests: XCTestCase {
|
|||||||
func testAssetContentJson() {
|
func testAssetContentJson() {
|
||||||
// Given
|
// Given
|
||||||
let imageName = "the_name"
|
let imageName = "the_name"
|
||||||
let parsedImage = ParsedImage(
|
let parsedImage = ParsedImage(name: imageName,
|
||||||
name: imageName,
|
|
||||||
tags: "id",
|
tags: "id",
|
||||||
width: 10,
|
width: 10,
|
||||||
height: 10
|
height: 10)
|
||||||
)
|
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let property = parsedImage.generateImageContent(isVector: false)
|
let property = parsedImage.generateImageContent(isVector: false)
|
||||||
|
@@ -8,10 +8,10 @@
|
|||||||
// CPD-OFF
|
// CPD-OFF
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
@testable import ResgenSwift
|
|
||||||
import ToolCore
|
|
||||||
import XCTest
|
import XCTest
|
||||||
|
|
||||||
|
@testable import ResgenSwift
|
||||||
|
|
||||||
final class DefinitionTests: XCTestCase {
|
final class DefinitionTests: XCTestCase {
|
||||||
|
|
||||||
// MARK: - Match line
|
// MARK: - Match line
|
||||||
@@ -94,24 +94,9 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getNSLocalizedStringProperty(
|
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr")
|
||||||
forLang: "fr",
|
let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en")
|
||||||
isStatic: false,
|
let propertyEnUs = definition.getNSLocalizedStringProperty(forLang: "en-us")
|
||||||
visibility: .public,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
let propertyEn = definition.getNSLocalizedStringProperty(
|
|
||||||
forLang: "en",
|
|
||||||
isStatic: false,
|
|
||||||
visibility: .public,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
let propertyEnUs = definition.getNSLocalizedStringProperty(
|
|
||||||
forLang: "en-us",
|
|
||||||
isStatic: false,
|
|
||||||
visibility: .public,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
@@ -120,7 +105,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// This is a comment
|
/// This is a comment
|
||||||
public var definition_name: String {
|
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")
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -131,7 +116,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// This is a comment
|
/// This is a comment
|
||||||
public var definition_name: String {
|
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")
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -142,7 +127,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// This is a comment
|
/// This is a comment
|
||||||
public var definition_name: String {
|
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")
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -164,24 +149,9 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getNSLocalizedStringProperty(
|
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr")
|
||||||
forLang: "fr",
|
let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en")
|
||||||
isStatic: false,
|
let propertyEnUs = definition.getNSLocalizedStringProperty(forLang: "en-us")
|
||||||
visibility: .private,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
let propertyEn = definition.getNSLocalizedStringProperty(
|
|
||||||
forLang: "en",
|
|
||||||
isStatic: false,
|
|
||||||
visibility: .private,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
let propertyEnUs = definition.getNSLocalizedStringProperty(
|
|
||||||
forLang: "en-us",
|
|
||||||
isStatic: false,
|
|
||||||
visibility: .private,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
@@ -190,7 +160,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
private var definition_name: String {
|
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: "")
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -201,7 +171,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
private var definition_name: String {
|
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: "")
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -212,7 +182,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
private var definition_name: String {
|
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: "")
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -233,24 +203,9 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getNSLocalizedStringProperty(
|
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr")
|
||||||
forLang: "fr",
|
let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en")
|
||||||
isStatic: false,
|
let propertyEnUs = definition.getNSLocalizedStringProperty(forLang: "en-us")
|
||||||
visibility: .public,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
let propertyEn = definition.getNSLocalizedStringProperty(
|
|
||||||
forLang: "en",
|
|
||||||
isStatic: false,
|
|
||||||
visibility: .public,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
let propertyEnUs = definition.getNSLocalizedStringProperty(
|
|
||||||
forLang: "en-us",
|
|
||||||
isStatic: false,
|
|
||||||
visibility: .public,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
@@ -259,7 +214,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
public var definition_name: String {
|
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: "")
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -270,7 +225,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
public var definition_name: String {
|
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: "")
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -281,7 +236,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
public var definition_name: String {
|
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: "")
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -291,7 +246,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - getNSLocalizedStringProperty - static
|
// MARK: - getNSLocalizedStringStaticProperty
|
||||||
|
|
||||||
func testGeneratedNSLocalizedStringStaticProperty() {
|
func testGeneratedNSLocalizedStringStaticProperty() {
|
||||||
// Given
|
// Given
|
||||||
@@ -305,24 +260,9 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getNSLocalizedStringProperty(
|
let propertyFr = definition.getNSLocalizedStringStaticProperty(forLang: "fr")
|
||||||
forLang: "fr",
|
let propertyEn = definition.getNSLocalizedStringStaticProperty(forLang: "en")
|
||||||
isStatic: true,
|
let propertyEnUs = definition.getNSLocalizedStringStaticProperty(forLang: "en-us")
|
||||||
visibility: .public,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
let propertyEn = definition.getNSLocalizedStringProperty(
|
|
||||||
forLang: "en",
|
|
||||||
isStatic: true,
|
|
||||||
visibility: .public,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
let propertyEnUs = definition.getNSLocalizedStringProperty(
|
|
||||||
forLang: "en-us",
|
|
||||||
isStatic: true,
|
|
||||||
visibility: .public,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
@@ -331,7 +271,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// This is a comment
|
/// This is a comment
|
||||||
public static var definition_name: String {
|
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")
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -342,7 +282,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// This is a comment
|
/// This is a comment
|
||||||
public static var definition_name: String {
|
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")
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -353,7 +293,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// This is a comment
|
/// This is a comment
|
||||||
public static var definition_name: String {
|
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")
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -375,24 +315,9 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getNSLocalizedStringProperty(
|
let propertyFr = definition.getNSLocalizedStringStaticProperty(forLang: "fr")
|
||||||
forLang: "fr",
|
let propertyEn = definition.getNSLocalizedStringStaticProperty(forLang: "en")
|
||||||
isStatic: true,
|
let propertyEnUs = definition.getNSLocalizedStringStaticProperty(forLang: "en-us")
|
||||||
visibility: .internal,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
let propertyEn = definition.getNSLocalizedStringProperty(
|
|
||||||
forLang: "en",
|
|
||||||
isStatic: true,
|
|
||||||
visibility: .internal,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
let propertyEnUs = definition.getNSLocalizedStringProperty(
|
|
||||||
forLang: "en-us",
|
|
||||||
isStatic: true,
|
|
||||||
visibility: .internal,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
@@ -401,7 +326,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
internal static var definition_name: String {
|
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: "")
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -412,7 +337,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
internal static var definition_name: String {
|
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: "")
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -423,7 +348,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
internal static var definition_name: String {
|
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: "")
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -444,24 +369,9 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getNSLocalizedStringProperty(
|
let propertyFr = definition.getNSLocalizedStringStaticProperty(forLang: "fr")
|
||||||
forLang: "fr",
|
let propertyEn = definition.getNSLocalizedStringStaticProperty(forLang: "en")
|
||||||
isStatic: true,
|
let propertyEnUs = definition.getNSLocalizedStringStaticProperty(forLang: "en-us")
|
||||||
visibility: .internal,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
let propertyEn = definition.getNSLocalizedStringProperty(
|
|
||||||
forLang: "en",
|
|
||||||
isStatic: true,
|
|
||||||
visibility: .internal,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
let propertyEnUs = definition.getNSLocalizedStringProperty(
|
|
||||||
forLang: "en-us",
|
|
||||||
isStatic: true,
|
|
||||||
visibility: .internal,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
@@ -470,7 +380,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
internal static var definition_name: String {
|
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: "")
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -481,7 +391,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
internal static var definition_name: String {
|
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: "")
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -492,7 +402,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
internal static var definition_name: String {
|
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: "")
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -512,12 +422,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getNSLocalizedStringProperty(
|
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr")
|
||||||
forLang: "fr",
|
|
||||||
isStatic: false,
|
|
||||||
visibility: .internal,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
@@ -526,7 +431,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// This is a comment
|
/// This is a comment
|
||||||
internal var definition_name: String {
|
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")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -535,7 +440,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// This is a comment
|
/// This is a comment
|
||||||
internal func definition_name(arg0: String) -> String {
|
func definition_name(arg0: String) -> String {
|
||||||
String(format: self.definition_name, arg0)
|
String(format: self.definition_name, arg0)
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -553,12 +458,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getNSLocalizedStringProperty(
|
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr")
|
||||||
forLang: "fr",
|
|
||||||
isStatic: false,
|
|
||||||
visibility: .private,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
@@ -567,7 +467,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// This is a comment
|
/// This is a comment
|
||||||
private var definition_name: String {
|
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")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -576,7 +476,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// This is a comment
|
/// This is a comment
|
||||||
private func definition_name(arg0: String, arg1: Int, arg2: Double) -> String {
|
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)
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -595,18 +495,8 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getNSLocalizedStringProperty(
|
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr")
|
||||||
forLang: "fr",
|
let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en")
|
||||||
isStatic: false,
|
|
||||||
visibility: .public,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
let propertyEn = definition.getNSLocalizedStringProperty(
|
|
||||||
forLang: "en",
|
|
||||||
isStatic: false,
|
|
||||||
visibility: .public,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
|
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
/// Translation in fr :
|
/// Translation in fr :
|
||||||
@@ -614,7 +504,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// This is a comment
|
/// This is a comment
|
||||||
public var definition_name: String {
|
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")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -623,7 +513,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// This is a comment
|
/// This is a comment
|
||||||
public func definition_name(arg0: String, arg1: String, arg2: Int) -> String {
|
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)
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -634,7 +524,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// This is a comment
|
/// This is a comment
|
||||||
public var definition_name: String {
|
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")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -643,7 +533,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// This is a comment
|
/// This is a comment
|
||||||
public func definition_name(arg0: String, arg1: String, arg2: Int) -> String {
|
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)
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -666,21 +556,9 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getProperty(
|
let propertyFr = definition.getProperty(forLang: "fr")
|
||||||
forLang: "fr",
|
let propertyEn = definition.getProperty(forLang: "en")
|
||||||
visibility: .public,
|
let propertyEnUs = definition.getProperty(forLang: "en-us")
|
||||||
isStatic: false
|
|
||||||
)
|
|
||||||
let propertyEn = definition.getProperty(
|
|
||||||
forLang: "en",
|
|
||||||
visibility: .public,
|
|
||||||
isStatic: false
|
|
||||||
)
|
|
||||||
let propertyEnUs = definition.getProperty(
|
|
||||||
forLang: "en-us",
|
|
||||||
visibility: .public,
|
|
||||||
isStatic: false
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
@@ -689,7 +567,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// This is a comment
|
/// This is a comment
|
||||||
public var definition_name: String {
|
var definition_name: String {
|
||||||
"C'est la traduction francaise"
|
"C'est la traduction francaise"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -700,7 +578,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// This is a comment
|
/// This is a comment
|
||||||
public var definition_name: String {
|
var definition_name: String {
|
||||||
"This is the english translation"
|
"This is the english translation"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -711,7 +589,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// This is a comment
|
/// This is a comment
|
||||||
public var definition_name: String {
|
var definition_name: String {
|
||||||
"This is the english us translation"
|
"This is the english us translation"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -733,21 +611,9 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getProperty(
|
let propertyFr = definition.getProperty(forLang: "fr")
|
||||||
forLang: "fr",
|
let propertyEn = definition.getProperty(forLang: "en")
|
||||||
visibility: .package,
|
let propertyEnUs = definition.getProperty(forLang: "en-us")
|
||||||
isStatic: false
|
|
||||||
)
|
|
||||||
let propertyEn = definition.getProperty(
|
|
||||||
forLang: "en",
|
|
||||||
visibility: .package,
|
|
||||||
isStatic: false
|
|
||||||
)
|
|
||||||
let propertyEnUs = definition.getProperty(
|
|
||||||
forLang: "en-us",
|
|
||||||
visibility: .package,
|
|
||||||
isStatic: false
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
@@ -756,7 +622,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
package var definition_name: String {
|
var definition_name: String {
|
||||||
"C'est la traduction francaise"
|
"C'est la traduction francaise"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -767,7 +633,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
package var definition_name: String {
|
var definition_name: String {
|
||||||
"This is the english translation"
|
"This is the english translation"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -778,7 +644,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
package var definition_name: String {
|
var definition_name: String {
|
||||||
"This is the english us translation"
|
"This is the english us translation"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -799,21 +665,9 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getProperty(
|
let propertyFr = definition.getProperty(forLang: "fr")
|
||||||
forLang: "fr",
|
let propertyEn = definition.getProperty(forLang: "en")
|
||||||
visibility: .private,
|
let propertyEnUs = definition.getProperty(forLang: "en-us")
|
||||||
isStatic: false
|
|
||||||
)
|
|
||||||
let propertyEn = definition.getProperty(
|
|
||||||
forLang: "en",
|
|
||||||
visibility: .private,
|
|
||||||
isStatic: false
|
|
||||||
)
|
|
||||||
let propertyEnUs = definition.getProperty(
|
|
||||||
forLang: "en-us",
|
|
||||||
visibility: .private,
|
|
||||||
isStatic: false
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
@@ -822,7 +676,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
private var definition_name: String {
|
var definition_name: String {
|
||||||
"C'est la traduction francaise"
|
"C'est la traduction francaise"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -833,7 +687,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
private var definition_name: String {
|
var definition_name: String {
|
||||||
"This is the english translation"
|
"This is the english translation"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -844,7 +698,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
private var definition_name: String {
|
var definition_name: String {
|
||||||
"This is the english us translation"
|
"This is the english us translation"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -868,21 +722,9 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getProperty(
|
let propertyFr = definition.getStaticProperty(forLang: "fr")
|
||||||
forLang: "fr",
|
let propertyEn = definition.getStaticProperty(forLang: "en")
|
||||||
visibility: .internal,
|
let propertyEnUs = definition.getStaticProperty(forLang: "en-us")
|
||||||
isStatic: true
|
|
||||||
)
|
|
||||||
let propertyEn = definition.getProperty(
|
|
||||||
forLang: "en",
|
|
||||||
visibility: .internal,
|
|
||||||
isStatic: true
|
|
||||||
)
|
|
||||||
let propertyEnUs = definition.getProperty(
|
|
||||||
forLang: "en-us",
|
|
||||||
visibility: .internal,
|
|
||||||
isStatic: true
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
@@ -891,7 +733,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// This is a comment
|
/// This is a comment
|
||||||
internal static var definition_name: String {
|
static var definition_name: String {
|
||||||
"C'est la traduction francaise"
|
"C'est la traduction francaise"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -902,7 +744,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// This is a comment
|
/// This is a comment
|
||||||
internal static var definition_name: String {
|
static var definition_name: String {
|
||||||
"This is the english translation"
|
"This is the english translation"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -913,7 +755,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// This is a comment
|
/// This is a comment
|
||||||
internal static var definition_name: String {
|
static var definition_name: String {
|
||||||
"This is the english us translation"
|
"This is the english us translation"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -935,21 +777,9 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getProperty(
|
let propertyFr = definition.getStaticProperty(forLang: "fr")
|
||||||
forLang: "fr",
|
let propertyEn = definition.getStaticProperty(forLang: "en")
|
||||||
visibility: .internal,
|
let propertyEnUs = definition.getStaticProperty(forLang: "en-us")
|
||||||
isStatic: true
|
|
||||||
)
|
|
||||||
let propertyEn = definition.getProperty(
|
|
||||||
forLang: "en",
|
|
||||||
visibility: .internal,
|
|
||||||
isStatic: true
|
|
||||||
)
|
|
||||||
let propertyEnUs = definition.getProperty(
|
|
||||||
forLang: "en-us",
|
|
||||||
visibility: .internal,
|
|
||||||
isStatic: true
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
@@ -958,7 +788,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
internal static var definition_name: String {
|
static var definition_name: String {
|
||||||
"C'est la traduction francaise"
|
"C'est la traduction francaise"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -969,7 +799,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
internal static var definition_name: String {
|
static var definition_name: String {
|
||||||
"This is the english translation"
|
"This is the english translation"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -980,7 +810,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
internal static var definition_name: String {
|
static var definition_name: String {
|
||||||
"This is the english us translation"
|
"This is the english us translation"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -1001,21 +831,9 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getProperty(
|
let propertyFr = definition.getStaticProperty(forLang: "fr")
|
||||||
forLang: "fr",
|
let propertyEn = definition.getStaticProperty(forLang: "en")
|
||||||
visibility: .internal,
|
let propertyEnUs = definition.getStaticProperty(forLang: "en-us")
|
||||||
isStatic: true
|
|
||||||
)
|
|
||||||
let propertyEn = definition.getProperty(
|
|
||||||
forLang: "en",
|
|
||||||
visibility: .internal,
|
|
||||||
isStatic: true
|
|
||||||
)
|
|
||||||
let propertyEnUs = definition.getProperty(
|
|
||||||
forLang: "en-us",
|
|
||||||
visibility: .internal,
|
|
||||||
isStatic: true
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
@@ -1024,7 +842,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
internal static var definition_name: String {
|
static var definition_name: String {
|
||||||
"C'est la traduction francaise"
|
"C'est la traduction francaise"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -1035,7 +853,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
internal static var definition_name: String {
|
static var definition_name: String {
|
||||||
"This is the english translation"
|
"This is the english translation"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -1046,7 +864,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
internal static var definition_name: String {
|
static var definition_name: String {
|
||||||
"This is the english us translation"
|
"This is the english us translation"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
@@ -11,7 +11,7 @@ import ToolCore
|
|||||||
extension StringsFileGeneratorTests {
|
extension StringsFileGeneratorTests {
|
||||||
|
|
||||||
static func getExtensionContentExpectation(
|
static func getExtensionContentExpectation(
|
||||||
isStatic: Bool,
|
staticVar: Bool,
|
||||||
s1DefOneFr: String = "Section Un - Definition Un",
|
s1DefOneFr: String = "Section Un - Definition Un",
|
||||||
s1DefOneComment: String = "",
|
s1DefOneComment: String = "",
|
||||||
s1DefTwoFr: String = "Section Un - Definition Deux",
|
s1DefTwoFr: String = "Section Un - Definition Deux",
|
||||||
@@ -20,8 +20,6 @@ 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,
|
|
||||||
assetBundle: AssetBundle = .main
|
|
||||||
) -> String {
|
) -> String {
|
||||||
"""
|
"""
|
||||||
// Generated by ResgenSwift.Strings.Stringium \(ResgenSwiftVersion)
|
// Generated by ResgenSwift.Strings.Stringium \(ResgenSwiftVersion)
|
||||||
@@ -32,13 +30,13 @@ extension StringsFileGeneratorTests {
|
|||||||
|
|
||||||
extension GenStrings {
|
extension GenStrings {
|
||||||
|
|
||||||
\(visibility) enum KeyStrings: String {
|
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"
|
||||||
|
|
||||||
\(visibility) var keyPath: KeyPath<GenStrings, String> {
|
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
|
||||||
@@ -55,8 +53,8 @@ extension StringsFileGeneratorTests {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// \(s1DefOneComment.isEmpty ? "No comment" : s1DefOneComment)
|
/// \(s1DefOneComment.isEmpty ? "No comment" : s1DefOneComment)
|
||||||
\(visibility) \(isStatic ? "static " : "")var s1_def_one: String {
|
\(staticVar ? "static " : "")var s1_def_one: String {
|
||||||
NSLocalizedString("s1_def_one", tableName: kStringsFileName, bundle: Bundle.\(assetBundle), value: "Section Un - Definition Un", comment: "\(s1DefOneComment)")
|
NSLocalizedString("s1_def_one", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Un - Definition Un", comment: "\(s1DefOneComment)")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Translation in fr :
|
/// Translation in fr :
|
||||||
@@ -64,8 +62,8 @@ extension StringsFileGeneratorTests {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// \(s1DefTwoComment.isEmpty ? "No comment" : s1DefTwoComment)
|
/// \(s1DefTwoComment.isEmpty ? "No comment" : s1DefTwoComment)
|
||||||
\(visibility) \(isStatic ? "static " : "")var s1_def_two: String {
|
\(staticVar ? "static " : "")var s1_def_two: String {
|
||||||
NSLocalizedString("s1_def_two", tableName: kStringsFileName, bundle: Bundle.\(assetBundle), value: "Section Un - Definition Deux", comment: "\(s1DefTwoComment)")
|
NSLocalizedString("s1_def_two", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Un - Definition Deux", comment: "\(s1DefTwoComment)")
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - section_two
|
// MARK: - section_two
|
||||||
@@ -75,8 +73,8 @@ extension StringsFileGeneratorTests {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// \(s2DefOneComment.isEmpty ? "No comment" : s2DefOneComment)
|
/// \(s2DefOneComment.isEmpty ? "No comment" : s2DefOneComment)
|
||||||
\(visibility) \(isStatic ? "static " : "")var s2_def_one: String {
|
\(staticVar ? "static " : "")var s2_def_one: String {
|
||||||
NSLocalizedString("s2_def_one", tableName: kStringsFileName, bundle: Bundle.\(assetBundle), value: "Section Deux - Definition Un", comment: "\(s2DefOneComment)")
|
NSLocalizedString("s2_def_one", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Deux - Definition Un", comment: "\(s2DefOneComment)")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Translation in fr :
|
/// Translation in fr :
|
||||||
@@ -84,8 +82,8 @@ extension StringsFileGeneratorTests {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// \(s2DefTwoComment.isEmpty ? "No comment" : s2DefTwoComment)
|
/// \(s2DefTwoComment.isEmpty ? "No comment" : s2DefTwoComment)
|
||||||
\(visibility) \(isStatic ? "static " : "")var s2_def_two: String {
|
\(staticVar ? "static " : "")var s2_def_two: String {
|
||||||
NSLocalizedString("s2_def_two", tableName: kStringsFileName, bundle: Bundle.\(assetBundle), value: "Section Deux - Definition Deux", comment: "\(s2DefTwoComment)")
|
NSLocalizedString("s2_def_two", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Deux - Definition Deux", comment: "\(s2DefTwoComment)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
@@ -373,21 +373,17 @@ final class StringsFileGeneratorTests: XCTestCase {
|
|||||||
let sectionTwo = Section.Mock.getSectionTwo()
|
let sectionTwo = Section.Mock.getSectionTwo()
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let extensionContent = StringsFileGenerator.getExtensionContent(
|
let extensionContent = StringsFileGenerator.getExtensionContent(sections: [sectionOne, sectionTwo],
|
||||||
sections: [sectionOne, sectionTwo],
|
|
||||||
defaultLang: "fr",
|
defaultLang: "fr",
|
||||||
tags: ["ios", "iosonly", "notranslation"],
|
tags: ["ios", "iosonly", "notranslation"],
|
||||||
isStatic: false,
|
staticVar: false,
|
||||||
inputFilename: "myInputFilename",
|
inputFilename: "myInputFilename",
|
||||||
extensionName: "GenStrings",
|
extensionName: "GenStrings",
|
||||||
extensionSuffix: "strings",
|
extensionSuffix: "strings")
|
||||||
visibility: .internal,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = Self.getExtensionContentExpectation(
|
let expect = Self.getExtensionContentExpectation(
|
||||||
isStatic: false
|
staticVar: false
|
||||||
)
|
)
|
||||||
|
|
||||||
if extensionContent != expect {
|
if extensionContent != expect {
|
||||||
@@ -408,26 +404,21 @@ final class StringsFileGeneratorTests: XCTestCase {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let extensionContent = StringsFileGenerator.getExtensionContent(
|
let extensionContent = StringsFileGenerator.getExtensionContent(sections: [sectionOne, sectionTwo],
|
||||||
sections: [sectionOne, sectionTwo],
|
|
||||||
defaultLang: "fr",
|
defaultLang: "fr",
|
||||||
tags: ["ios", "iosonly", "notranslation"],
|
tags: ["ios", "iosonly", "notranslation"],
|
||||||
isStatic: false,
|
staticVar: false,
|
||||||
inputFilename: "myInputFilename",
|
inputFilename: "myInputFilename",
|
||||||
extensionName: "GenStrings",
|
extensionName: "GenStrings",
|
||||||
extensionSuffix: "strings",
|
extensionSuffix: "strings")
|
||||||
visibility: .public,
|
|
||||||
assetBundle: .main
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = Self.getExtensionContentExpectation(
|
let expect = Self.getExtensionContentExpectation(
|
||||||
isStatic: false,
|
staticVar: false,
|
||||||
s1DefOneComment: "This is a comment",
|
s1DefOneComment: "This is a comment",
|
||||||
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 {
|
||||||
@@ -437,29 +428,23 @@ final class StringsFileGeneratorTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Extension Content Static
|
// MARK: - Extension Content Static
|
||||||
func testGeneratedExtensionContentWithIsStatic() {
|
func testGeneratedExtensionContentWithStaticVar() {
|
||||||
// Given
|
// Given
|
||||||
let sectionOne = Section.Mock.getSectionOne()
|
let sectionOne = Section.Mock.getSectionOne()
|
||||||
let sectionTwo = Section.Mock.getSectionTwo()
|
let sectionTwo = Section.Mock.getSectionTwo()
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let extensionContent = StringsFileGenerator.getExtensionContent(
|
let extensionContent = StringsFileGenerator.getExtensionContent(sections: [sectionOne, sectionTwo],
|
||||||
sections: [sectionOne, sectionTwo],
|
|
||||||
defaultLang: "fr",
|
defaultLang: "fr",
|
||||||
tags: ["ios", "iosonly", "notranslation"],
|
tags: ["ios", "iosonly", "notranslation"],
|
||||||
isStatic: true,
|
staticVar: true,
|
||||||
inputFilename: "myInputFilename",
|
inputFilename: "myInputFilename",
|
||||||
extensionName: "GenStrings",
|
extensionName: "GenStrings",
|
||||||
extensionSuffix: "strings",
|
extensionSuffix: "strings")
|
||||||
visibility: .package,
|
|
||||||
assetBundle: .module
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = Self.getExtensionContentExpectation(
|
let expect = Self.getExtensionContentExpectation(
|
||||||
isStatic: true,
|
staticVar: true
|
||||||
visibility: .package,
|
|
||||||
assetBundle: .module
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if extensionContent != expect {
|
if extensionContent != expect {
|
||||||
@@ -468,7 +453,7 @@ final class StringsFileGeneratorTests: XCTestCase {
|
|||||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
}
|
}
|
||||||
|
|
||||||
func testGeneratedExtensionContentWithIsStaticWithComment() {
|
func testGeneratedExtensionContentWithStaticVarWithComment() {
|
||||||
// Given
|
// Given
|
||||||
let sectionOne = Section.Mock.getSectionOne(
|
let sectionOne = Section.Mock.getSectionOne(
|
||||||
defOneComment: "This is a comment",
|
defOneComment: "This is a comment",
|
||||||
@@ -480,27 +465,21 @@ final class StringsFileGeneratorTests: XCTestCase {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let extensionContent = StringsFileGenerator.getExtensionContent(
|
let extensionContent = StringsFileGenerator.getExtensionContent(sections: [sectionOne, sectionTwo],
|
||||||
sections: [sectionOne, sectionTwo],
|
|
||||||
defaultLang: "fr",
|
defaultLang: "fr",
|
||||||
tags: ["ios", "iosonly", "notranslation"],
|
tags: ["ios", "iosonly", "notranslation"],
|
||||||
isStatic: true,
|
staticVar: true,
|
||||||
inputFilename: "myInputFilename",
|
inputFilename: "myInputFilename",
|
||||||
extensionName: "GenStrings",
|
extensionName: "GenStrings",
|
||||||
extensionSuffix: "strings",
|
extensionSuffix: "strings")
|
||||||
visibility: .internal,
|
|
||||||
assetBundle: .module
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = Self.getExtensionContentExpectation(
|
let expect = Self.getExtensionContentExpectation(
|
||||||
isStatic: true,
|
staticVar: true,
|
||||||
s1DefOneComment: "This is a comment",
|
s1DefOneComment: "This is a comment",
|
||||||
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,
|
|
||||||
assetBundle: .module
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if extensionContent != expect {
|
if extensionContent != expect {
|
||||||
|
@@ -13,11 +13,7 @@ import ToolCore
|
|||||||
|
|
||||||
final class TagsGeneratorTests: XCTestCase {
|
final class TagsGeneratorTests: XCTestCase {
|
||||||
|
|
||||||
private func getDefinition(
|
private func getDefinition(name: String, lang: String, tags: [String]) -> Definition {
|
||||||
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"]
|
||||||
@@ -45,15 +41,11 @@ final class TagsGeneratorTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let extensionContent = TagsGenerator.getExtensionContent(
|
let extensionContent = TagsGenerator.getExtensionContent(sections: [sectionOne, sectionTwo, sectionThree],
|
||||||
sections: [sectionOne, sectionTwo, sectionThree],
|
|
||||||
lang: "ium",
|
lang: "ium",
|
||||||
tags: ["ios", "iosonly"],
|
tags: ["ios", "iosonly"],
|
||||||
isStatic: false,
|
staticVar: false,
|
||||||
extensionName: "GenTags",
|
extensionName: "GenTags")
|
||||||
visibility: .public
|
|
||||||
)
|
|
||||||
|
|
||||||
// Expect Tags
|
// Expect Tags
|
||||||
let expect = """
|
let expect = """
|
||||||
// Generated by ResgenSwift.Strings.Tags \(ResgenSwiftVersion)
|
// Generated by ResgenSwift.Strings.Tags \(ResgenSwiftVersion)
|
||||||
@@ -68,7 +60,7 @@ final class TagsGeneratorTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
public var s1_def_one: String {
|
var s1_def_one: String {
|
||||||
"Some translation"
|
"Some translation"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +69,7 @@ final class TagsGeneratorTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
public var s1_def_two: String {
|
var s1_def_two: String {
|
||||||
"Some translation"
|
"Some translation"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +80,7 @@ final class TagsGeneratorTests: XCTestCase {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// No comment
|
/// No comment
|
||||||
public var s2_def_one: String {
|
var s2_def_one: String {
|
||||||
"Some translation"
|
"Some translation"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user