diff --git a/README.md b/README.md index cea2e85..6996ea6 100644 --- a/README.md +++ b/README.md @@ -38,8 +38,8 @@ brew install swiftfindrefs ## ⚙️ Command line options ### Common options (available for all subcommands) -- `-p, --projectName` helps the tool infer the right DerivedData folder when you do not pass `derivedDataPath`. -- `-d, --derivedDataPath` points directly to a DerivedData (or IndexStoreDB) directory and skips discovery. +- `-p, --projectName` helps the tool infer the right DerivedData folder when `dataStorePath` is not provided. +- `-d, --dataStorePath` points directly to a DataStore directory. When provided, this takes priority over `--projectName`. - `-v, --verbose` enables verbose output for diagnostic purposes (flag, no value required). ### Search subcommand diff --git a/Sources/SwiftFindRefs/CompositionRoot/RemoveCompositionRoot.swift b/Sources/SwiftFindRefs/CompositionRoot/RemoveCompositionRoot.swift index 23058f8..553701a 100644 --- a/Sources/SwiftFindRefs/CompositionRoot/RemoveCompositionRoot.swift +++ b/Sources/SwiftFindRefs/CompositionRoot/RemoveCompositionRoot.swift @@ -3,7 +3,7 @@ import Foundation struct RemoveCompositionRoot { let projectName: String? - let derivedDataPath: String? + let dataStorePath: String? let excludeCompilationConditionals: Bool let print: (String) -> Void let vPrint: (String) -> Void @@ -12,14 +12,20 @@ struct RemoveCompositionRoot { let removerFactory: (String) -> UnnecessaryTestableRemoving func run() async throws { - let derivedDataPaths = try derivedDataLocator.locateDerivedData( - projectName: projectName, - derivedDataPath: derivedDataPath - ) - vPrint("DerivedData path: \(derivedDataPaths.derivedDataURL.path)") - vPrint("IndexStoreDB path: \(derivedDataPaths.indexStoreDBURL.path)") - let indexStorePath = derivedDataPaths.indexStoreDBURL.deletingLastPathComponent().path - let remover = removerFactory(indexStorePath) + var pathToDataStore: String + if let dataStorePath { + guard fileSystem.fileExists(atPath: dataStorePath) else { throw DataStorePathValidationError.invalidPath(dataStorePath) } + pathToDataStore = dataStorePath + } else { + let derivedDataPaths = try derivedDataLocator.locateDerivedData( + projectName: projectName + ) + pathToDataStore = derivedDataPaths.dataStoreURL.path() + vPrint("Discovering DataStore path based on projectName: \(String(describing: projectName))") + } + vPrint("Using DataStore path: \(pathToDataStore)") + + let remover = removerFactory(pathToDataStore) let updatedFiles = try await remover.run() print("✅ Updated \(updatedFiles.count) files") vPrint("Updated files:") diff --git a/Sources/SwiftFindRefs/CompositionRoot/SearchCompositionRoot.swift b/Sources/SwiftFindRefs/CompositionRoot/SearchCompositionRoot.swift index 45a3f3f..1f901d2 100644 --- a/Sources/SwiftFindRefs/CompositionRoot/SearchCompositionRoot.swift +++ b/Sources/SwiftFindRefs/CompositionRoot/SearchCompositionRoot.swift @@ -2,7 +2,7 @@ import Foundation struct SearchCompositionRoot { let projectName: String? - let derivedDataPath: String? + let dataStorePath: String? let symbolName: String let symbolType: String? let print: (String) -> Void @@ -11,14 +11,19 @@ struct SearchCompositionRoot { let derivedDataLocator: DerivedDataLocatorProtocol func run() async throws { - let derivedDataPaths = try derivedDataLocator.locateDerivedData( - projectName: projectName, - derivedDataPath: derivedDataPath - ) - vPrint("DerivedData path: \(derivedDataPaths.derivedDataURL.path)") - vPrint("IndexStoreDB path: \(derivedDataPaths.indexStoreDBURL.path)") - let indexStorePath = derivedDataPaths.indexStoreDBURL.deletingLastPathComponent().path - let indexStoreFinder = IndexStoreFinder(indexStorePath: indexStorePath) + var pathToDataStore: String + if let dataStorePath { + guard fileSystem.fileExists(atPath: dataStorePath) else { throw DataStorePathValidationError.invalidPath(dataStorePath) } + pathToDataStore = dataStorePath + + } else { + let derivedDataPaths = try derivedDataLocator.locateDerivedData(projectName: projectName) + pathToDataStore = derivedDataPaths.dataStoreURL.path() + vPrint("Discovering DataStore path based on projectName: \(String(describing: projectName))") + } + vPrint("Using DataStore path: \(pathToDataStore)") + + let indexStoreFinder = IndexStoreFinder(indexStorePath: pathToDataStore) print("🔍 Searching for references to symbol '\(symbolName)' of type '\(symbolType ?? "any")'") let references = try await indexStoreFinder.fileReferences(of: symbolName, symbolType: symbolType) print("✅ Found \(references.count) references:\n\(references.joined(separator: "\n"))") diff --git a/Sources/SwiftFindRefs/DerivedData/DataStorePathValidationError.swift b/Sources/SwiftFindRefs/DerivedData/DataStorePathValidationError.swift new file mode 100644 index 0000000..b1cb19b --- /dev/null +++ b/Sources/SwiftFindRefs/DerivedData/DataStorePathValidationError.swift @@ -0,0 +1,14 @@ +import Foundation + +/// Errors thrown while validating the DataPath for a project. +enum DataStorePathValidationError: LocalizedError { + case invalidPath(String) + + /// Human-readable description surfaced to end users. + var errorDescription: String? { + switch self { + case .invalidPath(let path): + "❌ The provided DataStore path does not exist: \(path)." + } + } +} diff --git a/Sources/SwiftFindRefs/DerivedData/DerivedDataLocator.swift b/Sources/SwiftFindRefs/DerivedData/DerivedDataLocator.swift index f11fcfb..42a5365 100644 --- a/Sources/SwiftFindRefs/DerivedData/DerivedDataLocator.swift +++ b/Sources/SwiftFindRefs/DerivedData/DerivedDataLocator.swift @@ -21,20 +21,12 @@ struct DerivedDataLocator: DerivedDataLocatorProtocol { /// Finds the DerivedData directory for the given inputs and indicates whether helper paths should be appended. /// - Parameters: /// - projectName: The name of the Xcode project whose DerivedData should be inferred when no explicit path is supplied. - /// - derivedDataPath: An optional explicit DerivedData path which, when present, takes precedence over project resolution. + /// - dataStorePath: An optional explicit DataStore path which, when present, takes precedence over project resolution. /// - Returns: A ``DerivedDataPaths`` value containing the resolved URL and whether additional IndexStore paths should be appended. /// - Throws: ``DerivedDataLocatorError`` when inputs are missing, invalid, or when the DerivedData directory cannot be found. func locateDerivedData( - projectName: String?, - derivedDataPath: String? + projectName: String? ) throws -> DerivedDataPaths { - if let derivedDataPath, !derivedDataPath.isEmpty { - guard fileSystem.fileExists(atPath: derivedDataPath) else { - throw DerivedDataLocatorError.invalidPath(derivedDataPath) - } - return DerivedDataPaths(derivedDataURL: URL(fileURLWithPath: derivedDataPath), shouldAppendExtraPaths: false) - } - guard let projectName, !projectName.isEmpty else { throw DerivedDataLocatorError.missingInputs } diff --git a/Sources/SwiftFindRefs/DerivedData/DerivedDataLocatorError.swift b/Sources/SwiftFindRefs/DerivedData/DerivedDataLocatorError.swift index 70a3f79..54cc957 100644 --- a/Sources/SwiftFindRefs/DerivedData/DerivedDataLocatorError.swift +++ b/Sources/SwiftFindRefs/DerivedData/DerivedDataLocatorError.swift @@ -2,26 +2,22 @@ import Foundation /// Errors thrown while locating the DerivedData directory for a project. enum DerivedDataLocatorError: LocalizedError { - /// No usable `projectName` or `derivedDataPath` was provided. + /// No usable `projectName` or `dataStorePath` was provided. case missingInputs /// The default DerivedData root directory does not exist at the expected path. case derivedDataRootMissing(String) /// A DerivedData entry matching the provided project name was not found. case projectNotFound(String) - /// The explicit DerivedData path provided by the caller could not be resolved on disk. - case invalidPath(String) /// Human-readable description surfaced to end users. var errorDescription: String? { switch self { case .missingInputs: - "❌ Either projectName or derivedDataPath must be provided." + "❌ Either projectName or dataStorePath must be provided." case .derivedDataRootMissing(let path): "❌ DerivedData root directory was not found at \(path)." case .projectNotFound(let name): "❌ No DerivedData entry matching project \(name) was found." - case .invalidPath(let path): - "❌ The provided DerivedData path does not exist: \(path)." } } } diff --git a/Sources/SwiftFindRefs/DerivedData/DerivedDataLocatorProtocol.swift b/Sources/SwiftFindRefs/DerivedData/DerivedDataLocatorProtocol.swift index 4a113b9..597bdc6 100644 --- a/Sources/SwiftFindRefs/DerivedData/DerivedDataLocatorProtocol.swift +++ b/Sources/SwiftFindRefs/DerivedData/DerivedDataLocatorProtocol.swift @@ -5,11 +5,10 @@ protocol DerivedDataLocatorProtocol { /// Locates the DerivedData directory either from an explicit path or by inferring it from the project name. /// - Parameters: /// - projectName: The name of the Xcode project whose DerivedData should be searched. - /// - derivedDataPath: An optional explicit DerivedData path that takes precedence when provided. + /// - dataStorePath: An optional explicit DataStore path that takes precedence when provided. /// - Returns: Paths describing the resolved DerivedData location and whether helper paths should be appended. /// - Throws: ``DerivedDataLocatorError`` when the provided inputs are invalid or the DerivedData directory cannot be found. func locateDerivedData( - projectName: String?, - derivedDataPath: String? + projectName: String? ) throws -> DerivedDataPaths } diff --git a/Sources/SwiftFindRefs/DerivedData/DerivedDataPaths.swift b/Sources/SwiftFindRefs/DerivedData/DerivedDataPaths.swift index 38d5210..7bb21d9 100644 --- a/Sources/SwiftFindRefs/DerivedData/DerivedDataPaths.swift +++ b/Sources/SwiftFindRefs/DerivedData/DerivedDataPaths.swift @@ -8,11 +8,10 @@ struct DerivedDataPaths { let shouldAppendExtraPaths: Bool /// Points to the IndexStore database, automatically appending the Xcode-specific subpath when needed. - var indexStoreDBURL: URL { + var dataStoreURL: URL { shouldAppendExtraPaths ? derivedDataURL .appendingPathComponent("Index.noindex", isDirectory: true) .appendingPathComponent("DataStore", isDirectory: true) - .appendingPathComponent("IndexStoreDB", isDirectory: true) : derivedDataURL } } diff --git a/Sources/SwiftFindRefs/SwiftFindRefs.swift b/Sources/SwiftFindRefs/SwiftFindRefs.swift index d88e91b..1f1a0f2 100644 --- a/Sources/SwiftFindRefs/SwiftFindRefs.swift +++ b/Sources/SwiftFindRefs/SwiftFindRefs.swift @@ -17,16 +17,16 @@ extension SwiftFindRefs { @Option(name: [.short, .customLong("projectName")], help: "The name of the Xcode project to help CLI find the Derived Data Index Store Path") var projectName: String? - @Option(name: [.short, .customLong("derivedDataPath")], help: "The Derived Data path where Xcode stores build data") - var derivedDataPath: String? + @Option(name: [.short, .customLong("dataStorePath")], help: "The DataStore path inside DerivedData where Xcode stores index data") + var dataStorePath: String? /// Flag to enable verbose output for diagnostic purposes. @Flag(name: .shortAndLong, help: "Enable verbose output.") var verbose: Bool = false func validate() throws { - guard projectName?.isEmpty == false || derivedDataPath?.isEmpty == false else { - throw ValidationError("Provide either --projectName or --derivedDataPath.") + guard projectName?.isEmpty == false || dataStorePath?.isEmpty == false else { + throw ValidationError("Provide either --projectName or --dataStorePath.") } } } @@ -48,7 +48,7 @@ extension SwiftFindRefs { let derivedDataLocator = DerivedDataLocator(fileSystem: fileSystem) let compositionRoot = SearchCompositionRoot( projectName: common.projectName, - derivedDataPath: common.derivedDataPath, + dataStorePath: common.dataStorePath, symbolName: name, symbolType: type, print: { print($0) }, @@ -79,7 +79,7 @@ extension SwiftFindRefs { let derivedDataLocator = DerivedDataLocator(fileSystem: fileSystem) let compositionRoot = RemoveCompositionRoot( projectName: common.projectName, - derivedDataPath: common.derivedDataPath, + dataStorePath: common.dataStorePath, excludeCompilationConditionals: excludeCompilationConditionals, print: { print($0) }, vPrint: { if common.verbose { print($0) } }, diff --git a/Tests/SwiftFindRefs/CompositionRoot/RemoveCompositionRootTests.swift b/Tests/SwiftFindRefs/CompositionRoot/RemoveCompositionRootTests.swift index c8dff1d..acb6460 100644 --- a/Tests/SwiftFindRefs/CompositionRoot/RemoveCompositionRootTests.swift +++ b/Tests/SwiftFindRefs/CompositionRoot/RemoveCompositionRootTests.swift @@ -10,14 +10,14 @@ struct RemoveCompositionRootTests { let fileSystem = MockFileSystem(fileExistsResults: [invalidPath: false]) let sut = makeRemoveSUT( projectName: "Project", - derivedDataPath: invalidPath, + dataStorePath: invalidPath, excludeCompilationConditionals: false, fileSystem: fileSystem, removerFactory: { _ in MockRemover(result: []) } ) // When - let error = await #expect(throws: DerivedDataLocatorError.self) { + let error = await #expect(throws: DataStorePathValidationError.self) { try await sut.run() } @@ -32,12 +32,12 @@ struct RemoveCompositionRootTests { @Test("test run prints updated files count when nothing updated") func test_run_WhenNoUpdates_PrintsUpdatedCount() async throws { // Given - let derivedDataPath = "/mock/DerivedData/IndexStoreDB" - let fileSystem = MockFileSystem(fileExistsResults: [derivedDataPath: true]) + let dataStorePath = "/mock/DerivedData/IndexStoreDB" + let fileSystem = MockFileSystem(fileExistsResults: [dataStorePath: true]) var printMessages: [String] = [] let sut = makeRemoveSUT( projectName: "Project", - derivedDataPath: derivedDataPath, + dataStorePath: dataStorePath, excludeCompilationConditionals: false, fileSystem: fileSystem, print: { printMessages.append($0) }, @@ -54,15 +54,15 @@ struct RemoveCompositionRootTests { @Test("test run prints updated files when remover returns results") func test_run_WhenUpdatesExist_PrintsUpdatedFiles() async throws { // Given - let derivedDataPath = "/mock/DerivedData/IndexStoreDB" - let fileSystem = MockFileSystem(fileExistsResults: [derivedDataPath: true]) + let dataStorePath = "/mock/DerivedData/IndexStoreDB" + let fileSystem = MockFileSystem(fileExistsResults: [dataStorePath: true]) var printMessages: [String] = [] var vPrintMessages: [String] = [] let updatedFiles = ["/mock/FileA.swift", "/mock/FileB.swift"] var receivedIndexStorePath: String? let sut = makeRemoveSUT( projectName: "Project", - derivedDataPath: derivedDataPath, + dataStorePath: dataStorePath, excludeCompilationConditionals: false, fileSystem: fileSystem, print: { printMessages.append($0) }, @@ -77,7 +77,7 @@ struct RemoveCompositionRootTests { try await sut.run() // Then - #expect(receivedIndexStorePath == "/mock/DerivedData") + #expect(receivedIndexStorePath == "/mock/DerivedData/IndexStoreDB") #expect(printMessages.contains("✅ Updated 2 files")) #expect(vPrintMessages.contains("Updated files:")) #expect(vPrintMessages.contains("/mock/FileA.swift")) @@ -86,7 +86,7 @@ struct RemoveCompositionRootTests { private func makeRemoveSUT( projectName: String?, - derivedDataPath: String?, + dataStorePath: String?, excludeCompilationConditionals: Bool, fileSystem: MockFileSystem, print: @escaping (String) -> Void = { _ in }, @@ -95,7 +95,7 @@ struct RemoveCompositionRootTests { ) -> RemoveCompositionRoot { RemoveCompositionRoot( projectName: projectName, - derivedDataPath: derivedDataPath, + dataStorePath: dataStorePath, excludeCompilationConditionals: excludeCompilationConditionals, print: print, vPrint: vPrint, diff --git a/Tests/SwiftFindRefs/CompositionRoot/SearchCompositionRootTests.swift b/Tests/SwiftFindRefs/CompositionRoot/SearchCompositionRootTests.swift index 04d3858..0ebe5cb 100644 --- a/Tests/SwiftFindRefs/CompositionRoot/SearchCompositionRootTests.swift +++ b/Tests/SwiftFindRefs/CompositionRoot/SearchCompositionRootTests.swift @@ -12,7 +12,7 @@ struct SearchCompositionRootTests { let fileSystem = MockFileSystem() let sut = makeSearchSUT( projectName: nil, - derivedDataPath: nil, + dataStorePath: nil, symbolType: "class", fileSystem: fileSystem ) @@ -36,13 +36,13 @@ struct SearchCompositionRootTests { let fileSystem = MockFileSystem(fileExistsResults: [invalidPath: false]) let sut = makeSearchSUT( projectName: "Project", - derivedDataPath: invalidPath, + dataStorePath: invalidPath, symbolType: "class", fileSystem: fileSystem ) // When - let error = await #expect(throws: DerivedDataLocatorError.self) { + let error = await #expect(throws: DataStorePathValidationError.self) { try await sut.run() } @@ -57,13 +57,13 @@ struct SearchCompositionRootTests { @Test("test run with nil symbol type logs fallback before index store failure") func test_run_WithNilSymbolType_logsFallbackBeforeIndexStoreFailure() async throws { // Given - let derivedDataPath = "/tmp/nonexistent/IndexStoreDB" - let fileSystem = MockFileSystem(fileExistsResults: [derivedDataPath: true]) + let dataStorePath = "/tmp/nonexistent/IndexStoreDB" + let fileSystem = MockFileSystem(fileExistsResults: [dataStorePath: true]) var standardMessages: [String] = [] var verboseMessages: [String] = [] let sut = makeSearchSUT( projectName: "Project", - derivedDataPath: derivedDataPath, + dataStorePath: dataStorePath, symbolType: nil, fileSystem: fileSystem, print: { standardMessages.append($0) }, @@ -76,8 +76,7 @@ struct SearchCompositionRootTests { } // Then - #expect(verboseMessages.contains("DerivedData path: \(derivedDataPath)")) - #expect(verboseMessages.contains("IndexStoreDB path: \(derivedDataPath)")) + #expect(verboseMessages.contains("Using DataStore path: \(dataStorePath)")) let searchMessage = try #require(standardMessages.first { $0.contains("Searching for references") }) #expect(searchMessage.contains("symbol 'MySymbol'")) #expect(searchMessage.contains("of type 'any'")) @@ -87,7 +86,7 @@ struct SearchCompositionRootTests { private func makeSearchSUT( projectName: String?, - derivedDataPath: String?, + dataStorePath: String?, symbolName: String = "MySymbol", symbolType: String? = "class", fileSystem: MockFileSystem, @@ -96,7 +95,7 @@ struct SearchCompositionRootTests { ) -> SearchCompositionRoot { SearchCompositionRoot( projectName: projectName, - derivedDataPath: derivedDataPath, + dataStorePath: dataStorePath, symbolName: symbolName, symbolType: symbolType, print: print, @@ -106,3 +105,4 @@ struct SearchCompositionRootTests { ) } } + diff --git a/Tests/SwiftFindRefs/DerivedData/DerivedDataLocatorErrorTests.swift b/Tests/SwiftFindRefs/DerivedData/DerivedDataLocatorErrorTests.swift index 5970fd6..5c2f57b 100644 --- a/Tests/SwiftFindRefs/DerivedData/DerivedDataLocatorErrorTests.swift +++ b/Tests/SwiftFindRefs/DerivedData/DerivedDataLocatorErrorTests.swift @@ -13,7 +13,7 @@ struct DerivedDataLocatorErrorTests { let description = try #require(sut.errorDescription) // Then - #expect(description == "❌ Either projectName or derivedDataPath must be provided.") + #expect(description == "❌ Either projectName or dataStorePath must be provided.") } @Test("test errorDescription with missing derived data root includes provided path") @@ -41,17 +41,4 @@ struct DerivedDataLocatorErrorTests { // Then #expect(description == "❌ No DerivedData entry matching project \(projectName) was found.") } - - @Test("test errorDescription with invalid path includes the invalid value") - func test_errorDescription_WithInvalidPath_returnsDetailedMessage() throws { - // Given - let invalidPath = "/invalid/path" - let sut: DerivedDataLocatorError = .invalidPath(invalidPath) - - // When - let description = try #require(sut.errorDescription) - - // Then - #expect(description == "❌ The provided DerivedData path does not exist: \(invalidPath).") - } } diff --git a/Tests/SwiftFindRefs/DerivedData/DerivedDataLocatorTests.swift b/Tests/SwiftFindRefs/DerivedData/DerivedDataLocatorTests.swift index 552b75e..7ccc573 100644 --- a/Tests/SwiftFindRefs/DerivedData/DerivedDataLocatorTests.swift +++ b/Tests/SwiftFindRefs/DerivedData/DerivedDataLocatorTests.swift @@ -5,53 +5,15 @@ import Testing @Suite("DerivedDataLocator Tests") struct DerivedDataLocatorTests { // MARK: - Tests - @Test("test locateDerivedData with direct path exists returns provided URL") - func test_locateDerivedData_WithDirectPathExists_returnsProvidedURL() throws { - // Given - let providedPath = "/tmp/ManualDerivedData-\(UUID().uuidString)" - let fileSystem = MockFileSystem( - fileExistsResults: [providedPath: true] - ) - let sut = makeSUT(fileSystem: fileSystem) - - // When - let result = try sut.locateDerivedData(projectName: nil, derivedDataPath: providedPath) - - // Then - let expectedURL = URL(fileURLWithPath: providedPath).standardizedFileURL - #expect(result.derivedDataURL == expectedURL) - } - - @Test("test locateDerivedData with direct path missing throws invalidPath") - func test_locateDerivedData_WithDirectPathMissing_throwsInvalidPath() { - // Given - let providedPath = "/tmp/MissingDerivedData-\(UUID().uuidString)" - let fileSystem = MockFileSystem() - let sut = makeSUT(fileSystem: fileSystem) - - // When - let error = #expect(throws: DerivedDataLocatorError.self) { - try sut.locateDerivedData(projectName: nil, derivedDataPath: providedPath) - } - - // Then - switch error { - case .invalidPath(let path): - let expectedPath = URL(fileURLWithPath: providedPath).standardizedFileURL.path - #expect(path == expectedPath) - default: - Issue.record("Expected invalidPath error, received \(error)") - } - } - @Test("test locateDerivedData without project and derived path throws missingInputs") + @Test("test locateDerivedData without project name throws missingInputs") func test_locateDerivedData_WithoutInputs_throwsMissingInputs() { // Given let sut = makeSUT() // When let error = #expect(throws: DerivedDataLocatorError.self) { - try sut.locateDerivedData(projectName: nil, derivedDataPath: nil) + try sut.locateDerivedData(projectName: nil) } // Then @@ -73,7 +35,7 @@ struct DerivedDataLocatorTests { // When let error = #expect(throws: DerivedDataLocatorError.self) { - try sut.locateDerivedData(projectName: "SampleProject", derivedDataPath: nil) + try sut.locateDerivedData(projectName: "SampleProject") } // Then @@ -103,7 +65,7 @@ struct DerivedDataLocatorTests { // When let error = #expect(throws: DerivedDataLocatorError.self) { - try sut.locateDerivedData(projectName: "TargetProject", derivedDataPath: nil) + try sut.locateDerivedData(projectName: "TargetProject") } // Then @@ -135,7 +97,7 @@ struct DerivedDataLocatorTests { let sut = makeSUT(fileSystem: fileSystem) // When - let result = try sut.locateDerivedData(projectName: projectName, derivedDataPath: nil) + let result = try sut.locateDerivedData(projectName: projectName) // Then #expect(result.derivedDataURL == hierarchy.newestURL.standardizedFileURL) diff --git a/Tests/SwiftFindRefs/DerivedData/DerivedDataPathsTests.swift b/Tests/SwiftFindRefs/DerivedData/DerivedDataPathsTests.swift index ceb9142..fc9b2cf 100644 --- a/Tests/SwiftFindRefs/DerivedData/DerivedDataPathsTests.swift +++ b/Tests/SwiftFindRefs/DerivedData/DerivedDataPathsTests.swift @@ -5,25 +5,24 @@ import Testing @Suite("DerivedDataPaths Tests") struct DerivedDataPathsTests { // MARK: - Tests - @Test("test indexStoreDBURL with base derived data returns nested IndexStoreDB path") - func test_indexStoreDBURL_WithBaseDerivedData_returnsNestedIndexStoreDBPath() { + @Test("test dataStoreURL with base derived data returns nested DataStore path") + func test_dataStoreURL_WithBaseDerivedData_returnsNestedDataStorePath() { // Given let derivedDataURL = URL(fileURLWithPath: "/tmp/DerivedData", isDirectory: true) let sut = makeSUT(derivedDataURL: derivedDataURL) let expectedURL = derivedDataURL .appendingPathComponent("Index.noindex", isDirectory: true) .appendingPathComponent("DataStore", isDirectory: true) - .appendingPathComponent("IndexStoreDB", isDirectory: true) // When - let result = sut.indexStoreDBURL + let result = sut.dataStoreURL // Then #expect(result == expectedURL) } - @Test("test indexStoreDBURL with preexisting components still appends all segments") - func test_indexStoreDBURL_WithExistingIndexSegments_returnsExtendedPath() { + @Test("test dataStoreURL with preexisting components still appends all segments") + func test_dataStoreURL_WithExistingIndexSegments_returnsExtendedPath() { // Given let derivedDataURL = URL( fileURLWithPath: "/tmp/DerivedData/Index.noindex", @@ -33,10 +32,9 @@ struct DerivedDataPathsTests { let expectedURL = derivedDataURL .appendingPathComponent("Index.noindex", isDirectory: true) .appendingPathComponent("DataStore", isDirectory: true) - .appendingPathComponent("IndexStoreDB", isDirectory: true) // When - let result = sut.indexStoreDBURL + let result = sut.dataStoreURL // Then #expect(result == expectedURL) diff --git a/swiftfindrefs/SKILL.md b/swiftfindrefs/SKILL.md index 5b9efe5..c935f83 100644 --- a/swiftfindrefs/SKILL.md +++ b/swiftfindrefs/SKILL.md @@ -31,7 +31,7 @@ swiftfindrefs \ ``` Optional flags: -- `--derivedDataPath `: explicit DerivedData (or IndexStoreDB) path; skips discovery +- `--dataStorePath `: explicit DataStore (or IndexStoreDB) path; skips discovery - `-v, --verbose`: enables verbose output for diagnostic purposes (flag, no value required) ## Output contract diff --git a/swiftfindrefs/references/cli.md b/swiftfindrefs/references/cli.md index 0bbf1d6..04cd5e1 100644 --- a/swiftfindrefs/references/cli.md +++ b/swiftfindrefs/references/cli.md @@ -7,10 +7,10 @@ ## Flags - `-p, --projectName` - Helps infer the correct DerivedData folder when `--derivedDataPath` is not provided. + Helps infer the correct DerivedData folder when `--dataStorePath` is not provided. -- `-d, --derivedDataPath` - Points directly to a DerivedData (or IndexStoreDB) directory and skips discovery. +- `-d, --dataStorePath` + Points directly to a DataStore (or IndexStoreDB) directory and skips discovery. - `-v, --verbose` (flag, no value required) Enables verbose output for diagnostic purposes. diff --git a/swiftfindrefs/references/troubleshooting.md b/swiftfindrefs/references/troubleshooting.md index 8d8af35..a7d3174 100644 --- a/swiftfindrefs/references/troubleshooting.md +++ b/swiftfindrefs/references/troubleshooting.md @@ -9,7 +9,7 @@ - If multiple DerivedData folders exist for the same project `swiftfindrefs` will use the most recent one. ## Wrong DerivedData selected -- Prefer explicit `--derivedDataPath` in CI or multi-clone setups. +- Prefer explicit `--dataStorePath` in CI or multi-clone setups. - Use `-v` or `--verbose` flag to confirm path selection. ## Do not fall back to grep