Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
xcode_version:
- "15.0.1"
- "15.4"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[note] Required to bump to get Swift 5.10

env:
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode_version }}.app
steps:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Test on Linux
runs-on: ubuntu-22.04
container:
image: swift:5.9
image: swift:5.10
steps:
- uses: actions/checkout@v2
- name: Show Environments
Expand All @@ -26,11 +26,11 @@ jobs:
run: make test
macOS:
name: Test on macOS
runs-on: macos-13
runs-on: macos-14
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[note] Required to get Xcode 15.4 support

strategy:
matrix:
xcode_version:
- "15.0.1"
- "15.4"
env:
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode_version }}.app
steps:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SWIFT_BUILD_FLAGS := -c release --disable-sandbox
TOOL_NAME := swift-mod
XCODE_DEFAULT_TOOLCHAIN := /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain
GITHUB_REPO := ra1028/$(TOOL_NAME)
DOCKER_IMAGE_NAME := swift:5.9
DOCKER_IMAGE_NAME := swift:5.10

ifeq ($(shell uname), Darwin)
SWIFT_BUILD_FLAGS += --arch arm64 --arch x86_64
Expand Down
34 changes: 13 additions & 21 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.9
// swift-tools-version:5.10

import PackageDescription

Expand All @@ -14,10 +14,10 @@ let package = Package(
)
],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser", .upToNextMinor(from: "1.1.2")),
.package(url: "https://github.com/apple/swift-syntax", .upToNextMinor(from: "509.0.1")),
.package(url: "https://github.com/apple/swift-tools-support-core.git", from: "0.2.3"),
.package(url: "https://github.com/jpsim/Yams.git", from: "5.0.0")
.package(url: "https://github.com/apple/swift-argument-parser.git", exact: "1.5.0"),
.package(url: "https://github.com/swiftlang/swift-syntax.git", exact: "510.0.3"),
.package(url: "https://github.com/swiftlang/swift-tools-support-core.git", exact: "0.7.1"),
.package(url: "https://github.com/jpsim/Yams.git", exact: "5.1.3")
],
targets: [
.executableTarget(
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ A tool for Swift code modification intermediating between code generation and fo

`swift-mod` is a tool for Swift code modification that intermediating between code generator and formatter built on top of [apple/SwiftSyntax](https://github.com/apple/swift-syntax).
It can generates boilerplate code, such as access control or memberwise initializers in modularized source code, taking into account the state of the [AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree).
You can improve your productivity for writing more advanced Swift codes with introducing `swift-mod`.
You can improve your productivity for writing more advanced Swift codes by introducing `swift-mod`.

### Example

Expand Down Expand Up @@ -301,10 +301,10 @@ You can also install swift-mod by downloading `swift-mod.zip` from the latest Gi

### Swift Version Support

`swift-mod` depends on [SwiftSyntax](https://github.com/apple/swift-syntax) that the version in use must match the toolchain version until Swift 5.7.
Copy link
Contributor Author

@rasberik rasberik Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[note] Very difficult sentence that I couldnt understand, simplified

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

until Swift 5.7 is not if important historical matter or forgotten to update

So you should use swift-mod version that built with compatible version of Swift you are using.
`swift-mod` depends on [SwiftSyntax](https://github.com/apple/swift-syntax) version that matches the toolchain version in use.
So you should use swift-mod version that built with compatible version of Swift you are using.

|Swift Version|Last Supported swift-mod Release|
|Swift Version|Last Supported `swift-mod` |
|:------------|:-------------------------------|
|5.1 |0.0.2 |
|5.2 |0.0.4 |
Expand All @@ -313,7 +313,9 @@ So you should use swift-mod version that built with compatible version of Swift
|5.5 |0.0.7 |
|5.6 |0.1.0 |
|5.7 |0.1.1 |
|5.8 and later|latest |
|5.8 |0.2.0 |
|5.9 |0.2.0 |
|5.10 |0.2.1 |
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[note] To be: 0.2.1


---

Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftModCommands/Arguments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public enum Mode: String, CaseIterable, ExpressibleByArgument {
extension AbsolutePath: ExpressibleByArgument {
public init?(argument: String) {
if let cwd = localFileSystem.currentWorkingDirectory {
self.init(argument, relativeTo: cwd)
try? self.init(validating: argument, relativeTo: cwd)
}
else {
try? self.init(validating: argument)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftModCore/Helpers/DirectoryIterator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public final class DirectoryIterator: DirectoryEnumerable, IteratorProtocol {
return nil
}

return AbsolutePath(pathURL.path)
return try? AbsolutePath(validating: pathURL.path)
}
}
2 changes: 1 addition & 1 deletion Sources/SwiftModCore/Helpers/FileManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public final class InMemoryFileManager: FileManagerProtocol {

public func createFile(atPath path: String) -> Bool {
do {
try fileSystem.writeFileContents(AbsolutePath(path), bytes: ByteString())
try fileSystem.writeFileContents(AbsolutePath(validating: path), bytes: ByteString())
return true
}
catch {
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftModCore/Helpers/InteractiveWriter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public final class InteractiveWriter: InteractiveWriterProtocol {
term.write(string, inColor: color, bold: bold)
}
else {
stream <<< string
stream.send(string)
stream.flush()
}
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/SwiftModCommandsTests/InitCommandRunnerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ final class InitCommandTests: XCTestCase {
func testRun() throws {
let fileSystem = InMemoryFileSystem()
let fileManager = InMemoryFileManager(fileSystem: fileSystem)
let output = AbsolutePath("/home/cwd/output/.swift-mod.yml")
let output = try AbsolutePath(validating: "/home/cwd/output/.swift-mod.yml")
let runner = InitCommandRunner(
output: output,
fileSystem: fileSystem,
Expand Down
18 changes: 9 additions & 9 deletions Tests/SwiftModCommandsTests/RunCommandRunnerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,28 @@ final class RunCommandRunnerTests: XCTestCase {
)
]
)
let configurationPath = AbsolutePath("/home/cwd/.swift-mod.yml")
let configurationPath = try AbsolutePath(validating: "/home/cwd/.swift-mod.yml")

try fileSystem.createDirectory(AbsolutePath("/home/cwd/test"), recursive: true)
try fileSystem.createDirectory(AbsolutePath(validating: "/home/cwd/test"), recursive: true)
try fileSystem.writeFileContents(
configurationPath,
bytes: ByteString(encodingAsUTF8: try YAMLEncoder().encode(configuration))
)
try fileSystem.writeFileContents(
AbsolutePath("/home/cwd/test/file1.swift"),
AbsolutePath(validating: "/home/cwd/test/file1.swift"),
bytes: #"let cat = "meow""#
)
try fileSystem.writeFileContents(
AbsolutePath("/home/cwd/test/file2.swift"),
AbsolutePath(validating: "/home/cwd/test/file2.swift"),
bytes: #"let dog = "woof""#
)

let runner = RunCommandRunner(
let runner = try RunCommandRunner(
configuration: configurationPath,
mode: .modify,
paths: [
AbsolutePath("/home/cwd/test/file1.swift"),
AbsolutePath("/home/cwd/test/file2.swift"),
AbsolutePath(validating: "/home/cwd/test/file1.swift"),
AbsolutePath(validating: "/home/cwd/test/file2.swift"),
],
fileSystem: fileSystem,
fileManager: fileManager,
Expand All @@ -57,11 +57,11 @@ final class RunCommandRunnerTests: XCTestCase {
try runner.run()

XCTAssertEqual(
try fileSystem.readFileContents(AbsolutePath("/home/cwd/test/file1.swift")),
try fileSystem.readFileContents(AbsolutePath(validating: "/home/cwd/test/file1.swift")),
#"public let cat = "meow""#
)
XCTAssertEqual(
try fileSystem.readFileContents(AbsolutePath("/home/cwd/test/file2.swift")),
try fileSystem.readFileContents(AbsolutePath(validating: "/home/cwd/test/file2.swift")),
#"public let dog = "woof""#
)
}
Expand Down
97 changes: 48 additions & 49 deletions Tools/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Tools/Package.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// swift-tools-version:5.9
// swift-tools-version:5.10

import PackageDescription

let package = Package(
name: "Tools",
dependencies: [
.package(url: "https://github.com/apple/swift-format.git", .upToNextMinor(from: "509.0.0")),
.package(url: "https://github.com/swiftlang/swift-format.git", exact: "510.1.0"),
]
)
Loading