Compare commits
2 Commits
stencil
...
636584ca45
Author | SHA1 | Date | |
---|---|---|---|
636584ca45 | |||
c8cfe82109 |
2
Jenkinsfile
vendored
2
Jenkinsfile
vendored
@ -1,6 +1,6 @@
|
|||||||
library "openiumpipeline"
|
library "openiumpipeline"
|
||||||
|
|
||||||
env.DEVELOPER_DIR="/Applications/Xcode-15.0.1.app/Contents/Developer"
|
env.DEVELOPER_DIR="/Applications/Xcode-15.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
|
||||||
|
@ -18,15 +18,6 @@
|
|||||||
"version" : "1.8.0"
|
"version" : "1.8.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"identity" : "pathkit",
|
|
||||||
"kind" : "remoteSourceControl",
|
|
||||||
"location" : "https://github.com/kylef/PathKit.git",
|
|
||||||
"state" : {
|
|
||||||
"revision" : "3bfd2737b700b9a36565a8c94f4ad2b050a5e574",
|
|
||||||
"version" : "1.0.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"identity" : "sourcekitten",
|
"identity" : "sourcekitten",
|
||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
@ -36,24 +27,6 @@
|
|||||||
"version" : "0.34.1"
|
"version" : "0.34.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"identity" : "spectre",
|
|
||||||
"kind" : "remoteSourceControl",
|
|
||||||
"location" : "https://github.com/kylef/Spectre.git",
|
|
||||||
"state" : {
|
|
||||||
"revision" : "26cc5e9ae0947092c7139ef7ba612e34646086c7",
|
|
||||||
"version" : "0.10.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identity" : "stencil",
|
|
||||||
"kind" : "remoteSourceControl",
|
|
||||||
"location" : "https://github.com/stencilproject/Stencil.git",
|
|
||||||
"state" : {
|
|
||||||
"revision" : "4f222ac85d673f35df29962fc4c36ccfdaf9da5b",
|
|
||||||
"version" : "0.15.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"identity" : "swift-argument-parser",
|
"identity" : "swift-argument-parser",
|
||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
|
@ -11,7 +11,6 @@ let package = Package(
|
|||||||
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0"),
|
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0"),
|
||||||
.package(url: "https://github.com/jpsim/Yams.git", from: "5.0.1"),
|
.package(url: "https://github.com/jpsim/Yams.git", from: "5.0.1"),
|
||||||
.package(url: "https://github.com/realm/SwiftLint.git", .upToNextMajor(from: "0.54.0")),
|
.package(url: "https://github.com/realm/SwiftLint.git", .upToNextMajor(from: "0.54.0")),
|
||||||
.package(url: "https://github.com/stencilproject/Stencil.git", .upToNextMajor(from: "0.15.1")),
|
|
||||||
],
|
],
|
||||||
targets: [
|
targets: [
|
||||||
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
|
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
|
||||||
@ -21,8 +20,7 @@ let package = Package(
|
|||||||
dependencies: [
|
dependencies: [
|
||||||
"ToolCore",
|
"ToolCore",
|
||||||
.product(name: "ArgumentParser", package: "swift-argument-parser"),
|
.product(name: "ArgumentParser", package: "swift-argument-parser"),
|
||||||
"Yams",
|
"Yams"
|
||||||
"Stencil",
|
|
||||||
],
|
],
|
||||||
plugins: [.plugin(name: "SwiftLintPlugin", package: "SwiftLint")]
|
plugins: [.plugin(name: "SwiftLintPlugin", package: "SwiftLint")]
|
||||||
),
|
),
|
||||||
|
@ -4,25 +4,18 @@ import SwiftUI
|
|||||||
|
|
||||||
extension ColorYolo {
|
extension ColorYolo {
|
||||||
|
|
||||||
|
/// Color red is #FF0000 (light) or #FF0000 (dark)"
|
||||||
/// Color red is #FF0000 #FF0000 or #FF0000 #FF0000"
|
|
||||||
var red: Color {
|
var red: Color {
|
||||||
Color("red")
|
Color("red")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Color green_alpha_50 is #A000FF00 (light) or #A000FF00 (dark)"
|
||||||
|
|
||||||
/// Color green_alpha_50 is #A000FF00 #A000FF00 or #A000FF00 #A000FF00"
|
|
||||||
var green_alpha_50: Color {
|
var green_alpha_50: Color {
|
||||||
Color("green_alpha_50")
|
Color("green_alpha_50")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Color blue_light_dark is #0000FF (light) or #0000AA (dark)"
|
||||||
|
|
||||||
/// Color blue_light_dark is #0000FF #0000FF or #0000AA #0000AA"
|
|
||||||
var blue_light_dark: Color {
|
var blue_light_dark: Color {
|
||||||
Color("blue_light_dark")
|
Color("blue_light_dark")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,25 +4,18 @@ import UIKit
|
|||||||
|
|
||||||
extension UIColorYolo {
|
extension UIColorYolo {
|
||||||
|
|
||||||
|
/// Color red is #FF0000 (light) or #FF0000 (dark)"
|
||||||
/// Color red is #FF0000 #FF0000 or #FF0000 #FF0000"
|
|
||||||
@objc var red: UIColor {
|
@objc var red: UIColor {
|
||||||
UIColor(named: "red")!
|
UIColor(named: "red")!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Color green_alpha_50 is #A000FF00 (light) or #A000FF00 (dark)"
|
||||||
|
|
||||||
/// Color green_alpha_50 is #A000FF00 #A000FF00 or #A000FF00 #A000FF00"
|
|
||||||
@objc var green_alpha_50: UIColor {
|
@objc var green_alpha_50: UIColor {
|
||||||
UIColor(named: "green_alpha_50")!
|
UIColor(named: "green_alpha_50")!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Color blue_light_dark is #0000FF (light) or #0000AA (dark)"
|
||||||
|
|
||||||
/// Color blue_light_dark is #0000FF #0000FF or #0000AA #0000AA"
|
|
||||||
@objc var blue_light_dark: UIColor {
|
@objc var blue_light_dark: UIColor {
|
||||||
UIColor(named: "blue_light_dark")!
|
UIColor(named: "blue_light_dark")!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
// Generated by ResgenSwift.Color 1.2
|
|
||||||
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
|
|
||||||
extension UIhkjhkColorYolo {
|
|
||||||
|
|
||||||
|
|
||||||
/// Color red is #FF0000 #FF0000 or #FF0000 #FF0000"
|
|
||||||
@objc var red: UIColor {
|
|
||||||
UIColor(named: "red")!
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Color green_alpha_50 is #A000FF00 #A000FF00 or #A000FF00 #A000FF00"
|
|
||||||
@objc var green_alpha_50: UIColor {
|
|
||||||
UIColor(named: "green_alpha_50")!
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Color blue_light_dark is #0000FF #0000FF or #0000AA #0000AA"
|
|
||||||
@objc var blue_light_dark: UIColor {
|
|
||||||
UIColor(named: "blue_light_dark")!
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -12,14 +12,14 @@ FORCE_FLAG="$1"
|
|||||||
#
|
#
|
||||||
#echo "\n-------------------------\n"
|
#echo "\n-------------------------\n"
|
||||||
#
|
#
|
||||||
# Color
|
## Color
|
||||||
swift run -c release ResgenSwift colors $FORCE_FLAG "./Colors/sampleColors1.txt" \
|
#swift run -c release ResgenSwift colors $FORCE_FLAG "./Colors/sampleColors1.txt" \
|
||||||
--style all \
|
# --style all \
|
||||||
--xcassets-path "./Colors/colors.xcassets" \
|
# --xcassets-path "./Colors/colors.xcassets" \
|
||||||
--extension-output-path "./Colors/Generated/" \
|
# --extension-output-path "./Colors/Generated/" \
|
||||||
--extension-name "ColorYolo" \
|
# --extension-name "ColorYolo" \
|
||||||
--extension-name-ui-kit "UIColorYolo" \
|
# --extension-name-ui-kit "UIhkjhkColorYolo" \
|
||||||
--extension-suffix "GenAllScript"
|
# --extension-suffix "GenAllScript"
|
||||||
#
|
#
|
||||||
#echo "\n-------------------------\n"
|
#echo "\n-------------------------\n"
|
||||||
#
|
#
|
||||||
@ -52,12 +52,12 @@ swift run -c release ResgenSwift colors $FORCE_FLAG "./Colors/sampleColors1.txt"
|
|||||||
|
|
||||||
#echo "\n-------------------------\n"
|
#echo "\n-------------------------\n"
|
||||||
|
|
||||||
## Analytics
|
# Analytics
|
||||||
#swift run -c release ResgenSwift analytics $FORCE_FLAG "./Tags/sampleTags.yml" \
|
swift run -c release ResgenSwift analytics $FORCE_FLAG "./Tags/sampleTags.yml" \
|
||||||
# --target "matomo firebase" \
|
--target "matomo firebase" \
|
||||||
# --extension-output-path "./Tags/Generated" \
|
--extension-output-path "./Tags/Generated" \
|
||||||
# --extension-name "Analytics" \
|
--extension-name "Analytics" \
|
||||||
# --extension-suffix "GenAllScript"
|
--extension-suffix "GenAllScript"
|
||||||
|
|
||||||
#echo "\n-------------------------\n"
|
#echo "\n-------------------------\n"
|
||||||
#
|
#
|
||||||
|
@ -41,28 +41,12 @@ struct ColorExtensionGenerator {
|
|||||||
staticVar: Bool,
|
staticVar: Bool,
|
||||||
extensionName: String,
|
extensionName: String,
|
||||||
isSwiftUI: Bool) -> String {
|
isSwiftUI: Bool) -> String {
|
||||||
// [
|
[
|
||||||
// Self.getHeader(extensionClassname: extensionName, isSwiftUI: isSwiftUI),
|
Self.getHeader(extensionClassname: extensionName, isSwiftUI: isSwiftUI),
|
||||||
// Self.getProperties(for: colors, withStaticVar: staticVar, isSwiftUI: isSwiftUI),
|
Self.getProperties(for: colors, withStaticVar: staticVar, isSwiftUI: isSwiftUI),
|
||||||
// Self.getFooter()
|
Self.getFooter()
|
||||||
// ]
|
|
||||||
// .joined(separator: "\n")
|
|
||||||
do {
|
|
||||||
let context: [String: Any] = [
|
|
||||||
"colors": colors,
|
|
||||||
"isStatic": staticVar,
|
|
||||||
"isSwiftUI": isSwiftUI,
|
|
||||||
"toolName": Colors.toolName,
|
|
||||||
"resgenVersion": ResgenSwiftVersion,
|
|
||||||
"extensionClassname": extensionName
|
|
||||||
]
|
]
|
||||||
|
.joined(separator: "\n")
|
||||||
return try ResgenSwift.environment.renderTemplate(name: "Colors/main_template", context: context)
|
|
||||||
} catch {
|
|
||||||
// let error = ColorsToolError.writeExtension(extensionFilePath, error.localizedDescription)
|
|
||||||
// print(error.description)
|
|
||||||
Colors.exit(withError: error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func getHeader(extensionClassname: String, isSwiftUI: Bool) -> String {
|
private static func getHeader(extensionClassname: String, isSwiftUI: Bool) -> String {
|
||||||
|
@ -119,7 +119,7 @@ class XcassetsGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write Content.json
|
// Write Content.json
|
||||||
let imagesetContentJson = parsedImage.contentJson
|
guard let imagesetContentJson = parsedImage.contentJson else { return }
|
||||||
let contentJsonFilePath = "\(imagesetPath)/Contents.json"
|
let contentJsonFilePath = "\(imagesetPath)/Contents.json"
|
||||||
|
|
||||||
let contentJsonFilePathURL = URL(fileURLWithPath: contentJsonFilePath)
|
let contentJsonFilePathURL = URL(fileURLWithPath: contentJsonFilePath)
|
||||||
|
32
Sources/ResgenSwift/Images/Model/ImageContent.swift
Normal file
32
Sources/ResgenSwift/Images/Model/ImageContent.swift
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
//
|
||||||
|
// ImageContent.swift
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by Quentin Bandera on 19/04/2024.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
struct AssetContent: Codable, Equatable {
|
||||||
|
let images: [AssetImageDescription]
|
||||||
|
let info: AssetInfo
|
||||||
|
|
||||||
|
static func == (lhs: AssetContent, rhs: AssetContent) -> Bool {
|
||||||
|
guard lhs.images.count == rhs.images.count else { return false }
|
||||||
|
let lhsImages = lhs.images.sorted(by: { $0.scale < $1.scale })
|
||||||
|
let rhsImages = rhs.images.sorted(by: { $0.scale < $1.scale })
|
||||||
|
|
||||||
|
return lhsImages == rhsImages
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct AssetImageDescription: Codable, Equatable {
|
||||||
|
let idiom: String
|
||||||
|
let scale: String
|
||||||
|
let filename: String
|
||||||
|
}
|
||||||
|
|
||||||
|
struct AssetInfo: Codable, Equatable {
|
||||||
|
let version: Int
|
||||||
|
let author: String
|
||||||
|
}
|
@ -42,32 +42,43 @@ struct ParsedImage {
|
|||||||
|
|
||||||
// MARK: - Assets
|
// MARK: - Assets
|
||||||
|
|
||||||
var contentJson: String {
|
var contentJson: String? {
|
||||||
"""
|
let encoder = JSONEncoder()
|
||||||
{
|
encoder.outputFormatting = .prettyPrinted
|
||||||
"images" : [
|
|
||||||
{
|
guard let data = try? encoder.encode(imageContent) else {
|
||||||
"idiom" : "universal",
|
let error = ImagesError.writeFile("Contents.json", "Error encoding json file")
|
||||||
"scale" : "1x",
|
print(error.description)
|
||||||
"filename" : "\(name).\(XcassetsGenerator.outputImageExtension)"
|
Images.exit(withError: error)
|
||||||
},
|
|
||||||
{
|
|
||||||
"idiom" : "universal",
|
|
||||||
"scale" : "2x",
|
|
||||||
"filename" : "\(name)@2x.\(XcassetsGenerator.outputImageExtension)"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"idiom" : "universal",
|
|
||||||
"scale" : "3x",
|
|
||||||
"filename" : "\(name)@3x.\(XcassetsGenerator.outputImageExtension)"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return String(data: data, encoding: .utf8)
|
||||||
|
}
|
||||||
|
|
||||||
|
var imageContent: AssetContent {
|
||||||
|
return AssetContent(
|
||||||
|
images: [
|
||||||
|
AssetImageDescription(
|
||||||
|
idiom: "universal",
|
||||||
|
scale: "1x",
|
||||||
|
filename: "\(name).\(XcassetsGenerator.outputImageExtension)"
|
||||||
|
),
|
||||||
|
AssetImageDescription(
|
||||||
|
idiom: "universal",
|
||||||
|
scale: "2x",
|
||||||
|
filename: "\(name)@2x.\(XcassetsGenerator.outputImageExtension)"
|
||||||
|
),
|
||||||
|
AssetImageDescription(
|
||||||
|
idiom: "universal",
|
||||||
|
scale: "3x",
|
||||||
|
filename: "\(name)@3x.\(XcassetsGenerator.outputImageExtension)"
|
||||||
|
)
|
||||||
],
|
],
|
||||||
"info" : {
|
info: AssetInfo(
|
||||||
"version" : 1,
|
version: 1,
|
||||||
"author" : "ResgenSwift-Imagium"
|
author: "ResgenSwift-Imagium"
|
||||||
}
|
)
|
||||||
}
|
)
|
||||||
"""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Extension property
|
// MARK: - Extension property
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
import ToolCore
|
import ToolCore
|
||||||
import Foundation
|
import Foundation
|
||||||
import ArgumentParser
|
import ArgumentParser
|
||||||
import Stencil
|
|
||||||
import PathKit
|
|
||||||
|
|
||||||
struct ResgenSwift: ParsableCommand {
|
struct ResgenSwift: ParsableCommand {
|
||||||
|
|
||||||
@ -34,20 +32,6 @@ struct ResgenSwift: ParsableCommand {
|
|||||||
// subcommand is not given on the command line.
|
// subcommand is not given on the command line.
|
||||||
//defaultSubcommand: Twine.self
|
//defaultSubcommand: Twine.self
|
||||||
)
|
)
|
||||||
|
|
||||||
static let projectDirectory = URL(fileURLWithPath: #file) // ProjectDir/Sources/ResgenSwift/main.swift
|
|
||||||
.deletingLastPathComponent() // ProjectDir/Sources/ResgenSwift/
|
|
||||||
.deletingLastPathComponent() // ProjectDir/Sources/
|
|
||||||
.deletingLastPathComponent() // ProjectDir/
|
|
||||||
|
|
||||||
static let environment = Environment(
|
|
||||||
loader: FileSystemLoader(
|
|
||||||
paths: [
|
|
||||||
Path("\(projectDirectory.path)/Templates/")
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print(ResgenSwift.projectDirectory.path)
|
|
||||||
ResgenSwift.main()
|
ResgenSwift.main()
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
// Generated by ResgenSwift.{{ toolName }} {{ resgenVersion }}
|
|
||||||
{% if isSwiftUI %}
|
|
||||||
import SwiftUI
|
|
||||||
{% else %}
|
|
||||||
import UIKit
|
|
||||||
{% endif %}
|
|
||||||
extension {{ extensionClassname }} {
|
|
||||||
{% for color in colors %}
|
|
||||||
{% if isSwiftUI %}
|
|
||||||
/// Color {{ color.name }} is {{ color.light }} {{ color.light }} or {{ color.dark }} {{ color.dark }}"
|
|
||||||
{% if isStatic %}static {% endif %}var {{ color.name }}: Color {
|
|
||||||
Color("{{ color.name }}")
|
|
||||||
}
|
|
||||||
{% else %}
|
|
||||||
/// Color {{ color.name }} is {{ color.light }} {{ color.light }} or {{ color.dark }} {{ color.dark }}"
|
|
||||||
{% if isStatic %}static {% else %}@objc {% endif %}var {{ color.name }}: UIColor {
|
|
||||||
UIColor(named: "{{ color.name }}")!
|
|
||||||
}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
/// Color {{ color.name }} is {{ color.light }} {{ color.light }} or {{ color.dark }} {{ color.dark }}"
|
|
||||||
{% if isStatic %}static {% endif %}var {{ color.name }}: Color {
|
|
||||||
Color("{{ color.name }}")
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
/// Color {{ color.name }} is {{ color.light }} {{ color.light }} or {{ color.dark }} {{ color.dark }}"
|
|
||||||
{% if isStatic %}static {% else %}@objc {% endif %}var {{ color.name }}: UIColor {
|
|
||||||
UIColor(named: "{{ color.name }}")!
|
|
||||||
}
|
|
@ -127,35 +127,33 @@ final class ParsedImageTests: XCTestCase {
|
|||||||
height: 10)
|
height: 10)
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let property = parsedImage.contentJson
|
let property = parsedImage.imageContent
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = AssetContent(
|
||||||
{
|
images: [
|
||||||
"images" : [
|
AssetImageDescription(
|
||||||
{
|
idiom: "universal",
|
||||||
"idiom" : "universal",
|
scale: "1x",
|
||||||
"scale" : "1x",
|
filename: "\(parsedImage.name).\(XcassetsGenerator.outputImageExtension)"
|
||||||
"filename" : "\(imageName).\(XcassetsGenerator.outputImageExtension)"
|
),
|
||||||
},
|
AssetImageDescription(
|
||||||
{
|
idiom: "universal",
|
||||||
"idiom" : "universal",
|
scale: "2x",
|
||||||
"scale" : "2x",
|
filename: "\(parsedImage.name)@2x.\(XcassetsGenerator.outputImageExtension)"
|
||||||
"filename" : "\(imageName)@2x.\(XcassetsGenerator.outputImageExtension)"
|
),
|
||||||
},
|
AssetImageDescription(
|
||||||
{
|
idiom: "universal",
|
||||||
"idiom" : "universal",
|
scale: "3x",
|
||||||
"scale" : "3x",
|
filename: "\(parsedImage.name)@3x.\(XcassetsGenerator.outputImageExtension)"
|
||||||
"filename" : "\(imageName)@3x.\(XcassetsGenerator.outputImageExtension)"
|
)
|
||||||
}
|
|
||||||
],
|
],
|
||||||
"info" : {
|
info: AssetInfo(
|
||||||
"version" : 1,
|
version: 1,
|
||||||
"author" : "ResgenSwift-Imagium"
|
author: "ResgenSwift-Imagium"
|
||||||
}
|
)
|
||||||
}
|
)
|
||||||
"""
|
|
||||||
|
|
||||||
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
XCTAssertEqual(property, expect)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user