forked from eneko/Ninety-Nine-Swift-Solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Package.swift
45 lines (37 loc) · 1.96 KB
/
Package.swift
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
// swift-tools-version:4.1
import PackageDescription
import Foundation
let products: [Product] = [
.executable(name: "test", targets: ["test"]),
.executable(name: "setup", targets: ["setup"]),
.library(name: "Command", targets: ["Command"]),
.library(name: "NinetyNineSwiftProblems", targets: ["NinetyNineSwiftProblems"]),
.library(name: "SolutionTester", targets: ["SolutionTester"])
]
let packageDependencies: [PackageDescription.Package.Dependency] = [
.package(url: "https://github.com/apple/swift-package-manager.git", from: "0.1.0"),
.package(url: "https://github.com/onevcat/Rainbow", from: "3.0.0"),
.package(url: "https://github.com/eneko/Logger", from: "0.0.0"),
]
let targetDependencies: [Target.Dependency] = [
"Command", "NinetyNineSwiftProblems", "SolutionTester", "SwiftPM", "Logger"
]
let defaultTargets: [Target] = [
.target(name: "Command", dependencies: ["SwiftPM", "Logger"]),
.target(name: "NinetyNineSwiftProblems", dependencies: []),
.target(name: "SolutionTester", dependencies: ["Command", "NinetyNineSwiftProblems", "Rainbow", "SwiftPM"]),
.target(name: "runner", dependencies: targetDependencies),
.target(name: "setup", dependencies: ["Command", "NinetyNineSwiftProblems", "SolutionTester", "Rainbow", "SwiftPM"]),
.target(name: "test", dependencies: targetDependencies),
]
var userTargets: [Target] {
var usernames = (try? FileManager.default.contentsOfDirectory(atPath: "Solutions")) ?? []
usernames = usernames.filter { $0.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty == false }
.filter { $0.hasPrefix(".") == false }
.filter { $0 != "_tests" }
return usernames.map { Target.target(name: $0, dependencies: targetDependencies, path: "Solutions/\($0)") }
}
let package = Package(name: "NinetyNineSwiftSolutions",
products: products,
dependencies: packageDependencies,
targets: defaultTargets + userTargets)