From 54ad92c6a0e59cc0959f94b22956e32cab4d8be1 Mon Sep 17 00:00:00 2001 From: 417-72KI <417.72ki@gmail.com> Date: Mon, 2 Oct 2023 00:02:56 +0900 Subject: [PATCH 1/3] rename executable target name to match binary name --- Package.swift | 13 ++++++++----- .../BuildConfig.swift | 0 .../Environment.swift | 0 .../BuildConfigswiftTests.swift | 0 .../ProcessExtension.swift | 0 .../Resources/output/production/BuildConfig.plist | Bin .../Resources/output/staging/BuildConfig.plist | Bin .../Resources/src/.env/production.yaml | 0 .../Resources/src/.env/staging.json | 0 .../Resources/src/API.yaml | 0 .../Resources/src/keys.yml | 0 .../Util.swift | 0 12 files changed, 8 insertions(+), 5 deletions(-) rename Sources/{BuildConfig.swift => buildconfigswift}/BuildConfig.swift (100%) rename Sources/{BuildConfig.swift => buildconfigswift}/Environment.swift (100%) rename Tests/{BuildConfig.swiftTests => buildconfigswiftTests}/BuildConfigswiftTests.swift (100%) rename Tests/{BuildConfig.swiftTests => buildconfigswiftTests}/ProcessExtension.swift (100%) rename Tests/{BuildConfig.swiftTests => buildconfigswiftTests}/Resources/output/production/BuildConfig.plist (100%) rename Tests/{BuildConfig.swiftTests => buildconfigswiftTests}/Resources/output/staging/BuildConfig.plist (100%) rename Tests/{BuildConfig.swiftTests => buildconfigswiftTests}/Resources/src/.env/production.yaml (100%) rename Tests/{BuildConfig.swiftTests => buildconfigswiftTests}/Resources/src/.env/staging.json (100%) rename Tests/{BuildConfig.swiftTests => buildconfigswiftTests}/Resources/src/API.yaml (100%) rename Tests/{BuildConfig.swiftTests => buildconfigswiftTests}/Resources/src/keys.yml (100%) rename Tests/{BuildConfig.swiftTests => buildconfigswiftTests}/Util.swift (100%) diff --git a/Package.swift b/Package.swift index 31e9dd8..a95a684 100644 --- a/Package.swift +++ b/Package.swift @@ -7,7 +7,10 @@ let package = Package( name: "BuildConfig.swift", platforms: [ .macOS(.v12) ], products: [ - .executable(name: "buildconfigswift", targets: ["BuildConfig.swift"]) + .executable( + name: "buildconfigswift", + targets: ["buildconfigswift"] + ), ], dependencies: [ .package(url: "https://github.com/apple/swift-argument-parser", from: "1.2.3"), @@ -19,7 +22,7 @@ let package = Package( ], targets: [ .executableTarget( - name: "BuildConfig.swift", + name: "buildconfigswift", dependencies: [ .product(name: "ArgumentParser", package: "swift-argument-parser"), "Core" @@ -55,9 +58,9 @@ let package = Package( ] ), .testTarget( - name: "BuildConfig.swiftTests", + name: "buildconfigswiftTests", dependencies: [ - "BuildConfig.swift", + "buildconfigswift", // "MirrorDiffKit" ], resources: [.copy("Resources")] @@ -77,7 +80,7 @@ let package = Package( "MirrorDiffKit" ], resources: [.copy("Resources")] - ) + ), ], swiftLanguageVersions: [.v5] ) diff --git a/Sources/BuildConfig.swift/BuildConfig.swift b/Sources/buildconfigswift/BuildConfig.swift similarity index 100% rename from Sources/BuildConfig.swift/BuildConfig.swift rename to Sources/buildconfigswift/BuildConfig.swift diff --git a/Sources/BuildConfig.swift/Environment.swift b/Sources/buildconfigswift/Environment.swift similarity index 100% rename from Sources/BuildConfig.swift/Environment.swift rename to Sources/buildconfigswift/Environment.swift diff --git a/Tests/BuildConfig.swiftTests/BuildConfigswiftTests.swift b/Tests/buildconfigswiftTests/BuildConfigswiftTests.swift similarity index 100% rename from Tests/BuildConfig.swiftTests/BuildConfigswiftTests.swift rename to Tests/buildconfigswiftTests/BuildConfigswiftTests.swift diff --git a/Tests/BuildConfig.swiftTests/ProcessExtension.swift b/Tests/buildconfigswiftTests/ProcessExtension.swift similarity index 100% rename from Tests/BuildConfig.swiftTests/ProcessExtension.swift rename to Tests/buildconfigswiftTests/ProcessExtension.swift diff --git a/Tests/BuildConfig.swiftTests/Resources/output/production/BuildConfig.plist b/Tests/buildconfigswiftTests/Resources/output/production/BuildConfig.plist similarity index 100% rename from Tests/BuildConfig.swiftTests/Resources/output/production/BuildConfig.plist rename to Tests/buildconfigswiftTests/Resources/output/production/BuildConfig.plist diff --git a/Tests/BuildConfig.swiftTests/Resources/output/staging/BuildConfig.plist b/Tests/buildconfigswiftTests/Resources/output/staging/BuildConfig.plist similarity index 100% rename from Tests/BuildConfig.swiftTests/Resources/output/staging/BuildConfig.plist rename to Tests/buildconfigswiftTests/Resources/output/staging/BuildConfig.plist diff --git a/Tests/BuildConfig.swiftTests/Resources/src/.env/production.yaml b/Tests/buildconfigswiftTests/Resources/src/.env/production.yaml similarity index 100% rename from Tests/BuildConfig.swiftTests/Resources/src/.env/production.yaml rename to Tests/buildconfigswiftTests/Resources/src/.env/production.yaml diff --git a/Tests/BuildConfig.swiftTests/Resources/src/.env/staging.json b/Tests/buildconfigswiftTests/Resources/src/.env/staging.json similarity index 100% rename from Tests/BuildConfig.swiftTests/Resources/src/.env/staging.json rename to Tests/buildconfigswiftTests/Resources/src/.env/staging.json diff --git a/Tests/BuildConfig.swiftTests/Resources/src/API.yaml b/Tests/buildconfigswiftTests/Resources/src/API.yaml similarity index 100% rename from Tests/BuildConfig.swiftTests/Resources/src/API.yaml rename to Tests/buildconfigswiftTests/Resources/src/API.yaml diff --git a/Tests/BuildConfig.swiftTests/Resources/src/keys.yml b/Tests/buildconfigswiftTests/Resources/src/keys.yml similarity index 100% rename from Tests/BuildConfig.swiftTests/Resources/src/keys.yml rename to Tests/buildconfigswiftTests/Resources/src/keys.yml diff --git a/Tests/BuildConfig.swiftTests/Util.swift b/Tests/buildconfigswiftTests/Util.swift similarity index 100% rename from Tests/BuildConfig.swiftTests/Util.swift rename to Tests/buildconfigswiftTests/Util.swift From dbe231e5d93552f3fec70ff3dcf5611654ea38ad Mon Sep 17 00:00:00 2001 From: 417-72KI <417.72ki@gmail.com> Date: Mon, 2 Oct 2023 00:05:36 +0900 Subject: [PATCH 2/3] fix spacing --- Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index a95a684..fea85cd 100644 --- a/Package.swift +++ b/Package.swift @@ -5,7 +5,7 @@ import PackageDescription let package = Package( name: "BuildConfig.swift", - platforms: [ .macOS(.v12) ], + platforms: [.macOS(.v12)], products: [ .executable( name: "buildconfigswift", From 2b2154ebf2b8c78088944a9c4c909174562178ff Mon Sep 17 00:00:00 2001 From: 417-72KI <417.72ki@gmail.com> Date: Mon, 2 Oct 2023 00:13:32 +0900 Subject: [PATCH 3/3] rename entrypoint --- .../buildconfigswift/{BuildConfig.swift => App.swift} | 11 +++++++---- .../buildconfigswiftTests/BuildConfigswiftTests.swift | 8 ++++---- 2 files changed, 11 insertions(+), 8 deletions(-) rename Sources/buildconfigswift/{BuildConfig.swift => App.swift} (87%) diff --git a/Sources/buildconfigswift/BuildConfig.swift b/Sources/buildconfigswift/App.swift similarity index 87% rename from Sources/buildconfigswift/BuildConfig.swift rename to Sources/buildconfigswift/App.swift index 264799d..6cd8cd7 100644 --- a/Sources/buildconfigswift/BuildConfig.swift +++ b/Sources/buildconfigswift/App.swift @@ -5,7 +5,7 @@ import Foundation import PathKit @main -struct BuildConfigSwift: ParsableCommand { +struct App: ParsableCommand { @Option(name: .shortAndLong, help: "The directory to output BuildConfig.plist and BuildConfig.generated.swift.") var outputDirectory: String = "./" @@ -16,13 +16,16 @@ struct BuildConfigSwift: ParsableCommand { var srcDir: String } -extension BuildConfigSwift { +extension App { static var configuration: CommandConfiguration { - CommandConfiguration(version: ApplicationInfo.version) + CommandConfiguration( + commandName: "buildconfigswift", + version: ApplicationInfo.version + ) } } -extension BuildConfigSwift { +extension App { func run() throws { let outputDirectory = Path(outputDirectory) let environment = environment.flatMap { $0.isEmpty ? nil : $0 } diff --git a/Tests/buildconfigswiftTests/BuildConfigswiftTests.swift b/Tests/buildconfigswiftTests/BuildConfigswiftTests.swift index 5146193..8fb83c0 100644 --- a/Tests/buildconfigswiftTests/BuildConfigswiftTests.swift +++ b/Tests/buildconfigswiftTests/BuildConfigswiftTests.swift @@ -142,8 +142,8 @@ final class BuildConfigswiftTests: XCTestCase { XCTAssertEqual(process.exitCode, .validationFailure) XCTAssertEqual(stderr.outputString, """ Error: SCRIPT_INPUT_FILE_COUNT must be Int. Invalid value `foo` - Usage: build-config-swift [--output-directory ] [--environment ] - See 'build-config-swift --help' for more information. + Usage: buildconfigswift [--output-directory ] [--environment ] + See 'buildconfigswift --help' for more information. """) } try context("SCRIPT_OUTPUT_FILE_COUNT") { @@ -161,8 +161,8 @@ final class BuildConfigswiftTests: XCTestCase { XCTAssertEqual(process.exitCode, .validationFailure) XCTAssertEqual(stderr.outputString, """ Error: SCRIPT_OUTPUT_FILE_COUNT must be Int. Invalid value `bar` - Usage: build-config-swift [--output-directory ] [--environment ] - See 'build-config-swift --help' for more information. + Usage: buildconfigswift [--output-directory ] [--environment ] + See 'buildconfigswift --help' for more information. """) } }