11import ProjectDescription
22
33public enum DevLogPackages {
4- public static let swiftLintPackage : Package = . package (
5- url: " https://github.com/realm/SwiftLint " ,
6- . upToNextMajor( from: " 0.62.1 " )
7- )
84 public static let markdownUIPackage : Package = . package (
95 url: " https://github.com/gonzalezreal/swift-markdown-ui.git " ,
106 . upToNextMajor( from: " 2.4.1 " )
@@ -13,6 +9,10 @@ public enum DevLogPackages {
139 url: " https://github.com/apple/swift-collections.git " ,
1410 . upToNextMajor( from: " 1.3.0 " )
1511 )
12+ public static let composableArchitecturePackage : Package = . package (
13+ url: " https://github.com/pointfreeco/swift-composable-architecture " ,
14+ . upToNextMajor( from: " 1.25.5 " )
15+ )
1616 public static let firebasePackage : Package = . package (
1717 url: " https://github.com/firebase/firebase-ios-sdk " ,
1818 . upToNextMajor( from: " 11.15.0 " )
@@ -26,12 +26,8 @@ public enum DevLogPackages {
2626 . upToNextMajor( from: " 1.1.0 " )
2727 )
2828
29- public static let swiftLintPlugin : TargetDependency = . package (
30- product: " SwiftLintBuildToolPlugin " ,
31- type: . plugin
32- )
33-
3429 public static let presentationPackageDependencies : [ TargetDependency ] = [
30+ . package ( product: " ComposableArchitecture " ) ,
3531 . package ( product: " MarkdownUI " ) ,
3632 . package ( product: " OrderedCollections " ) ,
3733 ]
@@ -47,20 +43,62 @@ public enum DevLogPackages {
4743 . package ( product: " Nexa " ) ,
4844 ]
4945
50- public static let lintOnlyPackages : [ Package ] = [
51- swiftLintPackage,
52- ]
46+ public static let defaultPackages : [ Package ] = [ ]
5347
5448 public static let presentationPackages : [ Package ] = [
55- swiftLintPackage ,
49+ composableArchitecturePackage ,
5650 markdownUIPackage,
5751 swiftCollectionsPackage,
5852 ]
5953
6054 public static let infraPackages : [ Package ] = [
61- swiftLintPackage,
6255 firebasePackage,
6356 googleSignInPackage,
6457 nexaPackage,
6558 ]
6659}
60+
61+ public enum DevLogScripts {
62+ public static func swiftLint(
63+ sourcePath: String ,
64+ configPath: String = " ../../.swiftlint.yml "
65+ ) -> TargetScript {
66+ TargetScript . pre (
67+ script: """
68+ export PATH= " /opt/homebrew/bin:/usr/local/bin:$PATH "
69+
70+ swiftLintPath= " $(command -v swiftlint || true) "
71+ if [ -z " $swiftLintPath " ]; then
72+ echo " error: SwiftLint is not installed. Run 'brew install swiftlint'. "
73+ exit 1
74+ fi
75+
76+ configPath= " ${SRCROOT}/ \( configPath) "
77+ sourcePathName= " \( sourcePath) "
78+ lintSourcePath= " ${SRCROOT}/${sourcePathName} "
79+
80+ if [ " $sourcePathName " != " . " ]; then
81+ " $swiftLintPath " lint --config " $configPath " " $lintSourcePath "
82+ else
83+ swiftFilePaths=()
84+ while IFS= read -r -d '' swiftFilePath; do
85+ swiftFilePaths+=( " $swiftFilePath " )
86+ done < <(find " $lintSourcePath " -name " *.swift " -not -path " */Derived/* " -not -name " Project.swift " -print0)
87+
88+ if [ ${#swiftFilePaths[@]} -lt 1 ]; then
89+ exit 0
90+ fi
91+
92+ " $swiftLintPath " lint --config " $configPath " " ${swiftFilePaths[@]} "
93+ fi
94+ """ ,
95+ name: " SwiftLint " ,
96+ inputPaths: [
97+ " $(SRCROOT)/ \( configPath) " ,
98+ " $(SRCROOT)/ \( sourcePath) " ,
99+ ] ,
100+ basedOnDependencyAnalysis: false ,
101+ shellPath: " /bin/bash "
102+ )
103+ }
104+ }
0 commit comments