Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
7d6bb4fcb9 | |||
844a8aec45 | |||
beb28e652d | |||
78be15d57d | |||
d6c4702390 | |||
1e073af5df | |||
188178fe6a | |||
c31d0b1618 | |||
b662fc64f3 | |||
9ab7e74991 | |||
fc427733ee | |||
5a3d273acc | |||
a7a850799d | |||
7d3652f1f9 | |||
41733d2680 |
@ -102,6 +102,20 @@
|
|||||||
ReferencedContainer = "container:">
|
ReferencedContainer = "container:">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
</BuildableProductRunnable>
|
</BuildableProductRunnable>
|
||||||
|
<CommandLineArguments>
|
||||||
|
<CommandLineArgument
|
||||||
|
argument = "generate"
|
||||||
|
isEnabled = "YES">
|
||||||
|
</CommandLineArgument>
|
||||||
|
<CommandLineArgument
|
||||||
|
argument = ""$(PROJECT_DIR)/../SampleFiles/resgenConfiguration.yml""
|
||||||
|
isEnabled = "YES">
|
||||||
|
</CommandLineArgument>
|
||||||
|
<CommandLineArgument
|
||||||
|
argument = "--project-directory "$(PROJECT_DIR)""
|
||||||
|
isEnabled = "YES">
|
||||||
|
</CommandLineArgument>
|
||||||
|
</CommandLineArguments>
|
||||||
</LaunchAction>
|
</LaunchAction>
|
||||||
<ProfileAction
|
<ProfileAction
|
||||||
buildConfiguration = "Release"
|
buildConfiguration = "Release"
|
||||||
|
34
CHANGELOG.md
34
CHANGELOG.md
@ -0,0 +1,34 @@
|
|||||||
|
# v1.2 - Architecture generation
|
||||||
|
|
||||||
|
## New
|
||||||
|
- New section in configuration file: `architecture`. Define your ressources accessors achitecture and let ResgenSwift generate it for you. Check out Readme to know more.
|
||||||
|
|
||||||
|
## Fixes
|
||||||
|
- Errors and Warnings are now shown in Xcode Issue Navigator
|
||||||
|
|
||||||
|
---
|
||||||
|
# v1.1 - SwiftUI compatibility
|
||||||
|
|
||||||
|
## New
|
||||||
|
- Update plist `UIAppFonts` when generated fonts (use plistBuddy)
|
||||||
|
- New parameter: `infoPlistPaths`
|
||||||
|
- Generate SwiftUI extensions for colors, fonts and images
|
||||||
|
- New parameter: `extensionNameSwiftUI`
|
||||||
|
- Adding Makefile to install, unsintall and create man page.
|
||||||
|
|
||||||
|
## Fixes
|
||||||
|
Fix SwiftLint rule `trailing_newline`
|
||||||
|
|
||||||
|
---
|
||||||
|
# v1.0 - Configuration file
|
||||||
|
|
||||||
|
## Major
|
||||||
|
- A new command has been added: `generate`. Instead of runnning every single command, it will run all necessary command based on a `yaml` configuration file. Check out Readme to know more.
|
||||||
|
|
||||||
|
## Minors
|
||||||
|
- Code refactoring
|
||||||
|
- Huge performance improvements
|
||||||
|
- Readme.md update
|
||||||
|
- Add option to generate static properties/methods (`staticMembers`)
|
||||||
|
- Add option to specify the project directory (`--project-directory`). It allows to run ResgenSwift from anywhere
|
||||||
|
- Add `install.sh` script to install ResgenSwift in `/usr/local/bin`
|
||||||
|
2
Jenkinsfile
vendored
2
Jenkinsfile
vendored
@ -1,6 +1,6 @@
|
|||||||
library "openiumpipeline"
|
library "openiumpipeline"
|
||||||
|
|
||||||
env.DEVELOPER_DIR="/Applications/Xcode_13.3.0.app/Contents/Developer"
|
env.DEVELOPER_DIR= "/Applications/Xcode-14.3.0.app/Contents/Developer"
|
||||||
//env.SIMULATOR_DEVICE_TYPES="iPad--7th-generation-"
|
//env.SIMULATOR_DEVICE_TYPES="iPad--7th-generation-"
|
||||||
env.IS_PACKAGE_SWIFT=1
|
env.IS_PACKAGE_SWIFT=1
|
||||||
env.TARGETS_MACOS=1
|
env.TARGETS_MACOS=1
|
||||||
|
63
Makefile
Normal file
63
Makefile
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
SHELL = /bin/zsh
|
||||||
|
|
||||||
|
#INSTALL_DIR ?= /usr/local/bin
|
||||||
|
INSTALL_DIR = /tmp/ResgenYolo
|
||||||
|
|
||||||
|
MAN_DIR := /usr/local/share/man
|
||||||
|
MAN_PAGE_NAME = resgen-swift.1
|
||||||
|
REPO_DIR = $(shell pwd)
|
||||||
|
BUILD_DIR = $(REPO_DIR)/.build
|
||||||
|
|
||||||
|
#
|
||||||
|
# Man pages
|
||||||
|
#
|
||||||
|
|
||||||
|
# create-man-files:
|
||||||
|
# swift package plugin generate-manual
|
||||||
|
# cp $(BUILDDIR)/plugins/GenerateManualPlugin/outputs/ResgenSwift/resgen-swift.1 $(REPODIR)/man/resgen-swift.1
|
||||||
|
|
||||||
|
# install-man-files:
|
||||||
|
# mkdir -p ${DESTDIR}${mandir}/man1
|
||||||
|
# cp $(REPODIR)/man/resgen-swift.1 ${DESTDIR}${mandir}/man1/resgen-swift.1
|
||||||
|
|
||||||
|
create-and-install-man-files:
|
||||||
|
swift package plugin generate-manual
|
||||||
|
mkdir -p ${MAN_DIR}/man1
|
||||||
|
cp $(BUILD_DIR)/plugins/GenerateManualPlugin/outputs/ResgenSwift/${MAN_PAGE_NAME} ${MAN_DIR}/man1/${MAN_PAGE_NAME}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Build and install
|
||||||
|
#
|
||||||
|
|
||||||
|
build-debug:
|
||||||
|
@swift build \
|
||||||
|
-c debug \
|
||||||
|
--build-path "$(BUILD_DIR)"
|
||||||
|
|
||||||
|
build-release:
|
||||||
|
@swift build \
|
||||||
|
-c release \
|
||||||
|
--build-path "$(BUILD_DIR)"
|
||||||
|
|
||||||
|
.PHONY: install
|
||||||
|
install: build-release
|
||||||
|
@install -d "$(INSTALL_DIR)"
|
||||||
|
@install "$(wildcard $(BUILD_DIR)/**/release/ResgenSwift)" "$(INSTALL_DIR)/resgen-swift"
|
||||||
|
@make create-and-install-man-files
|
||||||
|
|
||||||
|
#
|
||||||
|
# Uninstall and cleaning
|
||||||
|
#
|
||||||
|
|
||||||
|
.PHONY: uninstall
|
||||||
|
uninstall:
|
||||||
|
@rm -rf "$(INSTALL_DIR)/resgen-swift"
|
||||||
|
@rm -rf ${MAN_DIR}/man1/${MAN_PAGE_NAME}
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
distclean:
|
||||||
|
@rm -f $(BUILD_DIR)/release
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean: distclean
|
||||||
|
@rm -rf $(BUILD_DIR)
|
@ -1,25 +1,23 @@
|
|||||||
{
|
{
|
||||||
"object": {
|
"pins" : [
|
||||||
"pins": [
|
{
|
||||||
{
|
"identity" : "swift-argument-parser",
|
||||||
"package": "swift-argument-parser",
|
"kind" : "remoteSourceControl",
|
||||||
"repositoryURL": "https://github.com/apple/swift-argument-parser",
|
"location" : "https://github.com/apple/swift-argument-parser",
|
||||||
"state": {
|
"state" : {
|
||||||
"branch": null,
|
"revision" : "9f39744e025c7d377987f30b03770805dcb0bcd1",
|
||||||
"revision": "e1465042f195f374b94f915ba8ca49de24300a0d",
|
"version" : "1.1.4"
|
||||||
"version": "1.0.2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"package": "Yams",
|
|
||||||
"repositoryURL": "https://github.com/jpsim/Yams.git",
|
|
||||||
"state": {
|
|
||||||
"branch": null,
|
|
||||||
"revision": "01835dc202670b5bb90d07f3eae41867e9ed29f6",
|
|
||||||
"version": "5.0.1"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
},
|
||||||
},
|
{
|
||||||
"version": 1
|
"identity" : "yams",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/jpsim/Yams.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "01835dc202670b5bb90d07f3eae41867e9ed29f6",
|
||||||
|
"version" : "5.0.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version" : 2
|
||||||
}
|
}
|
||||||
|
118
README.md
118
README.md
@ -6,8 +6,9 @@ ResgenSwift is a package, fully written in Swift, to help you automatize ressour
|
|||||||
|
|
||||||
## Fonts
|
## Fonts
|
||||||
|
|
||||||
Font generator generates an extension of `UIFont` (or a custom class). It also prints `UIAppFonts` to put in your project `.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`.
|
|
||||||
|
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`.
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
@ -15,8 +16,10 @@ iOS required to use the **real name** of the font, this name can be different fr
|
|||||||
swift run -c release ResgenSwift fonts $FORCE_FLAG "./Fonts/fonts.txt" \
|
swift run -c release ResgenSwift fonts $FORCE_FLAG "./Fonts/fonts.txt" \
|
||||||
--extension-output-path "./Fonts/Generated" \
|
--extension-output-path "./Fonts/Generated" \
|
||||||
--extension-name "AppFont" \
|
--extension-name "AppFont" \
|
||||||
|
--extension-name-swift-ui "SUIAppFont" \
|
||||||
--extension-suffix "GreatApp" \
|
--extension-suffix "GreatApp" \
|
||||||
--static-members true
|
--static-members true \
|
||||||
|
--info-plist-paths "./path/one/to/Info.plist ./path/two/to/Info.plist"
|
||||||
```
|
```
|
||||||
|
|
||||||
**Parameters**
|
**Parameters**
|
||||||
@ -24,9 +27,11 @@ swift run -c release ResgenSwift fonts $FORCE_FLAG "./Fonts/fonts.txt" \
|
|||||||
1. `-f`: force generation
|
1. `-f`: force generation
|
||||||
2. Font input folder, it will search for every `.ttf` and `.otf` files specified in `fonts.txt`
|
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
|
3. `--extension-output-path`: path where to generate generated extension
|
||||||
4. `--extension-name` *(optional)* : name of thee class to add the extension
|
4. `--extension-name` *(optional)* : name of the class to add UIKit getters
|
||||||
5. `--extension-suffix` *(optional)* : additional text which is added to the filename (ex: `AppFont+GreatApp.swift`)
|
5. `--extension-name-swift-ui` *(optional)* : name of the class to add SwiftUI getters
|
||||||
6. `--static-members` *(optional)*: generate static properties or not
|
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
|
||||||
@ -39,6 +44,7 @@ swift run -c release ResgenSwift colors $FORCE_FLAG "./Colors/colors.txt" \
|
|||||||
--xcassets-path "./Colors/colors.xcassets" \
|
--xcassets-path "./Colors/colors.xcassets" \
|
||||||
--extension-output-path "./Colors/Generated/" \
|
--extension-output-path "./Colors/Generated/" \
|
||||||
--extension-name "AppColor" \
|
--extension-name "AppColor" \
|
||||||
|
--extension-name-swift-ui "SUIAppColor" \
|
||||||
--extension-suffix "GreatApp" \
|
--extension-suffix "GreatApp" \
|
||||||
--static-members true
|
--static-members true
|
||||||
```
|
```
|
||||||
@ -49,9 +55,10 @@ swift run -c release ResgenSwift colors $FORCE_FLAG "./Colors/colors.txt" \
|
|||||||
2. Input colors file
|
2. Input colors file
|
||||||
3. `--style` can be `all` or `light`
|
3. `--style` can be `all` or `light`
|
||||||
4. `--extension-output-path`: path where to generate generated extension
|
4. `--extension-output-path`: path where to generate generated extension
|
||||||
5. `--extension-name` *(optional)* : name of class to add the extension
|
5. `--extension-name` *(optional)* : name of the class to add UIKit getters
|
||||||
6. `--extension-suffix` *(optional)* : additional text which is added to filename (ex: `AppColor+GreatApp.swift`)
|
6. `--extension-name-swift-ui` *(optional)* : name of the class to add SwiftUI getters
|
||||||
7. `--static-members` *(optional)*: generate static properties or not
|
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
|
||||||
@ -135,6 +142,7 @@ swift run -c release ResgenSwift images $FORCE_FLAG "./Images/images.txt" \
|
|||||||
--xcassets-path "./Images/app.xcassets" \
|
--xcassets-path "./Images/app.xcassets" \
|
||||||
--extension-output-path "./Images/Generated" \
|
--extension-output-path "./Images/Generated" \
|
||||||
--extension-name "AppImage" \
|
--extension-name "AppImage" \
|
||||||
|
--extension-name-swift-ui "SUIAppImage" \
|
||||||
--extension-suffix "GreatApp" \
|
--extension-suffix "GreatApp" \
|
||||||
--static-members true
|
--static-members true
|
||||||
```
|
```
|
||||||
@ -145,7 +153,8 @@ swift run -c release ResgenSwift images $FORCE_FLAG "./Images/images.txt" \
|
|||||||
2. Input images definitions file
|
2. Input images definitions file
|
||||||
3. `--xcassets-path`: xcasset path where to generate imagesets
|
3. `--xcassets-path`: xcasset path where to generate imagesets
|
||||||
4. `--extension-output-path`: path where to generate generated extension
|
4. `--extension-output-path`: path where to generate generated extension
|
||||||
5. `--extension-name` *(optional)* : name of class to add the extension
|
5. `--extension-name` *(optional)* : name of the class to add UIKit getters
|
||||||
|
6. `--extension-name-swift-ui` *(optional)* : name of the class to add SwiftUI getters
|
||||||
6. `--extension-suffix` *(optional)* : additional text which is added to filename (ex: `AppImage+GreatApp.swift`)
|
6. `--extension-suffix` *(optional)* : additional text which is added to filename (ex: `AppImage+GreatApp.swift`)
|
||||||
7. `--static-members` *(optional)*: generate static properties or not
|
7. `--static-members` *(optional)*: generate static properties or not
|
||||||
|
|
||||||
@ -167,6 +176,7 @@ colors:
|
|||||||
xcassetsPath: String
|
xcassetsPath: String
|
||||||
extensionOutputPath: String
|
extensionOutputPath: String
|
||||||
extensionName: String?
|
extensionName: String?
|
||||||
|
extensionNameSwiftUI: String?
|
||||||
extensionSuffix: String?
|
extensionSuffix: String?
|
||||||
staticMembers: Bool?
|
staticMembers: Bool?
|
||||||
|
|
||||||
@ -175,15 +185,18 @@ fonts:
|
|||||||
inputFile: String
|
inputFile: String
|
||||||
extensionOutputPath: String
|
extensionOutputPath: String
|
||||||
extensionName: String?
|
extensionName: String?
|
||||||
|
extensionNameSwiftUI: String?
|
||||||
extensionSuffix: String?
|
extensionSuffix: String?
|
||||||
staticMembers: Bool?
|
staticMembers: Bool?
|
||||||
|
infoPlistPaths: [String]
|
||||||
|
|
||||||
images:
|
images:
|
||||||
-
|
-
|
||||||
inputFile: String
|
inputFile: String
|
||||||
xcassetsPath: String
|
xcassetsPath: String
|
||||||
extensionOutputPath: String
|
extensionOutputPath: String
|
||||||
extensionName: String?
|
extensionName: String?
|
||||||
|
extensionNameSwiftUI: String?
|
||||||
extensionSuffix: String?
|
extensionSuffix: String?
|
||||||
staticMembers: Bool?
|
staticMembers: Bool?
|
||||||
|
|
||||||
@ -223,6 +236,7 @@ colors:
|
|||||||
xcassetsPath: String
|
xcassetsPath: String
|
||||||
extensionOutputPath: String
|
extensionOutputPath: String
|
||||||
extensionName: String?
|
extensionName: String?
|
||||||
|
extensionNameSwiftUI: String?
|
||||||
extensionSuffix: String?
|
extensionSuffix: String?
|
||||||
staticMembers: Bool?
|
staticMembers: Bool?
|
||||||
-
|
-
|
||||||
@ -231,6 +245,7 @@ colors:
|
|||||||
xcassetsPath: String
|
xcassetsPath: String
|
||||||
extensionOutputPath: String
|
extensionOutputPath: String
|
||||||
extensionName: String?
|
extensionName: String?
|
||||||
|
extensionNameSwiftUI: String?
|
||||||
extensionSuffix: String?
|
extensionSuffix: String?
|
||||||
staticMembers: Bool?
|
staticMembers: Bool?
|
||||||
...
|
...
|
||||||
@ -246,6 +261,67 @@ tags: []
|
|||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### File architecture
|
||||||
|
|
||||||
|
ResgenSwift generate extension of classes. Those classes must exists in your project. You can create them yourself OR you can let ResgenSwift create them by specifying what you want. Do as follow:
|
||||||
|
|
||||||
|
```
|
||||||
|
architecture:
|
||||||
|
property: R *(required but not used)*
|
||||||
|
classname: R
|
||||||
|
path: ./path/to/generate
|
||||||
|
children:
|
||||||
|
- property: images
|
||||||
|
classname: R2Image
|
||||||
|
- property: strings
|
||||||
|
classname: R2String
|
||||||
|
- property: fonts
|
||||||
|
classname: R2Font
|
||||||
|
- property: images
|
||||||
|
classname: R2Image
|
||||||
|
- property: uikit
|
||||||
|
classname: R2UI
|
||||||
|
children:
|
||||||
|
- property: images
|
||||||
|
classname: R2UIImage
|
||||||
|
- property: fonts
|
||||||
|
classname: R2UIFont
|
||||||
|
- property: images
|
||||||
|
classname: R2UIImage
|
||||||
|
```
|
||||||
|
|
||||||
|
This will generate a file named as the architecture classname: `R.swift`. Based on the previous architecture, it will generate:
|
||||||
|
```
|
||||||
|
class R {
|
||||||
|
static let images = R2Image()
|
||||||
|
static let strings = R2String()
|
||||||
|
static let fonts = R2Font()
|
||||||
|
static let images = R2Image()
|
||||||
|
static let uikit = R2UI()
|
||||||
|
}
|
||||||
|
|
||||||
|
class R2Image {}
|
||||||
|
|
||||||
|
class R2String {}
|
||||||
|
|
||||||
|
class R2Font {}
|
||||||
|
|
||||||
|
class R2Image {}
|
||||||
|
|
||||||
|
class R2UI {
|
||||||
|
let images = R2UIImage()
|
||||||
|
let fonts = R2UIFont()
|
||||||
|
let images = R2UIImage()
|
||||||
|
}
|
||||||
|
|
||||||
|
class R2UIImage {}
|
||||||
|
|
||||||
|
class R2UIFont {}
|
||||||
|
|
||||||
|
class R2UIImage {}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
@ -255,12 +331,22 @@ swift run -c release ResgenSwift generate path/to/configuration.yml --project-di
|
|||||||
> ⚠️ Every path in `configuration.yml` will be prepended by content of `--project-directory` if they are relative path (not starting with `/`)
|
> ⚠️ Every path in `configuration.yml` will be prepended by content of `--project-directory` if they are relative path (not starting with `/`)
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
## Binary usage
|
||||||
|
|
||||||
Simple run `./install.sh`. Binary will be install in `/usr/local/bin`. Then, use ResgenSwift like any other command:
|
### Installation
|
||||||
|
|
||||||
Example:
|
Run `make install`. Binary will be install in `/usr/local/bin`.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
ResgenSwift generate path/to/configuration.yml --project-directory ${PROJECT_DIR}
|
resgen-swift generate path/to/configuration.yml --project-directory ${PROJECT_DIR}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Man page
|
||||||
|
|
||||||
|
Commands parameters and details can be find by running `resgen-swift --help`. If you prefer, a man page is also available. Run `man resgen-swift`. Man page is installed on `make install` but you can install manually by running `make create-and-install-man-file`.
|
||||||
|
|
||||||
|
### Uninstallation
|
||||||
|
|
||||||
|
To uninstall ResgenSwift: `make uninstall`.
|
||||||
|
21
SampleFiles/Colors/Generated/ColorYolo+GenAllScript.swift
Normal file
21
SampleFiles/Colors/Generated/ColorYolo+GenAllScript.swift
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// Generated by ResgenSwift.Color 1.2
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
extension ColorYolo {
|
||||||
|
|
||||||
|
/// Color red is #FF0000 (light) or #FF0000 (dark)"
|
||||||
|
var red: Color {
|
||||||
|
Color("red")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Color green_alpha_50 is #A000FF00 (light) or #A000FF00 (dark)"
|
||||||
|
var green_alpha_50: Color {
|
||||||
|
Color("green_alpha_50")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Color blue_light_dark is #0000FF (light) or #0000AA (dark)"
|
||||||
|
var blue_light_dark: Color {
|
||||||
|
Color("blue_light_dark")
|
||||||
|
}
|
||||||
|
}
|
@ -1,21 +0,0 @@
|
|||||||
// Generated from ColorToolCore at 2021-12-20 15:16:18 +0000
|
|
||||||
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
extension UIColor {
|
|
||||||
|
|
||||||
/// Color red is #FF0000 (light) or #FF0000 (dark)"
|
|
||||||
static var red: UIColor {
|
|
||||||
UIColor(named: "red")!
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Color green_alpha_50 is #A000FF00 (light) or #A000FF00 (dark)"
|
|
||||||
static var green_alpha_50: UIColor {
|
|
||||||
UIColor(named: "green_alpha_50")!
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Color blue_light_dark is #0000FF (light) or #0000AA (dark)"
|
|
||||||
static var blue_light_dark: UIColor {
|
|
||||||
UIColor(named: "blue_light_dark")!
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
// Generated from ColorToolCore at 2022-02-14 09:30:19 +0000
|
|
||||||
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
extension UIColor {
|
|
||||||
|
|
||||||
/// Color red is #FF0000 (light) or #FF0000 (dark)"
|
|
||||||
static var red: UIColor {
|
|
||||||
UIColor(named: "red")!
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Color green_alpha_50 is #A000FF00 (light) or #A000FF00 (dark)"
|
|
||||||
static var green_alpha_50: UIColor {
|
|
||||||
UIColor(named: "green_alpha_50")!
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Color blue_light_dark is #0000FF (light) or #0000AA (dark)"
|
|
||||||
static var blue_light_dark: UIColor {
|
|
||||||
UIColor(named: "blue_light_dark")!
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
// Generated from ColorToolCore at 2021-12-20 15:17:10 +0000
|
|
||||||
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
extension UIColor {
|
|
||||||
|
|
||||||
/// Color red is #FF0000 (light) or #FF0000 (dark)"
|
|
||||||
static var red: UIColor {
|
|
||||||
UIColor(named: "red")!
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Color green_alpha_50 is #A000FF00 (light) or #A000FF00 (dark)"
|
|
||||||
static var green_alpha_50: UIColor {
|
|
||||||
UIColor(named: "green_alpha_50")!
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Color blue_light_dark is #0000FF (light) or #0000AA (dark)"
|
|
||||||
static var blue_light_dark: UIColor {
|
|
||||||
UIColor(named: "blue_light_dark")!
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
// Generated by ResgenSwift.ColorTool 1.0.0
|
|
||||||
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
extension UIColor {
|
|
||||||
|
|
||||||
/// Color red is #FF0000 (light) or #FF0000 (dark)"
|
|
||||||
static var red: UIColor {
|
|
||||||
UIColor(named: "red")!
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Color green_alpha_50 is #A000FF00 (light) or #A000FF00 (dark)"
|
|
||||||
static var green_alpha_50: UIColor {
|
|
||||||
UIColor(named: "green_alpha_50")!
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Color blue_light_dark is #0000FF (light) or #0000AA (dark)"
|
|
||||||
static var blue_light_dark: UIColor {
|
|
||||||
UIColor(named: "blue_light_dark")!
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +1,8 @@
|
|||||||
// Generated from ColorToolCore at 2021-12-20 15:34:55 +0000
|
// Generated by ResgenSwift.Color 1.2
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
extension R2Color {
|
extension UIColorYolo {
|
||||||
|
|
||||||
/// Color red is #FF0000 (light) or #FF0000 (dark)"
|
/// Color red is #FF0000 (light) or #FF0000 (dark)"
|
||||||
@objc var red: UIColor {
|
@objc var red: UIColor {
|
||||||
@ -14,8 +14,8 @@ extension R2Color {
|
|||||||
UIColor(named: "green_alpha_50")!
|
UIColor(named: "green_alpha_50")!
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Color blue_light_dark is #0000FF (light) or #0000FF (dark)"
|
/// Color blue_light_dark is #0000FF (light) or #0000AA (dark)"
|
||||||
@objc var blue_light_dark: UIColor {
|
@objc var blue_light_dark: UIColor {
|
||||||
UIColor(named: "blue_light_dark")!
|
UIColor(named: "blue_light_dark")!
|
||||||
}
|
}
|
||||||
}
|
}
|
61
SampleFiles/Fonts/Generated/FontYolo+GenAllScript.swift
Normal file
61
SampleFiles/Fonts/Generated/FontYolo+GenAllScript.swift
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
// Generated by ResgenSwift.Fonts 1.2
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
extension FontYolo {
|
||||||
|
|
||||||
|
enum FontName: String {
|
||||||
|
case LatoItalic = "Lato-Italic"
|
||||||
|
case LatoLightItalic = "Lato-LightItalic"
|
||||||
|
case LatoHairline = "Lato-Hairline"
|
||||||
|
case LatoBold = "Lato-Bold"
|
||||||
|
case LatoBlack = "Lato-Black"
|
||||||
|
case LatoRegular = "Lato-Regular"
|
||||||
|
case LatoBlackItalic = "Lato-BlackItalic"
|
||||||
|
case LatoBoldItalic = "Lato-BoldItalic"
|
||||||
|
case LatoLight = "Lato-Light"
|
||||||
|
case LatoHairlineItalic = "Lato-HairlineItalic"
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Getter
|
||||||
|
|
||||||
|
func LatoItalic(withSize size: CGFloat) -> Font {
|
||||||
|
Font.custom(FontName.LatoItalic.rawValue, size: size)
|
||||||
|
}
|
||||||
|
|
||||||
|
func LatoLightItalic(withSize size: CGFloat) -> Font {
|
||||||
|
Font.custom(FontName.LatoLightItalic.rawValue, size: size)
|
||||||
|
}
|
||||||
|
|
||||||
|
func LatoHairline(withSize size: CGFloat) -> Font {
|
||||||
|
Font.custom(FontName.LatoHairline.rawValue, size: size)
|
||||||
|
}
|
||||||
|
|
||||||
|
func LatoBold(withSize size: CGFloat) -> Font {
|
||||||
|
Font.custom(FontName.LatoBold.rawValue, size: size)
|
||||||
|
}
|
||||||
|
|
||||||
|
func LatoBlack(withSize size: CGFloat) -> Font {
|
||||||
|
Font.custom(FontName.LatoBlack.rawValue, size: size)
|
||||||
|
}
|
||||||
|
|
||||||
|
func LatoRegular(withSize size: CGFloat) -> Font {
|
||||||
|
Font.custom(FontName.LatoRegular.rawValue, size: size)
|
||||||
|
}
|
||||||
|
|
||||||
|
func LatoBlackItalic(withSize size: CGFloat) -> Font {
|
||||||
|
Font.custom(FontName.LatoBlackItalic.rawValue, size: size)
|
||||||
|
}
|
||||||
|
|
||||||
|
func LatoBoldItalic(withSize size: CGFloat) -> Font {
|
||||||
|
Font.custom(FontName.LatoBoldItalic.rawValue, size: size)
|
||||||
|
}
|
||||||
|
|
||||||
|
func LatoLight(withSize size: CGFloat) -> Font {
|
||||||
|
Font.custom(FontName.LatoLight.rawValue, size: size)
|
||||||
|
}
|
||||||
|
|
||||||
|
func LatoHairlineItalic(withSize size: CGFloat) -> Font {
|
||||||
|
Font.custom(FontName.LatoHairlineItalic.rawValue, size: size)
|
||||||
|
}
|
||||||
|
}
|
@ -1,62 +0,0 @@
|
|||||||
// Generated from FontToolCore
|
|
||||||
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
extension R2Font {
|
|
||||||
|
|
||||||
enum FontName: String {
|
|
||||||
case LatoItalic = "Lato-Italic"
|
|
||||||
case LatoLightItalic = "Lato-LightItalic"
|
|
||||||
case LatoHairline = "Lato-Hairline"
|
|
||||||
case LatoBold = "Lato-Bold"
|
|
||||||
case LatoBlack = "Lato-Black"
|
|
||||||
case LatoRegular = "Lato-Regular"
|
|
||||||
case LatoBlackItalic = "Lato-BlackItalic"
|
|
||||||
case LatoBoldItalic = "Lato-BoldItalic"
|
|
||||||
case LatoLight = "Lato-Light"
|
|
||||||
case LatoHairlineItalic = "Lato-HairlineItalic"
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - Getter
|
|
||||||
|
|
||||||
func LatoItalic(withSize size: CGFloat) -> UIFont {
|
|
||||||
UIFont(name: FontName.LatoItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
func LatoLightItalic(withSize size: CGFloat) -> UIFont {
|
|
||||||
UIFont(name: FontName.LatoLightItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
func LatoHairline(withSize size: CGFloat) -> UIFont {
|
|
||||||
UIFont(name: FontName.LatoHairline.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
func LatoBold(withSize size: CGFloat) -> UIFont {
|
|
||||||
UIFont(name: FontName.LatoBold.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
func LatoBlack(withSize size: CGFloat) -> UIFont {
|
|
||||||
UIFont(name: FontName.LatoBlack.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
func LatoRegular(withSize size: CGFloat) -> UIFont {
|
|
||||||
UIFont(name: FontName.LatoRegular.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
func LatoBlackItalic(withSize size: CGFloat) -> UIFont {
|
|
||||||
UIFont(name: FontName.LatoBlackItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
func LatoBoldItalic(withSize size: CGFloat) -> UIFont {
|
|
||||||
UIFont(name: FontName.LatoBoldItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
func LatoLight(withSize size: CGFloat) -> UIFont {
|
|
||||||
UIFont(name: FontName.LatoLight.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
func LatoHairlineItalic(withSize size: CGFloat) -> UIFont {
|
|
||||||
UIFont(name: FontName.LatoHairlineItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
// Generated from FontToolCore
|
|
||||||
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
extension R2Font {
|
|
||||||
|
|
||||||
enum FontName: String {
|
|
||||||
case LatoItalic = "Lato-Italic"
|
|
||||||
case LatoLightItalic = "Lato-LightItalic"
|
|
||||||
case LatoHairline = "Lato-Hairline"
|
|
||||||
case LatoBold = "Lato-Bold"
|
|
||||||
case LatoBlack = "Lato-Black"
|
|
||||||
case LatoRegular = "Lato-Regular"
|
|
||||||
case LatoBlackItalic = "Lato-BlackItalic"
|
|
||||||
case LatoBoldItalic = "Lato-BoldItalic"
|
|
||||||
case LatoLight = "Lato-Light"
|
|
||||||
case LatoHairlineItalic = "Lato-HairlineItalic"
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - Getter
|
|
||||||
|
|
||||||
func LatoItalic(withSize size: CGFloat) -> UIFont {
|
|
||||||
UIFont(name: FontName.LatoItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
func LatoLightItalic(withSize size: CGFloat) -> UIFont {
|
|
||||||
UIFont(name: FontName.LatoLightItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
func LatoHairline(withSize size: CGFloat) -> UIFont {
|
|
||||||
UIFont(name: FontName.LatoHairline.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
func LatoBold(withSize size: CGFloat) -> UIFont {
|
|
||||||
UIFont(name: FontName.LatoBold.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
func LatoBlack(withSize size: CGFloat) -> UIFont {
|
|
||||||
UIFont(name: FontName.LatoBlack.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
func LatoRegular(withSize size: CGFloat) -> UIFont {
|
|
||||||
UIFont(name: FontName.LatoRegular.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
func LatoBlackItalic(withSize size: CGFloat) -> UIFont {
|
|
||||||
UIFont(name: FontName.LatoBlackItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
func LatoBoldItalic(withSize size: CGFloat) -> UIFont {
|
|
||||||
UIFont(name: FontName.LatoBoldItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
func LatoLight(withSize size: CGFloat) -> UIFont {
|
|
||||||
UIFont(name: FontName.LatoLight.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
func LatoHairlineItalic(withSize size: CGFloat) -> UIFont {
|
|
||||||
UIFont(name: FontName.LatoHairlineItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
// Lato/Lato-Italic.ttf Lato/Lato-LightItalic.ttf Lato/Lato-Thin.ttf Lato/Lato-Bold.ttf Lato/Lato-Black.ttf Lato/Lato-Regular.ttf Lato/Lato-BlackItalic.ttf Lato/Lato-BoldItalic.ttf Lato/Lato-Light.ttf Lato/Lato-ThinItalic.ttf
|
|
||||||
// Generated from FontToolCore
|
|
||||||
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
extension UIFont {
|
|
||||||
|
|
||||||
enum FontName: String {
|
|
||||||
case LatoItalic = "Lato-Italic"
|
|
||||||
case LatoLightItalic = "Lato-LightItalic"
|
|
||||||
case LatoHairline = "Lato-Hairline"
|
|
||||||
case LatoBold = "Lato-Bold"
|
|
||||||
case LatoBlack = "Lato-Black"
|
|
||||||
case LatoRegular = "Lato-Regular"
|
|
||||||
case LatoBlackItalic = "Lato-BlackItalic"
|
|
||||||
case LatoBoldItalic = "Lato-BoldItalic"
|
|
||||||
case LatoLight = "Lato-Light"
|
|
||||||
case LatoHairlineItalic = "Lato-HairlineItalic"
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - Getter
|
|
||||||
|
|
||||||
static let LatoItalic: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoLightItalic: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoLightItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoHairline: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoHairline.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoBold: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoBold.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoBlack: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoBlack.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoRegular: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoRegular.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoBlackItalic: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoBlackItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoBoldItalic: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoBoldItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoLight: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoLight.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoHairlineItalic: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoHairlineItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
// Generated from FontToolCore
|
|
||||||
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
extension UIFont {
|
|
||||||
|
|
||||||
enum FontName: String {
|
|
||||||
case LatoItalic = "Lato-Italic"
|
|
||||||
case LatoLightItalic = "Lato-LightItalic"
|
|
||||||
case LatoHairline = "Lato-Hairline"
|
|
||||||
case LatoBold = "Lato-Bold"
|
|
||||||
case LatoBlack = "Lato-Black"
|
|
||||||
case LatoRegular = "Lato-Regular"
|
|
||||||
case LatoBlackItalic = "Lato-BlackItalic"
|
|
||||||
case LatoBoldItalic = "Lato-BoldItalic"
|
|
||||||
case LatoLight = "Lato-Light"
|
|
||||||
case LatoHairlineItalic = "Lato-HairlineItalic"
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - Getter
|
|
||||||
|
|
||||||
static let LatoItalic: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoLightItalic: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoLightItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoHairline: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoHairline.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoBold: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoBold.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoBlack: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoBlack.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoRegular: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoRegular.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoBlackItalic: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoBlackItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoBoldItalic: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoBoldItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoLight: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoLight.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoHairlineItalic: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoHairlineItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
// Generated by ResgenSwift.FontTool 1.0.0
|
|
||||||
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
extension UIFont {
|
|
||||||
|
|
||||||
enum FontName: String {
|
|
||||||
case LatoItalic = "Lato-Italic"
|
|
||||||
case LatoLightItalic = "Lato-LightItalic"
|
|
||||||
case LatoHairline = "Lato-Hairline"
|
|
||||||
case LatoBold = "Lato-Bold"
|
|
||||||
case LatoBlack = "Lato-Black"
|
|
||||||
case LatoRegular = "Lato-Regular"
|
|
||||||
case LatoBlackItalic = "Lato-BlackItalic"
|
|
||||||
case LatoBoldItalic = "Lato-BoldItalic"
|
|
||||||
case LatoLight = "Lato-Light"
|
|
||||||
case LatoHairlineItalic = "Lato-HairlineItalic"
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - Getter
|
|
||||||
|
|
||||||
static let LatoItalic: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoLightItalic: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoLightItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoHairline: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoHairline.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoBold: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoBold.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoBlack: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoBlack.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoRegular: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoRegular.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoBlackItalic: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoBlackItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoBoldItalic: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoBoldItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoLight: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoLight.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoHairlineItalic: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoHairlineItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
}
|
|
61
SampleFiles/Fonts/Generated/UIFontYolo+GenAllScript.swift
Normal file
61
SampleFiles/Fonts/Generated/UIFontYolo+GenAllScript.swift
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
// Generated by ResgenSwift.Fonts 1.2
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
extension UIFontYolo {
|
||||||
|
|
||||||
|
enum FontName: String {
|
||||||
|
case LatoItalic = "Lato-Italic"
|
||||||
|
case LatoLightItalic = "Lato-LightItalic"
|
||||||
|
case LatoHairline = "Lato-Hairline"
|
||||||
|
case LatoBold = "Lato-Bold"
|
||||||
|
case LatoBlack = "Lato-Black"
|
||||||
|
case LatoRegular = "Lato-Regular"
|
||||||
|
case LatoBlackItalic = "Lato-BlackItalic"
|
||||||
|
case LatoBoldItalic = "Lato-BoldItalic"
|
||||||
|
case LatoLight = "Lato-Light"
|
||||||
|
case LatoHairlineItalic = "Lato-HairlineItalic"
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Getter
|
||||||
|
|
||||||
|
func LatoItalic(withSize size: CGFloat) -> UIFont {
|
||||||
|
UIFont(name: FontName.LatoItalic.rawValue, size: size)!
|
||||||
|
}
|
||||||
|
|
||||||
|
func LatoLightItalic(withSize size: CGFloat) -> UIFont {
|
||||||
|
UIFont(name: FontName.LatoLightItalic.rawValue, size: size)!
|
||||||
|
}
|
||||||
|
|
||||||
|
func LatoHairline(withSize size: CGFloat) -> UIFont {
|
||||||
|
UIFont(name: FontName.LatoHairline.rawValue, size: size)!
|
||||||
|
}
|
||||||
|
|
||||||
|
func LatoBold(withSize size: CGFloat) -> UIFont {
|
||||||
|
UIFont(name: FontName.LatoBold.rawValue, size: size)!
|
||||||
|
}
|
||||||
|
|
||||||
|
func LatoBlack(withSize size: CGFloat) -> UIFont {
|
||||||
|
UIFont(name: FontName.LatoBlack.rawValue, size: size)!
|
||||||
|
}
|
||||||
|
|
||||||
|
func LatoRegular(withSize size: CGFloat) -> UIFont {
|
||||||
|
UIFont(name: FontName.LatoRegular.rawValue, size: size)!
|
||||||
|
}
|
||||||
|
|
||||||
|
func LatoBlackItalic(withSize size: CGFloat) -> UIFont {
|
||||||
|
UIFont(name: FontName.LatoBlackItalic.rawValue, size: size)!
|
||||||
|
}
|
||||||
|
|
||||||
|
func LatoBoldItalic(withSize size: CGFloat) -> UIFont {
|
||||||
|
UIFont(name: FontName.LatoBoldItalic.rawValue, size: size)!
|
||||||
|
}
|
||||||
|
|
||||||
|
func LatoLight(withSize size: CGFloat) -> UIFont {
|
||||||
|
UIFont(name: FontName.LatoLight.rawValue, size: size)!
|
||||||
|
}
|
||||||
|
|
||||||
|
func LatoHairlineItalic(withSize size: CGFloat) -> UIFont {
|
||||||
|
UIFont(name: FontName.LatoHairlineItalic.rawValue, size: size)!
|
||||||
|
}
|
||||||
|
}
|
@ -1,62 +0,0 @@
|
|||||||
// Generated from FontToolCore
|
|
||||||
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
extension UIFont {
|
|
||||||
|
|
||||||
enum FontName: String {
|
|
||||||
case LatoItalic = "Lato-Italic"
|
|
||||||
case LatoLightItalic = "Lato-LightItalic"
|
|
||||||
case LatoHairline = "Lato-Hairline"
|
|
||||||
case LatoBold = "Lato-Bold"
|
|
||||||
case LatoBlack = "Lato-Black"
|
|
||||||
case LatoRegular = "Lato-Regular"
|
|
||||||
case LatoBlackItalic = "Lato-BlackItalic"
|
|
||||||
case LatoBoldItalic = "Lato-BoldItalic"
|
|
||||||
case LatoLight = "Lato-Light"
|
|
||||||
case LatoHairlineItalic = "Lato-HairlineItalic"
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - Getter
|
|
||||||
|
|
||||||
static let LatoItalic: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoLightItalic: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoLightItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoHairline: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoHairline.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoBold: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoBold.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoBlack: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoBlack.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoRegular: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoRegular.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoBlackItalic: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoBlackItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoBoldItalic: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoBoldItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoLight: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoLight.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
static let LatoHairlineItalic: ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.LatoHairlineItalic.rawValue, size: size)!
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
21
SampleFiles/Fonts/Generated/test.plist
Normal file
21
SampleFiles/Fonts/Generated/test.plist
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>NewArr</key>
|
||||||
|
<array/>
|
||||||
|
<key>UIAppFonts</key>
|
||||||
|
<array>
|
||||||
|
<string>Lato-Italic</string>
|
||||||
|
<string>Lato-LightItalic</string>
|
||||||
|
<string>Lato-Hairline</string>
|
||||||
|
<string>Lato-Bold</string>
|
||||||
|
<string>Lato-Black</string>
|
||||||
|
<string>Lato-Regular</string>
|
||||||
|
<string>Lato-BlackItalic</string>
|
||||||
|
<string>Lato-BoldItalic</string>
|
||||||
|
<string>Lato-Light</string>
|
||||||
|
<string>Lato-HairlineItalic</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
21
SampleFiles/Fonts/Generated/test2.plist
Normal file
21
SampleFiles/Fonts/Generated/test2.plist
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>NewArr</key>
|
||||||
|
<array/>
|
||||||
|
<key>UIAppFonts</key>
|
||||||
|
<array>
|
||||||
|
<string>Lato-Italic</string>
|
||||||
|
<string>Lato-LightItalic</string>
|
||||||
|
<string>Lato-Hairline</string>
|
||||||
|
<string>Lato-Bold</string>
|
||||||
|
<string>Lato-Black</string>
|
||||||
|
<string>Lato-Regular</string>
|
||||||
|
<string>Lato-BlackItalic</string>
|
||||||
|
<string>Lato-BoldItalic</string>
|
||||||
|
<string>Lato-Light</string>
|
||||||
|
<string>Lato-HairlineItalic</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
31
SampleFiles/Images/Generated/ImageYolo+GenAllScript.swift
Normal file
31
SampleFiles/Images/Generated/ImageYolo+GenAllScript.swift
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// Generated by ResgenSwift.Images 1.2
|
||||||
|
// Images from sampleImages
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
extension ImageYolo {
|
||||||
|
|
||||||
|
var article_notification_pull_detail: Image {
|
||||||
|
Image("article_notification_pull_detail")
|
||||||
|
}
|
||||||
|
|
||||||
|
var article_notification_pull: Image {
|
||||||
|
Image("article_notification_pull")
|
||||||
|
}
|
||||||
|
|
||||||
|
var new_article: Image {
|
||||||
|
Image("new_article")
|
||||||
|
}
|
||||||
|
|
||||||
|
var welcome_background: Image {
|
||||||
|
Image("welcome_background")
|
||||||
|
}
|
||||||
|
|
||||||
|
var article_trash: Image {
|
||||||
|
Image("article_trash")
|
||||||
|
}
|
||||||
|
|
||||||
|
var ic_close_article: Image {
|
||||||
|
Image("ic_close_article")
|
||||||
|
}
|
||||||
|
}
|
@ -1,32 +1,31 @@
|
|||||||
// Generated by ResgenSwift.Imagium 1.0.0
|
// Generated by ResgenSwift.Images 1.2
|
||||||
// Images from sampleImages
|
// Images from sampleImages
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
extension UIImage {
|
extension UIImage {
|
||||||
|
|
||||||
static var article_notification_pull_detail: UIImage {
|
var article_notification_pull_detail: UIImage {
|
||||||
UIImage(named: "article_notification_pull_detail")!
|
UIImage(named: "article_notification_pull_detail")!
|
||||||
}
|
}
|
||||||
|
|
||||||
static var article_notification_pull: UIImage {
|
var article_notification_pull: UIImage {
|
||||||
UIImage(named: "article_notification_pull")!
|
UIImage(named: "article_notification_pull")!
|
||||||
}
|
}
|
||||||
|
|
||||||
static var new_article: UIImage {
|
var new_article: UIImage {
|
||||||
UIImage(named: "new_article")!
|
UIImage(named: "new_article")!
|
||||||
}
|
}
|
||||||
|
|
||||||
static var welcome_background: UIImage {
|
var welcome_background: UIImage {
|
||||||
UIImage(named: "welcome_background")!
|
UIImage(named: "welcome_background")!
|
||||||
}
|
}
|
||||||
|
|
||||||
static var article_trash: UIImage {
|
var article_trash: UIImage {
|
||||||
UIImage(named: "article_trash")!
|
UIImage(named: "article_trash")!
|
||||||
}
|
}
|
||||||
|
|
||||||
static var ic_close_article: UIImage {
|
var ic_close_article: UIImage {
|
||||||
UIImage(named: "ic_close_article")!
|
UIImage(named: "ic_close_article")!
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
// Generated from Imagium at 2022-02-14 09:30:23 +0000
|
|
||||||
// Images from sampleImages
|
|
||||||
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
extension UIImage {
|
|
||||||
|
|
||||||
static var article_notification_pull_detail: UIImage {
|
|
||||||
UIImage(named: "article_notification_pull_detail")!
|
|
||||||
}
|
|
||||||
|
|
||||||
static var article_notification_pull: UIImage {
|
|
||||||
UIImage(named: "article_notification_pull")!
|
|
||||||
}
|
|
||||||
|
|
||||||
static var new_article: UIImage {
|
|
||||||
UIImage(named: "new_article")!
|
|
||||||
}
|
|
||||||
|
|
||||||
static var welcome_background: UIImage {
|
|
||||||
UIImage(named: "welcome_background")!
|
|
||||||
}
|
|
||||||
|
|
||||||
static var article_trash: UIImage {
|
|
||||||
UIImage(named: "article_trash")!
|
|
||||||
}
|
|
||||||
|
|
||||||
static var ic_close_article: UIImage {
|
|
||||||
UIImage(named: "ic_close_article")!
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
// Generated from StringToolCore at 2022-01-10 08:27:11 +0000
|
|
||||||
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
fileprivate let kStringsFileName = "sampleStrings"
|
|
||||||
|
|
||||||
extension MyString {
|
|
||||||
|
|
||||||
// MARK: - Webservice
|
|
||||||
|
|
||||||
/// Translation in en :
|
|
||||||
/// en
|
|
||||||
var param_lang: String {
|
|
||||||
NSLocalizedString("param_lang", tableName: kStringsFileName, bundle: Bundle.main, value: "en", comment: "")
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - Generic
|
|
||||||
|
|
||||||
/// Translation in en :
|
|
||||||
/// Back
|
|
||||||
var generic_back: String {
|
|
||||||
NSLocalizedString("generic_back", tableName: kStringsFileName, bundle: Bundle.main, value: "Back", comment: "")
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Translation in en :
|
|
||||||
/// Loading data...
|
|
||||||
var generic_loading_data: String {
|
|
||||||
NSLocalizedString("generic_loading_data", tableName: kStringsFileName, bundle: Bundle.main, value: "Loading data...", comment: "")
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Translation in en :
|
|
||||||
/// Welcome %@ !
|
|
||||||
var generic_welcome_firstname_format: String {
|
|
||||||
NSLocalizedString("generic_welcome_firstname_format", tableName: kStringsFileName, bundle: Bundle.main, value: "Welcome %@ !", comment: "")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
// Generated by ResgenSwift.Strings.Stringium 1.0.0
|
// Generated by ResgenSwift.Strings.Stringium 1.2
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
@ -6,60 +6,79 @@ fileprivate let kStringsFileName = "sampleStrings"
|
|||||||
|
|
||||||
extension String {
|
extension String {
|
||||||
|
|
||||||
// MARK: - Webservice
|
enum KeyGenAllScript: String {
|
||||||
|
case param_lang = "param_lang"
|
||||||
|
case generic_back = "generic_back"
|
||||||
|
case generic_loading_data = "generic_loading_data"
|
||||||
|
case generic_welcome_firstname_format = "generic_welcome_firstname_format"
|
||||||
|
case test_equal_symbol = "test_equal_symbol"
|
||||||
|
case placeholders_test_one = "placeholders_test_one"
|
||||||
|
|
||||||
|
var keyPath: KeyPath<String, String> {
|
||||||
|
switch self {
|
||||||
|
case .param_lang: return \String.param_lang
|
||||||
|
case .generic_back: return \String.generic_back
|
||||||
|
case .generic_loading_data: return \String.generic_loading_data
|
||||||
|
case .generic_welcome_firstname_format: return \String.generic_welcome_firstname_format
|
||||||
|
case .test_equal_symbol: return \String.test_equal_symbol
|
||||||
|
case .placeholders_test_one: return \String.placeholders_test_one
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Webservice
|
||||||
|
|
||||||
/// Translation in en :
|
/// Translation in en :
|
||||||
/// en
|
/// en
|
||||||
static 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: "")
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Generic
|
// MARK: - Generic
|
||||||
|
|
||||||
/// Translation in en :
|
/// Translation in en :
|
||||||
/// Back
|
/// Back
|
||||||
static 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: "")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Translation in en :
|
/// Translation in en :
|
||||||
/// Loading data...
|
/// Loading data...
|
||||||
static 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: "")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Translation in en :
|
/// Translation in en :
|
||||||
/// Welcome \"%@\" !
|
/// Welcome \"%@\" !
|
||||||
static 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 :
|
||||||
/// Welcome \"%@\" !
|
/// Welcome \"%@\" !
|
||||||
static 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - EqualSymbol
|
// MARK: - EqualSymbol
|
||||||
|
|
||||||
/// Translation in en :
|
/// Translation in en :
|
||||||
/// 1€ = 1 point !
|
/// 1€ = 1 point !
|
||||||
static 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: "")
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Placeholders
|
// MARK: - Placeholders
|
||||||
|
|
||||||
/// Translation in en :
|
/// Translation in en :
|
||||||
/// You %%: %2$@ %1$@ Age: %3$d
|
/// You %%: %2$@ %1$@ Age: %3$d
|
||||||
static 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 :
|
||||||
/// You %%: %2$@ %1$@ Age: %3$d
|
/// You %%: %2$@ %1$@ Age: %3$d
|
||||||
static 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,57 +0,0 @@
|
|||||||
// Generated from Strings-Stringium at 2022-03-07 11:02:15 +0000
|
|
||||||
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
fileprivate let kStringsFileName = "sampleStrings"
|
|
||||||
|
|
||||||
extension String {
|
|
||||||
|
|
||||||
// MARK: - Webservice
|
|
||||||
|
|
||||||
/// Translation in en :
|
|
||||||
/// en
|
|
||||||
static var param_lang: String {
|
|
||||||
NSLocalizedString("param_lang", tableName: kStringsFileName, bundle: Bundle.main, value: "en", comment: "")
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - Generic
|
|
||||||
|
|
||||||
/// Translation in en :
|
|
||||||
/// Back
|
|
||||||
static var generic_back: String {
|
|
||||||
NSLocalizedString("generic_back", tableName: kStringsFileName, bundle: Bundle.main, value: "Back", comment: "")
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Translation in en :
|
|
||||||
/// Loading data...
|
|
||||||
static var generic_loading_data: String {
|
|
||||||
NSLocalizedString("generic_loading_data", tableName: kStringsFileName, bundle: Bundle.main, value: "Loading data...", comment: "")
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Translation in en :
|
|
||||||
/// Welcome \"%@\" !
|
|
||||||
static var generic_welcome_firstname_format: String {
|
|
||||||
NSLocalizedString("generic_welcome_firstname_format", tableName: kStringsFileName, bundle: Bundle.main, value: "Welcome \"%@\" !", comment: "")
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Translation in en :
|
|
||||||
/// Welcome \"%@\" !
|
|
||||||
static func generic_welcome_firstname_format(arg0: String) -> String {
|
|
||||||
String(format: Self.generic_welcome_firstname_format, arg0)
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - Placeholders
|
|
||||||
|
|
||||||
/// Translation in en :
|
|
||||||
/// You %%: %2$@ %1$@ Age: %3$d
|
|
||||||
static var placeholders_test_one: String {
|
|
||||||
NSLocalizedString("placeholders_test_one", tableName: kStringsFileName, bundle: Bundle.main, value: "You %%: %2$@ %1$@ Age: %3$d", comment: "")
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Translation in en :
|
|
||||||
/// You %%: %2$@ %1$@ Age: %3$d
|
|
||||||
static func placeholders_test_one(arg0: String, arg1: String, arg2: Int) -> String {
|
|
||||||
String(format: Self.placeholders_test_one, arg0, arg1, arg2)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
// Generated from StringToolCore at 2022-01-10 08:39:52 +0000
|
|
||||||
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
fileprivate let kStringsFileName = "sampleStrings"
|
|
||||||
|
|
||||||
extension String {
|
|
||||||
|
|
||||||
// MARK: - Webservice
|
|
||||||
|
|
||||||
/// Translation in en :
|
|
||||||
/// en
|
|
||||||
static var param_lang: String {
|
|
||||||
NSLocalizedString("param_lang", tableName: kStringsFileName, bundle: Bundle.main, value: "en", comment: "")
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - Generic
|
|
||||||
|
|
||||||
/// Translation in en :
|
|
||||||
/// Back
|
|
||||||
static var generic_back: String {
|
|
||||||
NSLocalizedString("generic_back", tableName: kStringsFileName, bundle: Bundle.main, value: "Back", comment: "")
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Translation in en :
|
|
||||||
/// Loading data...
|
|
||||||
static var generic_loading_data: String {
|
|
||||||
NSLocalizedString("generic_loading_data", tableName: kStringsFileName, bundle: Bundle.main, value: "Loading data...", comment: "")
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Translation in en :
|
|
||||||
/// Welcome \"%@\" !
|
|
||||||
static var generic_welcome_firstname_format: String {
|
|
||||||
NSLocalizedString("generic_welcome_firstname_format", tableName: kStringsFileName, bundle: Bundle.main, value: "Welcome \"%@\" !", comment: "")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
// Generated from Strings-Stringium at 2022-03-07 11:00:52 +0000
|
|
||||||
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
fileprivate let kStringsFileName = "sampleStrings"
|
|
||||||
|
|
||||||
extension StringTest {
|
|
||||||
|
|
||||||
// MARK: - Webservice
|
|
||||||
|
|
||||||
/// Translation in en :
|
|
||||||
/// en
|
|
||||||
var param_lang: String {
|
|
||||||
NSLocalizedString("param_lang", tableName: kStringsFileName, bundle: Bundle.main, value: "en", comment: "")
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - Generic
|
|
||||||
|
|
||||||
/// Translation in en :
|
|
||||||
/// Back
|
|
||||||
var generic_back: String {
|
|
||||||
NSLocalizedString("generic_back", tableName: kStringsFileName, bundle: Bundle.main, value: "Back", comment: "")
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Translation in en :
|
|
||||||
/// Loading data...
|
|
||||||
var generic_loading_data: String {
|
|
||||||
NSLocalizedString("generic_loading_data", tableName: kStringsFileName, bundle: Bundle.main, value: "Loading data...", comment: "")
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Translation in en :
|
|
||||||
/// Welcome \"%@\" !
|
|
||||||
var generic_welcome_firstname_format: String {
|
|
||||||
NSLocalizedString("generic_welcome_firstname_format", tableName: kStringsFileName, bundle: Bundle.main, value: "Welcome \"%@\" !", comment: "")
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Translation in en :
|
|
||||||
/// Welcome \"%@\" !
|
|
||||||
func generic_welcome_firstname_format(arg0: String) -> String {
|
|
||||||
String(format: self.generic_welcome_firstname_format, arg0)
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - Placeholders
|
|
||||||
|
|
||||||
/// Translation in en :
|
|
||||||
/// You %%: %2$@ %1$@ Age: %3$d
|
|
||||||
var placeholders_test_one: String {
|
|
||||||
NSLocalizedString("placeholders_test_one", tableName: kStringsFileName, bundle: Bundle.main, value: "You %%: %2$@ %1$@ Age: %3$d", comment: "")
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Translation in en :
|
|
||||||
/// You %%: %2$@ %1$@ Age: %3$d
|
|
||||||
func placeholders_test_one(arg0: String, arg1: String, arg2: Int) -> String {
|
|
||||||
String(format: self.placeholders_test_one, arg0, arg1, arg2)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* Apple Strings File
|
* Apple Strings File
|
||||||
* Generated by ResgenSwift 1.0.0
|
* Generated by ResgenSwift 1.2
|
||||||
* Language: en-us
|
* Language: en-us
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* Apple Strings File
|
* Apple Strings File
|
||||||
* Generated by ResgenSwift 1.0.0
|
* Generated by ResgenSwift 1.2
|
||||||
* Language: en
|
* Language: en
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* Apple Strings File
|
* Apple Strings File
|
||||||
* Generated by ResgenSwift 1.0.0
|
* Generated by ResgenSwift 1.2
|
||||||
* Language: fr
|
* Language: fr
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,23 +1,20 @@
|
|||||||
// Generated by ResgenSwift.Strings.Tags 1.0.0
|
// Generated by ResgenSwift.Strings.Tags 1.2
|
||||||
|
|
||||||
// typelias Tags = String
|
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
extension Tags {
|
extension Tags {
|
||||||
|
|
||||||
// MARK: - ScreenTag
|
// MARK: - ScreenTag
|
||||||
|
|
||||||
/// Translation in ium :
|
/// Translation in ium :
|
||||||
/// Ecran un
|
/// Ecran un
|
||||||
static var screen_one: String {
|
var screen_one: String {
|
||||||
"Ecran un"
|
"Ecran un"
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Translation in ium :
|
/// Translation in ium :
|
||||||
/// Ecran deux
|
/// Ecran deux
|
||||||
static var screen_two: String {
|
var screen_two: String {
|
||||||
"Ecran deux"
|
"Ecran deux"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
// Generated from Strings-Tags at 2022-02-14 09:30:20 +0000
|
|
||||||
|
|
||||||
// typelias Tags = String
|
|
||||||
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
extension Tags {
|
|
||||||
|
|
||||||
// MARK: - ScreenTag
|
|
||||||
|
|
||||||
/// Translation in ium :
|
|
||||||
/// Ecran un
|
|
||||||
static var screen_one: String {
|
|
||||||
"Ecran un"
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Translation in ium :
|
|
||||||
/// Ecran deux
|
|
||||||
static var screen_two: String {
|
|
||||||
"Ecran deux"
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -2,35 +2,38 @@
|
|||||||
|
|
||||||
FORCE_FLAG="$1"
|
FORCE_FLAG="$1"
|
||||||
|
|
||||||
# Font
|
## Font
|
||||||
swift run -c release FontTool $FORCE_FLAG "./Fonts/sampleFontsAll.txt" \
|
#swift run -c release ResgenSwift fonts $FORCE_FLAG "./Fonts/sampleFontsAll.txt" \
|
||||||
--extension-output-path "./Fonts/Generated" \
|
# --extension-output-path "./Fonts/Generated" \
|
||||||
--extension-name "UIFont" \
|
# --extension-name "UIFontYolo" \
|
||||||
--extension-suffix "GenAllScript"
|
# --extension-name-swift-ui "FontYolo" \
|
||||||
|
# --extension-suffix "GenAllScript" \
|
||||||
echo "\n-------------------------\n"
|
# --info-plist-paths "./Fonts/Generated/test.plist ./Fonts/Generated/test2.plist"
|
||||||
|
#
|
||||||
# Color
|
#echo "\n-------------------------\n"
|
||||||
swift run -c release ColorTool $FORCE_FLAG "./Colors/sampleColors1.txt" \
|
#
|
||||||
--style all \
|
## Color
|
||||||
--xcassets-path "./Colors/colors.xcassets" \
|
#swift run -c release ResgenSwift colors $FORCE_FLAG "./Colors/sampleColors1.txt" \
|
||||||
--extension-output-path "./Colors/Generated/" \
|
# --style all \
|
||||||
--extension-name "UIColor" \
|
# --xcassets-path "./Colors/colors.xcassets" \
|
||||||
--extension-suffix "GenAllScript"
|
# --extension-output-path "./Colors/Generated/" \
|
||||||
|
# --extension-name "UIColorYolo" \
|
||||||
echo "\n-------------------------\n"
|
# --extension-name-swift-ui "ColorYolo" \
|
||||||
|
# --extension-suffix "GenAllScript"
|
||||||
# Twine
|
#
|
||||||
swift run -c release Strings twine $FORCE_FLAG "./Twine/sampleStrings.txt" \
|
#echo "\n-------------------------\n"
|
||||||
--output-path "./Twine/Generated" \
|
#
|
||||||
--langs "fr en en-us" \
|
## Twine
|
||||||
--default-lang "en" \
|
#swift run -c release ResgenSwift strings twine $FORCE_FLAG "./Twine/sampleStrings.txt" \
|
||||||
--extension-output-path "./Twine/Generated"
|
# --output-path "./Twine/Generated" \
|
||||||
|
# --langs "fr en en-us" \
|
||||||
|
# --default-lang "en" \
|
||||||
|
# --extension-output-path "./Twine/Generated"
|
||||||
|
|
||||||
echo "\n-------------------------\n"
|
echo "\n-------------------------\n"
|
||||||
|
|
||||||
# Strings
|
# Strings
|
||||||
swift run -c release Strings stringium $FORCE_FLAG "./Strings/sampleStrings.txt" \
|
swift run -c release ResgenSwift strings stringium $FORCE_FLAG "./Strings/sampleStrings.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" \
|
||||||
@ -40,18 +43,19 @@ swift run -c release Strings stringium $FORCE_FLAG "./Strings/sampleStrings.txt"
|
|||||||
|
|
||||||
echo "\n-------------------------\n"
|
echo "\n-------------------------\n"
|
||||||
|
|
||||||
# Tags
|
## Tags
|
||||||
swift run -c release Strings tags $FORCE_FLAG "./Tags/sampleTags.txt" \
|
#swift run -c release ResgenSwift strings tags $FORCE_FLAG "./Tags/sampleTags.txt" \
|
||||||
--lang "ium" \
|
# --lang "ium" \
|
||||||
--extension-output-path "./Tags/Generated" \
|
# --extension-output-path "./Tags/Generated" \
|
||||||
--extension-name "Tags" \
|
# --extension-name "Tags" \
|
||||||
--extension-suffix "GenAllScript"
|
# --extension-suffix "GenAllScript"
|
||||||
|
#
|
||||||
echo "\n-------------------------\n"
|
#echo "\n-------------------------\n"
|
||||||
|
#
|
||||||
# Images
|
## Images
|
||||||
swift run -c release Imagium $FORCE_FLAG "./Images/sampleImages.txt" \
|
#swift run -c release ResgenSwift images $FORCE_FLAG "./Images/sampleImages.txt" \
|
||||||
--xcassets-path "./Images/imagium.xcassets" \
|
# --xcassets-path "./Images/imagium.xcassets" \
|
||||||
--extension-output-path "./Images/Generated" \
|
# --extension-output-path "./Images/Generated" \
|
||||||
--extension-name "UIImage" \
|
# --extension-name "UIImage" \
|
||||||
--extension-suffix "GenAllScript"
|
# --extension-name-swift-ui "ImageYolo" \
|
||||||
|
# --extension-suffix "GenAllScript"
|
||||||
|
91
SampleFiles/resgenConfiguration.yml
Normal file
91
SampleFiles/resgenConfiguration.yml
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
---
|
||||||
|
#
|
||||||
|
# Class architecture
|
||||||
|
#
|
||||||
|
architecture:
|
||||||
|
property: R
|
||||||
|
classname: R
|
||||||
|
path: ./Tags
|
||||||
|
children:
|
||||||
|
- property: images
|
||||||
|
classname: R2Image
|
||||||
|
- property: strings
|
||||||
|
classname: R2String
|
||||||
|
- property: fonts
|
||||||
|
classname: R2Font
|
||||||
|
- property: images
|
||||||
|
classname: R2Image
|
||||||
|
- property: ui
|
||||||
|
classname: R2UI
|
||||||
|
children:
|
||||||
|
- property: images
|
||||||
|
classname: R2UIImage
|
||||||
|
- property: fonts
|
||||||
|
classname: R2UIFont
|
||||||
|
- property: images
|
||||||
|
classname: R2UIImage
|
||||||
|
|
||||||
|
#
|
||||||
|
# Strings
|
||||||
|
#
|
||||||
|
strings:
|
||||||
|
-
|
||||||
|
inputFile: ./Strings/sampleStrings.txt
|
||||||
|
outputPath: ./Strings/Generated
|
||||||
|
langs: "fr en en-us"
|
||||||
|
defaultLang: en
|
||||||
|
extensionOutputPath: ./Strings/Generated
|
||||||
|
extensionName: String
|
||||||
|
extensionSuffix: GenAllScript
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Images
|
||||||
|
#
|
||||||
|
images:
|
||||||
|
-
|
||||||
|
inputFile: ./Images/sampleImages.txt
|
||||||
|
xcassetsPath: ./Images/imagium.xcassets
|
||||||
|
extensionOutputPath: ./Images/Generated
|
||||||
|
extensionName: UIImage
|
||||||
|
extensionNameSwiftUI: ImageYolo
|
||||||
|
extensionSuffix: GenAllScript
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Colors
|
||||||
|
#
|
||||||
|
colors:
|
||||||
|
-
|
||||||
|
inputFile: ./Colors/sampleColors1.txt
|
||||||
|
style: all
|
||||||
|
xcassetsPath: ./Colors/colors.xcassets
|
||||||
|
extensionOutputPath: ./Colors/Generated/
|
||||||
|
extensionName: UIColorYolo
|
||||||
|
extensionNameSwiftUI: ColorYolo
|
||||||
|
extensionSuffix: GenAllScript
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Tags
|
||||||
|
#
|
||||||
|
tags:
|
||||||
|
-
|
||||||
|
inputFile: ./Tags/sampleTags.txt
|
||||||
|
lang: ium
|
||||||
|
extensionOutputPath: ./Tags/Generated
|
||||||
|
extensionName: Tags
|
||||||
|
extensionSuffix: GenAllScript
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Fonts
|
||||||
|
#
|
||||||
|
fonts:
|
||||||
|
-
|
||||||
|
inputFile: ./Fonts/sampleFontsAll.txt
|
||||||
|
extensionOutputPath: ./Fonts/Generated
|
||||||
|
extensionName: UIFontYolo
|
||||||
|
extensionNameSwiftUI: FontYolo
|
||||||
|
extensionSuffix: GenAllScript
|
||||||
|
infoPlistPaths: "./Fonts/Generated/test.plist ./Fonts/Generated/test2.plist"
|
@ -22,6 +22,7 @@ struct Colors: ParsableCommand {
|
|||||||
|
|
||||||
static let toolName = "Color"
|
static let toolName = "Color"
|
||||||
static let defaultExtensionName = "UIColor"
|
static let defaultExtensionName = "UIColor"
|
||||||
|
static let defaultExtensionNameSUI = "Color"
|
||||||
static let assetsColorsFolderName = "Colors"
|
static let assetsColorsFolderName = "Colors"
|
||||||
|
|
||||||
// MARK: - Command options
|
// MARK: - Command options
|
||||||
@ -43,7 +44,7 @@ struct Colors: ParsableCommand {
|
|||||||
|
|
||||||
// Get colors to generate
|
// Get colors to generate
|
||||||
let parsedColors = ColorFileParser.parse(options.inputFile,
|
let parsedColors = ColorFileParser.parse(options.inputFile,
|
||||||
colorStyle: options.colorStyle)
|
colorStyle: options.style)
|
||||||
// -> Time: 0.0020350217819213867 seconds
|
// -> Time: 0.0020350217819213867 seconds
|
||||||
|
|
||||||
// Generate all colors in xcassets
|
// Generate all colors in xcassets
|
||||||
@ -55,9 +56,16 @@ struct Colors: ParsableCommand {
|
|||||||
ColorExtensionGenerator.writeExtensionFile(colors: parsedColors,
|
ColorExtensionGenerator.writeExtensionFile(colors: parsedColors,
|
||||||
staticVar: options.staticMembers,
|
staticVar: options.staticMembers,
|
||||||
extensionName: options.extensionName,
|
extensionName: options.extensionName,
|
||||||
extensionFilePath: options.extensionFilePath)
|
extensionFilePath: options.extensionFilePath,
|
||||||
// -> Time: 0.0010340213775634766 seconds
|
isSwiftUI: false)
|
||||||
|
|
||||||
|
// Generate extension
|
||||||
|
ColorExtensionGenerator.writeExtensionFile(colors: parsedColors,
|
||||||
|
staticVar: options.staticMembers,
|
||||||
|
extensionName: options.extensionNameSwiftUI,
|
||||||
|
extensionFilePath: options.extensionFilePathSwiftUI,
|
||||||
|
isSwiftUI: true)
|
||||||
|
|
||||||
print("[\(Self.toolName)] Colors generated")
|
print("[\(Self.toolName)] Colors generated")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,14 +77,21 @@ struct Colors: ParsableCommand {
|
|||||||
// Check if input file exists
|
// Check if input file exists
|
||||||
guard fileManager.fileExists(atPath: options.inputFile) else {
|
guard fileManager.fileExists(atPath: options.inputFile) else {
|
||||||
let error = ColorsToolError.fileNotExists(options.inputFile)
|
let error = ColorsToolError.fileNotExists(options.inputFile)
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Colors.exit(withError: error)
|
Colors.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if xcassets file exists
|
// Check if xcassets file exists
|
||||||
guard fileManager.fileExists(atPath: options.xcassetsPath) else {
|
guard fileManager.fileExists(atPath: options.xcassetsPath) else {
|
||||||
let error = ColorsToolError.fileNotExists(options.xcassetsPath)
|
let error = ColorsToolError.fileNotExists(options.xcassetsPath)
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
|
Colors.exit(withError: error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extension for UIKit and SwiftUI should have different name
|
||||||
|
guard options.extensionName != options.extensionNameSwiftUI else {
|
||||||
|
let error = ColorsToolError.extensionNamesCollision(options.extensionName)
|
||||||
|
print(error.description)
|
||||||
Colors.exit(withError: error)
|
Colors.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +117,7 @@ struct Colors: ParsableCommand {
|
|||||||
try fileManager.removeItem(atPath: assetsColorPath)
|
try fileManager.removeItem(atPath: assetsColorPath)
|
||||||
} catch {
|
} catch {
|
||||||
let error = ColorsToolError.deleteExistingColors("\(options.xcassetsPath)/Colors")
|
let error = ColorsToolError.deleteExistingColors("\(options.xcassetsPath)/Colors")
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Colors.exit(withError: error)
|
Colors.exit(withError: error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
enum ColorsToolError: Error {
|
enum ColorsToolError: Error {
|
||||||
|
case extensionNamesCollision(String)
|
||||||
case badFormat(String)
|
case badFormat(String)
|
||||||
case writeAsset(String)
|
case writeAsset(String)
|
||||||
case createAssetFolder(String)
|
case createAssetFolder(String)
|
||||||
@ -18,26 +19,29 @@ enum ColorsToolError: Error {
|
|||||||
|
|
||||||
var description: String {
|
var description: String {
|
||||||
switch self {
|
switch self {
|
||||||
|
case .extensionNamesCollision(let extensionName):
|
||||||
|
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\""
|
||||||
|
|
||||||
case .writeAsset(let info):
|
case .writeAsset(let info):
|
||||||
return "error:[\(Colors.toolName)] An error occured while writing color in Xcasset: \(info)"
|
return "error: [\(Colors.toolName)] An error occured while writing color in Xcasset: \(info)"
|
||||||
|
|
||||||
case .createAssetFolder(let assetsFolder):
|
case .createAssetFolder(let assetsFolder):
|
||||||
return "error:[\(Colors.toolName)] An error occured while creating colors folder `\(assetsFolder)`"
|
return "error: [\(Colors.toolName)] An error occured while creating colors folder `\(assetsFolder)`"
|
||||||
|
|
||||||
case .writeExtension(let filename, let info):
|
case .writeExtension(let filename, let info):
|
||||||
return "error:[\(Colors.toolName)] An error occured while writing extension in \(filename): \(info)"
|
return "error: [\(Colors.toolName)] An error occured while writing extension in \(filename): \(info)"
|
||||||
|
|
||||||
case .fileNotExists(let filename):
|
case .fileNotExists(let filename):
|
||||||
return "error:[\(Colors.toolName)] File \(filename) does not exists"
|
return "error: [\(Colors.toolName)] File \(filename) does not exists"
|
||||||
|
|
||||||
case .badColorDefinition(let lightColor, let darkColor):
|
case .badColorDefinition(let lightColor, let darkColor):
|
||||||
return "error:[\(Colors.toolName)] One of these two colors has invalid synthax: -\(lightColor)- or -\(darkColor)-"
|
return "error: [\(Colors.toolName)] One of these two colors has invalid synthax: -\(lightColor)- or -\(darkColor)-"
|
||||||
|
|
||||||
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)`"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ struct ColorsToolOptions: ParsableArguments {
|
|||||||
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")
|
||||||
fileprivate var style: String
|
var style: ColorStyle
|
||||||
|
|
||||||
@Option(help: "Path of xcassets where to generate colors", transform: { $0.replaceTiltWithHomeDirectoryPath() })
|
@Option(help: "Path of xcassets where to generate colors", transform: { $0.replaceTiltWithHomeDirectoryPath() })
|
||||||
var xcassetsPath: String
|
var xcassetsPath: String
|
||||||
@ -27,9 +27,12 @@ struct ColorsToolOptions: ParsableArguments {
|
|||||||
@Option(help: "Tell if it will generate static properties or not")
|
@Option(help: "Tell if it will generate static properties or not")
|
||||||
var staticMembers: Bool = false
|
var staticMembers: Bool = false
|
||||||
|
|
||||||
@Option(help: "Extension name. If not specified, it will generate an UIColor extension. Using default extension name will generate static property.")
|
@Option(help: "Extension name. If not specified, it will generate an UIColor extension.")
|
||||||
var extensionName: String = Colors.defaultExtensionName
|
var extensionName: String = Colors.defaultExtensionName
|
||||||
|
|
||||||
|
@Option(help: "SwiftUI Extension name. If not specified, it will generate an Color extension.")
|
||||||
|
var extensionNameSwiftUI: String = Colors.defaultExtensionNameSUI
|
||||||
|
|
||||||
@Option(help: "Extension suffix. Ex: MyApp, it will generate {extensionName}+ColorsMyApp.swift")
|
@Option(help: "Extension suffix. Ex: MyApp, it will generate {extensionName}+ColorsMyApp.swift")
|
||||||
var extensionSuffix: String?
|
var extensionSuffix: String?
|
||||||
}
|
}
|
||||||
@ -37,9 +40,8 @@ struct ColorsToolOptions: ParsableArguments {
|
|||||||
// MARK: - Computed var
|
// MARK: - Computed var
|
||||||
|
|
||||||
extension ColorsToolOptions {
|
extension ColorsToolOptions {
|
||||||
var colorStyle: ColorStyle {
|
|
||||||
ColorStyle(rawValue: style) ?? .all
|
// MARK: - UIKit
|
||||||
}
|
|
||||||
|
|
||||||
var extensionFileName: String {
|
var extensionFileName: String {
|
||||||
if let extensionSuffix = extensionSuffix {
|
if let extensionSuffix = extensionSuffix {
|
||||||
@ -51,4 +53,17 @@ extension ColorsToolOptions {
|
|||||||
var extensionFilePath: String {
|
var extensionFilePath: String {
|
||||||
"\(extensionOutputPath)/\(extensionFileName)"
|
"\(extensionOutputPath)/\(extensionFileName)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - SwiftUI
|
||||||
|
|
||||||
|
var extensionFileNameSwiftUI: String {
|
||||||
|
if let extensionSuffix = extensionSuffix {
|
||||||
|
return "\(extensionNameSwiftUI)+\(extensionSuffix).swift"
|
||||||
|
}
|
||||||
|
return "\(extensionNameSwiftUI).swift"
|
||||||
|
}
|
||||||
|
|
||||||
|
var extensionFilePathSwiftUI: String {
|
||||||
|
"\(extensionOutputPath)/\(extensionFileNameSwiftUI)"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,18 @@ struct ColorExtensionGenerator {
|
|||||||
let colors: [ParsedColor]
|
let colors: [ParsedColor]
|
||||||
let extensionClassname: String
|
let extensionClassname: String
|
||||||
|
|
||||||
static func writeExtensionFile(colors: [ParsedColor], staticVar: Bool, extensionName: String, extensionFilePath: String) {
|
// MARK: - UIKit
|
||||||
|
|
||||||
|
static func writeExtensionFile(colors: [ParsedColor],
|
||||||
|
staticVar: Bool,
|
||||||
|
extensionName: String,
|
||||||
|
extensionFilePath: String,
|
||||||
|
isSwiftUI: Bool) {
|
||||||
// Create extension content
|
// Create extension content
|
||||||
let extensionContent = Self.getExtensionContent(colors: colors,
|
let extensionContent = Self.getExtensionContent(colors: colors,
|
||||||
staticVar: staticVar,
|
staticVar: staticVar,
|
||||||
extensionName: extensionName)
|
extensionName: extensionName,
|
||||||
|
isSwiftUI: isSwiftUI)
|
||||||
|
|
||||||
// Write content
|
// Write content
|
||||||
let extensionFilePathURL = URL(fileURLWithPath: extensionFilePath)
|
let extensionFilePathURL = URL(fileURLWithPath: extensionFilePath)
|
||||||
@ -25,25 +32,28 @@ struct ColorExtensionGenerator {
|
|||||||
try extensionContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8)
|
try extensionContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8)
|
||||||
} catch (let error) {
|
} catch (let error) {
|
||||||
let error = ColorsToolError.writeExtension(extensionFilePath, error.localizedDescription)
|
let error = ColorsToolError.writeExtension(extensionFilePath, error.localizedDescription)
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Colors.exit(withError: error)
|
Colors.exit(withError: error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static func getExtensionContent(colors: [ParsedColor], staticVar: Bool, extensionName: String) -> String {
|
static func getExtensionContent(colors: [ParsedColor],
|
||||||
|
staticVar: Bool,
|
||||||
|
extensionName: String,
|
||||||
|
isSwiftUI: Bool) -> String {
|
||||||
[
|
[
|
||||||
Self.getHeader(extensionClassname: extensionName),
|
Self.getHeader(extensionClassname: extensionName, isSwiftUI: isSwiftUI),
|
||||||
Self.getProperties(for: colors, withStaticVar: staticVar),
|
Self.getProperties(for: colors, withStaticVar: staticVar, isSwiftUI: isSwiftUI),
|
||||||
Self.getFooter()
|
Self.getFooter()
|
||||||
]
|
]
|
||||||
.joined(separator: "\n")
|
.joined(separator: "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func getHeader(extensionClassname: String) -> String {
|
private static func getHeader(extensionClassname: String, isSwiftUI: Bool) -> String {
|
||||||
"""
|
"""
|
||||||
// Generated by ResgenSwift.\(Colors.toolName) \(ResgenSwiftVersion)
|
// Generated by ResgenSwift.\(Colors.toolName) \(ResgenSwiftVersion)
|
||||||
|
|
||||||
import UIKit
|
import \(isSwiftUI ? "SwiftUI" : "UIKit")
|
||||||
|
|
||||||
extension \(extensionClassname) {\n
|
extension \(extensionClassname) {\n
|
||||||
"""
|
"""
|
||||||
@ -52,15 +62,15 @@ struct ColorExtensionGenerator {
|
|||||||
private static func getFooter() -> String {
|
private static func getFooter() -> String {
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func getProperties(for colors: [ParsedColor], withStaticVar staticVar: Bool) -> String {
|
private static func getProperties(for colors: [ParsedColor],
|
||||||
|
withStaticVar staticVar: Bool,
|
||||||
|
isSwiftUI: Bool) -> String {
|
||||||
colors.map {
|
colors.map {
|
||||||
if staticVar {
|
$0.getColorProperty(isStatic: staticVar, isSwiftUI: isSwiftUI)
|
||||||
return $0.getColorStaticProperty()
|
|
||||||
}
|
|
||||||
return $0.getColorProperty()
|
|
||||||
}
|
}
|
||||||
.joined(separator: "\n\n")
|
.joined(separator: "\n\n")
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ struct ColorXcassetHelper {
|
|||||||
withIntermediateDirectories: true)
|
withIntermediateDirectories: true)
|
||||||
} catch {
|
} catch {
|
||||||
let error = ColorsToolError.createAssetFolder(colorSetPath)
|
let error = ColorsToolError.createAssetFolder(colorSetPath)
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Colors.exit(withError: error)
|
Colors.exit(withError: error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -40,7 +40,7 @@ struct ColorXcassetHelper {
|
|||||||
try color.contentsJSON().write(to: contentsJsonPathURL, atomically: false, encoding: .utf8)
|
try color.contentsJSON().write(to: contentsJsonPathURL, atomically: false, encoding: .utf8)
|
||||||
} catch (let error) {
|
} catch (let error) {
|
||||||
let error = ColorsToolError.writeAsset(error.localizedDescription)
|
let error = ColorsToolError.writeAsset(error.localizedDescription)
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Colors.exit(withError: error)
|
Colors.exit(withError: error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,16 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
import ArgumentParser
|
||||||
|
|
||||||
enum ColorStyle: String, Decodable {
|
enum ColorStyle: String, Decodable, ExpressibleByArgument {
|
||||||
case light
|
case light
|
||||||
case all
|
case all
|
||||||
|
|
||||||
|
static var allValueStrings: [String] {
|
||||||
|
[
|
||||||
|
Self.light.rawValue,
|
||||||
|
Self.all.rawValue
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ struct ParsedColor {
|
|||||||
|
|
||||||
guard allComponents.contains(true) == false else {
|
guard allComponents.contains(true) == false else {
|
||||||
let error = ColorsToolError.badColorDefinition(light, dark)
|
let error = ColorsToolError.badColorDefinition(light, dark)
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Colors.exit(withError: error)
|
Colors.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,19 +72,20 @@ struct ParsedColor {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
func getColorProperty() -> String {
|
// MARK: - UIKit
|
||||||
"""
|
|
||||||
|
func getColorProperty(isStatic: Bool, isSwiftUI: Bool) -> String {
|
||||||
|
if isSwiftUI {
|
||||||
|
return """
|
||||||
|
/// Color \(name) is \(light) (light) or \(dark) (dark)"
|
||||||
|
\(isStatic ? "static " : "")var \(name): Color {
|
||||||
|
Color("\(name)")
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
return """
|
||||||
/// Color \(name) is \(light) (light) or \(dark) (dark)"
|
/// Color \(name) is \(light) (light) or \(dark) (dark)"
|
||||||
@objc var \(name): UIColor {
|
\(isStatic ? "static " : "@objc ")var \(name): UIColor {
|
||||||
UIColor(named: "\(name)")!
|
|
||||||
}
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
|
|
||||||
func getColorStaticProperty() -> String {
|
|
||||||
"""
|
|
||||||
/// Color \(name) is \(light) (light) or \(dark) (dark)"
|
|
||||||
static var \(name): UIColor {
|
|
||||||
UIColor(named: "\(name)")!
|
UIColor(named: "\(name)")!
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
@ -37,7 +37,7 @@ class ColorFileParser {
|
|||||||
|
|
||||||
guard colorContent.count >= 2 else {
|
guard colorContent.count >= 2 else {
|
||||||
let error = ColorsToolError.badFormat(colorLine)
|
let error = ColorsToolError.badFormat(colorLine)
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Colors.exit(withError: error)
|
Colors.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,16 +21,25 @@ struct FontsOptions: ParsableArguments {
|
|||||||
@Option(help: "Tell if it will generate static properties or methods")
|
@Option(help: "Tell if it will generate static properties or methods")
|
||||||
var staticMembers: Bool = false
|
var staticMembers: Bool = false
|
||||||
|
|
||||||
@Option(help: "Extension name. If not specified, it will generate an UIFont extension. Using default extension name will generate static property.")
|
@Option(help: "Extension name. If not specified, it will generate an UIFont extension.")
|
||||||
var extensionName: String = Fonts.defaultExtensionName
|
var extensionName: String = Fonts.defaultExtensionName
|
||||||
|
|
||||||
|
@Option(help: "Extension name. If not specified, it will generate an Font extension.")
|
||||||
|
var extensionNameSwiftUI: String = Fonts.defaultExtensionNameSUI
|
||||||
|
|
||||||
@Option(help: "Extension 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")
|
||||||
|
fileprivate var infoPlistPathsRaw: String = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Computed var
|
// MARK: - Computed var
|
||||||
|
|
||||||
extension FontsOptions {
|
extension FontsOptions {
|
||||||
|
|
||||||
|
// MARK: - UIKit
|
||||||
|
|
||||||
var extensionFileName: String {
|
var extensionFileName: String {
|
||||||
if extensionSuffix.isEmpty == false {
|
if extensionSuffix.isEmpty == false {
|
||||||
return "\(extensionName)+\(extensionSuffix).swift"
|
return "\(extensionName)+\(extensionSuffix).swift"
|
||||||
@ -41,4 +50,25 @@ extension FontsOptions {
|
|||||||
var extensionFilePath: String {
|
var extensionFilePath: String {
|
||||||
"\(extensionOutputPath)/\(extensionFileName)"
|
"\(extensionOutputPath)/\(extensionFileName)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - SwiftUI
|
||||||
|
|
||||||
|
var extensionFileNameSwiftUI: String {
|
||||||
|
if extensionSuffix.isEmpty == false {
|
||||||
|
return "\(extensionNameSwiftUI)+\(extensionSuffix).swift"
|
||||||
|
}
|
||||||
|
return "\(extensionNameSwiftUI).swift"
|
||||||
|
}
|
||||||
|
|
||||||
|
var extensionFilePathSwiftUI: String {
|
||||||
|
"\(extensionOutputPath)/\(extensionFileNameSwiftUI)"
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: -
|
||||||
|
|
||||||
|
var infoPlistPaths: [String] {
|
||||||
|
infoPlistPathsRaw
|
||||||
|
.split(separator: " ")
|
||||||
|
.map { String($0) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ struct Fonts: ParsableCommand {
|
|||||||
|
|
||||||
static let toolName = "Fonts"
|
static let toolName = "Fonts"
|
||||||
static let defaultExtensionName = "UIFont"
|
static let defaultExtensionName = "UIFont"
|
||||||
|
static let defaultExtensionNameSUI = "Font"
|
||||||
|
|
||||||
// MARK: - Command Options
|
// MARK: - Command Options
|
||||||
|
|
||||||
@ -50,10 +51,17 @@ struct Fonts: ParsableCommand {
|
|||||||
FontExtensionGenerator.writeExtensionFile(fontsNames: fontsNames,
|
FontExtensionGenerator.writeExtensionFile(fontsNames: fontsNames,
|
||||||
staticVar: options.staticMembers,
|
staticVar: options.staticMembers,
|
||||||
extensionName: options.extensionName,
|
extensionName: options.extensionName,
|
||||||
extensionFilePath: options.extensionFilePath)
|
extensionFilePath: options.extensionFilePath,
|
||||||
|
isSwiftUI: false)
|
||||||
|
|
||||||
print("Info.plist information:")
|
FontExtensionGenerator.writeExtensionFile(fontsNames: fontsNames,
|
||||||
print("\(FontPlistGenerator.generatePlistUIAppsFontContent(for: fontsNames))")
|
staticVar: options.staticMembers,
|
||||||
|
extensionName: options.extensionNameSwiftUI,
|
||||||
|
extensionFilePath: options.extensionFilePathSwiftUI,
|
||||||
|
isSwiftUI: true)
|
||||||
|
|
||||||
|
print("Info.plist has been updated with:")
|
||||||
|
print("\(FontPlistGenerator.generatePlistUIAppsFontContent(for: fontsNames, infoPlistPaths: options.infoPlistPaths))")
|
||||||
|
|
||||||
print("[\(Self.toolName)] Fonts generated")
|
print("[\(Self.toolName)] Fonts generated")
|
||||||
}
|
}
|
||||||
@ -66,7 +74,14 @@ struct Fonts: ParsableCommand {
|
|||||||
// Check input file exists
|
// Check input file exists
|
||||||
guard fileManager.fileExists(atPath: options.inputFile) else {
|
guard fileManager.fileExists(atPath: options.inputFile) else {
|
||||||
let error = FontsToolError.fileNotExists(options.inputFile)
|
let error = FontsToolError.fileNotExists(options.inputFile)
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
|
Fonts.exit(withError: error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extension for UIKit and SwiftUI should have different name
|
||||||
|
guard options.extensionName != options.extensionNameSwiftUI else {
|
||||||
|
let error = FontsToolError.extensionNamesCollision(options.extensionName)
|
||||||
|
print(error.description)
|
||||||
Fonts.exit(withError: error)
|
Fonts.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,24 +8,28 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
enum FontsToolError: Error {
|
enum FontsToolError: Error {
|
||||||
|
case extensionNamesCollision(String)
|
||||||
case fcScan(String, Int32, String?)
|
case fcScan(String, Int32, String?)
|
||||||
case inputFolderNotFound(String)
|
case inputFolderNotFound(String)
|
||||||
case fileNotExists(String)
|
case fileNotExists(String)
|
||||||
case writeExtension(String, String)
|
case writeExtension(String, String)
|
||||||
|
|
||||||
var localizedDescription: String {
|
var description: String {
|
||||||
switch self {
|
switch self {
|
||||||
|
case .extensionNamesCollision(let extensionName):
|
||||||
|
return "error: [\(Fonts.toolName)] Error on extension names, extension name and SwiftUI extension name should be different (\(extensionName) is used on both)"
|
||||||
|
|
||||||
case .fcScan(let path, let code, let output):
|
case .fcScan(let path, let code, let output):
|
||||||
return "error:[\(Fonts.toolName)] Error while getting fontName (fc-scan --format %{postscriptname} \(path). fc-scan exit with \(code) and output is: \(output ?? "no output")"
|
return "error: [\(Fonts.toolName)] Error while getting fontName (fc-scan --format %{postscriptname} \(path). fc-scan exit with \(code) and output is: \(output ?? "no output")"
|
||||||
|
|
||||||
case .inputFolderNotFound(let inputFolder):
|
case .inputFolderNotFound(let inputFolder):
|
||||||
return " error:[\(Fonts.toolName)] Input folder not found: \(inputFolder)"
|
return "error: [\(Fonts.toolName)] Input folder not found: \(inputFolder)"
|
||||||
|
|
||||||
case .fileNotExists(let filename):
|
case .fileNotExists(let filename):
|
||||||
return " error:[\(Fonts.toolName)] File \(filename) does not exists"
|
return "error: [\(Fonts.toolName)] File \(filename) does not exists"
|
||||||
|
|
||||||
case .writeExtension(let filename, let info):
|
case .writeExtension(let filename, let 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)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ class FontsToolHelper {
|
|||||||
let fileManager = FileManager()
|
let fileManager = FileManager()
|
||||||
guard fileManager.fileExists(atPath: inputFolder) else {
|
guard fileManager.fileExists(atPath: inputFolder) else {
|
||||||
let error = FontsToolError.inputFolderNotFound(inputFolder)
|
let error = FontsToolError.inputFolderNotFound(inputFolder)
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Fonts.exit(withError: error)
|
Fonts.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ class FontsToolHelper {
|
|||||||
|
|
||||||
guard let fontName = task.output, task.terminationStatus == 0 else {
|
guard let fontName = task.output, task.terminationStatus == 0 else {
|
||||||
let error = FontsToolError.fcScan(path, task.terminationStatus, task.output)
|
let error = FontsToolError.fcScan(path, task.terminationStatus, task.output)
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Fonts.exit(withError: error)
|
Fonts.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,12 +6,34 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
import ToolCore
|
||||||
|
|
||||||
class FontPlistGenerator {
|
class FontPlistGenerator {
|
||||||
static func generatePlistUIAppsFontContent(for fonts: [FontName]) -> String {
|
static func generatePlistUIAppsFontContent(for fonts: [FontName], infoPlistPaths: [String]) -> String {
|
||||||
var plistData = "<key>UIAppFonts</key>\n\t<array>\n"
|
let fontsToAddToPlist = fonts
|
||||||
fonts
|
|
||||||
.compactMap { $0 }
|
.compactMap { $0 }
|
||||||
|
|
||||||
|
// Update each plist
|
||||||
|
infoPlistPaths.forEach { infoPlist in
|
||||||
|
// Remove UIAppFonts value
|
||||||
|
Shell.shell(launchPath: "/usr/libexec/PlistBuddy",
|
||||||
|
["-c", "delete :UIAppFonts", infoPlist])
|
||||||
|
|
||||||
|
// Add UIAppFonts empty array
|
||||||
|
debugPrint("Will PlistBuddy -c add :UIAppFonts array \(infoPlist)")
|
||||||
|
Shell.shell(launchPath: "/usr/libexec/PlistBuddy",
|
||||||
|
["-c", "add :UIAppFonts array", infoPlist])
|
||||||
|
|
||||||
|
// Fill array with fonts
|
||||||
|
fontsToAddToPlist
|
||||||
|
.forEach {
|
||||||
|
Shell.shell(launchPath: "/usr/libexec/PlistBuddy",
|
||||||
|
["-c", "add :UIAppFonts: string \($0)", infoPlist])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var plistData = "<key>UIAppFonts</key>\n\t<array>\n"
|
||||||
|
fontsToAddToPlist
|
||||||
.forEach {
|
.forEach {
|
||||||
plistData += "\t\t<string>\($0)</string>\n"
|
plistData += "\t\t<string>\($0)</string>\n"
|
||||||
}
|
}
|
||||||
|
@ -9,44 +9,7 @@ import Foundation
|
|||||||
import ToolCore
|
import ToolCore
|
||||||
|
|
||||||
class FontExtensionGenerator {
|
class FontExtensionGenerator {
|
||||||
|
|
||||||
static func writeExtensionFile(fontsNames: [String], staticVar: Bool, extensionName: String, extensionFilePath: String) {
|
|
||||||
// Create extension content
|
|
||||||
let extensionContent = Self.getExtensionContent(fontsNames: fontsNames,
|
|
||||||
staticVar: staticVar,
|
|
||||||
extensionName: extensionName)
|
|
||||||
|
|
||||||
// Write content
|
|
||||||
let extensionFilePathURL = URL(fileURLWithPath: extensionFilePath)
|
|
||||||
do {
|
|
||||||
try extensionContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8)
|
|
||||||
} catch (let error) {
|
|
||||||
let error = FontsToolError.writeExtension(extensionFilePath, error.localizedDescription)
|
|
||||||
print(error.localizedDescription)
|
|
||||||
Fonts.exit(withError: error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static func getExtensionContent(fontsNames: [String], staticVar: Bool, extensionName: String) -> String {
|
|
||||||
[
|
|
||||||
Self.getHeader(extensionClassname: extensionName),
|
|
||||||
Self.getFontNameEnum(fontsNames: fontsNames),
|
|
||||||
Self.getFontMethods(fontsNames: fontsNames, staticVar: staticVar),
|
|
||||||
Self.getFooter()
|
|
||||||
]
|
|
||||||
.joined(separator: "\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
private static func getHeader(extensionClassname: String) -> String {
|
|
||||||
"""
|
|
||||||
// Generated by ResgenSwift.\(Fonts.toolName) \(ResgenSwiftVersion)
|
|
||||||
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
extension \(extensionClassname) {\n
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
|
|
||||||
private static func getFontNameEnum(fontsNames: [String]) -> String {
|
private static func getFontNameEnum(fontsNames: [String]) -> String {
|
||||||
var enumDefinition = " enum FontName: String {\n"
|
var enumDefinition = " enum FontName: String {\n"
|
||||||
|
|
||||||
@ -58,17 +21,58 @@ class FontExtensionGenerator {
|
|||||||
return enumDefinition
|
return enumDefinition
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func getFontMethods(fontsNames: [FontName], staticVar: Bool) -> String {
|
static func writeExtensionFile(fontsNames: [String],
|
||||||
|
staticVar: Bool,
|
||||||
|
extensionName: String,
|
||||||
|
extensionFilePath: String,
|
||||||
|
isSwiftUI: Bool) {
|
||||||
|
// Create extension content
|
||||||
|
let extensionContent = Self.getExtensionContent(fontsNames: fontsNames,
|
||||||
|
staticVar: staticVar,
|
||||||
|
extensionName: extensionName,
|
||||||
|
isSwiftUI: isSwiftUI)
|
||||||
|
|
||||||
|
// Write content
|
||||||
|
let extensionFilePathURL = URL(fileURLWithPath: extensionFilePath)
|
||||||
|
do {
|
||||||
|
try extensionContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8)
|
||||||
|
} catch (let error) {
|
||||||
|
let error = FontsToolError.writeExtension(extensionFilePath, error.localizedDescription)
|
||||||
|
print(error.description)
|
||||||
|
Fonts.exit(withError: error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static func getExtensionContent(fontsNames: [String],
|
||||||
|
staticVar: Bool,
|
||||||
|
extensionName: String,
|
||||||
|
isSwiftUI: Bool) -> String {
|
||||||
|
[
|
||||||
|
Self.getHeader(extensionClassname: extensionName, isSwiftUI: isSwiftUI),
|
||||||
|
Self.getFontNameEnum(fontsNames: fontsNames),
|
||||||
|
Self.getFontMethods(fontsNames: fontsNames, staticVar: staticVar, isSwiftUI: isSwiftUI),
|
||||||
|
Self.getFooter()
|
||||||
|
]
|
||||||
|
.joined(separator: "\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
private static func getHeader(extensionClassname: String, isSwiftUI: Bool) -> String {
|
||||||
|
"""
|
||||||
|
// Generated by ResgenSwift.\(Fonts.toolName) \(ResgenSwiftVersion)
|
||||||
|
|
||||||
|
import \(isSwiftUI ? "SwiftUI" : "UIKit")
|
||||||
|
|
||||||
|
extension \(extensionClassname) {\n
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
|
||||||
|
private static func getFontMethods(fontsNames: [FontName], staticVar: Bool, isSwiftUI: Bool) -> String {
|
||||||
let pragma = " // MARK: - Getter"
|
let pragma = " // MARK: - Getter"
|
||||||
|
|
||||||
var propertiesOrMethods: [String] = fontsNames
|
var propertiesOrMethods: [String] = fontsNames
|
||||||
.unique()
|
.unique()
|
||||||
.map {
|
.map {
|
||||||
if staticVar {
|
$0.getProperty(isStatic: staticVar, isSwiftUI: isSwiftUI)
|
||||||
return $0.staticProperty
|
|
||||||
} else {
|
|
||||||
return $0.method
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
propertiesOrMethods.insert(pragma, at: 0)
|
propertiesOrMethods.insert(pragma, at: 0)
|
||||||
@ -78,6 +82,7 @@ class FontExtensionGenerator {
|
|||||||
private static func getFooter() -> String {
|
private static func getFooter() -> String {
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,19 +14,33 @@ extension FontName {
|
|||||||
self.removeCharacters(from: "[]+-_")
|
self.removeCharacters(from: "[]+-_")
|
||||||
}
|
}
|
||||||
|
|
||||||
var method: String {
|
func getProperty(isStatic: Bool, isSwiftUI: Bool) -> String {
|
||||||
"""
|
if isSwiftUI {
|
||||||
|
if isStatic {
|
||||||
|
return """
|
||||||
|
static let \(fontNameSanitize): ((_ size: CGFloat) -> Font) = { size in
|
||||||
|
Font.custom(FontName.\(fontNameSanitize).rawValue, size: size)
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
return """
|
||||||
|
func \(fontNameSanitize)(withSize size: CGFloat) -> Font {
|
||||||
|
Font.custom(FontName.\(fontNameSanitize).rawValue, size: size)
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
// UIKit
|
||||||
|
if isStatic {
|
||||||
|
return """
|
||||||
|
static let \(fontNameSanitize): ((_ size: CGFloat) -> UIFont) = { size in
|
||||||
|
UIFont(name: FontName.\(fontNameSanitize).rawValue, size: size)!
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
return """
|
||||||
func \(fontNameSanitize)(withSize size: CGFloat) -> UIFont {
|
func \(fontNameSanitize)(withSize size: CGFloat) -> UIFont {
|
||||||
UIFont(name: FontName.\(fontNameSanitize).rawValue, size: size)!
|
UIFont(name: FontName.\(fontNameSanitize).rawValue, size: size)!
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
var staticProperty: String {
|
|
||||||
"""
|
|
||||||
static let \(fontNameSanitize): ((_ size: CGFloat) -> UIFont) = { size in
|
|
||||||
UIFont(name: FontName.\(fontNameSanitize).rawValue, size: size)!
|
|
||||||
}
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import Foundation
|
|||||||
extension String {
|
extension String {
|
||||||
|
|
||||||
func prependIfRelativePath(_ prependPath: String) -> String {
|
func prependIfRelativePath(_ prependPath: String) -> String {
|
||||||
|
// If path starts with "/", it's an absolute path
|
||||||
if self.hasPrefix("/") {
|
if self.hasPrefix("/") {
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
@ -34,14 +34,17 @@ struct Generate: ParsableCommand {
|
|||||||
// Parse
|
// Parse
|
||||||
let configuration = ConfigurationFileParser.parse(options.configurationFile)
|
let configuration = ConfigurationFileParser.parse(options.configurationFile)
|
||||||
print("Found configurations :")
|
print("Found configurations :")
|
||||||
print(" - \(configuration.colors.count) colors configuration")
|
print(" - \(configuration.colors.count) colors configuration(s)")
|
||||||
print(" - \(configuration.fonts.count) fonts configuration")
|
print(" - \(configuration.fonts.count) fonts configuration(s)")
|
||||||
print(" - \(configuration.images.count) images configuration")
|
print(" - \(configuration.images.count) images configuration(s)")
|
||||||
print(" - \(configuration.strings.count) strings configuration")
|
print(" - \(configuration.strings.count) strings configuration(s)")
|
||||||
print(" - \(configuration.tags.count) tags configuration")
|
print(" - \(configuration.tags.count) tags configuration(s)")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
print("Input file: \(configuration.colors.first?.inputFile ?? "no input file")")
|
if let architecture = configuration.architecture {
|
||||||
|
ArchitectureGenerator.writeArchitecture(architecture,
|
||||||
|
projectDirectory: options.projectDirectory)
|
||||||
|
}
|
||||||
|
|
||||||
// Execute commands
|
// Execute commands
|
||||||
configuration.runnableConfigurations
|
configuration.runnableConfigurations
|
||||||
|
@ -11,20 +11,24 @@ enum GenerateError: Error {
|
|||||||
case fileNotExists(String)
|
case fileNotExists(String)
|
||||||
case invalidConfigurationFile(String)
|
case invalidConfigurationFile(String)
|
||||||
case commandError([String], String)
|
case commandError([String], String)
|
||||||
|
case writeFile(String, String)
|
||||||
|
|
||||||
var localizedDescription: String {
|
var description: String {
|
||||||
switch self {
|
switch self {
|
||||||
case .fileNotExists(let filename):
|
case .fileNotExists(let filename):
|
||||||
return " error:[\(Generate.toolName)] File \(filename) does not exists"
|
return "error: [\(Generate.toolName)] File \(filename) does not exists"
|
||||||
|
|
||||||
case .invalidConfigurationFile(let filename):
|
case .invalidConfigurationFile(let filename):
|
||||||
return " error:[\(Generate.toolName)] File \(filename) is not a valid configuration file"
|
return "error: [\(Generate.toolName)] File \(filename) is not a valid configuration file"
|
||||||
|
|
||||||
case .commandError(let command, let terminationStatus):
|
case .commandError(let command, let terminationStatus):
|
||||||
let readableCommand = command
|
let readableCommand = command
|
||||||
.map { $0 }
|
.map { $0 }
|
||||||
.joined(separator: " ")
|
.joined(separator: " ")
|
||||||
return "error:[\(Generate.toolName)] An error occured while running command '\(readableCommand)'. Command terminate with status code: \(terminationStatus)"
|
return "error: [\(Generate.toolName)] An error occured while running command '\(readableCommand)'. Command terminate with status code: \(terminationStatus)"
|
||||||
|
|
||||||
|
case .writeFile(let filename, let info):
|
||||||
|
return "error: [\(Generate.toolName)] An error occured while writing file in \(filename): \(info)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
//
|
||||||
|
// ArchitectureGenerator.swift
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by Thibaut Schmitt on 18/11/2022.
|
||||||
|
//
|
||||||
|
|
||||||
|
import ToolCore
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
struct ArchitectureGenerator {
|
||||||
|
static func writeArchitecture(_ architecture: ConfigurationArchitecture, projectDirectory: String) {
|
||||||
|
// Create extension content
|
||||||
|
let architectureContent = [
|
||||||
|
"// Generated by ResgenSwift.\(Generate.toolName) \(ResgenSwiftVersion)",
|
||||||
|
architecture.getClass()
|
||||||
|
]
|
||||||
|
.joined(separator: "\n\n")
|
||||||
|
|
||||||
|
let filename = "\(architecture.classname).swift"
|
||||||
|
guard let filePath = architecture.path?.prependIfRelativePath(projectDirectory) else {
|
||||||
|
let error = GenerateError.writeFile(filename, "Path of file is not defined.")
|
||||||
|
print(error.description)
|
||||||
|
Generate.exit(withError: error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write content
|
||||||
|
let architectureFilePathURL = URL(fileURLWithPath: "\(filePath)/\(filename)")
|
||||||
|
do {
|
||||||
|
try architectureContent.write(to: architectureFilePathURL, atomically: false, encoding: .utf8)
|
||||||
|
} catch (let error) {
|
||||||
|
let error = GenerateError.writeFile(filename, error.localizedDescription)
|
||||||
|
print(error.description)
|
||||||
|
Generate.exit(withError: error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
struct ConfigurationFile: Codable, CustomDebugStringConvertible {
|
struct ConfigurationFile: Codable, CustomDebugStringConvertible {
|
||||||
|
var architecture: ConfigurationArchitecture?
|
||||||
var colors: [ColorsConfiguration]
|
var colors: [ColorsConfiguration]
|
||||||
var fonts: [FontsConfiguration]
|
var fonts: [FontsConfiguration]
|
||||||
var images: [ImagesConfiguration]
|
var images: [ImagesConfiguration]
|
||||||
@ -38,6 +39,42 @@ struct ConfigurationFile: Codable, CustomDebugStringConvertible {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ConfigurationArchitecture: Codable {
|
||||||
|
let property: String
|
||||||
|
let classname: String
|
||||||
|
let path: String?
|
||||||
|
let children: [ConfigurationArchitecture]?
|
||||||
|
|
||||||
|
func getProperty(isStatic: Bool) -> String {
|
||||||
|
" \(isStatic ? "static " : "")let \(property) = \(classname)()"
|
||||||
|
}
|
||||||
|
|
||||||
|
func getClass(generateStaticProperty: Bool = true) -> String {
|
||||||
|
guard children?.isEmpty == false else {
|
||||||
|
return "class \(classname) {}"
|
||||||
|
}
|
||||||
|
|
||||||
|
let classDefinition = [
|
||||||
|
"class \(classname) {",
|
||||||
|
children?.map { $0.getProperty(isStatic: generateStaticProperty) }.joined(separator: "\n"),
|
||||||
|
"}"
|
||||||
|
]
|
||||||
|
.compactMap { $0 }
|
||||||
|
.joined(separator: "\n")
|
||||||
|
|
||||||
|
return [classDefinition, "", getSubclass()]
|
||||||
|
.compactMap { $0 }
|
||||||
|
.joined(separator: "\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
func getSubclass() -> String? {
|
||||||
|
guard let children else { return nil }
|
||||||
|
return children.compactMap { arch in
|
||||||
|
arch.getClass(generateStaticProperty: false)
|
||||||
|
}
|
||||||
|
.joined(separator: "\n\n")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct ColorsConfiguration: Codable, CustomDebugStringConvertible {
|
struct ColorsConfiguration: Codable, CustomDebugStringConvertible {
|
||||||
let inputFile: String
|
let inputFile: String
|
||||||
@ -45,6 +82,7 @@ struct ColorsConfiguration: Codable, CustomDebugStringConvertible {
|
|||||||
let xcassetsPath: String
|
let xcassetsPath: String
|
||||||
let extensionOutputPath: String
|
let extensionOutputPath: String
|
||||||
let extensionName: String?
|
let extensionName: String?
|
||||||
|
let extensionNameSwiftUI: String?
|
||||||
let extensionSuffix: String?
|
let extensionSuffix: String?
|
||||||
private let staticMembers: Bool?
|
private let staticMembers: Bool?
|
||||||
|
|
||||||
@ -55,6 +93,24 @@ struct ColorsConfiguration: Codable, CustomDebugStringConvertible {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal init(inputFile: String,
|
||||||
|
style: String,
|
||||||
|
xcassetsPath: String,
|
||||||
|
extensionOutputPath: String,
|
||||||
|
extensionName: String?,
|
||||||
|
extensionNameSwiftUI: String?,
|
||||||
|
extensionSuffix: String?,
|
||||||
|
staticMembers: Bool?) {
|
||||||
|
self.inputFile = inputFile
|
||||||
|
self.style = style
|
||||||
|
self.xcassetsPath = xcassetsPath
|
||||||
|
self.extensionOutputPath = extensionOutputPath
|
||||||
|
self.extensionName = extensionName
|
||||||
|
self.extensionNameSwiftUI = extensionNameSwiftUI
|
||||||
|
self.extensionSuffix = extensionSuffix
|
||||||
|
self.staticMembers = staticMembers
|
||||||
|
}
|
||||||
|
|
||||||
var debugDescription: String {
|
var debugDescription: String {
|
||||||
"""
|
"""
|
||||||
Colors configuration:
|
Colors configuration:
|
||||||
@ -63,6 +119,7 @@ struct ColorsConfiguration: Codable, CustomDebugStringConvertible {
|
|||||||
- Xcassets path: \(xcassetsPath)
|
- Xcassets path: \(xcassetsPath)
|
||||||
- Extension output path: \(extensionOutputPath)
|
- Extension output path: \(extensionOutputPath)
|
||||||
- Extension name: \(extensionName ?? "-")
|
- Extension name: \(extensionName ?? "-")
|
||||||
|
- Extension name SwiftUI: \(extensionNameSwiftUI ?? "-")
|
||||||
- Extension suffix: \(extensionSuffix ?? "-")
|
- Extension suffix: \(extensionSuffix ?? "-")
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
@ -72,7 +129,9 @@ struct FontsConfiguration: Codable, CustomDebugStringConvertible {
|
|||||||
let inputFile: String
|
let inputFile: String
|
||||||
let extensionOutputPath: String
|
let extensionOutputPath: String
|
||||||
let extensionName: String?
|
let extensionName: String?
|
||||||
|
let extensionNameSwiftUI: String?
|
||||||
let extensionSuffix: String?
|
let extensionSuffix: String?
|
||||||
|
let infoPlistPaths: String?
|
||||||
private let staticMembers: Bool?
|
private let staticMembers: Bool?
|
||||||
|
|
||||||
var staticMembersOptions: Bool {
|
var staticMembersOptions: Bool {
|
||||||
@ -82,13 +141,31 @@ struct FontsConfiguration: Codable, CustomDebugStringConvertible {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal init(inputFile: String,
|
||||||
|
extensionOutputPath: String,
|
||||||
|
extensionName: String?,
|
||||||
|
extensionNameSwiftUI: String?,
|
||||||
|
extensionSuffix: String?,
|
||||||
|
infoPlistPaths: String?,
|
||||||
|
staticMembers: Bool?) {
|
||||||
|
self.inputFile = inputFile
|
||||||
|
self.extensionOutputPath = extensionOutputPath
|
||||||
|
self.extensionName = extensionName
|
||||||
|
self.extensionNameSwiftUI = extensionNameSwiftUI
|
||||||
|
self.extensionSuffix = extensionSuffix
|
||||||
|
self.infoPlistPaths = infoPlistPaths
|
||||||
|
self.staticMembers = staticMembers
|
||||||
|
}
|
||||||
|
|
||||||
var debugDescription: String {
|
var debugDescription: String {
|
||||||
"""
|
"""
|
||||||
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 SwiftUI: \(extensionNameSwiftUI ?? "-")
|
||||||
- Extension suffix: \(extensionSuffix ?? "-")
|
- Extension suffix: \(extensionSuffix ?? "-")
|
||||||
|
- InfoPlistPaths: \(infoPlistPaths ?? "-")
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -98,6 +175,7 @@ struct ImagesConfiguration: Codable, CustomDebugStringConvertible {
|
|||||||
let xcassetsPath: String
|
let xcassetsPath: String
|
||||||
let extensionOutputPath: String
|
let extensionOutputPath: String
|
||||||
let extensionName: String?
|
let extensionName: String?
|
||||||
|
let extensionNameSwiftUI: String?
|
||||||
let extensionSuffix: String?
|
let extensionSuffix: String?
|
||||||
private let staticMembers: Bool?
|
private let staticMembers: Bool?
|
||||||
|
|
||||||
@ -108,6 +186,22 @@ struct ImagesConfiguration: Codable, CustomDebugStringConvertible {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal init(inputFile: String,
|
||||||
|
xcassetsPath: String,
|
||||||
|
extensionOutputPath: String,
|
||||||
|
extensionName: String?,
|
||||||
|
extensionNameSwiftUI: String?,
|
||||||
|
extensionSuffix: String?,
|
||||||
|
staticMembers: Bool?) {
|
||||||
|
self.inputFile = inputFile
|
||||||
|
self.xcassetsPath = xcassetsPath
|
||||||
|
self.extensionOutputPath = extensionOutputPath
|
||||||
|
self.extensionName = extensionName
|
||||||
|
self.extensionNameSwiftUI = extensionNameSwiftUI
|
||||||
|
self.extensionSuffix = extensionSuffix
|
||||||
|
self.staticMembers = staticMembers
|
||||||
|
}
|
||||||
|
|
||||||
var debugDescription: String {
|
var debugDescription: String {
|
||||||
"""
|
"""
|
||||||
Images configuration:
|
Images configuration:
|
||||||
@ -115,6 +209,7 @@ struct ImagesConfiguration: Codable, CustomDebugStringConvertible {
|
|||||||
- Xcassets path: \(xcassetsPath)
|
- Xcassets path: \(xcassetsPath)
|
||||||
- Extension output path: \(extensionOutputPath)
|
- Extension output path: \(extensionOutputPath)
|
||||||
- Extension name: \(extensionName ?? "-")
|
- Extension name: \(extensionName ?? "-")
|
||||||
|
- Extension name SwiftUI: \(extensionNameSwiftUI ?? "-")
|
||||||
- Extension suffix: \(extensionSuffix ?? "-")
|
- Extension suffix: \(extensionSuffix ?? "-")
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
@ -137,6 +232,24 @@ struct StringsConfiguration: Codable, CustomDebugStringConvertible {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal init(inputFile: String,
|
||||||
|
outputPath: String,
|
||||||
|
langs: String,
|
||||||
|
defaultLang: String,
|
||||||
|
extensionOutputPath: String,
|
||||||
|
extensionName: String?,
|
||||||
|
extensionSuffix: String?,
|
||||||
|
staticMembers: Bool?) {
|
||||||
|
self.inputFile = inputFile
|
||||||
|
self.outputPath = outputPath
|
||||||
|
self.langs = langs
|
||||||
|
self.defaultLang = defaultLang
|
||||||
|
self.extensionOutputPath = extensionOutputPath
|
||||||
|
self.extensionName = extensionName
|
||||||
|
self.extensionSuffix = extensionSuffix
|
||||||
|
self.staticMembers = staticMembers
|
||||||
|
}
|
||||||
|
|
||||||
var debugDescription: String {
|
var debugDescription: String {
|
||||||
"""
|
"""
|
||||||
Strings configuration:
|
Strings configuration:
|
||||||
@ -166,6 +279,20 @@ struct TagsConfiguration: Codable, CustomDebugStringConvertible {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal init(inputFile: String,
|
||||||
|
lang: String,
|
||||||
|
extensionOutputPath: String,
|
||||||
|
extensionName: String?,
|
||||||
|
extensionSuffix: String?,
|
||||||
|
staticMembers: Bool?) {
|
||||||
|
self.inputFile = inputFile
|
||||||
|
self.lang = lang
|
||||||
|
self.extensionOutputPath = extensionOutputPath
|
||||||
|
self.extensionName = extensionName
|
||||||
|
self.extensionSuffix = extensionSuffix
|
||||||
|
self.staticMembers = staticMembers
|
||||||
|
}
|
||||||
|
|
||||||
var debugDescription: String {
|
var debugDescription: String {
|
||||||
"""
|
"""
|
||||||
Tags configuration:
|
Tags configuration:
|
||||||
@ -177,4 +304,3 @@ struct TagsConfiguration: Codable, CustomDebugStringConvertible {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,13 +12,13 @@ class ConfigurationFileParser {
|
|||||||
static func parse(_ configurationFile: String) -> ConfigurationFile {
|
static func parse(_ configurationFile: String) -> ConfigurationFile {
|
||||||
guard let data = FileManager().contents(atPath: configurationFile) else {
|
guard let data = FileManager().contents(atPath: configurationFile) else {
|
||||||
let error = GenerateError.fileNotExists(configurationFile)
|
let error = GenerateError.fileNotExists(configurationFile)
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Generate.exit(withError: error)
|
Generate.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let configuration = try? YAMLDecoder().decode(ConfigurationFile.self, from: data) else {
|
guard let configuration = try? YAMLDecoder().decode(ConfigurationFile.self, from: data) else {
|
||||||
let error = GenerateError.invalidConfigurationFile(configurationFile)
|
let error = GenerateError.invalidConfigurationFile(configurationFile)
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Generate.exit(withError: error)
|
Generate.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,11 @@ import Foundation
|
|||||||
|
|
||||||
extension ColorsConfiguration: Runnable {
|
extension ColorsConfiguration: Runnable {
|
||||||
func run(projectDirectory: String, force: Bool) {
|
func run(projectDirectory: String, force: Bool) {
|
||||||
|
let args = getArguments(projectDirectory: projectDirectory, force: force)
|
||||||
|
Colors.main(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getArguments(projectDirectory: String, force: Bool) -> [String] {
|
||||||
var args = [String]()
|
var args = [String]()
|
||||||
|
|
||||||
if force {
|
if force {
|
||||||
@ -33,6 +38,12 @@ extension ColorsConfiguration: Runnable {
|
|||||||
extensionName
|
extensionName
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
if let extensionNameSwiftUI = extensionNameSwiftUI {
|
||||||
|
args += [
|
||||||
|
"--extension-name-swift-ui",
|
||||||
|
extensionNameSwiftUI
|
||||||
|
]
|
||||||
|
}
|
||||||
if let extensionSuffix = extensionSuffix {
|
if let extensionSuffix = extensionSuffix {
|
||||||
args += [
|
args += [
|
||||||
"--extension-suffix",
|
"--extension-suffix",
|
||||||
@ -40,6 +51,6 @@ extension ColorsConfiguration: Runnable {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
Colors.main(args)
|
return args
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,6 +9,11 @@ import Foundation
|
|||||||
|
|
||||||
extension FontsConfiguration: Runnable {
|
extension FontsConfiguration: Runnable {
|
||||||
func run(projectDirectory: String, force: Bool) {
|
func run(projectDirectory: String, force: Bool) {
|
||||||
|
let args = getArguments(projectDirectory: projectDirectory, force: force)
|
||||||
|
Fonts.main(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getArguments(projectDirectory: String, force: Bool) -> [String] {
|
||||||
var args = [String]()
|
var args = [String]()
|
||||||
|
|
||||||
if force {
|
if force {
|
||||||
@ -29,6 +34,12 @@ extension FontsConfiguration: Runnable {
|
|||||||
extensionName
|
extensionName
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
if let extensionNameSwiftUI = extensionNameSwiftUI {
|
||||||
|
args += [
|
||||||
|
"--extension-name-swift-ui",
|
||||||
|
extensionNameSwiftUI
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
if let extensionSuffix = extensionSuffix {
|
if let extensionSuffix = extensionSuffix {
|
||||||
args += [
|
args += [
|
||||||
@ -37,6 +48,18 @@ extension FontsConfiguration: Runnable {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
Fonts.main(args)
|
if let infoPlistPaths = infoPlistPaths {
|
||||||
|
let adjustedPlistPaths = infoPlistPaths
|
||||||
|
.split(separator: " ")
|
||||||
|
.map { String($0).prependIfRelativePath(projectDirectory) }
|
||||||
|
.joined(separator: " ")
|
||||||
|
|
||||||
|
args += [
|
||||||
|
"--info-plist-paths",
|
||||||
|
adjustedPlistPaths
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
return args
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,6 +9,11 @@ import Foundation
|
|||||||
|
|
||||||
extension ImagesConfiguration: Runnable {
|
extension ImagesConfiguration: Runnable {
|
||||||
func run(projectDirectory: String, force: Bool) {
|
func run(projectDirectory: String, force: Bool) {
|
||||||
|
let args = getArguments(projectDirectory: projectDirectory, force: force)
|
||||||
|
Images.main(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getArguments(projectDirectory: String, force: Bool) -> [String] {
|
||||||
var args = [String]()
|
var args = [String]()
|
||||||
|
|
||||||
if force {
|
if force {
|
||||||
@ -31,6 +36,12 @@ extension ImagesConfiguration: Runnable {
|
|||||||
extensionName
|
extensionName
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
if let extensionNameSwiftUI = extensionNameSwiftUI {
|
||||||
|
args += [
|
||||||
|
"--extension-name-swift-ui",
|
||||||
|
extensionNameSwiftUI
|
||||||
|
]
|
||||||
|
}
|
||||||
if let extensionSuffix = extensionSuffix {
|
if let extensionSuffix = extensionSuffix {
|
||||||
args += [
|
args += [
|
||||||
"--extension-suffix",
|
"--extension-suffix",
|
||||||
@ -38,6 +49,6 @@ extension ImagesConfiguration: Runnable {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
Images.main(args)
|
return args
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,7 +12,7 @@ extension FileManager {
|
|||||||
var files = [String]()
|
var files = [String]()
|
||||||
guard let enumerator = self.enumerator(at: URL(string: directory)!, includingPropertiesForKeys: [.isRegularFileKey], options: [.skipsHiddenFiles, .skipsPackageDescendants]) else {
|
guard let enumerator = self.enumerator(at: URL(string: directory)!, includingPropertiesForKeys: [.isRegularFileKey], options: [.skipsHiddenFiles, .skipsPackageDescendants]) else {
|
||||||
let error = ImagesError.unknown("Cannot enumerate file in \(directory)")
|
let error = ImagesError.unknown("Cannot enumerate file in \(directory)")
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Images.exit(withError: error)
|
Images.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ extension FileManager {
|
|||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
let error = ImagesError.getFileAttributed(fileURL.relativePath, error.localizedDescription)
|
let error = ImagesError.getFileAttributed(fileURL.relativePath, error.localizedDescription)
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Images.exit(withError: error)
|
Images.exit(withError: error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ extension FileManager {
|
|||||||
var files = [String]()
|
var files = [String]()
|
||||||
guard let enumerator = self.enumerator(at: URL(string: directory)!, includingPropertiesForKeys: [.isDirectoryKey], options: [.skipsHiddenFiles, .skipsPackageDescendants]) else {
|
guard let enumerator = self.enumerator(at: URL(string: directory)!, includingPropertiesForKeys: [.isDirectoryKey], options: [.skipsHiddenFiles, .skipsPackageDescendants]) else {
|
||||||
let error = ImagesError.unknown("Cannot enumerate imageset directory in \(directory)")
|
let error = ImagesError.unknown("Cannot enumerate imageset directory in \(directory)")
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Images.exit(withError: error)
|
Images.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ extension FileManager {
|
|||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
let error = ImagesError.getFileAttributed(fileURL.relativePath, error.localizedDescription)
|
let error = ImagesError.getFileAttributed(fileURL.relativePath, error.localizedDescription)
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Images.exit(withError: error)
|
Images.exit(withError: error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,18 +10,20 @@ import Foundation
|
|||||||
|
|
||||||
class ImageExtensionGenerator {
|
class ImageExtensionGenerator {
|
||||||
|
|
||||||
// MARK: - pragm
|
// MARK: - UIKit
|
||||||
|
|
||||||
static func generateExtensionFile(images: [ParsedImage],
|
static func generateExtensionFile(images: [ParsedImage],
|
||||||
staticVar: Bool,
|
staticVar: Bool,
|
||||||
inputFilename: String,
|
inputFilename: String,
|
||||||
extensionName: String,
|
extensionName: String,
|
||||||
extensionFilePath: String) {
|
extensionFilePath: String,
|
||||||
|
isSwiftUI: Bool) {
|
||||||
// Create extension conten1t
|
// Create extension conten1t
|
||||||
let extensionContent = Self.getExtensionContent(images: images,
|
let extensionContent = Self.getExtensionContent(images: images,
|
||||||
staticVar: staticVar,
|
staticVar: staticVar,
|
||||||
extensionName: extensionName,
|
extensionName: extensionName,
|
||||||
inputFilename: inputFilename)
|
inputFilename: inputFilename,
|
||||||
|
isSwiftUI: isSwiftUI)
|
||||||
|
|
||||||
// Write content
|
// Write content
|
||||||
let extensionFilePathURL = URL(fileURLWithPath: extensionFilePath)
|
let extensionFilePathURL = URL(fileURLWithPath: extensionFilePath)
|
||||||
@ -29,49 +31,47 @@ class ImageExtensionGenerator {
|
|||||||
try extensionContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8)
|
try extensionContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8)
|
||||||
} catch (let error) {
|
} catch (let error) {
|
||||||
let error = ImagesError.writeFile(extensionFilePath, error.localizedDescription)
|
let error = ImagesError.writeFile(extensionFilePath, error.localizedDescription)
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Images.exit(withError: error)
|
Images.exit(withError: error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Extension content
|
static func getExtensionContent(images: [ParsedImage],
|
||||||
|
staticVar: Bool,
|
||||||
static func getExtensionContent(images: [ParsedImage], staticVar: Bool, extensionName: String, inputFilename: String) -> String {
|
extensionName: String,
|
||||||
|
inputFilename: String,
|
||||||
|
isSwiftUI: Bool) -> String {
|
||||||
[
|
[
|
||||||
Self.getHeader(inputFilename: inputFilename, extensionClassname: extensionName),
|
Self.getHeader(inputFilename: inputFilename, extensionClassname: extensionName, isSwiftUI: isSwiftUI),
|
||||||
Self.getProperties(images: images, staticVar: staticVar),
|
Self.getProperties(images: images, staticVar: staticVar, isSwiftUI: isSwiftUI),
|
||||||
Self.getFooter()
|
Self.getFooter()
|
||||||
]
|
]
|
||||||
.joined(separator: "\n")
|
.joined(separator: "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Extension part
|
private static func getHeader(inputFilename: String,
|
||||||
|
extensionClassname: String,
|
||||||
private static func getHeader(inputFilename: String, extensionClassname: String) -> String {
|
isSwiftUI: Bool) -> String {
|
||||||
"""
|
"""
|
||||||
// Generated by ResgenSwift.\(Images.toolName) \(ResgenSwiftVersion)
|
// Generated by ResgenSwift.\(Images.toolName) \(ResgenSwiftVersion)
|
||||||
// Images from \(inputFilename)
|
// Images from \(inputFilename)
|
||||||
|
|
||||||
import UIKit
|
import \(isSwiftUI ? "SwiftUI" : "UIKit")
|
||||||
|
|
||||||
extension \(extensionClassname) {
|
extension \(extensionClassname) {
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func getProperties(images: [ParsedImage], staticVar: Bool) -> String {
|
private static func getProperties(images: [ParsedImage], staticVar: Bool, isSwiftUI: Bool) -> String {
|
||||||
if staticVar {
|
images
|
||||||
return images
|
.map { "\n\($0.getImageProperty(isStatic: staticVar, isSwiftUI: isSwiftUI))" }
|
||||||
.map { "\n\($0.getStaticImageProperty())" }
|
|
||||||
.joined(separator: "\n")
|
|
||||||
}
|
|
||||||
return images
|
|
||||||
.map { "\n\($0.getImageProperty())" }
|
|
||||||
.joined(separator: "\n")
|
.joined(separator: "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func getFooter() -> String {
|
private static func getFooter() -> String {
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ class XcassetsGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let error = ImagesError.unknownImageExtension(parsedImage.name)
|
let error = ImagesError.unknownImageExtension(parsedImage.name)
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Images.exit(withError: error)
|
Images.exit(withError: error)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ class XcassetsGenerator {
|
|||||||
withIntermediateDirectories: true)
|
withIntermediateDirectories: true)
|
||||||
} catch {
|
} catch {
|
||||||
let error = ImagesError.createAssetFolder(imagesetPath)
|
let error = ImagesError.createAssetFolder(imagesetPath)
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Images.exit(withError: error)
|
Images.exit(withError: error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ struct Images: ParsableCommand {
|
|||||||
|
|
||||||
static let toolName = "Images"
|
static let toolName = "Images"
|
||||||
static let defaultExtensionName = "UIImage"
|
static let defaultExtensionName = "UIImage"
|
||||||
|
static let defaultExtensionNameSUI = "Image"
|
||||||
|
|
||||||
// MARK: - Command Options
|
// MARK: - Command Options
|
||||||
|
|
||||||
@ -56,8 +57,15 @@ struct Images: ParsableCommand {
|
|||||||
staticVar: options.staticMembers,
|
staticVar: options.staticMembers,
|
||||||
inputFilename: options.inputFilenameWithoutExt,
|
inputFilename: options.inputFilenameWithoutExt,
|
||||||
extensionName: options.extensionName,
|
extensionName: options.extensionName,
|
||||||
extensionFilePath: options.extensionFilePath)
|
extensionFilePath: options.extensionFilePath,
|
||||||
|
isSwiftUI: false)
|
||||||
|
|
||||||
|
ImageExtensionGenerator.generateExtensionFile(images: imagesToGenerate,
|
||||||
|
staticVar: options.staticMembers,
|
||||||
|
inputFilename: options.inputFilenameWithoutExt,
|
||||||
|
extensionName: options.extensionNameSwiftUI,
|
||||||
|
extensionFilePath: options.extensionFilePathSwiftUI,
|
||||||
|
isSwiftUI: true)
|
||||||
|
|
||||||
print("[\(Self.toolName)] Images generated")
|
print("[\(Self.toolName)] Images generated")
|
||||||
}
|
}
|
||||||
@ -74,13 +82,20 @@ struct Images: ParsableCommand {
|
|||||||
// Input file
|
// Input file
|
||||||
guard fileManager.fileExists(atPath: options.inputFile) else {
|
guard fileManager.fileExists(atPath: options.inputFile) else {
|
||||||
let error = ImagesError.fileNotExists(options.inputFile)
|
let error = ImagesError.fileNotExists(options.inputFile)
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Images.exit(withError: error)
|
Images.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RSVG-Converter
|
// RSVG-Converter
|
||||||
_ = Images.getSvgConverterPath()
|
_ = Images.getSvgConverterPath()
|
||||||
|
|
||||||
|
// Extension for UIKit and SwiftUI should have different name
|
||||||
|
guard options.extensionName != options.extensionNameSwiftUI else {
|
||||||
|
let error = ImagesError.extensionNamesCollision(options.extensionName)
|
||||||
|
print(error.description)
|
||||||
|
Images.exit(withError: error)
|
||||||
|
}
|
||||||
|
|
||||||
// Check if needed to regenerate
|
// Check if needed to regenerate
|
||||||
guard GeneratorChecker.shouldGenerate(force: options.forceExecution,
|
guard GeneratorChecker.shouldGenerate(force: options.forceExecution,
|
||||||
inputFilePath: options.inputFile,
|
inputFilePath: options.inputFile,
|
||||||
@ -102,7 +117,7 @@ struct Images: ParsableCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let error = ImagesError.rsvgConvertNotFound
|
let error = ImagesError.rsvgConvertNotFound
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Images.exit(withError: error)
|
Images.exit(withError: error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
enum ImagesError: Error {
|
enum ImagesError: Error {
|
||||||
|
case extensionNamesCollision(String)
|
||||||
case inputFolderNotFound(String)
|
case inputFolderNotFound(String)
|
||||||
case fileNotExists(String)
|
case fileNotExists(String)
|
||||||
case unknownImageExtension(String)
|
case unknownImageExtension(String)
|
||||||
@ -17,31 +18,34 @@ enum ImagesError: Error {
|
|||||||
case createAssetFolder(String)
|
case createAssetFolder(String)
|
||||||
case unknown(String)
|
case unknown(String)
|
||||||
|
|
||||||
var localizedDescription: String {
|
var description: String {
|
||||||
switch self {
|
switch self {
|
||||||
|
case .extensionNamesCollision(let extensionName):
|
||||||
|
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)"
|
||||||
|
|
||||||
case .fileNotExists(let filename):
|
case .fileNotExists(let filename):
|
||||||
return " error:[\(Images.toolName)] File \(filename) does not exists"
|
return "error: [\(Images.toolName)] File \(filename) does not exists"
|
||||||
|
|
||||||
case .unknownImageExtension(let filename):
|
case .unknownImageExtension(let filename):
|
||||||
return " error:[\(Images.toolName)] File \(filename) have an unhandled file extension. Cannot generate image."
|
return "error: [\(Images.toolName)] File \(filename) have an unhandled file extension. Cannot generate image."
|
||||||
|
|
||||||
case .getFileAttributed(let filename, let errorDescription):
|
case .getFileAttributed(let filename, let errorDescription):
|
||||||
return " error:[\(Images.toolName)] Getting file attributes of \(filename) failed with error: \(errorDescription)"
|
return "error: [\(Images.toolName)] Getting file attributes of \(filename) failed with error: \(errorDescription)"
|
||||||
|
|
||||||
case .rsvgConvertNotFound:
|
case .rsvgConvertNotFound:
|
||||||
return " error:[\(Images.toolName)] Can't find rsvg-convert (can be installed with 'brew remove imagemagick && brew install imagemagick --with-librsvg')"
|
return "error: [\(Images.toolName)] Can't find rsvg-convert (can be installed with 'brew remove imagemagick && brew install imagemagick --with-librsvg')"
|
||||||
|
|
||||||
case .writeFile(let subErrorDescription, let filename):
|
case .writeFile(let subErrorDescription, let filename):
|
||||||
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:[\(Colors.toolName)] An error occured while creating folder `\(folder)`"
|
return "error: [\(Colors.toolName)] An error occured while creating folder `\(folder)`"
|
||||||
|
|
||||||
case .unknown(let errorDescription):
|
case .unknown(let errorDescription):
|
||||||
return " error:[\(Images.toolName)] Unknown error: \(errorDescription)"
|
return "error: [\(Images.toolName)] Unknown error: \(errorDescription)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,9 +27,12 @@ struct ImagesOptions: ParsableArguments {
|
|||||||
@Option(help: "Tell if it will generate static properties or not")
|
@Option(help: "Tell if it will generate static properties or not")
|
||||||
var staticMembers: Bool = false
|
var staticMembers: Bool = false
|
||||||
|
|
||||||
@Option(help: "Extension name. If not specified, it will generate an UIImage extension. Using default extension name will generate static property.")
|
@Option(help: "Extension name. If not specified, it will generate an UIImage extension.")
|
||||||
var extensionName: String = Images.defaultExtensionName
|
var extensionName: String = Images.defaultExtensionName
|
||||||
|
|
||||||
|
@Option(help: "Extension name. If not specified, it will generate an Image extension.")
|
||||||
|
var extensionNameSwiftUI: String = Images.defaultExtensionNameSUI
|
||||||
|
|
||||||
@Option(help: "Extension 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?
|
||||||
}
|
}
|
||||||
@ -37,6 +40,9 @@ struct ImagesOptions: ParsableArguments {
|
|||||||
// MARK: - Computed var
|
// MARK: - Computed var
|
||||||
|
|
||||||
extension ImagesOptions {
|
extension ImagesOptions {
|
||||||
|
|
||||||
|
// MARK: - UIKit
|
||||||
|
|
||||||
var extensionFileName: String {
|
var extensionFileName: String {
|
||||||
if let extensionSuffix = extensionSuffix {
|
if let extensionSuffix = extensionSuffix {
|
||||||
return "\(extensionName)+\(extensionSuffix).swift"
|
return "\(extensionName)+\(extensionSuffix).swift"
|
||||||
@ -48,6 +54,21 @@ extension ImagesOptions {
|
|||||||
"\(extensionOutputPath)/\(extensionFileName)"
|
"\(extensionOutputPath)/\(extensionFileName)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - SwiftUI
|
||||||
|
|
||||||
|
var extensionFileNameSwiftUI: String {
|
||||||
|
if let extensionSuffix = extensionSuffix {
|
||||||
|
return "\(extensionNameSwiftUI)+\(extensionSuffix).swift"
|
||||||
|
}
|
||||||
|
return "\(extensionNameSwiftUI).swift"
|
||||||
|
}
|
||||||
|
|
||||||
|
var extensionFilePathSwiftUI: String {
|
||||||
|
"\(extensionOutputPath)/\(extensionFileNameSwiftUI)"
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: -
|
||||||
|
|
||||||
var inputFilenameWithoutExt: String {
|
var inputFilenameWithoutExt: String {
|
||||||
URL(fileURLWithPath: inputFile)
|
URL(fileURLWithPath: inputFile)
|
||||||
.deletingPathExtension()
|
.deletingPathExtension()
|
||||||
|
@ -72,17 +72,16 @@ struct ParsedImage {
|
|||||||
|
|
||||||
// MARK: - Extension property
|
// MARK: - Extension property
|
||||||
|
|
||||||
func getImageProperty() -> String {
|
func getImageProperty(isStatic: Bool, isSwiftUI: Bool) -> String {
|
||||||
"""
|
if isSwiftUI {
|
||||||
var \(name): UIImage {
|
return """
|
||||||
UIImage(named: "\(name)")!
|
\(isStatic ? "static ": "")var \(name): Image {
|
||||||
}
|
Image("\(name)")
|
||||||
"""
|
}
|
||||||
}
|
"""
|
||||||
|
}
|
||||||
func getStaticImageProperty() -> String {
|
return """
|
||||||
"""
|
\(isStatic ? "static ": "")var \(name): UIImage {
|
||||||
static var \(name): UIImage {
|
|
||||||
UIImage(named: "\(name)")!
|
UIImage(named: "\(name)")!
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
@ -12,7 +12,12 @@ class StringsFileGenerator {
|
|||||||
|
|
||||||
// MARK: - Strings Files
|
// MARK: - Strings Files
|
||||||
|
|
||||||
static func writeStringsFiles(sections: [Section], langs: [String], defaultLang: String, tags: [String], outputPath: String, inputFilenameWithoutExt: String) {
|
static func writeStringsFiles(sections: [Section],
|
||||||
|
langs: [String],
|
||||||
|
defaultLang: String,
|
||||||
|
tags: [String],
|
||||||
|
outputPath: String,
|
||||||
|
inputFilenameWithoutExt: String) {
|
||||||
var stringsFilesContent = [String: String]()
|
var stringsFilesContent = [String: String]()
|
||||||
for lang in langs {
|
for lang in langs {
|
||||||
stringsFilesContent[lang] = Self.generateStringsFileContent(lang: lang,
|
stringsFilesContent[lang] = Self.generateStringsFileContent(lang: lang,
|
||||||
@ -31,13 +36,16 @@ class StringsFileGenerator {
|
|||||||
try fileContent.write(to: stringsFilePathURL, atomically: false, encoding: .utf8)
|
try fileContent.write(to: stringsFilePathURL, atomically: false, encoding: .utf8)
|
||||||
} catch (let error) {
|
} catch (let error) {
|
||||||
let error = StringiumError.writeFile(error.localizedDescription, stringsFilePath)
|
let error = StringiumError.writeFile(error.localizedDescription, stringsFilePath)
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Stringium.exit(withError: error)
|
Stringium.exit(withError: error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static func generateStringsFileContent(lang: String, defaultLang: String, tags inputTags: [String], sections: [Section]) -> String {
|
static func generateStringsFileContent(lang: String,
|
||||||
|
defaultLang: String,
|
||||||
|
tags inputTags: [String],
|
||||||
|
sections: [Section]) -> String {
|
||||||
var stringsFileContent = """
|
var stringsFileContent = """
|
||||||
/**
|
/**
|
||||||
* Apple Strings File
|
* Apple Strings File
|
||||||
@ -75,7 +83,7 @@ class StringsFileGenerator {
|
|||||||
stringsFileContent += "\"\(definition.name)\" = \"\(translation)\";\n\n"
|
stringsFileContent += "\"\(definition.name)\" = \"\(translation)\";\n\n"
|
||||||
} else if skipDefinition == false {
|
} else if skipDefinition == false {
|
||||||
let error = StringiumError.langNotDefined(lang, definition.name, definition.reference != nil)
|
let error = StringiumError.langNotDefined(lang, definition.name, definition.reference != nil)
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Stringium.exit(withError: error)
|
Stringium.exit(withError: error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,14 +94,22 @@ class StringsFileGenerator {
|
|||||||
|
|
||||||
// MARK: - Extension file
|
// MARK: - Extension file
|
||||||
|
|
||||||
static func writeExtensionFiles(sections: [Section], defaultLang lang: String, tags: [String], staticVar: Bool, inputFilename: String, extensionName: String, extensionFilePath: String) {
|
static func writeExtensionFiles(sections: [Section],
|
||||||
|
defaultLang lang: String,
|
||||||
|
tags: [String],
|
||||||
|
staticVar: Bool,
|
||||||
|
inputFilename: String,
|
||||||
|
extensionName: String,
|
||||||
|
extensionFilePath: String,
|
||||||
|
extensionSuffix: String) {
|
||||||
// Get extension content
|
// Get extension content
|
||||||
let extensionFileContent = Self.getExtensionContent(sections: sections,
|
let extensionFileContent = Self.getExtensionContent(sections: sections,
|
||||||
defaultLang: lang,
|
defaultLang: lang,
|
||||||
tags: tags,
|
tags: tags,
|
||||||
staticVar: staticVar,
|
staticVar: staticVar,
|
||||||
inputFilename: inputFilename,
|
inputFilename: inputFilename,
|
||||||
extensionName: extensionName)
|
extensionName: extensionName,
|
||||||
|
extensionSuffix: extensionSuffix)
|
||||||
|
|
||||||
// Write content
|
// Write content
|
||||||
let extensionFilePathURL = URL(fileURLWithPath: extensionFilePath)
|
let extensionFilePathURL = URL(fileURLWithPath: extensionFilePath)
|
||||||
@ -101,16 +117,23 @@ class StringsFileGenerator {
|
|||||||
try extensionFileContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8)
|
try extensionFileContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8)
|
||||||
} catch (let error) {
|
} catch (let error) {
|
||||||
let error = StringiumError.writeFile(extensionFilePath, error.localizedDescription)
|
let error = StringiumError.writeFile(extensionFilePath, error.localizedDescription)
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Stringium.exit(withError: error)
|
Stringium.exit(withError: error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Extension content
|
// MARK: - Extension content
|
||||||
|
|
||||||
static func getExtensionContent(sections: [Section], defaultLang lang: String, tags: [String], staticVar: Bool, inputFilename: String, extensionName: String) -> String {
|
static func getExtensionContent(sections: [Section],
|
||||||
|
defaultLang lang: String,
|
||||||
|
tags: [String],
|
||||||
|
staticVar: Bool,
|
||||||
|
inputFilename: String,
|
||||||
|
extensionName: String,
|
||||||
|
extensionSuffix: String) -> String {
|
||||||
[
|
[
|
||||||
Self.getHeader(stringsFilename: inputFilename, extensionClassname: extensionName),
|
Self.getHeader(stringsFilename: inputFilename, extensionClassname: extensionName),
|
||||||
|
Self.getEnumKey(sections: sections, tags: tags, extensionClassname: extensionName, extensionSuffix: extensionSuffix),
|
||||||
Self.getProperties(sections: sections, defaultLang: lang, tags: tags, staticVar: staticVar),
|
Self.getProperties(sections: sections, defaultLang: lang, tags: tags, staticVar: staticVar),
|
||||||
Self.getFooter()
|
Self.getFooter()
|
||||||
]
|
]
|
||||||
@ -131,6 +154,50 @@ class StringsFileGenerator {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static func getEnumKey(sections: [Section], tags: [String], extensionClassname: String, extensionSuffix: String) -> String {
|
||||||
|
var enumDefinition = "\n enum Key\(extensionSuffix.uppercasedFirst()): String {\n"
|
||||||
|
|
||||||
|
// Enum
|
||||||
|
sections.forEach { section in
|
||||||
|
// Check that at least one string will be generated
|
||||||
|
guard section.hasOneOrMoreMatchingTags(tags: tags) else {
|
||||||
|
return // Go to next section
|
||||||
|
}
|
||||||
|
|
||||||
|
section.definitions.forEach { definition in
|
||||||
|
guard definition.hasOneOrMoreMatchingTags(inputTags: tags) == true else {
|
||||||
|
return // Go to next definition
|
||||||
|
}
|
||||||
|
debugPrint("Found definition")
|
||||||
|
enumDefinition += " case \(definition.name) = \"\(definition.name)\"\n"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyPath accessors
|
||||||
|
enumDefinition += "\n"
|
||||||
|
enumDefinition += " var keyPath: KeyPath<\(extensionClassname), String> {\n"
|
||||||
|
enumDefinition += " switch self {\n"
|
||||||
|
sections.forEach { section in
|
||||||
|
// Check that at least one string will be generated
|
||||||
|
guard section.hasOneOrMoreMatchingTags(tags: tags) else {
|
||||||
|
return // Go to next section
|
||||||
|
}
|
||||||
|
|
||||||
|
section.definitions.forEach { definition in
|
||||||
|
guard definition.hasOneOrMoreMatchingTags(inputTags: tags) == true else {
|
||||||
|
return // Go to next definition
|
||||||
|
}
|
||||||
|
debugPrint("Found definition")
|
||||||
|
enumDefinition += " case .\(definition.name): return \\\(extensionClassname).\(definition.name)\n"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
enumDefinition += " }\n" // Switch
|
||||||
|
enumDefinition += " }\n" // var keyPath
|
||||||
|
enumDefinition += " }" // Enum
|
||||||
|
|
||||||
|
return enumDefinition
|
||||||
|
}
|
||||||
|
|
||||||
private static func getProperties(sections: [Section], defaultLang lang: String, tags: [String], staticVar: Bool) -> String {
|
private static func getProperties(sections: [Section], defaultLang lang: String, tags: [String], staticVar: Bool) -> 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
|
||||||
@ -158,6 +225,7 @@ class StringsFileGenerator {
|
|||||||
private static func getFooter() -> String {
|
private static func getFooter() -> String {
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ class TagsGenerator {
|
|||||||
try extensionFileContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8)
|
try extensionFileContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8)
|
||||||
} catch (let error) {
|
} catch (let error) {
|
||||||
let error = StringiumError.writeFile(extensionFilePath, error.localizedDescription)
|
let error = StringiumError.writeFile(extensionFilePath, error.localizedDescription)
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Stringium.exit(withError: error)
|
Stringium.exit(withError: error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -80,6 +80,7 @@ class TagsGenerator {
|
|||||||
private static func getFooter() -> String {
|
private static func getFooter() -> String {
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ class Definition {
|
|||||||
func getNSLocalizedStringProperty(forLang lang: String) -> String {
|
func getNSLocalizedStringProperty(forLang lang: String) -> 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.localizedDescription)
|
print(error.description)
|
||||||
Stringium.exit(withError: error)
|
Stringium.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ class Definition {
|
|||||||
func getNSLocalizedStringStaticProperty(forLang lang: String) -> String {
|
func getNSLocalizedStringStaticProperty(forLang lang: String) -> 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.localizedDescription)
|
print(error.description)
|
||||||
Stringium.exit(withError: error)
|
Stringium.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ class Definition {
|
|||||||
func getProperty(forLang lang: String) -> String {
|
func getProperty(forLang lang: String) -> 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.localizedDescription)
|
print(error.description)
|
||||||
Stringium.exit(withError: error)
|
Stringium.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ class Definition {
|
|||||||
func getStaticProperty(forLang lang: String) -> String {
|
func getStaticProperty(forLang lang: String) -> 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.localizedDescription)
|
print(error.description)
|
||||||
Stringium.exit(withError: error)
|
Stringium.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ class TwineFileParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if invalidDefinitionNames.count > 0 {
|
if invalidDefinitionNames.count > 0 {
|
||||||
print(" warning:[\(Stringium.toolName)] Found \(invalidDefinitionNames.count) definition (\(invalidDefinitionNames.joined(separator: ", "))")
|
print("warning: [\(Stringium.toolName)] Found \(invalidDefinitionNames.count) definition (\(invalidDefinitionNames.joined(separator: ", "))")
|
||||||
}
|
}
|
||||||
|
|
||||||
return sections
|
return sections
|
||||||
|
@ -57,7 +57,8 @@ struct Stringium: ParsableCommand {
|
|||||||
staticVar: options.staticMembers,
|
staticVar: options.staticMembers,
|
||||||
inputFilename: options.inputFilenameWithoutExt,
|
inputFilename: options.inputFilenameWithoutExt,
|
||||||
extensionName: options.extensionName,
|
extensionName: options.extensionName,
|
||||||
extensionFilePath: options.extensionFilePath)
|
extensionFilePath: options.extensionFilePath,
|
||||||
|
extensionSuffix: options.extensionSuffix)
|
||||||
|
|
||||||
print("[\(Self.toolName)] Strings generated")
|
print("[\(Self.toolName)] Strings generated")
|
||||||
}
|
}
|
||||||
@ -70,20 +71,20 @@ struct Stringium: ParsableCommand {
|
|||||||
// Input file
|
// Input file
|
||||||
guard fileManager.fileExists(atPath: options.inputFile) else {
|
guard fileManager.fileExists(atPath: options.inputFile) else {
|
||||||
let error = StringiumError.fileNotExists(options.inputFile)
|
let error = StringiumError.fileNotExists(options.inputFile)
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Stringium.exit(withError: error)
|
Stringium.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Langs
|
// Langs
|
||||||
guard options.langs.isEmpty == false else {
|
guard options.langs.isEmpty == false else {
|
||||||
let error = StringiumError.langsListEmpty
|
let error = StringiumError.langsListEmpty
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Stringium.exit(withError: error)
|
Stringium.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
guard options.langs.contains(options.defaultLang) else {
|
guard options.langs.contains(options.defaultLang) else {
|
||||||
let error = StringiumError.defaultLangsNotInLangs
|
let error = StringiumError.defaultLangsNotInLangs
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Stringium.exit(withError: error)
|
Stringium.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,25 +14,25 @@ enum StringiumError: Error {
|
|||||||
case writeFile(String, String)
|
case writeFile(String, String)
|
||||||
case langNotDefined(String, String, Bool)
|
case langNotDefined(String, String, Bool)
|
||||||
|
|
||||||
var localizedDescription: String {
|
var description: String {
|
||||||
switch self {
|
switch self {
|
||||||
case .fileNotExists(let filename):
|
case .fileNotExists(let filename):
|
||||||
return " error:[\(Stringium.toolName)] File \(filename) does not exists "
|
return "error: [\(Stringium.toolName)] File \(filename) does not exists "
|
||||||
|
|
||||||
case .langsListEmpty:
|
case .langsListEmpty:
|
||||||
return " error:[\(Stringium.toolName)] Langs list is empty"
|
return "error: [\(Stringium.toolName)] Langs list is empty"
|
||||||
|
|
||||||
case .defaultLangsNotInLangs:
|
case .defaultLangsNotInLangs:
|
||||||
return " error:[\(Stringium.toolName)] Langs list does not contains the default lang"
|
return "error: [\(Stringium.toolName)] Langs list does not contains the default lang"
|
||||||
|
|
||||||
case .writeFile(let subErrorDescription, let filename):
|
case .writeFile(let subErrorDescription, let filename):
|
||||||
return " error:[\(Stringium.toolName)] An error occured while writing content to \(filename): \(subErrorDescription)"
|
return "error: [\(Stringium.toolName)] An error occured while writing content to \(filename): \(subErrorDescription)"
|
||||||
|
|
||||||
case .langNotDefined(let lang, let definitionName, let isReference):
|
case .langNotDefined(let lang, let definitionName, let isReference):
|
||||||
if isReference {
|
if isReference {
|
||||||
return " error:[\(Stringium.toolName)] Reference are handled only by TwineTool. Please use it or remove reference from you strings file."
|
return "error: [\(Stringium.toolName)] Reference are handled only by Twine. Please use it or remove reference from you strings file."
|
||||||
}
|
}
|
||||||
return " error:[\(Stringium.toolName)] Lang \"\(lang)\" not found for \"\(definitionName)\""
|
return "error: [\(Stringium.toolName)] Lang \"\(lang)\" not found for \"\(definitionName)\""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,11 +33,11 @@ struct StringiumOptions: ParsableArguments {
|
|||||||
@Option(help: "Tell if it will generate static properties or not")
|
@Option(help: "Tell if it will generate static properties or not")
|
||||||
var staticMembers: Bool = false
|
var staticMembers: Bool = false
|
||||||
|
|
||||||
@Option(help: "Extension name. If not specified, it will generate an String extension. Using default extension name will generate static property.")
|
@Option(help: "Extension name. If not specified, it will generate an String extension.")
|
||||||
var extensionName: String = Stringium.defaultExtensionName
|
var extensionName: String = Stringium.defaultExtensionName
|
||||||
|
|
||||||
@Option(help: "Extension suffix. Ex: MyApp, it will generate {extensionName}+{extensionSuffix}.swift")
|
@Option(help: "Extension suffix: {extensionName}+{extensionSuffix}.swift")
|
||||||
var extensionSuffix: String?
|
var extensionSuffix: String
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Private var getter
|
// MARK: - Private var getter
|
||||||
@ -68,10 +68,7 @@ extension StringiumOptions {
|
|||||||
|
|
||||||
extension StringiumOptions {
|
extension StringiumOptions {
|
||||||
var extensionFileName: String {
|
var extensionFileName: String {
|
||||||
if let extensionSuffix = extensionSuffix {
|
"\(extensionName)+\(extensionSuffix).swift"
|
||||||
return "\(extensionName)+\(extensionSuffix).swift"
|
|
||||||
}
|
|
||||||
return "\(extensionName).swift"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var extensionFilePath: String {
|
var extensionFilePath: String {
|
||||||
|
@ -62,7 +62,7 @@ struct Tags: ParsableCommand {
|
|||||||
// Input file
|
// Input file
|
||||||
guard fileManager.fileExists(atPath: options.inputFile) else {
|
guard fileManager.fileExists(atPath: options.inputFile) else {
|
||||||
let error = StringiumError.fileNotExists(options.inputFile)
|
let error = StringiumError.fileNotExists(options.inputFile)
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Stringium.exit(withError: error)
|
Stringium.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ struct TagsOptions: ParsableArguments {
|
|||||||
@Option(help: "Tell if it will generate static properties or not")
|
@Option(help: "Tell if it will generate static properties or not")
|
||||||
var staticMembers: Bool = false
|
var staticMembers: Bool = false
|
||||||
|
|
||||||
@Option(help: "Extension name. If not specified, it will generate a Tag extension. Using default extension name will generate static property.")
|
@Option(help: "Extension name. If not specified, it will generate a Tag extension.")
|
||||||
var extensionName: String = Tags.defaultExtensionName
|
var extensionName: String = Tags.defaultExtensionName
|
||||||
|
|
||||||
@Option(help: "Extension suffix. Ex: MyApp, it will generate {extensionName}+Tag{extensionSuffix}.swift")
|
@Option(help: "Extension suffix. Ex: MyApp, it will generate {extensionName}+Tag{extensionSuffix}.swift")
|
||||||
|
@ -66,20 +66,20 @@ struct Twine: ParsableCommand {
|
|||||||
// Input file
|
// Input file
|
||||||
guard fileManager.fileExists(atPath: options.inputFile) else {
|
guard fileManager.fileExists(atPath: options.inputFile) else {
|
||||||
let error = TwineError.fileNotExists(options.inputFile)
|
let error = TwineError.fileNotExists(options.inputFile)
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Twine.exit(withError: error)
|
Twine.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Langs
|
// Langs
|
||||||
guard options.langs.isEmpty == false else {
|
guard options.langs.isEmpty == false else {
|
||||||
let error = TwineError.langsListEmpty
|
let error = TwineError.langsListEmpty
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Twine.exit(withError: error)
|
Twine.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
guard options.langs.contains(options.defaultLang) else {
|
guard options.langs.contains(options.defaultLang) else {
|
||||||
let error = TwineError.defaultLangsNotInLangs
|
let error = TwineError.defaultLangsNotInLangs
|
||||||
print(error.localizedDescription)
|
print(error.description)
|
||||||
Twine.exit(withError: error)
|
Twine.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,16 +12,16 @@ enum TwineError: Error {
|
|||||||
case langsListEmpty
|
case langsListEmpty
|
||||||
case defaultLangsNotInLangs
|
case defaultLangsNotInLangs
|
||||||
|
|
||||||
var localizedDescription: String {
|
var description: String {
|
||||||
switch self {
|
switch self {
|
||||||
case .fileNotExists(let filename):
|
case .fileNotExists(let filename):
|
||||||
return " error:[\(Twine.toolName)] File \(filename) does not exists "
|
return "error: [\(Twine.toolName)] File \(filename) does not exists "
|
||||||
|
|
||||||
case .langsListEmpty:
|
case .langsListEmpty:
|
||||||
return " error:[\(Twine.toolName)] Langs list is empty"
|
return "error: [\(Twine.toolName)] Langs list is empty"
|
||||||
|
|
||||||
case .defaultLangsNotInLangs:
|
case .defaultLangsNotInLangs:
|
||||||
return " error:[\(Twine.toolName)] Langs list does not contains the default lang"
|
return "error: [\(Twine.toolName)] Langs list does not contains the default lang"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,4 +85,8 @@ public extension String {
|
|||||||
blue = String(colorClean.prefix(2))
|
blue = String(colorClean.prefix(2))
|
||||||
return (alpha: alpha, red: red, green: green, blue: blue)
|
return (alpha: alpha, red: red, green: green, blue: blue)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func uppercasedFirst() -> String {
|
||||||
|
prefix(1).uppercased() + dropFirst()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,4 +7,4 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public let ResgenSwiftVersion = "1.0"
|
public let ResgenSwiftVersion = "1.2"
|
||||||
|
@ -13,7 +13,7 @@ import ToolCore
|
|||||||
|
|
||||||
final class ColorExtensionGeneratorTests: XCTestCase {
|
final class ColorExtensionGeneratorTests: XCTestCase {
|
||||||
|
|
||||||
func testGeneratedExtensionContent() {
|
func test_uiKit_GeneratedExtensionContent() {
|
||||||
// Given
|
// Given
|
||||||
let colors = [
|
let colors = [
|
||||||
ParsedColor(name: "colorOne", light: "#FF00FF", dark: "#00FF00"),
|
ParsedColor(name: "colorOne", light: "#FF00FF", dark: "#00FF00"),
|
||||||
@ -23,7 +23,8 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
|||||||
// When
|
// When
|
||||||
let extensionContent = ColorExtensionGenerator.getExtensionContent(colors: colors,
|
let extensionContent = ColorExtensionGenerator.getExtensionContent(colors: colors,
|
||||||
staticVar: false,
|
staticVar: false,
|
||||||
extensionName: "GenColors")
|
extensionName: "GenColors",
|
||||||
|
isSwiftUI: false)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
@ -48,7 +49,7 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
|||||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
}
|
}
|
||||||
|
|
||||||
func testGeneratedExtensionContentForStaticVar() {
|
func test_uiKit_GeneratedExtensionContentForStaticVar() {
|
||||||
// Given
|
// Given
|
||||||
let colors = [
|
let colors = [
|
||||||
ParsedColor(name: "colorOne", light: "#FF00FF", dark: "#00FF00"),
|
ParsedColor(name: "colorOne", light: "#FF00FF", dark: "#00FF00"),
|
||||||
@ -58,7 +59,8 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
|||||||
// When
|
// When
|
||||||
let extensionContent = ColorExtensionGenerator.getExtensionContent(colors: colors,
|
let extensionContent = ColorExtensionGenerator.getExtensionContent(colors: colors,
|
||||||
staticVar: true,
|
staticVar: true,
|
||||||
extensionName: "GenColor")
|
extensionName: "GenColor",
|
||||||
|
isSwiftUI: false)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
@ -82,4 +84,76 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
|||||||
|
|
||||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func test_swiftUI_GeneratedExtensionContent() {
|
||||||
|
// Given
|
||||||
|
let colors = [
|
||||||
|
ParsedColor(name: "colorOne", light: "#FF00FF", dark: "#00FF00"),
|
||||||
|
ParsedColor(name: "colorTwo", light: "#F0F0F0", dark: "#0F0F0F")
|
||||||
|
]
|
||||||
|
|
||||||
|
// When
|
||||||
|
let extensionContent = ColorExtensionGenerator.getExtensionContent(colors: colors,
|
||||||
|
staticVar: false,
|
||||||
|
extensionName: "GenColors",
|
||||||
|
isSwiftUI: true)
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expect = """
|
||||||
|
// Generated by ResgenSwift.Color \(ResgenSwiftVersion)
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
extension GenColors {
|
||||||
|
|
||||||
|
/// Color colorOne is #FF00FF (light) or #00FF00 (dark)"
|
||||||
|
var colorOne: Color {
|
||||||
|
Color("colorOne")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
|
||||||
|
var colorTwo: Color {
|
||||||
|
Color("colorTwo")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
|
}
|
||||||
|
|
||||||
|
func test_swiftUI_GeneratedExtensionContentForStaticVar() {
|
||||||
|
// Given
|
||||||
|
let colors = [
|
||||||
|
ParsedColor(name: "colorOne", light: "#FF00FF", dark: "#00FF00"),
|
||||||
|
ParsedColor(name: "colorTwo", light: "#F0F0F0", dark: "#0F0F0F")
|
||||||
|
]
|
||||||
|
|
||||||
|
// When
|
||||||
|
let extensionContent = ColorExtensionGenerator.getExtensionContent(colors: colors,
|
||||||
|
staticVar: true,
|
||||||
|
extensionName: "GenColor",
|
||||||
|
isSwiftUI: true)
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expect = """
|
||||||
|
// Generated by ResgenSwift.Color \(ResgenSwiftVersion)
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
extension GenColor {
|
||||||
|
|
||||||
|
/// Color colorOne is #FF00FF (light) or #00FF00 (dark)"
|
||||||
|
static var colorOne: Color {
|
||||||
|
Color("colorOne")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
|
||||||
|
static var colorTwo: Color {
|
||||||
|
Color("colorTwo")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,12 +12,12 @@ import XCTest
|
|||||||
|
|
||||||
final class ParsedColorTests: XCTestCase {
|
final class ParsedColorTests: XCTestCase {
|
||||||
|
|
||||||
func testGeneratedProperty() {
|
func test_uiKit_GeneratedProperty() {
|
||||||
// Given
|
// Given
|
||||||
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)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
@ -30,12 +30,12 @@ final class ParsedColorTests: XCTestCase {
|
|||||||
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
}
|
}
|
||||||
|
|
||||||
func testGeneratedStaticProperty() {
|
func test_uiKit_GeneratedStaticProperty() {
|
||||||
// Given
|
// Given
|
||||||
let color = ParsedColor(name: "red", light: "#FF0000", dark: "#0000FF")
|
let color = ParsedColor(name: "red", light: "#FF0000", dark: "#0000FF")
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let property = color.getColorStaticProperty()
|
let property = color.getColorProperty(isStatic: true, isSwiftUI: false)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
@ -48,6 +48,42 @@ final class ParsedColorTests: XCTestCase {
|
|||||||
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func test_swiftUI_GeneratedProperty() {
|
||||||
|
// Given
|
||||||
|
let color = ParsedColor(name: "red", light: "#FF0000", dark: "#0000FF")
|
||||||
|
|
||||||
|
// When
|
||||||
|
let property = color.getColorProperty(isStatic: false, isSwiftUI: true)
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expect = """
|
||||||
|
/// Color red is #FF0000 (light) or #0000FF (dark)"
|
||||||
|
var red: Color {
|
||||||
|
Color("red")
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
|
}
|
||||||
|
|
||||||
|
func test_swiftUI_GeneratedStaticProperty() {
|
||||||
|
// Given
|
||||||
|
let color = ParsedColor(name: "red", light: "#FF0000", dark: "#0000FF")
|
||||||
|
|
||||||
|
// When
|
||||||
|
let property = color.getColorProperty(isStatic: true, isSwiftUI: true)
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expect = """
|
||||||
|
/// Color red is #FF0000 (light) or #0000FF (dark)"
|
||||||
|
static var red: Color {
|
||||||
|
Color("red")
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
|
}
|
||||||
|
|
||||||
func testGeneratedColorAsset() {
|
func testGeneratedColorAsset() {
|
||||||
// Given
|
// Given
|
||||||
let color = ParsedColor(name: "red", light: "#FF0000", dark: "#0000FF")
|
let color = ParsedColor(name: "red", light: "#FF0000", dark: "#0000FF")
|
||||||
|
@ -13,7 +13,7 @@ import ToolCore
|
|||||||
|
|
||||||
final class FontExtensionGeneratorTests: XCTestCase {
|
final class FontExtensionGeneratorTests: XCTestCase {
|
||||||
|
|
||||||
func testGeneratedExtensionContent() {
|
func test_uiKit_GeneratedExtensionContent() {
|
||||||
// Given
|
// Given
|
||||||
let fontNames: [FontName] = [
|
let fontNames: [FontName] = [
|
||||||
"CircularStd-Regular",
|
"CircularStd-Regular",
|
||||||
@ -23,7 +23,8 @@ final class FontExtensionGeneratorTests: XCTestCase {
|
|||||||
// When
|
// When
|
||||||
let extensionContent = FontExtensionGenerator.getExtensionContent(fontsNames: fontNames,
|
let extensionContent = FontExtensionGenerator.getExtensionContent(fontsNames: fontNames,
|
||||||
staticVar: false,
|
staticVar: false,
|
||||||
extensionName: "GenFonts")
|
extensionName: "GenFonts",
|
||||||
|
isSwiftUI: false)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
@ -53,5 +54,47 @@ final class FontExtensionGeneratorTests: XCTestCase {
|
|||||||
|
|
||||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func test_swiftUI_GeneratedExtensionContent() {
|
||||||
|
// Given
|
||||||
|
let fontNames: [FontName] = [
|
||||||
|
"CircularStd-Regular",
|
||||||
|
"CircularStd-Bold"
|
||||||
|
]
|
||||||
|
|
||||||
|
// When
|
||||||
|
let extensionContent = FontExtensionGenerator.getExtensionContent(fontsNames: fontNames,
|
||||||
|
staticVar: false,
|
||||||
|
extensionName: "GenFonts",
|
||||||
|
isSwiftUI: true)
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expect = """
|
||||||
|
// Generated by ResgenSwift.Fonts \(ResgenSwiftVersion)
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
extension GenFonts {
|
||||||
|
|
||||||
|
enum FontName: String {
|
||||||
|
case CircularStdRegular = "CircularStd-Regular"
|
||||||
|
case CircularStdBold = "CircularStd-Bold"
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Getter
|
||||||
|
|
||||||
|
func CircularStdRegular(withSize size: CGFloat) -> Font {
|
||||||
|
Font.custom(FontName.CircularStdRegular.rawValue, size: size)
|
||||||
|
}
|
||||||
|
|
||||||
|
func CircularStdBold(withSize size: CGFloat) -> Font {
|
||||||
|
Font.custom(FontName.CircularStdBold.rawValue, size: size)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,12 +12,12 @@ import XCTest
|
|||||||
|
|
||||||
final class FontNameTests: XCTestCase {
|
final class FontNameTests: XCTestCase {
|
||||||
|
|
||||||
func testGeneratedProperty_noForbiddenCharacter() {
|
func test_uiKit_GeneratedProperty_noForbiddenCharacter() {
|
||||||
// Given
|
// Given
|
||||||
let fontName: FontName = "CircularStdBold"
|
let fontName: FontName = "CircularStdBold"
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let property = fontName.staticProperty
|
let property = fontName.getProperty(isStatic: true, isSwiftUI: false)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
@ -29,12 +29,12 @@ final class FontNameTests: XCTestCase {
|
|||||||
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
}
|
}
|
||||||
|
|
||||||
func testGeneratedProperty_withForbiddenCharacter() {
|
func test_uiKit_GeneratedProperty_withForbiddenCharacter() {
|
||||||
// Given
|
// Given
|
||||||
let fontName: FontName = "[Circular_Std+Bold-Underline]"
|
let fontName: FontName = "[Circular_Std+Bold-Underline]"
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let property = fontName.staticProperty
|
let property = fontName.getProperty(isStatic: true, isSwiftUI: false)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
@ -46,12 +46,12 @@ final class FontNameTests: XCTestCase {
|
|||||||
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
}
|
}
|
||||||
|
|
||||||
func testGeneratedMethod_noForbiddenCharacter() {
|
func test_uiKit_GeneratedMethod_noForbiddenCharacter() {
|
||||||
// Given
|
// Given
|
||||||
let fontName: FontName = "CircularStdBold"
|
let fontName: FontName = "CircularStdBold"
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let property = fontName.method
|
let property = fontName.getProperty(isStatic: false, isSwiftUI: false)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
@ -63,12 +63,12 @@ final class FontNameTests: XCTestCase {
|
|||||||
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
}
|
}
|
||||||
|
|
||||||
func testGeneratedMethod_withForbiddenCharacter() {
|
func test_uiKit_GeneratedMethod_withForbiddenCharacter() {
|
||||||
// Given
|
// Given
|
||||||
let fontName: FontName = "[Circular_Std+Bold-Underline]"
|
let fontName: FontName = "[Circular_Std+Bold-Underline]"
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let property = fontName.method
|
let property = fontName.getProperty(isStatic: false, isSwiftUI: false)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
@ -79,5 +79,72 @@ final class FontNameTests: XCTestCase {
|
|||||||
|
|
||||||
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func test_swiftUI_GeneratedProperty_noForbiddenCharacter() {
|
||||||
|
// Given
|
||||||
|
let fontName: FontName = "CircularStdBold"
|
||||||
|
|
||||||
|
// When
|
||||||
|
let property = fontName.getProperty(isStatic: true, isSwiftUI: true)
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expect = """
|
||||||
|
static let CircularStdBold: ((_ size: CGFloat) -> Font) = { size in
|
||||||
|
Font.custom(FontName.CircularStdBold.rawValue, size: size)
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
|
}
|
||||||
|
|
||||||
|
func test_swiftUI_GeneratedProperty_withForbiddenCharacter() {
|
||||||
|
// Given
|
||||||
|
let fontName: FontName = "[Circular_Std+Bold-Underline]"
|
||||||
|
|
||||||
|
// When
|
||||||
|
let property = fontName.getProperty(isStatic: true, isSwiftUI: true)
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expect = """
|
||||||
|
static let CircularStdBoldUnderline: ((_ size: CGFloat) -> Font) = { size in
|
||||||
|
Font.custom(FontName.CircularStdBoldUnderline.rawValue, size: size)
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
|
}
|
||||||
|
|
||||||
|
func test_swiftUI_GeneratedMethod_noForbiddenCharacter() {
|
||||||
|
// Given
|
||||||
|
let fontName: FontName = "CircularStdBold"
|
||||||
|
|
||||||
|
// When
|
||||||
|
let property = fontName.getProperty(isStatic: false, isSwiftUI: true)
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expect = """
|
||||||
|
func CircularStdBold(withSize size: CGFloat) -> Font {
|
||||||
|
Font.custom(FontName.CircularStdBold.rawValue, size: size)
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
|
}
|
||||||
|
|
||||||
|
func test_swiftUI_GeneratedMethod_withForbiddenCharacter() {
|
||||||
|
// Given
|
||||||
|
let fontName: FontName = "[Circular_Std+Bold-Underline]"
|
||||||
|
|
||||||
|
// When
|
||||||
|
let property = fontName.getProperty(isStatic: false, isSwiftUI: true)
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expect = """
|
||||||
|
func CircularStdBoldUnderline(withSize size: CGFloat) -> Font {
|
||||||
|
Font.custom(FontName.CircularStdBoldUnderline.rawValue, size: size)
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ final class FontPlistGeneratorTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let plistContent = FontPlistGenerator.generatePlistUIAppsFontContent(for: fontNames)
|
let plistContent = FontPlistGenerator.generatePlistUIAppsFontContent(for: fontNames, infoPlistPaths: [String]())
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
|
@ -0,0 +1,81 @@
|
|||||||
|
//
|
||||||
|
// ColorsConfigurationTests.swift
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by Thibaut Schmitt on 04/11/2022.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import XCTest
|
||||||
|
|
||||||
|
@testable import ResgenSwift
|
||||||
|
|
||||||
|
final class ColorsConfigurationTests: XCTestCase {
|
||||||
|
|
||||||
|
let projectDirectory = "projectDirectory/"
|
||||||
|
|
||||||
|
func test_argsGeneration_requiredArgs() {
|
||||||
|
// Given
|
||||||
|
let testingConfiguration = ColorsConfiguration(inputFile: "path/to/colors.txt",
|
||||||
|
style: ColorStyle.all.rawValue,
|
||||||
|
xcassetsPath: "path/to/assets.xcassets",
|
||||||
|
extensionOutputPath: "Colors/Generated",
|
||||||
|
extensionName: nil,
|
||||||
|
extensionNameSwiftUI: nil,
|
||||||
|
extensionSuffix: nil,
|
||||||
|
staticMembers: false)
|
||||||
|
// When
|
||||||
|
let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: false)
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expectedArguments = [
|
||||||
|
"projectDirectory/path/to/colors.txt",
|
||||||
|
"--style",
|
||||||
|
"all",
|
||||||
|
"--xcassets-path",
|
||||||
|
"projectDirectory/path/to/assets.xcassets",
|
||||||
|
"--extension-output-path",
|
||||||
|
"projectDirectory/Colors/Generated",
|
||||||
|
"--static-members",
|
||||||
|
"false"
|
||||||
|
]
|
||||||
|
|
||||||
|
XCTAssertEqual(arguments, expectedArguments)
|
||||||
|
}
|
||||||
|
|
||||||
|
func test_argsGeneration_allArguments() {
|
||||||
|
// Given
|
||||||
|
let testingConfiguration = ColorsConfiguration(inputFile: "path/to/colors.txt",
|
||||||
|
style: ColorStyle.all.rawValue,
|
||||||
|
xcassetsPath: "path/to/assets.xcassets",
|
||||||
|
extensionOutputPath: "Colors/Generated",
|
||||||
|
extensionName: "AppUIColor",
|
||||||
|
extensionNameSwiftUI: "AppColor",
|
||||||
|
extensionSuffix: "Testing",
|
||||||
|
staticMembers: false)
|
||||||
|
// When
|
||||||
|
let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: true)
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expectedArguments = [
|
||||||
|
"-f",
|
||||||
|
"projectDirectory/path/to/colors.txt",
|
||||||
|
"--style",
|
||||||
|
"all",
|
||||||
|
"--xcassets-path",
|
||||||
|
"projectDirectory/path/to/assets.xcassets",
|
||||||
|
"--extension-output-path",
|
||||||
|
"projectDirectory/Colors/Generated",
|
||||||
|
"--static-members",
|
||||||
|
"false",
|
||||||
|
"--extension-name",
|
||||||
|
"AppUIColor",
|
||||||
|
"--extension-name-swift-ui",
|
||||||
|
"AppColor",
|
||||||
|
"--extension-suffix",
|
||||||
|
"Testing",
|
||||||
|
]
|
||||||
|
|
||||||
|
XCTAssertEqual(arguments, expectedArguments)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
//
|
||||||
|
// FontsConfigurationTests.swift
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by Thibaut Schmitt on 04/11/2022.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import XCTest
|
||||||
|
|
||||||
|
@testable import ResgenSwift
|
||||||
|
|
||||||
|
final class FontsConfigurationTests: XCTestCase {
|
||||||
|
|
||||||
|
let projectDirectory = "projectDirectory/"
|
||||||
|
|
||||||
|
func test_argsGeneration_requiredArgs() {
|
||||||
|
// Given
|
||||||
|
let testingConfiguration = FontsConfiguration(inputFile: "path/to/fonts.txt",
|
||||||
|
extensionOutputPath: "Fonts/Generated",
|
||||||
|
extensionName: nil,
|
||||||
|
extensionNameSwiftUI: nil,
|
||||||
|
extensionSuffix: nil,
|
||||||
|
infoPlistPaths: nil,
|
||||||
|
staticMembers: nil)
|
||||||
|
// When
|
||||||
|
let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: false)
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expectedArguments = [
|
||||||
|
"projectDirectory/path/to/fonts.txt",
|
||||||
|
"--extension-output-path",
|
||||||
|
"projectDirectory/Fonts/Generated",
|
||||||
|
"--static-members",
|
||||||
|
"false"
|
||||||
|
]
|
||||||
|
|
||||||
|
XCTAssertEqual(arguments, expectedArguments)
|
||||||
|
}
|
||||||
|
|
||||||
|
func test_argsGeneration_allArguments() {
|
||||||
|
// Given
|
||||||
|
let testingConfiguration = FontsConfiguration(inputFile: "path/to/fonts.txt",
|
||||||
|
extensionOutputPath: "Fonts/Generated",
|
||||||
|
extensionName: "AppUIFont",
|
||||||
|
extensionNameSwiftUI: "AppFont",
|
||||||
|
extensionSuffix: "Testing",
|
||||||
|
infoPlistPaths: "path/to/plist1.plist path/to/plist2.plist",
|
||||||
|
staticMembers: true)
|
||||||
|
// When
|
||||||
|
let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: true)
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expectedArguments = [
|
||||||
|
"-f",
|
||||||
|
"projectDirectory/path/to/fonts.txt",
|
||||||
|
"--extension-output-path",
|
||||||
|
"projectDirectory/Fonts/Generated",
|
||||||
|
"--static-members",
|
||||||
|
"true",
|
||||||
|
"--extension-name",
|
||||||
|
"AppUIFont",
|
||||||
|
"--extension-name-swift-ui",
|
||||||
|
"AppFont",
|
||||||
|
"--extension-suffix",
|
||||||
|
"Testing",
|
||||||
|
"--info-plist-paths",
|
||||||
|
"projectDirectory/path/to/plist1.plist projectDirectory/path/to/plist2.plist"
|
||||||
|
]
|
||||||
|
|
||||||
|
XCTAssertEqual(arguments, expectedArguments)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
//
|
||||||
|
// ImagesConfigurationTests.swift
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by Thibaut Schmitt on 04/11/2022.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import XCTest
|
||||||
|
|
||||||
|
@testable import ResgenSwift
|
||||||
|
|
||||||
|
final class ImagesConfigurationTests: XCTestCase {
|
||||||
|
|
||||||
|
let projectDirectory = "projectDirectory/"
|
||||||
|
|
||||||
|
func test_argsGeneration_requiredArgs() {
|
||||||
|
// Given
|
||||||
|
let testingConfiguration = ImagesConfiguration(inputFile: "path/to/images.txt",
|
||||||
|
xcassetsPath: "path/to/assets.xcassets",
|
||||||
|
extensionOutputPath: "Images/Generated",
|
||||||
|
extensionName: nil,
|
||||||
|
extensionNameSwiftUI: nil,
|
||||||
|
extensionSuffix: nil,
|
||||||
|
staticMembers: nil)
|
||||||
|
|
||||||
|
// When
|
||||||
|
let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: false)
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expectedArguments = [
|
||||||
|
"projectDirectory/path/to/images.txt",
|
||||||
|
"--xcassets-path",
|
||||||
|
"projectDirectory/path/to/assets.xcassets",
|
||||||
|
"--extension-output-path",
|
||||||
|
"projectDirectory/Images/Generated",
|
||||||
|
"--static-members",
|
||||||
|
"false"
|
||||||
|
]
|
||||||
|
|
||||||
|
XCTAssertEqual(arguments, expectedArguments)
|
||||||
|
}
|
||||||
|
|
||||||
|
func test_argsGeneration_allArguments() {
|
||||||
|
// Given
|
||||||
|
let testingConfiguration = ImagesConfiguration(inputFile: "path/to/images.txt",
|
||||||
|
xcassetsPath: "path/to/assets.xcassets",
|
||||||
|
extensionOutputPath: "Images/Generated",
|
||||||
|
extensionName: "AppUIImage",
|
||||||
|
extensionNameSwiftUI: "AppImage",
|
||||||
|
extensionSuffix: "Testing",
|
||||||
|
staticMembers: true)
|
||||||
|
|
||||||
|
// When
|
||||||
|
let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: true)
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expectedArguments = [
|
||||||
|
"-f",
|
||||||
|
"projectDirectory/path/to/images.txt",
|
||||||
|
"--xcassets-path",
|
||||||
|
"projectDirectory/path/to/assets.xcassets",
|
||||||
|
"--extension-output-path",
|
||||||
|
"projectDirectory/Images/Generated",
|
||||||
|
"--static-members",
|
||||||
|
"true",
|
||||||
|
"--extension-name",
|
||||||
|
"AppUIImage",
|
||||||
|
"--extension-name-swift-ui",
|
||||||
|
"AppImage",
|
||||||
|
"--extension-suffix",
|
||||||
|
"Testing",
|
||||||
|
]
|
||||||
|
|
||||||
|
XCTAssertEqual(arguments, expectedArguments)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -13,7 +13,7 @@ import ToolCore
|
|||||||
|
|
||||||
final class ImageExtensionGeneratorTests: XCTestCase {
|
final class ImageExtensionGeneratorTests: XCTestCase {
|
||||||
|
|
||||||
func testGeneratedExtensionContent() {
|
func test_uiKit_GeneratedExtensionContent() {
|
||||||
// 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),
|
||||||
@ -24,7 +24,8 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
|||||||
let extensionContent = ImageExtensionGenerator.getExtensionContent(images: images,
|
let extensionContent = ImageExtensionGenerator.getExtensionContent(images: images,
|
||||||
staticVar: false,
|
staticVar: false,
|
||||||
extensionName: "GenImages",
|
extensionName: "GenImages",
|
||||||
inputFilename: "myInputFilename")
|
inputFilename: "myInputFilename",
|
||||||
|
isSwiftUI: false)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
@ -48,7 +49,7 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
|||||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
}
|
}
|
||||||
|
|
||||||
func testGeneratedExtensionContentForStaticVar() {
|
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),
|
||||||
@ -59,7 +60,8 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
|||||||
let extensionContent = ImageExtensionGenerator.getExtensionContent(images: images,
|
let extensionContent = ImageExtensionGenerator.getExtensionContent(images: images,
|
||||||
staticVar: true,
|
staticVar: true,
|
||||||
extensionName: "GenImages",
|
extensionName: "GenImages",
|
||||||
inputFilename: "myInputFilename")
|
inputFilename: "myInputFilename",
|
||||||
|
isSwiftUI: false)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
@ -82,4 +84,76 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
|||||||
|
|
||||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func test_swiftUI_GeneratedExtensionContent() {
|
||||||
|
// Given
|
||||||
|
let images = [
|
||||||
|
ParsedImage(name: "image_one", tags: "id", width: 10, height: 10),
|
||||||
|
ParsedImage(name: "image_two", tags: "id", width: 180, height: 90),
|
||||||
|
]
|
||||||
|
|
||||||
|
// When
|
||||||
|
let extensionContent = ImageExtensionGenerator.getExtensionContent(images: images,
|
||||||
|
staticVar: false,
|
||||||
|
extensionName: "GenImages",
|
||||||
|
inputFilename: "myInputFilename",
|
||||||
|
isSwiftUI: true)
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expect = """
|
||||||
|
// Generated by ResgenSwift.Images \(ResgenSwiftVersion)
|
||||||
|
// Images from myInputFilename
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
extension GenImages {
|
||||||
|
|
||||||
|
var image_one: Image {
|
||||||
|
Image("image_one")
|
||||||
|
}
|
||||||
|
|
||||||
|
var image_two: Image {
|
||||||
|
Image("image_two")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
|
}
|
||||||
|
|
||||||
|
func test_swiftUI_GeneratedExtensionContentForStaticVar() {
|
||||||
|
// Given
|
||||||
|
let images = [
|
||||||
|
ParsedImage(name: "image_one", tags: "id", width: 10, height: 10),
|
||||||
|
ParsedImage(name: "image_two", tags: "id", width: 180, height: 90),
|
||||||
|
]
|
||||||
|
|
||||||
|
// When
|
||||||
|
let extensionContent = ImageExtensionGenerator.getExtensionContent(images: images,
|
||||||
|
staticVar: true,
|
||||||
|
extensionName: "GenImages",
|
||||||
|
inputFilename: "myInputFilename",
|
||||||
|
isSwiftUI: true)
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expect = """
|
||||||
|
// Generated by ResgenSwift.Images \(ResgenSwiftVersion)
|
||||||
|
// Images from myInputFilename
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
extension GenImages {
|
||||||
|
|
||||||
|
static var image_one: Image {
|
||||||
|
Image("image_one")
|
||||||
|
}
|
||||||
|
|
||||||
|
static var image_two: Image {
|
||||||
|
Image("image_two")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ final class ParsedImageTests: XCTestCase {
|
|||||||
XCTAssertEqual(convertArguments.x3.height, "30")
|
XCTAssertEqual(convertArguments.x3.height, "30")
|
||||||
}
|
}
|
||||||
|
|
||||||
func testGeneratedProperty() {
|
func test_uiKit_GeneratedProperty() {
|
||||||
// Given
|
// Given
|
||||||
let imageName = "the_name"
|
let imageName = "the_name"
|
||||||
let parsedImage = ParsedImage(name: imageName,
|
let parsedImage = ParsedImage(name: imageName,
|
||||||
@ -43,7 +43,7 @@ final class ParsedImageTests: XCTestCase {
|
|||||||
height: 10)
|
height: 10)
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let property = parsedImage.getImageProperty()
|
let property = parsedImage.getImageProperty(isStatic: false, isSwiftUI: false)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
@ -55,7 +55,7 @@ final class ParsedImageTests: XCTestCase {
|
|||||||
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
}
|
}
|
||||||
|
|
||||||
func testGeneratedStaticProperty() {
|
func test_uiKit_GeneratedStaticProperty() {
|
||||||
// Given
|
// Given
|
||||||
let imageName = "the_name"
|
let imageName = "the_name"
|
||||||
let parsedImage = ParsedImage(name: imageName,
|
let parsedImage = ParsedImage(name: imageName,
|
||||||
@ -64,7 +64,7 @@ final class ParsedImageTests: XCTestCase {
|
|||||||
height: 10)
|
height: 10)
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let property = parsedImage.getStaticImageProperty()
|
let property = parsedImage.getImageProperty(isStatic: true, isSwiftUI: false)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
@ -76,6 +76,48 @@ final class ParsedImageTests: XCTestCase {
|
|||||||
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func test_swiftUI_GeneratedProperty() {
|
||||||
|
// Given
|
||||||
|
let imageName = "the_name"
|
||||||
|
let parsedImage = ParsedImage(name: imageName,
|
||||||
|
tags: "id",
|
||||||
|
width: 10,
|
||||||
|
height: 10)
|
||||||
|
|
||||||
|
// When
|
||||||
|
let property = parsedImage.getImageProperty(isStatic: false, isSwiftUI: true)
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expect = """
|
||||||
|
var \(imageName): Image {
|
||||||
|
Image("\(imageName)")
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
|
}
|
||||||
|
|
||||||
|
func test_swiftUI_GeneratedStaticProperty() {
|
||||||
|
// Given
|
||||||
|
let imageName = "the_name"
|
||||||
|
let parsedImage = ParsedImage(name: imageName,
|
||||||
|
tags: "id",
|
||||||
|
width: 10,
|
||||||
|
height: 10)
|
||||||
|
|
||||||
|
// When
|
||||||
|
let property = parsedImage.getImageProperty(isStatic: true, isSwiftUI: true)
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expect = """
|
||||||
|
static var \(imageName): Image {
|
||||||
|
Image("\(imageName)")
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
|
}
|
||||||
|
|
||||||
func testAssetContentJson() {
|
func testAssetContentJson() {
|
||||||
// Given
|
// Given
|
||||||
let imageName = "the_name"
|
let imageName = "the_name"
|
||||||
|
@ -131,7 +131,8 @@ final class StringsFileGeneratorTests: XCTestCase {
|
|||||||
tags: ["ios", "iosonly", "notranslation"],
|
tags: ["ios", "iosonly", "notranslation"],
|
||||||
staticVar: false,
|
staticVar: false,
|
||||||
inputFilename: "myInputFilename",
|
inputFilename: "myInputFilename",
|
||||||
extensionName: "GenStrings")
|
extensionName: "GenStrings",
|
||||||
|
extensionSuffix: "strings")
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
@ -207,7 +208,8 @@ final class StringsFileGeneratorTests: XCTestCase {
|
|||||||
tags: ["ios", "iosonly", "notranslation"],
|
tags: ["ios", "iosonly", "notranslation"],
|
||||||
staticVar: true,
|
staticVar: true,
|
||||||
inputFilename: "myInputFilename",
|
inputFilename: "myInputFilename",
|
||||||
extensionName: "GenStrings")
|
extensionName: "GenStrings",
|
||||||
|
extensionSuffix: "strings")
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
|
13
install-completion.sh
Executable file
13
install-completion.sh
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/zsh
|
||||||
|
|
||||||
|
if [[ $SHELL == "/bin/zsh" ]]
|
||||||
|
then
|
||||||
|
if [ ! -d "~/.oh-my-zsh/completions" ]
|
||||||
|
then
|
||||||
|
mkdir -p ~/.oh-my-zsh/completions
|
||||||
|
fi
|
||||||
|
resgen-swift --generate-completion-script zsh > ~/.oh-my-zsh/completions/_resgen-swift
|
||||||
|
else
|
||||||
|
echo "Completion file can only be installed automaticaly for oh-my-zsh shell. See https://apple.github.io/swift-argument-parser/documentation/argumentparser/installingcompletionscripts to install it ti your shell"
|
||||||
|
fi
|
||||||
|
|
@ -1,4 +0,0 @@
|
|||||||
#!/bin/zsh
|
|
||||||
|
|
||||||
swift build -c release
|
|
||||||
cp .build/release/ResgenSwift /usr/local/bin/ResgenSwift
|
|
Reference in New Issue
Block a user