Fix architecture generation and add enum key of each string in R2String
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
This commit is contained in:
parent
188178fe6a
commit
1e073af5df
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
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Generated by ResgenSwift.Color 1.0
|
// Generated by ResgenSwift.Color 1.2
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Generated by ResgenSwift.Fonts 1.0
|
// Generated by ResgenSwift.Fonts 1.2
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Generated by ResgenSwift.Fonts 1.0
|
// Generated by ResgenSwift.Fonts 1.2
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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 :
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -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)
|
||||||
|
@ -111,6 +111,7 @@ class StringsFileGenerator {
|
|||||||
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) -> String {
|
||||||
[
|
[
|
||||||
Self.getHeader(stringsFilename: inputFilename, extensionClassname: extensionName),
|
Self.getHeader(stringsFilename: inputFilename, extensionClassname: extensionName),
|
||||||
|
Self.getEnumKey(sections: sections, tags: tags),
|
||||||
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 +132,29 @@ class StringsFileGenerator {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static func getEnumKey(sections: [Section], tags: [String]) -> String {
|
||||||
|
var enumDefinition = "\n enum Key: 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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user