Merge pull request 'v1.2.1' (#4) from v1.2.1 into master
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
Reviewed-on: #4
This commit is contained in:
commit
78be15d57d
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
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Generated by ResgenSwift.Color 1.0
|
// Generated by ResgenSwift.Color 1.2
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
@ -18,4 +18,4 @@ extension ColorYolo {
|
|||||||
var blue_light_dark: Color {
|
var blue_light_dark: Color {
|
||||||
Color("blue_light_dark")
|
Color("blue_light_dark")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Generated by ResgenSwift.Color 1.0
|
// Generated by ResgenSwift.Color 1.2
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
@ -18,4 +18,4 @@ extension UIColorYolo {
|
|||||||
@objc var blue_light_dark: UIColor {
|
@objc var blue_light_dark: UIColor {
|
||||||
UIColor(named: "blue_light_dark")!
|
UIColor(named: "blue_light_dark")!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Generated by ResgenSwift.Fonts 1.0
|
// Generated by ResgenSwift.Fonts 1.2
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
@ -58,4 +58,4 @@ extension FontYolo {
|
|||||||
func LatoHairlineItalic(withSize size: CGFloat) -> Font {
|
func LatoHairlineItalic(withSize size: CGFloat) -> Font {
|
||||||
Font.custom(FontName.LatoHairlineItalic.rawValue, size: size)
|
Font.custom(FontName.LatoHairlineItalic.rawValue, size: size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Generated by ResgenSwift.Fonts 1.0
|
// Generated by ResgenSwift.Fonts 1.2
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
@ -58,4 +58,4 @@ extension UIFontYolo {
|
|||||||
func LatoHairlineItalic(withSize size: CGFloat) -> UIFont {
|
func LatoHairlineItalic(withSize size: CGFloat) -> UIFont {
|
||||||
UIFont(name: FontName.LatoHairlineItalic.rawValue, size: size)!
|
UIFont(name: FontName.LatoHairlineItalic.rawValue, size: size)!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Generated by ResgenSwift.Images 1.0
|
// Generated by ResgenSwift.Images 1.2
|
||||||
// Images from sampleImages
|
// Images from sampleImages
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
@ -28,4 +28,4 @@ extension ImageYolo {
|
|||||||
var ic_close_article: Image {
|
var ic_close_article: Image {
|
||||||
Image("ic_close_article")
|
Image("ic_close_article")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Generated by ResgenSwift.Images 1.0
|
// Generated by ResgenSwift.Images 1.2
|
||||||
// Images from sampleImages
|
// Images from sampleImages
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
@ -28,4 +28,4 @@ extension UIImage {
|
|||||||
var ic_close_article: UIImage {
|
var ic_close_article: UIImage {
|
||||||
UIImage(named: "ic_close_article")!
|
UIImage(named: "ic_close_article")!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Generated by ResgenSwift.Strings.Stringium 1.0
|
// Generated by ResgenSwift.Strings.Stringium 1.2
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
@ -6,6 +6,15 @@ fileprivate let kStringsFileName = "sampleStrings"
|
|||||||
|
|
||||||
extension String {
|
extension String {
|
||||||
|
|
||||||
|
enum Key: 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"
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Webservice
|
// MARK: - Webservice
|
||||||
|
|
||||||
/// Translation in en :
|
/// Translation in en :
|
||||||
@ -61,4 +70,4 @@ extension String {
|
|||||||
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,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* Apple Strings File
|
* Apple Strings File
|
||||||
* Generated by ResgenSwift 1.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
|
* Generated by ResgenSwift 1.2
|
||||||
* Language: en
|
* Language: en
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* Apple Strings File
|
* Apple Strings File
|
||||||
* Generated by ResgenSwift 1.0
|
* Generated by ResgenSwift 1.2
|
||||||
* Language: fr
|
* Language: fr
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Generated by ResgenSwift.Strings.Tags 1.0
|
// Generated by ResgenSwift.Strings.Tags 1.2
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
@ -17,4 +17,4 @@ extension Tags {
|
|||||||
var screen_two: String {
|
var screen_two: String {
|
||||||
"Ecran deux"
|
"Ecran deux"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,8 @@ struct Generate: ParsableCommand {
|
|||||||
print()
|
print()
|
||||||
|
|
||||||
if let architecture = configuration.architecture {
|
if let architecture = configuration.architecture {
|
||||||
ArchitectureGenerator.writeArchitecture(architecture)
|
ArchitectureGenerator.writeArchitecture(architecture,
|
||||||
|
projectDirectory: options.projectDirectory)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute commands
|
// Execute commands
|
||||||
|
@ -9,7 +9,7 @@ import ToolCore
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
struct ArchitectureGenerator {
|
struct ArchitectureGenerator {
|
||||||
static func writeArchitecture(_ architecture: ConfigurationArchitecture) {
|
static func writeArchitecture(_ architecture: ConfigurationArchitecture, projectDirectory: String) {
|
||||||
// Create extension content
|
// Create extension content
|
||||||
let architectureContent = [
|
let architectureContent = [
|
||||||
"// Generated by ResgenSwift.\(Generate.toolName) \(ResgenSwiftVersion)",
|
"// Generated by ResgenSwift.\(Generate.toolName) \(ResgenSwiftVersion)",
|
||||||
@ -18,7 +18,7 @@ struct ArchitectureGenerator {
|
|||||||
.joined(separator: "\n\n")
|
.joined(separator: "\n\n")
|
||||||
|
|
||||||
let filename = "\(architecture.classname).swift"
|
let filename = "\(architecture.classname).swift"
|
||||||
guard let filePath = architecture.path else {
|
guard let filePath = architecture.path?.prependIfRelativePath(projectDirectory) else {
|
||||||
let error = GenerateError.writeFile(filename, "Path of file is not defined.")
|
let error = GenerateError.writeFile(filename, "Path of file is not defined.")
|
||||||
print(error.description)
|
print(error.description)
|
||||||
Generate.exit(withError: error)
|
Generate.exit(withError: error)
|
||||||
|
@ -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,
|
||||||
@ -37,7 +42,10 @@ class StringsFileGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
@ -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)
|
||||||
@ -108,9 +124,16 @@ class StringsFileGenerator {
|
|||||||
|
|
||||||
// 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, 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,29 @@ class StringsFileGenerator {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static func getEnumKey(sections: [Section], tags: [String], extensionSuffix: String) -> String {
|
||||||
|
var enumDefinition = "\n enum Key\(extensionSuffix.uppercasedFirst()): String {\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) = \"\(definition.name)\"\n"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enumDefinition += " }"
|
||||||
|
|
||||||
|
return enumDefinition
|
||||||
|
}
|
||||||
|
|
||||||
private static func getProperties(sections: [Section], defaultLang lang: String, tags: [String], staticVar: Bool) -> String {
|
private static func getProperties(sections: [Section], defaultLang lang: String, tags: [String], staticVar: Bool) -> 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
|
||||||
|
@ -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")
|
||||||
}
|
}
|
||||||
|
@ -36,8 +36,8 @@ struct StringiumOptions: ParsableArguments {
|
|||||||
@Option(help: "Extension name. If not specified, it will generate an String extension.")
|
@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 {
|
||||||
|
@ -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()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 = """
|
||||||
|
Loading…
x
Reference in New Issue
Block a user