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" : [
|
||||
{
|
||||
"identity" : "combine-schedulers",
|
||||
@@ -24,8 +24,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-argument-parser.git",
|
||||
"state" : {
|
||||
"revision" : "8f4d2753f0e4778c76d5f05ad16c74f707390531",
|
||||
"version" : "1.2.3"
|
||||
"revision" : "41982a3656a71c768319979febd796c6fd111d5c",
|
||||
"version" : "1.5.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -42,8 +42,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/pointfreeco/swift-concurrency-extras",
|
||||
"state" : {
|
||||
"revision" : "ea631ce892687f5432a833312292b80db238186a",
|
||||
"version" : "1.0.0"
|
||||
"revision" : "82a4ae7170d98d8538ec77238b7eb8e7199ef2e8",
|
||||
"version" : "1.3.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -60,14 +60,14 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-docc-plugin.git",
|
||||
"state" : {
|
||||
"revision" : "26ac5758409154cc448d7ab82389c520fa8a8247",
|
||||
"version" : "1.3.0"
|
||||
"revision" : "85e4bb4e1cd62cec64a4b8e769dcefdf0c5b9d64",
|
||||
"version" : "1.4.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-docc-symbolkit",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-docc-symbolkit",
|
||||
"location" : "https://github.com/swiftlang/swift-docc-symbolkit",
|
||||
"state" : {
|
||||
"revision" : "b45d1f2ed151d057b54504d653e0da5552844e34",
|
||||
"version" : "1.0.0"
|
||||
@@ -78,8 +78,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-log.git",
|
||||
"state" : {
|
||||
"revision" : "532d8b529501fb73a2455b179e0bbb6d49b652ed",
|
||||
"version" : "1.5.3"
|
||||
"revision" : "96a2f8a0fa41e9e09af4585e2724c4e825410b91",
|
||||
"version" : "1.6.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// swift-tools-version: 5.10
|
||||
// swift-tools-version: 6.0
|
||||
|
||||
import PackageDescription
|
||||
|
||||
@@ -8,7 +8,7 @@ let package = Package(
|
||||
.macOS(.v13)
|
||||
],
|
||||
products: [
|
||||
.library(name: "CliVersion", targets: ["CliVersion"]),
|
||||
.library(name: "CliClient", targets: ["CliClient"]),
|
||||
.plugin(name: "BuildWithVersionPlugin", targets: ["BuildWithVersionPlugin"]),
|
||||
.plugin(name: "GenerateVersionPlugin", targets: ["GenerateVersionPlugin"]),
|
||||
.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/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-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: [
|
||||
.executableTarget(
|
||||
name: "cli-version",
|
||||
dependencies: [
|
||||
"CliVersion",
|
||||
"CliClient",
|
||||
.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(
|
||||
name: "FileClient",
|
||||
dependencies: [
|
||||
@@ -43,18 +56,7 @@ let package = Package(
|
||||
.product(name: "ShellClient", package: "swift-shell-client")
|
||||
]
|
||||
),
|
||||
.target(
|
||||
name: "CliVersion",
|
||||
dependencies: [
|
||||
"FileClient",
|
||||
"GitClient"
|
||||
]
|
||||
),
|
||||
.target(name: "TestSupport"),
|
||||
.testTarget(
|
||||
name: "CliVersionTests",
|
||||
dependencies: ["CliVersion", "TestSupport"]
|
||||
),
|
||||
.plugin(
|
||||
name: "BuildWithVersionPlugin",
|
||||
capability: .buildTool(),
|
||||
|
||||
@@ -7,24 +7,28 @@ struct GenerateVersionBuildPlugin: BuildToolPlugin {
|
||||
context: PackagePlugin.PluginContext,
|
||||
target: PackagePlugin.Target
|
||||
) async throws -> [PackagePlugin.Command] {
|
||||
guard let target = target as? SourceModuleTarget else { return [] }
|
||||
guard let target = target as? SwiftSourceModuleTarget else { return [] }
|
||||
|
||||
let gitDirectoryPath = target.directory
|
||||
.removingLastComponent()
|
||||
.removingLastComponent()
|
||||
let gitDirectoryPath = target.directoryURL
|
||||
.deletingLastPathComponent()
|
||||
.deletingLastPathComponent()
|
||||
|
||||
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 [
|
||||
.buildCommand(
|
||||
displayName: "Build With Version Plugin",
|
||||
executable: tool.path,
|
||||
arguments: ["build", "--verbose", "--git-directory", gitDirectoryPath.string, "--target", outputPath.string],
|
||||
displayName: "Build with Version Plugin",
|
||||
executable: tool.url,
|
||||
arguments: [
|
||||
"build", "--verbose",
|
||||
"--git-directory", gitDirectoryPath.absoluteString,
|
||||
"--target", outputPath.absoluteString
|
||||
],
|
||||
environment: [:],
|
||||
inputFiles: target.sourceFiles.map(\.path),
|
||||
inputFiles: target.sourceFiles.map(\.url),
|
||||
outputFiles: [outputFile]
|
||||
)
|
||||
]
|
||||
|
||||
@@ -15,7 +15,7 @@ struct GenerateVersionPlugin: CommandPlugin {
|
||||
else { continue }
|
||||
|
||||
let process = Process()
|
||||
process.executableURL = URL(fileURLWithPath: gitVersion.path.string)
|
||||
process.executableURL = gitVersion.url
|
||||
process.arguments = arguments
|
||||
try process.run()
|
||||
process.waitUntilExit()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import PackagePlugin
|
||||
import Foundation
|
||||
import PackagePlugin
|
||||
|
||||
@main
|
||||
struct UpdateVersionPlugin: CommandPlugin {
|
||||
@@ -15,7 +15,7 @@ struct UpdateVersionPlugin: CommandPlugin {
|
||||
else { continue }
|
||||
|
||||
let process = Process()
|
||||
process.executableURL = URL(fileURLWithPath: gitVersion.path.string)
|
||||
process.executableURL = gitVersion.url
|
||||
process.arguments = arguments
|
||||
try process.run()
|
||||
process.waitUntilExit()
|
||||
|
||||
|
Before Width: | Height: | Size: 206 KiB After Width: | Height: | Size: 206 KiB |
@@ -1,11 +1,11 @@
|
||||
import ArgumentParser
|
||||
import CliVersion
|
||||
import CliClient
|
||||
import Foundation
|
||||
import ShellClient
|
||||
|
||||
extension CliVersionCommand {
|
||||
struct Build: AsyncParsableCommand {
|
||||
static var configuration: CommandConfiguration = .init(
|
||||
static let configuration: CommandConfiguration = .init(
|
||||
abstract: "Used for the build with version plugin.",
|
||||
discussion: "This should generally not be interacted with directly, outside of the build plugin."
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import ArgumentParser
|
||||
import CliVersion
|
||||
import CliClient
|
||||
import Dependencies
|
||||
|
||||
extension CliVersionCommand {
|
||||
|
||||
@@ -3,7 +3,7 @@ import Foundation
|
||||
|
||||
@main
|
||||
struct CliVersionCommand: AsyncParsableCommand {
|
||||
static var configuration: CommandConfiguration = .init(
|
||||
static let configuration: CommandConfiguration = .init(
|
||||
commandName: "cli-version",
|
||||
version: VERSION ?? "0.0.0",
|
||||
subcommands: [
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import ArgumentParser
|
||||
import CliVersion
|
||||
import CliClient
|
||||
import Dependencies
|
||||
import Foundation
|
||||
import ShellClient
|
||||
|
||||
extension CliVersionCommand {
|
||||
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.",
|
||||
discussion: "This command can be interacted with directly, outside of the plugin usage context.",
|
||||
version: VERSION ?? "0.0.0"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import ArgumentParser
|
||||
@_spi(Internal) import CliVersion
|
||||
@_spi(Internal) import CliClient
|
||||
import Dependencies
|
||||
import Foundation
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import ArgumentParser
|
||||
import CliVersion
|
||||
import CliClient
|
||||
import Dependencies
|
||||
import Foundation
|
||||
import ShellClient
|
||||
@@ -7,7 +7,7 @@ import ShellClient
|
||||
extension CliVersionCommand {
|
||||
|
||||
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.",
|
||||
discussion: "This command can be interacted with directly outside of the plugin context."
|
||||
)
|
||||
|
||||
@@ -6,6 +6,7 @@ import ShellClient
|
||||
import TestSupport
|
||||
import XCTest
|
||||
|
||||
// TODO: Remove
|
||||
final class GitVersionTests: XCTestCase {
|
||||
|
||||
override func invokeTest() {
|
||||
@@ -28,6 +29,7 @@ final class GitVersionTests: XCTestCase {
|
||||
.cleanFilePath
|
||||
}
|
||||
|
||||
#if !os(Linux)
|
||||
func test_live() async throws {
|
||||
@Dependency(\.gitClient) var versionClient: GitClient
|
||||
|
||||
@@ -36,6 +38,7 @@ final class GitVersionTests: XCTestCase {
|
||||
// can't really have a predictable result for the live client.
|
||||
XCTAssertNotEqual(version, "blob")
|
||||
}
|
||||
#endif
|
||||
|
||||
func test_file_client() async throws {
|
||||
try await withTemporaryDirectory { tmpDir in
|
||||
|
||||
26
justfile
26
justfile
@@ -1,20 +1,44 @@
|
||||
product := "cli-version"
|
||||
docker_image := "cli-version"
|
||||
docker_tag := "test"
|
||||
|
||||
[private]
|
||||
default:
|
||||
@just --list
|
||||
|
||||
build configuration="release":
|
||||
# Build locally.
|
||||
build configuration="debug":
|
||||
@swift build \
|
||||
--disable-sandbox \
|
||||
--configuration {{configuration}} \
|
||||
--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:
|
||||
@swift run {{product}} {{ARGS}}
|
||||
|
||||
# Clean the build folder.
|
||||
clean:
|
||||
rm -rf .build
|
||||
|
||||
# Clean and build.
|
||||
clean-build configuration="debug": clean (build configuration)
|
||||
|
||||
alias cb := clean-build
|
||||
|
||||
# Test locally.
|
||||
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