feat: Renames some modules, updates plugins to stop using deprecated components.
This commit is contained in:
8
Dockerfile
Normal file
8
Dockerfile
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
ARG SWIFT_VERSION="6.0.3"
|
||||||
|
FROM swift:${SWIFT_VERSION}
|
||||||
|
WORKDIR /app
|
||||||
|
COPY ./Package.* ./
|
||||||
|
RUN swift package resolve
|
||||||
|
COPY . .
|
||||||
|
RUN swift build
|
||||||
|
CMD ["swift", "test"]
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"originHash" : "07a243cd8c2ed649f5fe5e76202ed091834801a0637c8b7785404e20b9e0cac1",
|
"originHash" : "867dabf4e0a92ed23018f0ef682d2d889f080ca5eaf99607665038dfb3a7532f",
|
||||||
"pins" : [
|
"pins" : [
|
||||||
{
|
{
|
||||||
"identity" : "combine-schedulers",
|
"identity" : "combine-schedulers",
|
||||||
@@ -24,8 +24,8 @@
|
|||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/apple/swift-argument-parser.git",
|
"location" : "https://github.com/apple/swift-argument-parser.git",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "8f4d2753f0e4778c76d5f05ad16c74f707390531",
|
"revision" : "41982a3656a71c768319979febd796c6fd111d5c",
|
||||||
"version" : "1.2.3"
|
"version" : "1.5.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -42,8 +42,8 @@
|
|||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/pointfreeco/swift-concurrency-extras",
|
"location" : "https://github.com/pointfreeco/swift-concurrency-extras",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "ea631ce892687f5432a833312292b80db238186a",
|
"revision" : "82a4ae7170d98d8538ec77238b7eb8e7199ef2e8",
|
||||||
"version" : "1.0.0"
|
"version" : "1.3.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -60,14 +60,14 @@
|
|||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/apple/swift-docc-plugin.git",
|
"location" : "https://github.com/apple/swift-docc-plugin.git",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "26ac5758409154cc448d7ab82389c520fa8a8247",
|
"revision" : "85e4bb4e1cd62cec64a4b8e769dcefdf0c5b9d64",
|
||||||
"version" : "1.3.0"
|
"version" : "1.4.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"identity" : "swift-docc-symbolkit",
|
"identity" : "swift-docc-symbolkit",
|
||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/apple/swift-docc-symbolkit",
|
"location" : "https://github.com/swiftlang/swift-docc-symbolkit",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "b45d1f2ed151d057b54504d653e0da5552844e34",
|
"revision" : "b45d1f2ed151d057b54504d653e0da5552844e34",
|
||||||
"version" : "1.0.0"
|
"version" : "1.0.0"
|
||||||
@@ -78,8 +78,8 @@
|
|||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/apple/swift-log.git",
|
"location" : "https://github.com/apple/swift-log.git",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "532d8b529501fb73a2455b179e0bbb6d49b652ed",
|
"revision" : "96a2f8a0fa41e9e09af4585e2724c4e825410b91",
|
||||||
"version" : "1.5.3"
|
"version" : "1.6.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// swift-tools-version: 5.10
|
// swift-tools-version: 6.0
|
||||||
|
|
||||||
import PackageDescription
|
import PackageDescription
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@ let package = Package(
|
|||||||
.macOS(.v13)
|
.macOS(.v13)
|
||||||
],
|
],
|
||||||
products: [
|
products: [
|
||||||
.library(name: "CliVersion", targets: ["CliVersion"]),
|
.library(name: "CliClient", targets: ["CliClient"]),
|
||||||
.plugin(name: "BuildWithVersionPlugin", targets: ["BuildWithVersionPlugin"]),
|
.plugin(name: "BuildWithVersionPlugin", targets: ["BuildWithVersionPlugin"]),
|
||||||
.plugin(name: "GenerateVersionPlugin", targets: ["GenerateVersionPlugin"]),
|
.plugin(name: "GenerateVersionPlugin", targets: ["GenerateVersionPlugin"]),
|
||||||
.plugin(name: "UpdateVersionPlugin", targets: ["UpdateVersionPlugin"])
|
.plugin(name: "UpdateVersionPlugin", targets: ["UpdateVersionPlugin"])
|
||||||
@@ -17,16 +17,29 @@ let package = Package(
|
|||||||
.package(url: "https://github.com/pointfreeco/swift-dependencies.git", from: "1.6.2"),
|
.package(url: "https://github.com/pointfreeco/swift-dependencies.git", from: "1.6.2"),
|
||||||
.package(url: "https://github.com/m-housh/swift-shell-client.git", from: "0.2.0"),
|
.package(url: "https://github.com/m-housh/swift-shell-client.git", from: "0.2.0"),
|
||||||
.package(url: "https://github.com/apple/swift-docc-plugin.git", from: "1.0.0"),
|
.package(url: "https://github.com/apple/swift-docc-plugin.git", from: "1.0.0"),
|
||||||
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.2")
|
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.0.0"),
|
||||||
|
.package(url: "https://github.com/apple/swift-log.git", from: "1.6.2")
|
||||||
],
|
],
|
||||||
targets: [
|
targets: [
|
||||||
.executableTarget(
|
.executableTarget(
|
||||||
name: "cli-version",
|
name: "cli-version",
|
||||||
dependencies: [
|
dependencies: [
|
||||||
"CliVersion",
|
"CliClient",
|
||||||
.product(name: "ArgumentParser", package: "swift-argument-parser")
|
.product(name: "ArgumentParser", package: "swift-argument-parser")
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
|
.target(
|
||||||
|
name: "CliClient",
|
||||||
|
dependencies: [
|
||||||
|
"FileClient",
|
||||||
|
"GitClient",
|
||||||
|
.product(name: "Logging", package: "swift-log")
|
||||||
|
]
|
||||||
|
),
|
||||||
|
.testTarget(
|
||||||
|
name: "CliVersionTests",
|
||||||
|
dependencies: ["CliClient", "TestSupport"]
|
||||||
|
),
|
||||||
.target(
|
.target(
|
||||||
name: "FileClient",
|
name: "FileClient",
|
||||||
dependencies: [
|
dependencies: [
|
||||||
@@ -43,18 +56,7 @@ let package = Package(
|
|||||||
.product(name: "ShellClient", package: "swift-shell-client")
|
.product(name: "ShellClient", package: "swift-shell-client")
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
.target(
|
|
||||||
name: "CliVersion",
|
|
||||||
dependencies: [
|
|
||||||
"FileClient",
|
|
||||||
"GitClient"
|
|
||||||
]
|
|
||||||
),
|
|
||||||
.target(name: "TestSupport"),
|
.target(name: "TestSupport"),
|
||||||
.testTarget(
|
|
||||||
name: "CliVersionTests",
|
|
||||||
dependencies: ["CliVersion", "TestSupport"]
|
|
||||||
),
|
|
||||||
.plugin(
|
.plugin(
|
||||||
name: "BuildWithVersionPlugin",
|
name: "BuildWithVersionPlugin",
|
||||||
capability: .buildTool(),
|
capability: .buildTool(),
|
||||||
|
|||||||
@@ -7,24 +7,28 @@ struct GenerateVersionBuildPlugin: BuildToolPlugin {
|
|||||||
context: PackagePlugin.PluginContext,
|
context: PackagePlugin.PluginContext,
|
||||||
target: PackagePlugin.Target
|
target: PackagePlugin.Target
|
||||||
) async throws -> [PackagePlugin.Command] {
|
) async throws -> [PackagePlugin.Command] {
|
||||||
guard let target = target as? SourceModuleTarget else { return [] }
|
guard let target = target as? SwiftSourceModuleTarget else { return [] }
|
||||||
|
|
||||||
let gitDirectoryPath = target.directory
|
let gitDirectoryPath = target.directoryURL
|
||||||
.removingLastComponent()
|
.deletingLastPathComponent()
|
||||||
.removingLastComponent()
|
.deletingLastPathComponent()
|
||||||
|
|
||||||
let tool = try context.tool(named: "cli-version")
|
let tool = try context.tool(named: "cli-version")
|
||||||
let outputPath = context.pluginWorkDirectory
|
let outputPath = context.pluginWorkDirectoryURL
|
||||||
|
|
||||||
let outputFile = outputPath.appending("Version.swift")
|
let outputFile = outputPath.appending(path: "Version.swift")
|
||||||
|
|
||||||
return [
|
return [
|
||||||
.buildCommand(
|
.buildCommand(
|
||||||
displayName: "Build With Version Plugin",
|
displayName: "Build with Version Plugin",
|
||||||
executable: tool.path,
|
executable: tool.url,
|
||||||
arguments: ["build", "--verbose", "--git-directory", gitDirectoryPath.string, "--target", outputPath.string],
|
arguments: [
|
||||||
|
"build", "--verbose",
|
||||||
|
"--git-directory", gitDirectoryPath.absoluteString,
|
||||||
|
"--target", outputPath.absoluteString
|
||||||
|
],
|
||||||
environment: [:],
|
environment: [:],
|
||||||
inputFiles: target.sourceFiles.map(\.path),
|
inputFiles: target.sourceFiles.map(\.url),
|
||||||
outputFiles: [outputFile]
|
outputFiles: [outputFile]
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ struct GenerateVersionPlugin: CommandPlugin {
|
|||||||
else { continue }
|
else { continue }
|
||||||
|
|
||||||
let process = Process()
|
let process = Process()
|
||||||
process.executableURL = URL(fileURLWithPath: gitVersion.path.string)
|
process.executableURL = gitVersion.url
|
||||||
process.arguments = arguments
|
process.arguments = arguments
|
||||||
try process.run()
|
try process.run()
|
||||||
process.waitUntilExit()
|
process.waitUntilExit()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import PackagePlugin
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
import PackagePlugin
|
||||||
|
|
||||||
@main
|
@main
|
||||||
struct UpdateVersionPlugin: CommandPlugin {
|
struct UpdateVersionPlugin: CommandPlugin {
|
||||||
@@ -15,7 +15,7 @@ struct UpdateVersionPlugin: CommandPlugin {
|
|||||||
else { continue }
|
else { continue }
|
||||||
|
|
||||||
let process = Process()
|
let process = Process()
|
||||||
process.executableURL = URL(fileURLWithPath: gitVersion.path.string)
|
process.executableURL = gitVersion.url
|
||||||
process.arguments = arguments
|
process.arguments = arguments
|
||||||
try process.run()
|
try process.run()
|
||||||
process.waitUntilExit()
|
process.waitUntilExit()
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 206 KiB After Width: | Height: | Size: 206 KiB |
@@ -1,11 +1,11 @@
|
|||||||
import ArgumentParser
|
import ArgumentParser
|
||||||
import CliVersion
|
import CliClient
|
||||||
import Foundation
|
import Foundation
|
||||||
import ShellClient
|
import ShellClient
|
||||||
|
|
||||||
extension CliVersionCommand {
|
extension CliVersionCommand {
|
||||||
struct Build: AsyncParsableCommand {
|
struct Build: AsyncParsableCommand {
|
||||||
static var configuration: CommandConfiguration = .init(
|
static let configuration: CommandConfiguration = .init(
|
||||||
abstract: "Used for the build with version plugin.",
|
abstract: "Used for the build with version plugin.",
|
||||||
discussion: "This should generally not be interacted with directly, outside of the build plugin."
|
discussion: "This should generally not be interacted with directly, outside of the build plugin."
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import ArgumentParser
|
import ArgumentParser
|
||||||
import CliVersion
|
import CliClient
|
||||||
import Dependencies
|
import Dependencies
|
||||||
|
|
||||||
extension CliVersionCommand {
|
extension CliVersionCommand {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import Foundation
|
|||||||
|
|
||||||
@main
|
@main
|
||||||
struct CliVersionCommand: AsyncParsableCommand {
|
struct CliVersionCommand: AsyncParsableCommand {
|
||||||
static var configuration: CommandConfiguration = .init(
|
static let configuration: CommandConfiguration = .init(
|
||||||
commandName: "cli-version",
|
commandName: "cli-version",
|
||||||
version: VERSION ?? "0.0.0",
|
version: VERSION ?? "0.0.0",
|
||||||
subcommands: [
|
subcommands: [
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import ArgumentParser
|
import ArgumentParser
|
||||||
import CliVersion
|
import CliClient
|
||||||
import Dependencies
|
import Dependencies
|
||||||
import Foundation
|
import Foundation
|
||||||
import ShellClient
|
import ShellClient
|
||||||
|
|
||||||
extension CliVersionCommand {
|
extension CliVersionCommand {
|
||||||
struct Generate: AsyncParsableCommand {
|
struct Generate: AsyncParsableCommand {
|
||||||
static var configuration: CommandConfiguration = .init(
|
static let configuration: CommandConfiguration = .init(
|
||||||
abstract: "Generates a version file in a command line tool that can be set via the git tag or git sha.",
|
abstract: "Generates a version file in a command line tool that can be set via the git tag or git sha.",
|
||||||
discussion: "This command can be interacted with directly, outside of the plugin usage context.",
|
discussion: "This command can be interacted with directly, outside of the plugin usage context.",
|
||||||
version: VERSION ?? "0.0.0"
|
version: VERSION ?? "0.0.0"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import ArgumentParser
|
import ArgumentParser
|
||||||
@_spi(Internal) import CliVersion
|
@_spi(Internal) import CliClient
|
||||||
import Dependencies
|
import Dependencies
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import ArgumentParser
|
import ArgumentParser
|
||||||
import CliVersion
|
import CliClient
|
||||||
import Dependencies
|
import Dependencies
|
||||||
import Foundation
|
import Foundation
|
||||||
import ShellClient
|
import ShellClient
|
||||||
@@ -7,7 +7,7 @@ import ShellClient
|
|||||||
extension CliVersionCommand {
|
extension CliVersionCommand {
|
||||||
|
|
||||||
struct Update: AsyncParsableCommand {
|
struct Update: AsyncParsableCommand {
|
||||||
static var configuration: CommandConfiguration = .init(
|
static let configuration: CommandConfiguration = .init(
|
||||||
abstract: "Updates a version string to the git tag or git sha.",
|
abstract: "Updates a version string to the git tag or git sha.",
|
||||||
discussion: "This command can be interacted with directly outside of the plugin context."
|
discussion: "This command can be interacted with directly outside of the plugin context."
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import ShellClient
|
|||||||
import TestSupport
|
import TestSupport
|
||||||
import XCTest
|
import XCTest
|
||||||
|
|
||||||
|
// TODO: Remove
|
||||||
final class GitVersionTests: XCTestCase {
|
final class GitVersionTests: XCTestCase {
|
||||||
|
|
||||||
override func invokeTest() {
|
override func invokeTest() {
|
||||||
@@ -28,6 +29,7 @@ final class GitVersionTests: XCTestCase {
|
|||||||
.cleanFilePath
|
.cleanFilePath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !os(Linux)
|
||||||
func test_live() async throws {
|
func test_live() async throws {
|
||||||
@Dependency(\.gitClient) var versionClient: GitClient
|
@Dependency(\.gitClient) var versionClient: GitClient
|
||||||
|
|
||||||
@@ -36,6 +38,7 @@ final class GitVersionTests: XCTestCase {
|
|||||||
// can't really have a predictable result for the live client.
|
// can't really have a predictable result for the live client.
|
||||||
XCTAssertNotEqual(version, "blob")
|
XCTAssertNotEqual(version, "blob")
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
func test_file_client() async throws {
|
func test_file_client() async throws {
|
||||||
try await withTemporaryDirectory { tmpDir in
|
try await withTemporaryDirectory { tmpDir in
|
||||||
|
|||||||
26
justfile
26
justfile
@@ -1,20 +1,44 @@
|
|||||||
product := "cli-version"
|
product := "cli-version"
|
||||||
|
docker_image := "cli-version"
|
||||||
|
docker_tag := "test"
|
||||||
|
|
||||||
[private]
|
[private]
|
||||||
default:
|
default:
|
||||||
@just --list
|
@just --list
|
||||||
|
|
||||||
build configuration="release":
|
# Build locally.
|
||||||
|
build configuration="debug":
|
||||||
@swift build \
|
@swift build \
|
||||||
--disable-sandbox \
|
--disable-sandbox \
|
||||||
--configuration {{configuration}} \
|
--configuration {{configuration}} \
|
||||||
--product {{product}}
|
--product {{product}}
|
||||||
|
|
||||||
|
alias b := build
|
||||||
|
|
||||||
|
# Build a docker image.
|
||||||
|
build-docker configuration="debug":
|
||||||
|
@docker build -t {{docker_image}}:{{docker_tag}} .
|
||||||
|
|
||||||
|
# Run the command-line tool.
|
||||||
run *ARGS:
|
run *ARGS:
|
||||||
@swift run {{product}} {{ARGS}}
|
@swift run {{product}} {{ARGS}}
|
||||||
|
|
||||||
|
# Clean the build folder.
|
||||||
clean:
|
clean:
|
||||||
rm -rf .build
|
rm -rf .build
|
||||||
|
|
||||||
|
# Clean and build.
|
||||||
|
clean-build configuration="debug": clean (build configuration)
|
||||||
|
|
||||||
|
alias cb := clean-build
|
||||||
|
|
||||||
|
# Test locally.
|
||||||
test *ARGS:
|
test *ARGS:
|
||||||
@swift test {{ARGS}}
|
@swift test {{ARGS}}
|
||||||
|
|
||||||
|
# Build docker test container and run tests.
|
||||||
|
test-docker: build-docker
|
||||||
|
@docker run --rm {{docker_image}}:{{docker_tag}}
|
||||||
|
|
||||||
|
test-docker-without-building:
|
||||||
|
@docker run --rm {{docker_image}}:{{docker_tag}} swift test
|
||||||
|
|||||||
Reference in New Issue
Block a user