-
Notifications
You must be signed in to change notification settings - Fork 0
/
Project.swift
102 lines (94 loc) · 3.44 KB
/
Project.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
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
import Foundation
import ProjectDescription
let name = "SwiftySpell"
let setupGitHooks = TargetScript.pre(
script: readFromFile(.relativeToRoot("Scripts/BuildPhases/setup-git-hooks.sh")),
name: "Setup Git Hooks",
basedOnDependencyAnalysis: false)
let runSwiftFormat = TargetScript.pre(
script: readFromFile(.relativeToRoot("Scripts/BuildPhases/run-swiftformat.sh")),
name: "Format Code With SwiftFormat",
basedOnDependencyAnalysis: false)
let runSwiftLint = TargetScript.pre(
script: readFromFile(.relativeToRoot("Scripts/BuildPhases/run-swiftlint.sh")),
name: "Lint Code With SwiftLint",
basedOnDependencyAnalysis: false)
let runSwiftySpell = TargetScript.pre(
script: readFromFile(.relativeToRoot("Scripts/BuildPhases/run-swiftyspell.sh")),
name: "Check Spelling With SwiftySpell",
basedOnDependencyAnalysis: false)
let runPeriphery = TargetScript.pre(
script: readFromFile(.relativeToRoot("Scripts/BuildPhases/run-periphery.sh")),
name: "Identify Unused Code With Periphery",
basedOnDependencyAnalysis: false)
let project = Project(
name: name,
packages: [
.package(url: "https://github.com/apple/swift-syntax.git", .exact("600.0.1")),
.package(url: "https://github.com/jpsim/Yams.git", .exact("5.1.3")),
.package(url: "https://github.com/apple/swift-argument-parser.git", .exact("1.5.0"))
],
settings: .settings(
base: [
"DEVELOPMENT_TEAM": "55DHYS5FJZ",
"MACOSX_DEPLOYMENT_TARGET": "13.0"
]),
targets: [
.target(
name: "\(name)CLI",
destinations: .macOS,
product: .commandLineTool,
bundleId: "io.github.yassinelafryhi.\(name)CLI",
sources: ["Sources/\(name)CLI/**"],
scripts: [
setupGitHooks,
runSwiftFormat,
runSwiftLint,
runSwiftySpell,
runPeriphery
],
dependencies: [
.target(name: "\(name)Core"),
.package(product: "ArgumentParser")
]),
.target(
name: "\(name)Core",
destinations: .macOS,
product: .framework,
bundleId: "io.github.yassinelafryhi.\(name)Core",
sources: ["Sources/\(name)Core/**"],
scripts: [
setupGitHooks,
runSwiftFormat,
runSwiftLint,
runSwiftySpell
// runPeriphery
],
dependencies: [
.package(product: "SwiftSyntax"),
.package(product: "SwiftParser"),
.package(product: "SwiftParserDiagnostics"),
.package(product: "Yams")
]),
.target(
name: "\(name)Tests",
destinations: .macOS,
product: .unitTests,
bundleId: "io.github.yassinelafryhi.\(name)Tests",
sources: ["Tests/\(name)Tests/**"],
scripts: [
setupGitHooks,
runSwiftFormat,
runSwiftLint,
runSwiftySpell
// runPeriphery,
],
dependencies: [
.target(name: "\(name)Core")
])
])
func readFromFile(_ path: ProjectDescription.Path) -> String {
let fileURL = URL(fileURLWithPath: path.pathString)
let content = try! String(contentsOf: fileURL, encoding: .utf8)
return content
}