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 " )
@@ -26,11 +22,6 @@ public enum DevLogPackages {
2622 . upToNextMajor( from: " 1.1.0 " )
2723 )
2824
29- public static let swiftLintPlugin : TargetDependency = . package (
30- product: " SwiftLintBuildToolPlugin " ,
31- type: . plugin
32- )
33-
3425 public static let presentationPackageDependencies : [ TargetDependency ] = [
3526 . package ( product: " MarkdownUI " ) ,
3627 . package ( product: " OrderedCollections " ) ,
@@ -47,20 +38,53 @@ public enum DevLogPackages {
4738 . package ( product: " Nexa " ) ,
4839 ]
4940
50- public static let lintOnlyPackages : [ Package ] = [
51- swiftLintPackage,
52- ]
41+ public static let defaultPackages : [ Package ] = [ ]
5342
5443 public static let presentationPackages : [ Package ] = [
55- swiftLintPackage,
5644 markdownUIPackage,
5745 swiftCollectionsPackage,
5846 ]
5947
6048 public static let infraPackages : [ Package ] = [
61- swiftLintPackage,
6249 firebasePackage,
6350 googleSignInPackage,
6451 nexaPackage,
6552 ]
6653}
54+
55+ public enum DevLogScripts {
56+ public static func swiftLint( sourcePath: String ) -> TargetScript {
57+ TargetScript . pre (
58+ script: """
59+ export PATH= " /opt/homebrew/bin:/usr/local/bin:$PATH "
60+
61+ swiftLintPath= " $(command -v swiftlint || true) "
62+ if [ -z " $swiftLintPath " ]; then
63+ echo " error: SwiftLint is not installed. Run 'brew install swiftlint'. "
64+ exit 1
65+ fi
66+
67+ configPath= " ${SRCROOT}/../../.swiftlint.yml "
68+ sourcePathName= " \( sourcePath) "
69+ lintSourcePath= " ${SRCROOT}/${sourcePathName} "
70+
71+ if [ " $sourcePathName " != " . " ]; then
72+ " $swiftLintPath " lint --config " $configPath " " $lintSourcePath "
73+ else
74+ status=0
75+ while IFS= read -r swiftFilePath; do
76+ " $swiftLintPath " lint --config " $configPath " " $swiftFilePath " || status=$?
77+ done < <(find " $lintSourcePath " -name " *.swift " -not -path " */Derived/* " -not -name " Project.swift " )
78+ exit " $status "
79+ fi
80+ """ ,
81+ name: " SwiftLint " ,
82+ inputPaths: [
83+ " $(SRCROOT)/../../.swiftlint.yml " ,
84+ " $(SRCROOT)/ \( sourcePath) " ,
85+ ] ,
86+ basedOnDependencyAnalysis: false ,
87+ shellPath: " /bin/bash "
88+ )
89+ }
90+ }
0 commit comments