-
-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (125 loc) · 4.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// swift-tools-version:6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
extension String {
static let coenttbMarkdown: Self = "CoenttbMarkdown"
static let coenttbHtml: Self = "CoenttbHTML"
static let coenttbEmail: Self = "CoenttbEmail"
static let coenttbHtmlToPdf: Self = "CoenttbHtmlToPdf"
}
extension Target.Dependency {
static var coenttbMarkdown: Self { .target(name: .coenttbMarkdown) }
static var coenttbHtml: Self { .target(name: .coenttbHtml) }
static var coenttbEmail: Self { .target(name: .coenttbEmail) }
static var coenttbHtmlToPdf: Self { .target(name: .coenttbHtmlToPdf) }
}
extension Target.Dependency {
static var language: Self { .product(name: "Languages", package: "swift-language") }
static var html: Self { .product(name: "HTML", package: "swift-html") }
static var dependencies: Self { .product(name: "Dependencies", package: "swift-dependencies") }
static var orderedCollections: Self { .product(name: "OrderedCollections", package: "swift-collections") }
static var swiftMarkdown: Self { .product(name: "Markdown", package: "swift-markdown") }
static var htmlToPdf: Self { .product(name: "HtmlToPdf", package: "swift-html-to-pdf") }
}
extension [Package.Dependency] {
static var `default`: Self {
[
.package(url: "https://github.com/apple/swift-collections.git", from: "1.1.2"),
.package(url: "https://github.com/coenttb/swift-language.git", branch: "main"),
.package(url: "https://github.com/coenttb/swift-html-to-pdf.git", branch: "main"),
.package(url: "https://github.com/coenttb/swift-html.git", branch: "main"),
.package(url: "https://github.com/pointfreeco/swift-dependencies.git", from: "1.3.5"),
.package(url: "https://github.com/swiftlang/swift-markdown.git", from: "0.4.0"),
]
}
}
struct CustomTarget {
let name: String
var library: Bool = true
var dependencies: [Target.Dependency] = []
}
extension Package {
static func html(
targets: [CustomTarget]
) -> Package {
return Package(
name: "coenttb-html",
platforms: [
.iOS(.v17),
.macOS(.v14),
.tvOS(.v17),
.watchOS(.v10),
],
products: [
[
.library(name: .coenttbEmail, targets: [.coenttbEmail]),
.library(name: .coenttbHtml, targets: [.coenttbHtml]),
.library(name: .coenttbMarkdown, targets: [.coenttbMarkdown]),
.library(name: .coenttbHtmlToPdf, targets: [.coenttbHtmlToPdf]),
]
].flatMap { $0
},
dependencies: .default,
targets: [
targets.map { target in
Target.target(
name: "\(target.name)",
dependencies: [] + target.dependencies
)
},
targets.map { target in
Target.testTarget(
name: "\(target.name) Tests",
dependencies: [.init(stringLiteral: target.name)]
)
}
].flatMap { $0 },
swiftLanguageModes: [.v5]
)
}
}
let package = Package.html(
targets: [
.init(
name: .coenttbMarkdown,
library: true,
dependencies: [
.dependencies,
.orderedCollections,
.coenttbHtml,
.swiftMarkdown,
]
),
.init(
name: .coenttbHtml,
library: true,
dependencies: [
.dependencies,
.orderedCollections,
.html,
.language
]
),
.init(
name: .coenttbEmail,
library: true,
dependencies: [
.dependencies,
.orderedCollections,
.swiftMarkdown,
.language,
.coenttbHtml,
.coenttbMarkdown,
]
),
.init(
name: .coenttbHtmlToPdf,
library: true,
dependencies: [
.dependencies,
.coenttbHtml,
.htmlToPdf,
]
),
]
)