diff --git a/.swiftpm/configuration/Package.resolved b/.swiftpm/configuration/Package.resolved index 3aa93ea..0b63525 100644 --- a/.swiftpm/configuration/Package.resolved +++ b/.swiftpm/configuration/Package.resolved @@ -1,88 +1,87 @@ { - "object": { - "pins": [ - { - "package": "Builder", - "repositoryURL": "https://github.com/elegantchaos/Builder.git", - "state": { - "branch": null, - "revision": "2c62722be9ed28035242a05f6abcc154a514ca9e", - "version": "1.2.3" - } - }, - { - "package": "BuilderConfiguration", - "repositoryURL": "https://github.com/elegantchaos/BuilderConfiguration.git", - "state": { - "branch": null, - "revision": "c21cebac262244d920894bba2351ff65c1378bf2", - "version": "1.1.5" - } - }, - { - "package": "Coercion", - "repositoryURL": "https://github.com/elegantchaos/Coercion.git", - "state": { - "branch": null, - "revision": "df699ebd4707bcfd99fcad4b9f6c09ddc1208af9", - "version": "1.1.3" - } - }, - { - "package": "Files", - "repositoryURL": "https://github.com/elegantchaos/Files.git", - "state": { - "branch": null, - "revision": "ccb417b5b4f2d473964594a7c906a50a62c8530c", - "version": "1.2.2" - } - }, - { - "package": "Logger", - "repositoryURL": "https://github.com/elegantchaos/Logger.git", - "state": { - "branch": null, - "revision": "a5cfb4ede43a0f4782afb2aea3175a04f206efcf", - "version": "1.8.1" - } - }, - { - "package": "Matchable", - "repositoryURL": "https://github.com/elegantchaos/Matchable.git", - "state": { - "branch": null, - "revision": "d53e807009960aafbd54f6229c2542f906628b38", - "version": "1.0.7" - } - }, - { - "package": "Runner", - "repositoryURL": "https://github.com/elegantchaos/Runner.git", - "state": { - "branch": null, - "revision": "65420eb4e534a58c8fb1bf18e344bc86edb42c65", - "version": "1.3.2" - } - }, - { - "package": "swift-argument-parser", - "repositoryURL": "https://github.com/apple/swift-argument-parser", - "state": { - "branch": null, - "revision": "6b2aa2748a7881eebb9f84fb10c01293e15b52ca", - "version": "0.5.0" - } - }, - { - "package": "XCTestExtensions", - "repositoryURL": "https://github.com/elegantchaos/XCTestExtensions.git", - "state": { - "branch": null, - "revision": "39694671be8bea1ab0bbd87114705b2a92567a8e", - "version": "1.5.0" - } + "originHash" : "4d3ddef0a76a3d4887a7b1677ec1f57b4271269d4b2cc37d8e19d1226c12928f", + "pins" : [ + { + "identity" : "chaosbytestreams", + "kind" : "remoteSourceControl", + "location" : "https://github.com/elegantchaos/ChaosByteStreams", + "state" : { + "revision" : "bb2be531b8b3d1410ba6b40a860b6bf8060e8fa3", + "version" : "1.0.0" } - ] - }, - "version": 1 + }, + { + "identity" : "coercion", + "kind" : "remoteSourceControl", + "location" : "https://github.com/elegantchaos/Coercion.git", + "state" : { + "revision" : "df699ebd4707bcfd99fcad4b9f6c09ddc1208af9", + "version" : "1.1.3" + } + }, + { + "identity" : "files", + "kind" : "remoteSourceControl", + "location" : "https://github.com/elegantchaos/Files.git", + "state" : { + "revision" : "ccb417b5b4f2d473964594a7c906a50a62c8530c", + "version" : "1.2.2" + } + }, + { + "identity" : "logger", + "kind" : "remoteSourceControl", + "location" : "https://github.com/elegantchaos/Logger.git", + "state" : { + "revision" : "a5cfb4ede43a0f4782afb2aea3175a04f206efcf", + "version" : "1.8.1" + } + }, + { + "identity" : "matchable", + "kind" : "remoteSourceControl", + "location" : "https://github.com/elegantchaos/Matchable.git", + "state" : { + "revision" : "d53e807009960aafbd54f6229c2542f906628b38", + "version" : "1.0.7" + } + }, + { + "identity" : "runner", + "kind" : "remoteSourceControl", + "location" : "https://github.com/elegantchaos/Runner.git", + "state" : { + "revision" : "4695591be15ed365323fb0b130bd21545f0aa91e", + "version" : "2.0.6" + } + }, + { + "identity" : "swift-argument-parser", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-argument-parser", + "state" : { + "revision" : "41982a3656a71c768319979febd796c6fd111d5c", + "version" : "1.5.0" + } + }, + { + "identity" : "versionator", + "kind" : "remoteSourceControl", + "location" : "https://github.com/elegantchaos/Versionator.git", + "state" : { + "revision" : "6d1cdddce7990f660c4f3b96c5a24be8dcce9007", + "version" : "2.0.2" + } + }, + { + "identity" : "xctestextensions", + "kind" : "remoteSourceControl", + "location" : "https://github.com/elegantchaos/XCTestExtensions.git", + "state" : { + "revision" : "39694671be8bea1ab0bbd87114705b2a92567a8e", + "version" : "1.5.0" + } + } + ], + "version" : 3 } diff --git a/.vscode/settings.json b/.vscode/settings.json index aeb73e7..05abd4a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,4 @@ { - "lldb.library": "/Applications/Xcode-16.1.0-Beta.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB", - "lldb.launch.expressions": "native", "swift.debugger.useDebugAdapterFromToolchain": true, "swift.backgroundCompilation": true, "swift.sourcekit-lsp.backgroundIndexing": false, diff --git a/Plugins/ReleaseToolPlugin/ReleaseToolPlugin.swift b/Plugins/ReleaseToolPlugin/ReleaseToolPlugin.swift index 7d90d60..8680ffa 100644 --- a/Plugins/ReleaseToolPlugin/ReleaseToolPlugin.swift +++ b/Plugins/ReleaseToolPlugin/ReleaseToolPlugin.swift @@ -7,50 +7,71 @@ import Foundation import PackagePlugin @main struct ReleaseToolsPlugin: CommandPlugin { - func run(tool: String, arguments: [String], context: PackagePlugin.PluginContext, cwd: URL) async throws -> String { - let tool = try context.tool(named: tool) - - Diagnostics.remark("Running \(tool) \(arguments.joined(separator: " ")).") - - let outputPipe = Pipe() - return try await withCheckedThrowingContinuation { continuation in - let process = Process() - process.executableURL = tool.url - process.arguments = arguments - process.currentDirectoryURL = cwd - - process.standardOutput = outputPipe - process.terminationHandler = { process in - let data = outputPipe.fileHandleForReading.readDataToEndOfFile() - continuation.resume( - returning: String(decoding: data, as: UTF8.self) + + func run(tool: PluginContext.Tool, arguments: [String], cwd: URL) async throws -> String { + Diagnostics.remark("Running \(tool) \(arguments.joined(separator: " ")).") + + let outputPipe = Pipe() + return try await withCheckedThrowingContinuation { continuation in + let process = Process() + process.executableURL = tool.url + process.arguments = arguments + process.currentDirectoryURL = cwd + + process.standardOutput = outputPipe + process.terminationHandler = { process in + let data = outputPipe.fileHandleForReading.readDataToEndOfFile() + continuation.resume( + returning: String(decoding: data, as: UTF8.self) + ) + } + do { + try process.run() + } catch { + continuation.resume(throwing: error) + } + } + } + + func performCommand(context: PackagePlugin.PluginContext, arguments: [String]) async throws { + let tool = try context.tool( + named: "ActionBuilderTool" ) - } - do { - try process.run() - } catch { - continuation.resume(throwing: error) - } + let output = try await run( + tool: tool, arguments: arguments, cwd: context.package.directoryURL) + + Diagnostics.remark(output) } - } - - func performCommand(context: PackagePlugin.PluginContext, arguments: [String]) async throws { - let output = try await run( - tool: "ActionBuilderTool", arguments: arguments, context: context, cwd: context.package.directoryURL) - - Diagnostics.remark(output) - } } #if canImport(XcodeProjectPlugin) - import XcodeProjectPlugin +import XcodeProjectPlugin - extension ReleaseToolsPlugin: XcodeCommandPlugin { - func performCommand(context: XcodePluginContext, arguments: [String]) throws { - let output = try await run( - tool: "ActionBuilderTool", arguments: arguments, context: context, cwd: context.package.directoryURL) +func runSync(tool: PluginContext.Tool, arguments: [String], cwd: URL) throws -> String { + Diagnostics.remark("Running \(tool) \(arguments.joined(separator: " ")).") + + let process = Process() + process.executableURL = tool.url + process.arguments = arguments + process.currentDirectoryURL = cwd + + let outputPipe = Pipe() + process.standardOutput = outputPipe + try process.run() + process.waitUntilExit() + + let data = outputPipe.fileHandleForReading.readDataToEndOfFile() + return String(decoding: data, as: UTF8.self) +} - Diagnostics.remark(output) +extension ReleaseToolsPlugin: XcodeCommandPlugin { + func performCommand(context: XcodePluginContext, arguments: [String]) throws { + let tool = try context.tool( + named: "ActionBuilderTool" + ) + + let output = try runSync(tool: tool, arguments: arguments, cwd: context.xcodeProject.directoryURL) + Diagnostics.remark(output) } - } +} #endif