From 46ed9763102a6f2c3db998d27afe7f32f6f10dc8 Mon Sep 17 00:00:00 2001 From: Lawrence Forooghian Date: Thu, 15 Dec 2022 11:16:37 -0300 Subject: [PATCH 1/2] =?UTF-8?q?Move=20the=20LogParser=20example=20app=20ou?= =?UTF-8?q?tside=20of=20the=20library=E2=80=99s=20directory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I want it to be easy for people to create a script that uses the LogParser library. The easiest thing I can think of is to be able to just copy and paste the existing example app and then make modifications to it. This isn’t very easy with the current structure, since the example app’s code and build config is a bit intertwined with that of the LogParser library. By putting the example app in a separate directory, we can make a copy of it by just duplicating the entire directory. --- .github/workflows/check.yml | 10 ++++---- Tools/LogParser/Package.swift | 16 +------------ Tools/LogParser/README.md | 6 +---- .../Package.resolved | 0 Tools/LogParserExample/Package.swift | 24 +++++++++++++++++++ Tools/LogParserExample/README.md | 9 +++++++ .../ParseLogFileCommand.swift | 0 .../example.txt | 0 8 files changed, 40 insertions(+), 25 deletions(-) rename Tools/{LogParser => LogParserExample}/Package.resolved (100%) create mode 100644 Tools/LogParserExample/Package.swift create mode 100644 Tools/LogParserExample/README.md rename Tools/{LogParser/Examples/CommandLineExample/Sources => LogParserExample/Sources/LogParserExample}/ParseLogFileCommand.swift (100%) rename Tools/{LogParser/Examples/CommandLineExample => LogParserExample}/example.txt (100%) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 2e8bcca2..4f94ab2b 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -48,9 +48,6 @@ jobs: check-log-parser: runs-on: macos-latest - defaults: - run: - working-directory: Tools/LogParser steps: - uses: actions/checkout@v2 with: @@ -58,5 +55,8 @@ jobs: - name: Run LogParser tests run: swift test - - name: Build LogParser command-line example app - run: swift build --target CommandLineExample + working-directory: Tools/LogParser + + - name: Build LogParserExample app + run: swift build + working-directory: Tools/LogParserExample diff --git a/Tools/LogParser/Package.swift b/Tools/LogParser/Package.swift index fb695eb8..9fe373f3 100644 --- a/Tools/LogParser/Package.swift +++ b/Tools/LogParser/Package.swift @@ -11,13 +11,7 @@ let package = Package( products: [ .library( name: "LogParser", - targets: ["LogParser"]), - .executable( - name: "CommandLineExample", - targets: ["CommandLineExample"]) - ], - dependencies: [ - .package(url: "https://github.com/apple/swift-argument-parser", from: "1.2.0") + targets: ["LogParser"]) ], targets: [ .target( @@ -26,14 +20,6 @@ let package = Package( .testTarget( name: "LogParserTests", dependencies: ["LogParser"] - ), - .executableTarget( - name: "CommandLineExample", - dependencies: [ - "LogParser", - .product(name: "ArgumentParser", package: "swift-argument-parser") - ], - path: "Examples/CommandLineExample/Sources" ) ] ) diff --git a/Tools/LogParser/README.md b/Tools/LogParser/README.md index 9268b6a3..b3883948 100644 --- a/Tools/LogParser/README.md +++ b/Tools/LogParser/README.md @@ -2,8 +2,4 @@ A package for parsing the log output of the Ably Asset Tracking Swift SDKs and their example apps. -There is an example command-line app in [`Examples/CommandLineExample`](Examples/CommandLineExample) which demonstrates how to use the library. You can run it on an example log file by running the following command from the current directory: - -```bash -swift run CommandLineExample Examples/CommandLineExample/example.txt -``` +There is an example command-line app in [`../LogParserExample`](../LogParserExample) which demonstrates how to use the library. diff --git a/Tools/LogParser/Package.resolved b/Tools/LogParserExample/Package.resolved similarity index 100% rename from Tools/LogParser/Package.resolved rename to Tools/LogParserExample/Package.resolved diff --git a/Tools/LogParserExample/Package.swift b/Tools/LogParserExample/Package.swift new file mode 100644 index 00000000..623b2329 --- /dev/null +++ b/Tools/LogParserExample/Package.swift @@ -0,0 +1,24 @@ +// swift-tools-version: 5.7 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "LogParserExample", + platforms: [ + .macOS(.v12) + ], + dependencies: [ + .package(url: "https://github.com/apple/swift-argument-parser", from: "1.2.0"), + .package(path: "../LogParser") + ], + targets: [ + .executableTarget( + name: "LogParserExample", + dependencies: [ + .product(name: "LogParser", package: "LogParser"), + .product(name: "ArgumentParser", package: "swift-argument-parser") + ] + ), + ] +) diff --git a/Tools/LogParserExample/README.md b/Tools/LogParserExample/README.md new file mode 100644 index 00000000..537c71a3 --- /dev/null +++ b/Tools/LogParserExample/README.md @@ -0,0 +1,9 @@ +# LogParserExample + +An example command-line app which demonstrates how to use the [LogParser library](../LogParser). + +You can run it on an example log file by running the following command from the current directory: + +```bash +swift run LogParserExample example.txt +``` diff --git a/Tools/LogParser/Examples/CommandLineExample/Sources/ParseLogFileCommand.swift b/Tools/LogParserExample/Sources/LogParserExample/ParseLogFileCommand.swift similarity index 100% rename from Tools/LogParser/Examples/CommandLineExample/Sources/ParseLogFileCommand.swift rename to Tools/LogParserExample/Sources/LogParserExample/ParseLogFileCommand.swift diff --git a/Tools/LogParser/Examples/CommandLineExample/example.txt b/Tools/LogParserExample/example.txt similarity index 100% rename from Tools/LogParser/Examples/CommandLineExample/example.txt rename to Tools/LogParserExample/example.txt From d53216aa429a1cedac85f1ac63ed6446db2f5577 Mon Sep 17 00:00:00 2001 From: Lawrence Forooghian Date: Thu, 15 Dec 2022 17:25:09 -0300 Subject: [PATCH 2/2] Move the LogParser library and example app into a Library directory I intend to add other things at the top level of the Tools directory (like tools that actually make use of the LogParser library). --- .github/workflows/check.yml | 4 ++-- Tools/{ => Library}/LogParser/Package.swift | 0 Tools/{ => Library}/LogParser/README.md | 0 .../LogParser/Sources/LogParser/ExampleAppLogFile.swift | 0 .../LogParser/Sources/LogParser/ExampleAppSDKLogLine.swift | 0 .../LogParser/Sources/LogParser/SDKLogMessage.swift | 0 .../Tests/LogParserTests/ExampleAppLogFileTests.swift | 0 .../Tests/LogParserTests/ExampleAppSDKLogLineTests.swift | 0 .../LogParser/Tests/LogParserTests/SDKLogMessageTests.swift | 0 Tools/{ => Library}/LogParserExample/Package.resolved | 0 Tools/{ => Library}/LogParserExample/Package.swift | 0 Tools/{ => Library}/LogParserExample/README.md | 0 .../Sources/LogParserExample/ParseLogFileCommand.swift | 0 Tools/{ => Library}/LogParserExample/example.txt | 0 Tools/README.md | 5 +++++ 15 files changed, 7 insertions(+), 2 deletions(-) rename Tools/{ => Library}/LogParser/Package.swift (100%) rename Tools/{ => Library}/LogParser/README.md (100%) rename Tools/{ => Library}/LogParser/Sources/LogParser/ExampleAppLogFile.swift (100%) rename Tools/{ => Library}/LogParser/Sources/LogParser/ExampleAppSDKLogLine.swift (100%) rename Tools/{ => Library}/LogParser/Sources/LogParser/SDKLogMessage.swift (100%) rename Tools/{ => Library}/LogParser/Tests/LogParserTests/ExampleAppLogFileTests.swift (100%) rename Tools/{ => Library}/LogParser/Tests/LogParserTests/ExampleAppSDKLogLineTests.swift (100%) rename Tools/{ => Library}/LogParser/Tests/LogParserTests/SDKLogMessageTests.swift (100%) rename Tools/{ => Library}/LogParserExample/Package.resolved (100%) rename Tools/{ => Library}/LogParserExample/Package.swift (100%) rename Tools/{ => Library}/LogParserExample/README.md (100%) rename Tools/{ => Library}/LogParserExample/Sources/LogParserExample/ParseLogFileCommand.swift (100%) rename Tools/{ => Library}/LogParserExample/example.txt (100%) create mode 100644 Tools/README.md diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 4f94ab2b..fb4298ac 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -55,8 +55,8 @@ jobs: - name: Run LogParser tests run: swift test - working-directory: Tools/LogParser + working-directory: Tools/Library/LogParser - name: Build LogParserExample app run: swift build - working-directory: Tools/LogParserExample + working-directory: Tools/Library/LogParserExample diff --git a/Tools/LogParser/Package.swift b/Tools/Library/LogParser/Package.swift similarity index 100% rename from Tools/LogParser/Package.swift rename to Tools/Library/LogParser/Package.swift diff --git a/Tools/LogParser/README.md b/Tools/Library/LogParser/README.md similarity index 100% rename from Tools/LogParser/README.md rename to Tools/Library/LogParser/README.md diff --git a/Tools/LogParser/Sources/LogParser/ExampleAppLogFile.swift b/Tools/Library/LogParser/Sources/LogParser/ExampleAppLogFile.swift similarity index 100% rename from Tools/LogParser/Sources/LogParser/ExampleAppLogFile.swift rename to Tools/Library/LogParser/Sources/LogParser/ExampleAppLogFile.swift diff --git a/Tools/LogParser/Sources/LogParser/ExampleAppSDKLogLine.swift b/Tools/Library/LogParser/Sources/LogParser/ExampleAppSDKLogLine.swift similarity index 100% rename from Tools/LogParser/Sources/LogParser/ExampleAppSDKLogLine.swift rename to Tools/Library/LogParser/Sources/LogParser/ExampleAppSDKLogLine.swift diff --git a/Tools/LogParser/Sources/LogParser/SDKLogMessage.swift b/Tools/Library/LogParser/Sources/LogParser/SDKLogMessage.swift similarity index 100% rename from Tools/LogParser/Sources/LogParser/SDKLogMessage.swift rename to Tools/Library/LogParser/Sources/LogParser/SDKLogMessage.swift diff --git a/Tools/LogParser/Tests/LogParserTests/ExampleAppLogFileTests.swift b/Tools/Library/LogParser/Tests/LogParserTests/ExampleAppLogFileTests.swift similarity index 100% rename from Tools/LogParser/Tests/LogParserTests/ExampleAppLogFileTests.swift rename to Tools/Library/LogParser/Tests/LogParserTests/ExampleAppLogFileTests.swift diff --git a/Tools/LogParser/Tests/LogParserTests/ExampleAppSDKLogLineTests.swift b/Tools/Library/LogParser/Tests/LogParserTests/ExampleAppSDKLogLineTests.swift similarity index 100% rename from Tools/LogParser/Tests/LogParserTests/ExampleAppSDKLogLineTests.swift rename to Tools/Library/LogParser/Tests/LogParserTests/ExampleAppSDKLogLineTests.swift diff --git a/Tools/LogParser/Tests/LogParserTests/SDKLogMessageTests.swift b/Tools/Library/LogParser/Tests/LogParserTests/SDKLogMessageTests.swift similarity index 100% rename from Tools/LogParser/Tests/LogParserTests/SDKLogMessageTests.swift rename to Tools/Library/LogParser/Tests/LogParserTests/SDKLogMessageTests.swift diff --git a/Tools/LogParserExample/Package.resolved b/Tools/Library/LogParserExample/Package.resolved similarity index 100% rename from Tools/LogParserExample/Package.resolved rename to Tools/Library/LogParserExample/Package.resolved diff --git a/Tools/LogParserExample/Package.swift b/Tools/Library/LogParserExample/Package.swift similarity index 100% rename from Tools/LogParserExample/Package.swift rename to Tools/Library/LogParserExample/Package.swift diff --git a/Tools/LogParserExample/README.md b/Tools/Library/LogParserExample/README.md similarity index 100% rename from Tools/LogParserExample/README.md rename to Tools/Library/LogParserExample/README.md diff --git a/Tools/LogParserExample/Sources/LogParserExample/ParseLogFileCommand.swift b/Tools/Library/LogParserExample/Sources/LogParserExample/ParseLogFileCommand.swift similarity index 100% rename from Tools/LogParserExample/Sources/LogParserExample/ParseLogFileCommand.swift rename to Tools/Library/LogParserExample/Sources/LogParserExample/ParseLogFileCommand.swift diff --git a/Tools/LogParserExample/example.txt b/Tools/Library/LogParserExample/example.txt similarity index 100% rename from Tools/LogParserExample/example.txt rename to Tools/Library/LogParserExample/example.txt diff --git a/Tools/README.md b/Tools/README.md new file mode 100644 index 00000000..807a8b81 --- /dev/null +++ b/Tools/README.md @@ -0,0 +1,5 @@ +# Developer tools for the Ably Asset Tracking Swift SDKs + +This directory contains tooling intended to be used by developers working on the Ably Asset Tracking Swift SDKs. + +It currently just contains the [`Library`](Library) directory, which contains the [`LogParser` library](Library/LogParser) for parsing logs emitted by these SDKs, as well as [an example app for the `LogParser` library](Library/LogParserExample).