diff --git a/.github/scripts/public_loc.sh b/.github/scripts/public_loc.sh new file mode 100755 index 0000000..5379f3a --- /dev/null +++ b/.github/scripts/public_loc.sh @@ -0,0 +1,3 @@ +curl -X POST $1 \ +-H 'Content-Type: application/json; charset=utf-8' \ +--data "$(cat tooling/loc/loc_report_slack.txt)" diff --git a/.github/workflows/daily_loc.yaml b/.github/workflows/daily_loc.yaml new file mode 100644 index 0000000..35b3059 --- /dev/null +++ b/.github/workflows/daily_loc.yaml @@ -0,0 +1,59 @@ +name: Daily Lines of Code Report + +on: + schedule: + # Every day at UTC midnight + - cron: "0 0 * * 1,2,3,4,5" + workflow_dispatch: + +jobs: + loc: + name: Count ethrex db loc and generate report + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Rustup toolchain install + uses: dtolnay/rust-toolchain@master + with: + toolchain: 1.87.0 + components: rustfmt, clippy + + - name: Add Rust Cache + uses: Swatinem/rust-cache@v2 + + - name: Restore cache + id: cache-loc-report + uses: actions/cache@v4 + with: + path: tooling/loc_report.json + key: loc-report-${{ github.ref_name }} + restore-keys: | + loc-report- + + - name: Rename cached loc_report.json to loc_report.json.old + if: steps.cache-loc-report.outputs.cache-hit != '' + run: mv tooling/loc_report.json tooling/loc_report.json.old + + - name: Generate the loc report + run: | + cd tooling && make loc + + - name: Save new loc_report.json to cache + if: success() + uses: actions/cache@v4 + with: + path: tooling/loc_report.json + key: loc-report-${{ github.ref_name }} + + - name: Post results in summary + run: | + echo "# EthrexDB Lines of Code Report" >> $GITHUB_STEP_SUMMARY + cat tooling/loc_report_github.txt >> $GITHUB_STEP_SUMMARY + + - name: Post results to Slack + if: always() + run: | + if [ -n "${{ secrets.SLACK_WEBHOOK }}" ]; then + sh .github/scripts/publish_loc.sh "${{ secrets.SLACK_WEBHOOK }}" + fi diff --git a/.github/workflows/pr_loc.yaml b/.github/workflows/pr_loc.yaml new file mode 100644 index 0000000..cf24187 --- /dev/null +++ b/.github/workflows/pr_loc.yaml @@ -0,0 +1,106 @@ +name: PR Lines of Code Analysis + +on: + pull_request: + branches: ["**"] + +permissions: + pull-requests: write + +jobs: + report-loc-changes: + name: Report PR Line Changes + runs-on: ubuntu-latest + # Skip the job if the PR is from a fork since it doesn't have permissions to post comments + if: github.event.pull_request.head.repo.fork == false + steps: + - name: Checkout PR Code + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Find merge base + id: find_merge_base + env: + HEAD_REF: ${{ github.event.pull_request.head.ref }} + BASE_REF: ${{ github.event.pull_request.base.ref }} + run: | + git fetch --depth=100000 origin $HEAD_REF + git fetch --depth=100000 origin $BASE_REF + MERGE_BASE=$(git merge-base origin/$HEAD_REF origin/$BASE_REF) + echo "merge_base=$MERGE_BASE" >> $GITHUB_OUTPUT + + - name: Checkout merge base commit + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ steps.find_merge_base.outputs.merge_base }} + + - name: Rustup toolchain install + uses: dtolnay/rust-toolchain@master + with: + toolchain: 1.87.0 + components: rustfmt, clippy + + - name: Add Rust Cache + uses: Swatinem/rust-cache@v2 + + - name: Run Lines of Code Counter for base + run: cd tooling && make loc-detailed + # This creates current_detailed_loc_report.json for the base branch + + - name: Rename base report to previous_detailed_loc_report.json + run: mv tooling/current_detailed_loc_report.json tooling/previous_detailed_loc_report.json + + - name: Checkout PR + uses: actions/checkout@v4 + with: + clean: "false" # Don't clean the workspace, so we can keep the previous report + ref: ${{ github.event.pull_request.head.sha }} + + - name: Rustup toolchain install + uses: dtolnay/rust-toolchain@master + with: + toolchain: 1.87.0 + components: rustfmt, clippy + + - name: Add Rust Cache + uses: Swatinem/rust-cache@v2 + + - name: Run Lines of Code Counter for PR + run: cd tooling && make loc-detailed + # This creates current_detailed_loc_report.json + + - name: Compare Detailed Lines of Code Count + run: cd tooling && make loc-compare-detailed + # This reads current_detailed_loc_report.json and previous_detailed_loc_report.json + # and outputs detailed_loc_report.txt + + - name: Check if report exists + id: check_report + run: | + if [ -s tooling/detailed_loc_report.txt ]; then + echo "report_exists=true" >> $GITHUB_OUTPUT + else + echo "report_exists=false" >> $GITHUB_OUTPUT + fi + + - name: Find comment + if: steps.check_report.outputs.report_exists == 'true' + continue-on-error: true + uses: peter-evans/find-comment@v3 + id: fc + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: "github-actions[bot]" + body-includes: "Total lines changed" + + - name: Create Comment + if: steps.check_report.outputs.report_exists == 'true' + uses: peter-evans/create-or-update-comment@v4 + with: + comment-id: ${{ steps.fc.outputs.comment-id }} + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.pull_request.number }} + body-path: tooling/detailed_loc_report.txt + edit-mode: replace diff --git a/.gitignore b/.gitignore index 5c9a5de..06e6f26 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,13 @@ target/ # Samply json profile.json.gz + +# LOC tooling generated files +tooling/loc_detailed_report.json +tooling/loc_report_github.txt +tooling/loc_report.json +tooling/slack_message.json +tooling/current_detailed_loc_report.json +tooling/previous_detailed_loc_report.json +tooling/detailed_loc_report.txt +tooling/loc_report_slack.txt diff --git a/Cargo.lock b/Cargo.lock index 57b45e4..f179683 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + [[package]] name = "aho-corasick" version = "1.1.3" @@ -11,18 +20,86 @@ dependencies = [ "memchr", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anes" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "anstream" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ae563653d1938f79b1ab1b5e668c87c76a9930414574a6583a7b7e11a8e6192" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + [[package]] name = "anstyle" version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" +[[package]] +name = "anstyle-parse" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e231f6134f61b71076a3eab506c379d4f36122f2af15a9ff04415ea4c3339e2" +dependencies = [ + "windows-sys 0.60.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e0633414522a32ffaac8ac6cc8f748e090c5717661fddeea04219e2344f5f2a" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.60.2", +] + [[package]] name = "anyhow" version = "1.0.99" @@ -41,6 +118,17 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi 0.1.19", + "libc", + "winapi", +] + [[package]] name = "autocfg" version = "1.5.0" @@ -53,7 +141,7 @@ version = "0.71.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f58bf3d7db68cfbac37cfc485a8d711e87e064c3d0fe0435b92f7a407f9d6b3" dependencies = [ - "bitflags", + "bitflags 2.9.1", "cexpr", "clang-sys", "itertools 0.13.0", @@ -80,6 +168,12 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bitflags" version = "2.9.1" @@ -107,6 +201,16 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bstr" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "234113d19d0d7d613b40e86fb654acf958910802bcceab913a4f9e7cda03b1a4" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "bumpalo" version = "3.19.0" @@ -164,6 +268,40 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" +[[package]] +name = "chrono" +version = "0.4.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "num-traits", + "windows-link", +] + +[[package]] +name = "chrono-tz" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93698b29de5e97ad0ae26447b344c482a7284c737d9ddc5f9e52b74a336671bb" +dependencies = [ + "chrono", + "chrono-tz-build", + "phf", +] + +[[package]] +name = "chrono-tz-build" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c088aee841df9c3041febbb73934cfc39708749bf96dc827e3359cd39ef11b1" +dependencies = [ + "parse-zoneinfo", + "phf", + "phf_codegen", +] + [[package]] name = "ciborium" version = "0.2.2" @@ -198,7 +336,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8c3d2abadaa28e0d277f9f6d07a2052544f045d929cd4d6f7bcfb43567c9767" dependencies = [ "hasher", - "parking_lot", + "parking_lot 0.12.4", "rlp 0.5.2", ] @@ -213,6 +351,21 @@ dependencies = [ "libloading", ] +[[package]] +name = "clap" +version = "2.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +dependencies = [ + "ansi_term", + "atty", + "bitflags 1.3.2", + "strsim 0.8.0", + "textwrap", + "unicode-width", + "vec_map", +] + [[package]] name = "clap" version = "4.5.45" @@ -220,6 +373,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fc0e74a703892159f5ae7d3aac52c8e6c392f5ae5f359c70b5881d60aaac318" dependencies = [ "clap_builder", + "clap_derive", ] [[package]] @@ -228,8 +382,31 @@ version = "4.5.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3e7f4214277f3c7aa526a59dd3fbe306a370daee1f8b7b8c987069cd8e888a8" dependencies = [ + "anstream", "anstyle", "clap_lex", + "strsim 0.11.1", +] + +[[package]] +name = "clap_complete" +version = "4.5.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d9501bd3f5f09f7bbee01da9a511073ed30a80cd7a509f1214bb74eadea71ad" +dependencies = [ + "clap 4.5.45", +] + +[[package]] +name = "clap_derive" +version = "4.5.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14cb31bb0a7d536caef2639baa7fad459e15c3144efefa6dbd1c84562c4739f6" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -238,6 +415,22 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" +[[package]] +name = "colorchoice" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" + +[[package]] +name = "colored" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c" +dependencies = [ + "lazy_static", + "windows-sys 0.59.0", +] + [[package]] name = "const_format" version = "0.2.34" @@ -258,6 +451,12 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + [[package]] name = "cpufeatures" version = "0.2.17" @@ -276,7 +475,7 @@ dependencies = [ "anes", "cast", "ciborium", - "clap", + "clap 4.5.45", "criterion-plot", "is-terminal", "itertools 0.10.5", @@ -303,6 +502,15 @@ dependencies = [ "itertools 0.10.5", ] +[[package]] +name = "crossbeam-channel" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-deque" version = "0.8.6" @@ -344,6 +552,38 @@ dependencies = [ "typenum", ] +[[package]] +name = "csv" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acdc4883a9c96732e4733212c01447ebd805833b7275a73ca3ee080fd77afdaf" +dependencies = [ + "csv-core", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "csv-core" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d02f3b0da4c6504f86e9cd789d8dbafab48c2321be74e9987593de5a894d93d" +dependencies = [ + "memchr", +] + +[[package]] +name = "dashmap" +version = "4.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e77a43b28d0668df09411cb0bc9a8c2adc40f9a048afe863e05fd43251e8e39c" +dependencies = [ + "cfg-if", + "num_cpus", + "serde", +] + [[package]] name = "derive_more" version = "1.0.0" @@ -365,6 +605,12 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "deunicode" +version = "1.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abd57806937c9cc163efc8ea3910e00a62e2aeb0b8119f1793a978088f8f6b04" + [[package]] name = "digest" version = "0.10.7" @@ -375,12 +621,90 @@ dependencies = [ "crypto-common", ] +[[package]] +name = "dirs" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + [[package]] name = "either" version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" +[[package]] +name = "encode_unicode" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" + +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "encoding_rs_io" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cc3c5651fb62ab8aa3103998dade57efdd028544bd300516baa31840c252a83" +dependencies = [ + "encoding_rs", +] + +[[package]] +name = "env_logger" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + [[package]] name = "equivalent" version = "1.0.2" @@ -442,7 +766,7 @@ dependencies = [ "rand 0.8.5", "sha3", "tempdir", - "thiserror", + "thiserror 2.0.14", "tinyvec", ] @@ -521,6 +845,54 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" +[[package]] +name = "globset" +version = "0.4.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54a1028dfc5f5df5da8a56a73e6c153c9a9708ec57232470703592a3f18e49f5" +dependencies = [ + "aho-corasick 1.1.3", + "bstr", + "log", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "globwalk" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf760ebf69878d9fd8f110c89703d90ce35095324d1f1edcb595c63945ee757" +dependencies = [ + "bitflags 2.9.1", + "ignore", + "walkdir", +] + +[[package]] +name = "grep-matcher" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47a3141a10a43acfedc7c98a60a834d7ba00dfe7bec9071cbfc19b55b292ac02" +dependencies = [ + "memchr", +] + +[[package]] +name = "grep-searcher" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9b6c14b3fc2e0a107d6604d3231dec0509e691e62447104bc385a46a7892cda" +dependencies = [ + "bstr", + "encoding_rs", + "encoding_rs_io", + "grep-matcher", + "log", + "memchr", + "memmap2", +] + [[package]] name = "half" version = "2.6.0" @@ -546,6 +918,21 @@ dependencies = [ "tiny-keccak", ] +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + [[package]] name = "hermit-abi" version = "0.5.2" @@ -564,6 +951,61 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "humansize" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6cb51c9a029ddc91b07a787f1d86b53ccfa49b0e86688c946ebe8d3555685dd7" +dependencies = [ + "libm", +] + +[[package]] +name = "humantime" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b112acc8b3adf4b107a8ec20977da0273a8c386765a3ec0229bd500a1443f9f" + +[[package]] +name = "iana-time-zone" +version = "0.1.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "ignore" +version = "0.4.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d89fd380afde86567dfba715db065673989d6253f42b88179abd3eae47bda4b" +dependencies = [ + "crossbeam-deque", + "globset", + "log", + "memchr", + "regex-automata", + "same-file", + "walkdir", + "winapi-util", +] + [[package]] name = "impl-codec" version = "0.7.1" @@ -618,17 +1060,32 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "instant" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" +dependencies = [ + "cfg-if", +] + [[package]] name = "is-terminal" version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9" dependencies = [ - "hermit-abi", + "hermit-abi 0.5.2", "libc", "windows-sys 0.59.0", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "itertools" version = "0.10.5" @@ -694,6 +1151,12 @@ dependencies = [ "windows-targets 0.53.3", ] +[[package]] +name = "libm" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" + [[package]] name = "libmdbx" version = "0.5.3" @@ -703,16 +1166,26 @@ dependencies = [ "anyhow", "arrayref", "arrayvec", - "bitflags", + "bitflags 2.9.1", "derive_more", "impls", "indexmap", "libc", "mdbx-sys", - "parking_lot", + "parking_lot 0.12.4", "sealed", "tempfile", - "thiserror", + "thiserror 2.0.14", +] + +[[package]] +name = "libredox" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "391290121bad3d37fbddad76d8f5d1c1c314cfc646d143d7e07a3086ddff0ce3" +dependencies = [ + "bitflags 2.9.1", + "libc", ] [[package]] @@ -721,6 +1194,20 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" +[[package]] +name = "loc" +version = "0.1.0" +dependencies = [ + "clap 4.5.45", + "clap_complete", + "colored", + "prettytable", + "serde", + "serde_json", + "spinoff", + "tokei", +] + [[package]] name = "lock_api" version = "0.4.13" @@ -767,88 +1254,242 @@ dependencies = [ name = "minimal-lexical" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num-format" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" +dependencies = [ + "arrayvec", + "itoa", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b" +dependencies = [ + "hermit-abi 0.5.2", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" + +[[package]] +name = "oorandom" +version = "11.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" + +[[package]] +name = "parity-scale-codec" +version = "3.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "799781ae679d79a948e13d4824a40970bfa500058d245760dd857301059810fa" +dependencies = [ + "arrayvec", + "bitvec", + "byte-slice-cast", + "const_format", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "rustversion", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34b4653168b563151153c9e4c08ebed57fb8262bebfa79711552fa983c623e7a" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core 0.8.6", +] + +[[package]] +name = "parking_lot" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" +dependencies = [ + "lock_api", + "parking_lot_core 0.9.11", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall 0.2.16", + "smallvec", + "winapi", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.5.17", + "smallvec", + "windows-targets 0.52.6", +] + +[[package]] +name = "parse-zoneinfo" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f2a05b18d44e2957b88f96ba460715e295bc1d7510468a2f3d3b44535d26c24" +dependencies = [ + "regex", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] -name = "nom" -version = "7.1.3" +name = "pest" +version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +checksum = "1db05f56d34358a8b1066f67cbb203ee3e7ed2ba674a6263a1d5ec6db2204323" dependencies = [ "memchr", - "minimal-lexical", + "thiserror 2.0.14", + "ucd-trie", ] [[package]] -name = "num-traits" -version = "0.2.19" +name = "pest_derive" +version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +checksum = "bb056d9e8ea77922845ec74a1c4e8fb17e7c218cc4fc11a15c5d25e189aa40bc" dependencies = [ - "autocfg", + "pest", + "pest_generator", ] [[package]] -name = "once_cell" -version = "1.21.3" +name = "pest_generator" +version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +checksum = "87e404e638f781eb3202dc82db6760c8ae8a1eeef7fb3fa8264b2ef280504966" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn", +] [[package]] -name = "oorandom" -version = "11.1.5" +name = "pest_meta" +version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" +checksum = "edd1101f170f5903fde0914f899bb503d9ff5271d7ba76bbb70bea63690cc0d5" +dependencies = [ + "pest", + "sha2", +] [[package]] -name = "parity-scale-codec" -version = "3.7.5" +name = "phf" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "799781ae679d79a948e13d4824a40970bfa500058d245760dd857301059810fa" +checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" dependencies = [ - "arrayvec", - "bitvec", - "byte-slice-cast", - "const_format", - "impl-trait-for-tuples", - "parity-scale-codec-derive", - "rustversion", - "serde", + "phf_shared", ] [[package]] -name = "parity-scale-codec-derive" -version = "3.7.5" +name = "phf_codegen" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34b4653168b563151153c9e4c08ebed57fb8262bebfa79711552fa983c623e7a" +checksum = "aef8048c789fa5e851558d709946d6d79a8ff88c0440c587967f8e94bfb1216a" dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", + "phf_generator", + "phf_shared", ] [[package]] -name = "parking_lot" -version = "0.12.4" +name = "phf_generator" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" +checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" dependencies = [ - "lock_api", - "parking_lot_core", + "phf_shared", + "rand 0.8.5", ] [[package]] -name = "parking_lot_core" -version = "0.9.11" +name = "phf_shared" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" +checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets 0.52.6", + "siphasher", ] [[package]] @@ -888,6 +1529,20 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "prettytable" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46480520d1b77c9a3482d39939fcf96831537a250ec62d4fd8fbdf8e0302e781" +dependencies = [ + "csv", + "encode_unicode", + "is-terminal", + "lazy_static", + "term", + "unicode-width", +] + [[package]] name = "primitive-types" version = "0.13.1" @@ -927,7 +1582,7 @@ checksum = "6fcdab19deb5195a31cf7726a210015ff1496ba1464fd42cb4f537b8b01b471f" dependencies = [ "bit-set", "bit-vec", - "bitflags", + "bitflags 2.9.1", "lazy_static", "num-traits", "rand 0.9.2", @@ -1091,13 +1746,33 @@ dependencies = [ "rand_core 0.3.1", ] +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "redox_syscall" version = "0.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77" dependencies = [ - "bitflags", + "bitflags 2.9.1", +] + +[[package]] +name = "redox_users" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" +dependencies = [ + "getrandom 0.2.16", + "libredox", + "thiserror 1.0.69", ] [[package]] @@ -1106,7 +1781,7 @@ version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ - "aho-corasick", + "aho-corasick 1.1.3", "memchr", "regex-automata", "regex-syntax", @@ -1118,7 +1793,7 @@ version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ - "aho-corasick", + "aho-corasick 1.1.3", "memchr", "regex-syntax", ] @@ -1176,7 +1851,7 @@ version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11181fbabf243db407ef8df94a6ce0b2f9a733bd8be4ad02b4eda9602296cac8" dependencies = [ - "bitflags", + "bitflags 2.9.1", "errno", "libc", "linux-raw-sys", @@ -1265,6 +1940,17 @@ dependencies = [ "serde", ] +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "sha3" version = "0.10.8" @@ -1281,18 +1967,57 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + +[[package]] +name = "slug" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "882a80f72ee45de3cc9a5afeb2da0331d58df69e4e7d8eeb5d3c7784ae67e724" +dependencies = [ + "deunicode", + "wasm-bindgen", +] + [[package]] name = "smallvec" version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" +[[package]] +name = "spinoff" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20aa2ed67fbb202e7b716ff8bfc6571dd9301617767380197d701c31124e88f6" +dependencies = [ + "colored", + "once_cell", + "paste", +] + [[package]] name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "syn" version = "2.0.104" @@ -1333,13 +2058,94 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "tera" +version = "1.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab9d851b45e865f178319da0abdbfe6acbc4328759ff18dafc3a41c16b4cd2ee" +dependencies = [ + "chrono", + "chrono-tz", + "globwalk", + "humansize", + "lazy_static", + "percent-encoding", + "pest", + "pest_derive", + "rand 0.8.5", + "regex", + "serde", + "serde_json", + "slug", + "unic-segment", +] + +[[package]] +name = "term" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" +dependencies = [ + "dirs-next", + "rustversion", + "winapi", +] + +[[package]] +name = "term_size" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e4129646ca0ed8f45d09b929036bafad5377103edd06e50bf574b353d2b08d9" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + [[package]] name = "thiserror" version = "2.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b0949c3a6c842cbde3f1686d6eea5a010516deb7085f79db747562d4102f41e" dependencies = [ - "thiserror-impl", + "thiserror-impl 2.0.14", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -1378,6 +2184,43 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09b3661f17e86524eccd4371ab0429194e0d7c008abb45f7a7495b1719463c71" +[[package]] +name = "tokei" +version = "12.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a41f915e075a8a98ad64a5f7be6b7cc1710fc835c5f07e4a3efcaeb013291c00" +dependencies = [ + "aho-corasick 0.7.20", + "clap 2.34.0", + "crossbeam-channel", + "dashmap", + "dirs", + "encoding_rs_io", + "env_logger", + "grep-searcher", + "ignore", + "log", + "num-format", + "once_cell", + "parking_lot 0.11.2", + "rayon", + "regex", + "serde", + "serde_json", + "tera", + "term_size", + "toml", +] + +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + [[package]] name = "toml_datetime" version = "0.6.11" @@ -1401,6 +2244,12 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" +[[package]] +name = "ucd-trie" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" + [[package]] name = "uint" version = "0.10.0" @@ -1419,18 +2268,86 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" +[[package]] +name = "unic-char-property" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8c57a407d9b6fa02b4795eb81c5b6652060a15a7903ea981f3d723e6c0be221" +dependencies = [ + "unic-char-range", +] + +[[package]] +name = "unic-char-range" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0398022d5f700414f6b899e10b8348231abf9173fa93144cbc1a43b9793c1fbc" + +[[package]] +name = "unic-common" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d7ff825a6a654ee85a63e80f92f054f904f21e7d12da4e22f9834a4aaa35bc" + +[[package]] +name = "unic-segment" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4ed5d26be57f84f176157270c112ef57b86debac9cd21daaabbe56db0f88f23" +dependencies = [ + "unic-ucd-segment", +] + +[[package]] +name = "unic-ucd-segment" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2079c122a62205b421f499da10f3ee0f7697f012f55b675e002483c73ea34700" +dependencies = [ + "unic-char-property", + "unic-char-range", + "unic-ucd-version", +] + +[[package]] +name = "unic-ucd-version" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96bd2f2237fe450fcd0a1d2f5f4e91711124f7857ba2e964247776ebeeb7b0c4" +dependencies = [ + "unic-common", +] + [[package]] name = "unicode-ident" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + [[package]] name = "unicode-xid" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + [[package]] name = "version_check" version = "0.9.5" @@ -1570,12 +2487,65 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-core" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "windows-link" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" +[[package]] +name = "windows-result" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +dependencies = [ + "windows-link", +] + [[package]] name = "windows-sys" version = "0.59.0" @@ -1738,7 +2708,7 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ - "bitflags", + "bitflags 2.9.1", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index e2046dd..ac804c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "ethrexdb" -version = "0.1.0" -edition = "2024" +version.workspace = true +edition.workspace = true description = "A simple database implementation based on the Merkle Patricia Trie (MPT)." keywords = ["database", "merkle", "patricia", "trie"] categories = ["database-implementations"] @@ -33,3 +33,10 @@ harness = false [profile.release-with-debug] inherits = "release" debug = 2 + +[workspace] +members = ["tooling"] + +[workspace.package] +version = "0.1.0" +edition = "2024" diff --git a/src/ethrex/mod.rs b/src/ethrex/mod.rs new file mode 100644 index 0000000..566effd --- /dev/null +++ b/src/ethrex/mod.rs @@ -0,0 +1,2 @@ +pub mod rlp; +pub mod trie; diff --git a/src/rlp/constants.rs b/src/ethrex/rlp/constants.rs similarity index 100% rename from src/rlp/constants.rs rename to src/ethrex/rlp/constants.rs diff --git a/src/rlp/decode.rs b/src/ethrex/rlp/decode.rs similarity index 100% rename from src/rlp/decode.rs rename to src/ethrex/rlp/decode.rs diff --git a/src/rlp/encode.rs b/src/ethrex/rlp/encode.rs similarity index 100% rename from src/rlp/encode.rs rename to src/ethrex/rlp/encode.rs diff --git a/src/rlp/error.rs b/src/ethrex/rlp/error.rs similarity index 100% rename from src/rlp/error.rs rename to src/ethrex/rlp/error.rs diff --git a/src/rlp/mod.rs b/src/ethrex/rlp/mod.rs similarity index 100% rename from src/rlp/mod.rs rename to src/ethrex/rlp/mod.rs diff --git a/src/rlp/structs.rs b/src/ethrex/rlp/structs.rs similarity index 100% rename from src/rlp/structs.rs rename to src/ethrex/rlp/structs.rs diff --git a/src/trie/branch.rs b/src/ethrex/trie/branch.rs similarity index 100% rename from src/trie/branch.rs rename to src/ethrex/trie/branch.rs diff --git a/src/trie/error.rs b/src/ethrex/trie/error.rs similarity index 100% rename from src/trie/error.rs rename to src/ethrex/trie/error.rs diff --git a/src/trie/extension.rs b/src/ethrex/trie/extension.rs similarity index 100% rename from src/trie/extension.rs rename to src/ethrex/trie/extension.rs diff --git a/src/trie/leaf.rs b/src/ethrex/trie/leaf.rs similarity index 100% rename from src/trie/leaf.rs rename to src/ethrex/trie/leaf.rs diff --git a/src/trie/mod.rs b/src/ethrex/trie/mod.rs similarity index 100% rename from src/trie/mod.rs rename to src/ethrex/trie/mod.rs diff --git a/src/trie/nibbles.rs b/src/ethrex/trie/nibbles.rs similarity index 100% rename from src/trie/nibbles.rs rename to src/ethrex/trie/nibbles.rs diff --git a/src/trie/node.rs b/src/ethrex/trie/node.rs similarity index 100% rename from src/trie/node.rs rename to src/ethrex/trie/node.rs diff --git a/src/trie/node_hash.rs b/src/ethrex/trie/node_hash.rs similarity index 100% rename from src/trie/node_hash.rs rename to src/ethrex/trie/node_hash.rs diff --git a/src/trie/test_utils.rs b/src/ethrex/trie/test_utils.rs similarity index 100% rename from src/trie/test_utils.rs rename to src/ethrex/trie/test_utils.rs diff --git a/src/lib.rs b/src/lib.rs index d2256e6..cbc18b7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,8 @@ mod file_manager; mod serialization; // ETHREX COPY STRUCTURES -mod rlp; -pub mod trie; +mod ethrex; +pub use ethrex::rlp; +pub use ethrex::trie; pub use db::EthrexDB; diff --git a/tooling/Cargo.toml b/tooling/Cargo.toml new file mode 100644 index 0000000..b578447 --- /dev/null +++ b/tooling/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "loc" +edition.workspace = true +version.workspace = true + +[dependencies] +clap = { version = "4.0.0", features = ["derive"] } +clap_complete = "4.4.3" +colored = "2.1.0" +prettytable = "0.10.0" +serde = { version = "1.0.152", features = ["derive"] } +serde_json = "1.0.0" +spinoff = "0.8.0" +tokei = "12.1.2" diff --git a/tooling/Makefile b/tooling/Makefile new file mode 100644 index 0000000..f840b20 --- /dev/null +++ b/tooling/Makefile @@ -0,0 +1,17 @@ +.PHONY: loc loc-stats loc-detailed loc-compare-detailed + +loc: + cargo run + +loc-stats: + if [ "$(QUIET)" = "true" ]; then \ + cargo run --quiet -- --summary;\ + else \ + cargo run -- --summary;\ + fi + +loc-detailed: + cargo run -- --detailed + +loc-compare-detailed: + cargo run -- --compare-detailed diff --git a/tooling/src/main.rs b/tooling/src/main.rs new file mode 100644 index 0000000..3d65050 --- /dev/null +++ b/tooling/src/main.rs @@ -0,0 +1,117 @@ +use std::collections::HashMap; +use std::fs; +use std::path::Path; + +use clap::Parser; +use report::{ + LinesOfCodeReport, LinesOfCodeReporterOptions, github_step_summary, pr_message, shell_summary, + slack_message, +}; +use spinoff::{Color, Spinner, spinners::Dots}; +use tokei::{Config, LanguageType, Languages}; + +mod report; + +fn count_lines_of_code() -> (usize, HashMap) { + let config = Config::default(); + let mut languages = Languages::new(); + let src_path = Path::new("../src"); + languages.get_statistics(&[src_path], &[], &config); + + let mut total_loc = 0; + let mut detailed_files = HashMap::new(); + + if let Some(rust) = languages.get(&LanguageType::Rust) { + for report in &rust.reports { + let file_path = report.name.to_string_lossy().to_string(); + if let Some(relative_path) = file_path.strip_prefix("../src/") { + // Exclude files in ethrex/ subdirectory + if !relative_path.starts_with("ethrex/") { + total_loc += report.stats.code; + detailed_files.insert(relative_path.to_string(), report.stats.code); + } + } + } + } + + (total_loc, detailed_files) +} + +fn main() { + let opts = LinesOfCodeReporterOptions::parse(); + + let mut spinner = Spinner::new(Dots, "Counting lines of code...", Color::Cyan); + + let (total_loc, detailed_files) = count_lines_of_code(); + + spinner.success("Lines of code calculated!"); + + let mut spinner = Spinner::new(Dots, "Generating report...", Color::Cyan); + + let new_report = LinesOfCodeReport { + ethrex_db: total_loc, + detailed_files: detailed_files.clone(), + }; + + if opts.detailed { + fs::write( + "current_detailed_loc_report.json", + serde_json::to_string(&detailed_files).unwrap(), + ) + .expect("current_detailed_loc_report.json could not be written"); + + spinner.success("Detailed report generated!"); + println!("{}", shell_summary(new_report)); + println!("\nDetailed breakdown:"); + + let mut files: Vec<_> = detailed_files.iter().collect(); + files.sort_by_key(|(name, _)| *name); + + for (file_name, loc) in files { + println!(" {}: {} lines", file_name, loc); + } + } else if opts.compare_detailed { + let current_detailed_loc_report = detailed_files; + + let previous_detailed_loc_report: HashMap = + fs::read_to_string("previous_detailed_loc_report.json") + .map(|s| serde_json::from_str(&s).unwrap()) + .unwrap_or(current_detailed_loc_report.clone()); + + fs::write( + "detailed_loc_report.txt", + pr_message(previous_detailed_loc_report, current_detailed_loc_report), + ) + .unwrap(); + + spinner.success("Comparison report generated!"); + } else if opts.summary { + spinner.success("Report generated!"); + println!("{}", shell_summary(new_report)); + } else { + // Default behavior - save all reports + fs::write( + "loc_report.json", + serde_json::to_string(&new_report).unwrap(), + ) + .expect("loc_report.json could not be written"); + + let old_report: LinesOfCodeReport = fs::read_to_string("loc_report.json.old") + .map(|s| serde_json::from_str(&s).unwrap()) + .unwrap_or(new_report.clone()); + + fs::write( + "loc_report_slack.txt", + slack_message(old_report.clone(), new_report.clone()), + ) + .unwrap(); + fs::write( + "loc_report_github.txt", + github_step_summary(old_report, new_report.clone()), + ) + .unwrap(); + + spinner.success("Report generated!"); + println!("{}", shell_summary(new_report)); + } +} diff --git a/tooling/src/report.rs b/tooling/src/report.rs new file mode 100644 index 0000000..fb057bc --- /dev/null +++ b/tooling/src/report.rs @@ -0,0 +1,190 @@ +use clap::Parser; +use colored::Colorize; +use prettytable::{Table, row}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +#[derive(Parser)] +pub struct LinesOfCodeReporterOptions { + #[arg(short, long, value_name = "SUMMARY", default_value = "false")] + pub summary: bool, + #[arg(short, long, value_name = "DETAILED", default_value = "false")] + pub detailed: bool, + #[arg(short, long, value_name = "PR_SUMMARY", default_value = "false")] + pub compare_detailed: bool, +} + +#[derive(Default, Serialize, Deserialize, Clone)] +pub struct LinesOfCodeReport { + pub ethrex_db: usize, + pub detailed_files: HashMap, +} + +pub fn pr_message( + old_report: HashMap, + new_report: HashMap, +) -> String { + let sorted_file_paths = { + let mut keys: Vec<_> = new_report.keys().collect(); + keys.sort(); + keys + }; + + let mut table = Table::new(); + table.add_row(row!["File", "Lines", "Diff"]); + + let mut total_lines_changed: i64 = 0; + let mut total_lines_added: i64 = 0; + let mut total_lines_removed: i64 = 0; + + for file_path in sorted_file_paths { + let current_loc = *new_report.get(file_path).unwrap() as i64; + let previous_loc = *old_report.get(file_path).unwrap_or(&0) as i64; + let loc_diff = current_loc - previous_loc; + + if loc_diff == 0 { + continue; + } + + if loc_diff > 0 { + total_lines_added += loc_diff; + } else { + total_lines_removed += loc_diff.abs(); + } + + total_lines_changed += loc_diff.abs(); + + table.add_row(row![ + file_path, + current_loc, + match current_loc.cmp(&previous_loc) { + std::cmp::Ordering::Greater => format!("+{loc_diff}"), + std::cmp::Ordering::Less => format!("{loc_diff}"), + std::cmp::Ordering::Equal => "-".to_owned(), + } + ]); + } + + if total_lines_changed == 0 { + return "".to_string(); + } + + let mut pr_message = String::new(); + + pr_message.push_str("

Lines of code report

\n"); + pr_message.push('\n'); + + pr_message.push_str(&pr_message_summary( + total_lines_added, + total_lines_removed, + total_lines_changed, + )); + + pr_message.push('\n'); + pr_message.push_str("
\n"); + pr_message.push_str("Detailed view\n"); + pr_message.push('\n'); + pr_message.push_str("```\n"); + pr_message.push_str(&format!("{table}\n")); + pr_message.push_str("```\n"); + pr_message.push_str("
\n"); + + pr_message +} + +fn pr_message_summary( + total_lines_added: i64, + total_lines_removed: i64, + total_lines_changed: i64, +) -> String { + let mut pr_message = String::new(); + + pr_message.push_str(&format!( + "Total lines added: `{}`\n", + match total_lines_added.cmp(&0) { + std::cmp::Ordering::Greater => format!("{total_lines_added}"), + std::cmp::Ordering::Less => + unreachable!("total_lines_added should never be less than 0"), + std::cmp::Ordering::Equal => format!("{total_lines_added}"), + } + )); + pr_message.push_str(&format!( + "Total lines removed: `{}`\n", + match total_lines_removed.cmp(&0) { + std::cmp::Ordering::Greater | std::cmp::Ordering::Equal => + format!("{total_lines_removed}"), + std::cmp::Ordering::Less => + unreachable!("total_lines_removed should never be less than 0"), + } + )); + pr_message.push_str(&format!( + "Total lines changed: `{}`\n", + match total_lines_changed.cmp(&0) { + std::cmp::Ordering::Greater | std::cmp::Ordering::Equal => + format!("{total_lines_changed}"), + std::cmp::Ordering::Less => + unreachable!("total_lines_changed should never be less than 0"), + } + )); + + pr_message +} + +pub fn slack_message(old_report: LinesOfCodeReport, new_report: LinesOfCodeReport) -> String { + let ethrex_db_diff = new_report.ethrex_db.abs_diff(old_report.ethrex_db); + + format!( + r#"{{ + "blocks": [ + {{ + "type": "header", + "text": {{ + "type": "plain_text", + "text": "EthrexDB Lines of Code Report" + }} + }}, + {{ + "type": "section", + "text": {{ + "type": "mrkdwn", + "text": "*ethrex_db:* {} {}" + }} + }} + ] +}}"#, + new_report.ethrex_db, + match new_report.ethrex_db.cmp(&old_report.ethrex_db) { + std::cmp::Ordering::Greater => format!("(+{ethrex_db_diff})"), + std::cmp::Ordering::Less => format!("(-{ethrex_db_diff})"), + std::cmp::Ordering::Equal => "".to_string(), + } + ) +} + +pub fn github_step_summary(old_report: LinesOfCodeReport, new_report: LinesOfCodeReport) -> String { + let ethrex_db_diff = new_report.ethrex_db.abs_diff(old_report.ethrex_db); + + format!( + r#"``` +EthrexDB Lines of Code Summary +============================== +ethrex_db: {} {} +```"#, + new_report.ethrex_db, + match new_report.ethrex_db.cmp(&old_report.ethrex_db) { + std::cmp::Ordering::Greater => format!("(+{ethrex_db_diff})"), + std::cmp::Ordering::Less => format!("(-{ethrex_db_diff})"), + std::cmp::Ordering::Equal => "".to_string(), + } + ) +} + +pub fn shell_summary(new_report: LinesOfCodeReport) -> String { + format!( + "{}\n{}\n{} {}", + "EthrexDB Lines of Code".bold(), + "======================".bold(), + "ethrex_db:".bold(), + new_report.ethrex_db, + ) +}