Skip to content

Commit

Permalink
Use a CSV, not a txt file. Require the CSV
Browse files Browse the repository at this point in the history
  • Loading branch information
dfed committed Jan 12, 2024
1 parent 475dc7b commit 01cacea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,16 @@ struct SafeDIGenerateDependencyTree: BuildToolPlugin {
.map(\.path)
}

let inputSwiftFilesFilePath = context.pluginWorkDirectory.appending(subpath: "InputSwiftFiles.txt").string
let inputSourcesFilePath = context.pluginWorkDirectory.appending(subpath: "InputSwiftFiles.csv").string
try Data(
(targetSwiftFiles + dependenciesSourceFiles)
.map(\.string)
.joined(separator: "\n")
.joined(separator: ",")
.utf8
)
.write(toPath: inputSwiftFilesFilePath)
.write(toPath: inputSourcesFilePath)
let arguments = [
"--swift-file-paths-file-path",
inputSwiftFilesFilePath,
inputSourcesFilePath,
"--dependency-tree-output",
outputSwiftFile.string
]
Expand Down Expand Up @@ -106,17 +105,16 @@ extension SafeDIGenerateDependencyTree: XcodeBuildToolPlugin {
}

let outputSwiftFile = context.pluginWorkDirectory.appending(subpath: "SafeDI.swift")
let inputSwiftFilesFilePath = context.pluginWorkDirectory.appending(subpath: "InputSwiftFiles.txt").string
let inputSourcesFilePath = context.pluginWorkDirectory.appending(subpath: "InputSwiftFiles.csv").string
try Data(
inputSwiftFiles
.map(\.string)
.joined(separator: "\n")
.joined(separator: ",")
.utf8
)
.write(toPath: inputSwiftFilesFilePath)
.write(toPath: inputSourcesFilePath)
let arguments = [
"--swift-file-paths-file-path",
inputSwiftFilesFilePath,
inputSourcesFilePath,
"--dependency-tree-output",
outputSwiftFile.string
]
Expand Down
17 changes: 4 additions & 13 deletions Sources/SafeDITool/SafeDITool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ struct SafeDITool: AsyncParsableCommand {

// MARK: Arguments

@Argument(help: "The Swift files to parse.")
var swiftFilePaths: [String] = []

@Option(help: "A path to a file containing newline-separated Swift files to parse.")
var swiftFilePathsFilePath: String?
@Argument(help: "A path to a CSV file containing paths of Swift files to parse.")
var swiftSourcesFilePath: String

@Option(parsing: .upToNextOption, help: "The names of modules to import in the generated dependency tree. This list is in addition to the import statements found in files that declare @Instantiable types.")
var additionalImportedModules: [String] = []
Expand Down Expand Up @@ -126,14 +123,8 @@ struct SafeDITool: AsyncParsableCommand {
of: String.self,
returning: [String].self
) { taskGroup in
let swiftFilePaths: [String]
if let swiftFilePathsFilePath {
swiftFilePaths = try String(contentsOfFile: swiftFilePathsFilePath)
.components(separatedBy: .newlines)
+ self.swiftFilePaths
} else {
swiftFilePaths = self.swiftFilePaths
}
let swiftFilePaths = try String(contentsOfFile: swiftSourcesFilePath)
.components(separatedBy: CharacterSet(arrayLiteral: ","))
for filePath in swiftFilePaths {
taskGroup.addTask {
let swiftFile = try String(contentsOfFile: filePath)
Expand Down

0 comments on commit 01cacea

Please sign in to comment.