From c2088d692c9c237acc6a0ddf5c1c28825091dde5 Mon Sep 17 00:00:00 2001 From: "Takuto NAKAMURA (Kyome)" Date: Thu, 26 Dec 2024 18:34:02 +0900 Subject: [PATCH 1/5] Update README.md --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5a7d6e7..2ba8819 100644 --- a/README.md +++ b/README.md @@ -41,9 +41,9 @@ $ ## Requirements -- Written in Swift 5.10 +- Written in Swift 6.0 - Compatible with macOS 14.0+ -- Development with Xcode 15.4+ +- Development with Xcode 16.0+ ## How to Use @@ -147,10 +147,9 @@ If your project directory structure is special and you want to specify the path @main struct LicenseCheckerCommand: CommandPlugin { func performCommand(context: PluginContext, arguments: [String]) async throws { - let licenseCheckerPath = try context.tool(named: "license-checker").path - let commandURL = URL(fileURLWithPath: licenseCheckerPath.string, isDirectory: false) + let tool = try context.tool(named: "license-checker") - let process = try Process.run(commandURL, arguments: arguments) + let process = try Process.run(tool.url, arguments: arguments) process.waitUntilExit() guard process.terminationReason == .exit else { From 694cb4530f0ff342fd9bd07e3f7201e8db974572 Mon Sep 17 00:00:00 2001 From: "Takuto NAKAMURA (Kyome)" Date: Thu, 26 Dec 2024 18:39:20 +0900 Subject: [PATCH 2/5] Update Package.swift --- Package.swift | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Package.swift b/Package.swift index f115615..b2d1362 100644 --- a/Package.swift +++ b/Package.swift @@ -1,7 +1,11 @@ -// swift-tools-version: 5.10 +// swift-tools-version: 6.0 import PackageDescription +let swiftSettings: [SwiftSetting] = [ + .enableUpcomingFeature("ExistentialAny"), +] + let package = Package( name: "LicenseChecker", platforms: [ @@ -27,11 +31,13 @@ let package = Package( dependencies: [ .target(name: "LicenseCheckerModule"), .product(name: "ArgumentParser", package: "swift-argument-parser") - ] + ], + swiftSettings: swiftSettings ), .target( name: "TestResources", - resources: [.copy("Resources/")] + resources: [.copy("Resources/")], + swiftSettings: swiftSettings ), .testTarget( name: "LicenseCheckerModuleTests", @@ -41,14 +47,16 @@ let package = Package( ], resources: [ .process("Resources") - ] + ], + swiftSettings: swiftSettings ), .testTarget( name: "LicenseCheckerTests", dependencies: [ .target(name: "license-checker"), .target(name: "TestResources") - ] + ], + swiftSettings: swiftSettings ), .plugin( name: "LicenseCheckerPlugin", From fb77ffed6b3a04adc865258126c60f8a98c579d5 Mon Sep 17 00:00:00 2001 From: "Takuto NAKAMURA (Kyome)" Date: Thu, 26 Dec 2024 18:39:53 +0900 Subject: [PATCH 3/5] Buildable Plugin --- Plugins/LicenseCheckerPlugin/main.swift | 44 ++++++++++++------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Plugins/LicenseCheckerPlugin/main.swift b/Plugins/LicenseCheckerPlugin/main.swift index a448514..52a0968 100644 --- a/Plugins/LicenseCheckerPlugin/main.swift +++ b/Plugins/LicenseCheckerPlugin/main.swift @@ -7,40 +7,40 @@ struct LicenseCheckerPlugin: BuildToolPlugin { let description: String = "SourcePackages not found" } - func sourcePackages(_ pluginWorkDirectory: Path) throws -> Path { - var tmpPath = pluginWorkDirectory - guard pluginWorkDirectory.string.contains("SourcePackages") else { + func sourcePackages(_ pluginWorkDirectory: URL) throws -> URL { + var tmpURL = pluginWorkDirectory + guard pluginWorkDirectory.absoluteURL.path().contains("SourcePackages") else { throw SourcePackagesNotFoundError() } - while tmpPath.lastComponent != "SourcePackages" { - tmpPath = tmpPath.removingLastComponent() + while tmpURL.lastPathComponent != "SourcePackages" { + tmpURL = tmpURL.deletingLastPathComponent() } - return tmpPath + return tmpURL } - func makeBuildCommand(executablePath: Path, sourcePackagesPath: Path, whiteListPath: Path, outputPath: Path) -> Command { - return .buildCommand( + func makeBuildCommand(executableURL: URL, sourcePackagesURL: URL, whiteListURL: URL, outputURL: URL) -> Command { + .buildCommand( displayName: "Check License", - executable: executablePath, + executable: executableURL, arguments: [ "--source-packages-path", - sourcePackagesPath.string, + sourcePackagesURL.absoluteURL.path(), "--white-list-path", - whiteListPath.string + whiteListURL.absoluteURL.path() ], outputFiles: [ - outputPath + outputURL ] ) } func createBuildCommands(context: PluginContext, target: Target) async throws -> [Command] { - return [ + [ makeBuildCommand( - executablePath: try context.tool(named: "license-checker").path, - sourcePackagesPath: try sourcePackages(context.pluginWorkDirectory), - whiteListPath: context.package.directory.appending(subpath: "white-list.json"), - outputPath: context.pluginWorkDirectory + executableURL: try context.tool(named: "license-checker").url, + sourcePackagesURL: try sourcePackages(context.pluginWorkDirectoryURL), + whiteListURL: context.package.directoryURL.appending(path: "white-list.json"), + outputURL: context.pluginWorkDirectoryURL ) ] } @@ -53,12 +53,12 @@ import XcodeProjectPlugin /// This command works with `Run Build Tool Plug-ins` in Xcode `Build Phase`. extension LicenseCheckerPlugin: XcodeBuildToolPlugin { func createBuildCommands(context: XcodePluginContext, target: XcodeTarget) throws -> [Command] { - return [ + [ makeBuildCommand( - executablePath: try context.tool(named: "license-checker").path, - sourcePackagesPath: try sourcePackages(context.pluginWorkDirectory), - whiteListPath: context.xcodeProject.directory.appending(subpath: "white-list.json"), - outputPath: context.pluginWorkDirectory + executableURL: try context.tool(named: "license-checker").url, + sourcePackagesURL: try sourcePackages(context.pluginWorkDirectoryURL), + whiteListURL: context.xcodeProject.directoryURL.appending(path: "white-list.json"), + outputURL: context.pluginWorkDirectoryURL ) ] } From 5bf971087697bd3fef675c4dbe384225c7eb0d09 Mon Sep 17 00:00:00 2001 From: "Takuto NAKAMURA (Kyome)" Date: Thu, 26 Dec 2024 18:40:14 +0900 Subject: [PATCH 4/5] Updated to ver 2.0.0 --- Sources/license-checker/LicenseChecker.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/license-checker/LicenseChecker.swift b/Sources/license-checker/LicenseChecker.swift index b90812a..14dc0d2 100644 --- a/Sources/license-checker/LicenseChecker.swift +++ b/Sources/license-checker/LicenseChecker.swift @@ -6,7 +6,7 @@ struct LicenseChecker: ParsableCommand { static let configuration = CommandConfiguration( commandName: "license-checker", abstract: "A tool to check license of swift package libraries.", - version: "1.0.0" + version: "2.0.0" ) @Option( From 61db9c02696004f022c13e2047e9efff4a63e4df Mon Sep 17 00:00:00 2001 From: "Takuto NAKAMURA (Kyome)" Date: Thu, 26 Dec 2024 18:45:19 +0900 Subject: [PATCH 5/5] Updated workflows --- .github/workflows/release-artifact-bundle.yml | 2 +- .github/workflows/test.yml | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release-artifact-bundle.yml b/.github/workflows/release-artifact-bundle.yml index 101da5d..2992bcb 100644 --- a/.github/workflows/release-artifact-bundle.yml +++ b/.github/workflows/release-artifact-bundle.yml @@ -11,7 +11,7 @@ jobs: runs-on: macos-14 timeout-minutes: 20 env: - DEVELOPER_DIR: "/Applications/Xcode_15.4.app/Contents/Developer" + DEVELOPER_DIR: "/Applications/Xcode_16.0.app/Contents/Developer" ARTIFACT_BUNDLE: "license-checker.artifactbundle" steps: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1be6086..d43a896 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,7 +9,7 @@ jobs: runs-on: macos-14 timeout-minutes: 20 env: - DEVELOPER_DIR: "/Applications/Xcode_15.4.app/Contents/Developer" + DEVELOPER_DIR: "/Applications/Xcode_16.0.app/Contents/Developer" steps: - name: Checkout @@ -25,9 +25,3 @@ jobs: -destination "platform=macOS" \ -resultBundlePath TestsResult | \ xcpretty -c && exit ${PIPESTATUS[0]} - - - name: Archive unit test results - if: success() || failure() - uses: kishikawakatsumi/xcresulttool@v1 - with: - path: TestsResult.xcresult