mirror of
https://github.com/kristoferssolo/project-finder.git
synced 2025-10-21 19:50:35 +00:00
feat: implement main functionality
This commit is contained in:
parent
39ccbd6e58
commit
73e1b44312
697
Cargo.lock
generated
Normal file
697
Cargo.lock
generated
Normal file
@ -0,0 +1,697 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "addr2line"
|
||||
version = "0.24.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1"
|
||||
dependencies = [
|
||||
"gimli",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "adler2"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
|
||||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.6.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"anstyle-parse",
|
||||
"anstyle-query",
|
||||
"anstyle-wincon",
|
||||
"colorchoice",
|
||||
"is_terminal_polyfill",
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9"
|
||||
dependencies = [
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-query"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"
|
||||
dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-wincon"
|
||||
version = "3.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"once_cell",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.97"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f"
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
|
||||
|
||||
[[package]]
|
||||
name = "backtrace"
|
||||
version = "0.3.74"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a"
|
||||
dependencies = [
|
||||
"addr2line",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"miniz_oxide",
|
||||
"object",
|
||||
"rustc-demangle",
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6088f3ae8c3608d19260cd7445411865a485688711b78b5be70d78cd96136f83"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22a7ef7f676155edfb82daa97f99441f3ebf4a58d5e32f295a56259f1b6facc8"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"clap_lex",
|
||||
"strsim",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.5.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
|
||||
|
||||
[[package]]
|
||||
name = "env_home"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c7f84e12ccf0a7ddc17a6c41c93326024c42920d7ee630d04950e6926645c0fe"
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.31.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "is_terminal_polyfill"
|
||||
version = "1.70.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.171"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.4.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e3e04debbb59698c15bacbb6d93584a8c0ca9cc3213cb423d31f760d8843ce5"
|
||||
dependencies = [
|
||||
"adler2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"wasi",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nu-ansi-term"
|
||||
version = "0.46.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
|
||||
dependencies = [
|
||||
"overload",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.36.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.21.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc"
|
||||
|
||||
[[package]]
|
||||
name = "overload"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.9.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"smallvec",
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.94"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "project-finder"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"which",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.40"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.5.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b8c0c260b63a8219631167be35e6a988e9554dbd323f8bd08439c8ed1302bd1"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||
|
||||
[[package]]
|
||||
name = "sharded-slab"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd"
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.5.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[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.100"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "2.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "2.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thread_local"
|
||||
version = "1.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.44.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f382da615b842244d4b8738c82ed1275e6c5dd90c459a30941cd07080b06c91a"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"bytes",
|
||||
"libc",
|
||||
"mio",
|
||||
"parking_lot",
|
||||
"pin-project-lite",
|
||||
"signal-hook-registry",
|
||||
"socket2",
|
||||
"tokio-macros",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-macros"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing"
|
||||
version = "0.1.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0"
|
||||
dependencies = [
|
||||
"pin-project-lite",
|
||||
"tracing-attributes",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-attributes"
|
||||
version = "0.1.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-core"
|
||||
version = "0.1.33"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"valuable",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-log"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3"
|
||||
dependencies = [
|
||||
"log",
|
||||
"once_cell",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-subscriber"
|
||||
version = "0.3.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008"
|
||||
dependencies = [
|
||||
"nu-ansi-term",
|
||||
"sharded-slab",
|
||||
"smallvec",
|
||||
"thread_local",
|
||||
"tracing-core",
|
||||
"tracing-log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "valuable"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
||||
[[package]]
|
||||
name = "which"
|
||||
version = "7.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2774c861e1f072b3aadc02f8ba886c26ad6321567ecc294c935434cad06f1283"
|
||||
dependencies = [
|
||||
"either",
|
||||
"env_home",
|
||||
"rustix",
|
||||
"winsafe",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.59.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
|
||||
[[package]]
|
||||
name = "winsafe"
|
||||
version = "0.0.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904"
|
||||
25
Cargo.toml
25
Cargo.toml
@ -1,6 +1,31 @@
|
||||
[package]
|
||||
name = "project-finder"
|
||||
authors = ["Kristofers Solo <dev@kristofers.xyz>"]
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
description = "Fast project finder for developers"
|
||||
repository = "https://github.com/kristoferssolo/project-finder"
|
||||
documentation = "https://docs.rs/project-finder"
|
||||
homepage = "https://github.com/kristoferssolo/project-finder"
|
||||
license = "MIT OR Apache-2.0"
|
||||
keywords = ["cli", "string", "text", "utility"]
|
||||
categories = ["command-line-utilities"]
|
||||
exclude = ["/.github", "/.gitignore", "/tests", "*.png", "*.md"]
|
||||
readme = "README.md"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1"
|
||||
clap = { version = "4.5", features = ["derive"] }
|
||||
thiserror = "2.0"
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = "0.3"
|
||||
which = "7.0"
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
[lints.clippy]
|
||||
pedantic = "warn"
|
||||
nursery = "warn"
|
||||
unwrap_used = "warn"
|
||||
expect_used = "warn"
|
||||
|
||||
104
src/commands.rs
Normal file
104
src/commands.rs
Normal file
@ -0,0 +1,104 @@
|
||||
use crate::errors::{ProjectFinderError, Result};
|
||||
use std::{
|
||||
path::{Path, PathBuf},
|
||||
process::Stdio,
|
||||
};
|
||||
use tokio::process::Command;
|
||||
use tracing::{debug, warn};
|
||||
|
||||
use crate::dependencies::Dependencies;
|
||||
|
||||
/// Run fd command to find files and directories
|
||||
pub async fn find_files(
|
||||
deps: &Dependencies,
|
||||
dir: &Path,
|
||||
pattern: &str,
|
||||
max_depth: usize,
|
||||
) -> Result<Vec<PathBuf>> {
|
||||
let mut cmd = Command::new(&deps.fd_path);
|
||||
|
||||
cmd.arg("--hidden")
|
||||
.arg("--no-ignore-vcs")
|
||||
.arg("--type")
|
||||
.arg("f")
|
||||
.arg("--max-depth")
|
||||
.arg(max_depth.to_string())
|
||||
.arg(pattern)
|
||||
.arg(dir)
|
||||
.stdout(Stdio::piped());
|
||||
|
||||
debug!("Running: fd {} in {}", pattern, dir.display());
|
||||
|
||||
let output = cmd.output().await.map_err(|e| {
|
||||
ProjectFinderError::CommandExecutionFailed(format!("Failed to execute fd: {e}"))
|
||||
})?;
|
||||
|
||||
if !output.status.success() {
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
warn!("fd command failed: {stderr}");
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
|
||||
let stdout = String::from_utf8(output.stdout).map_err(ProjectFinderError::Utf8Error)?;
|
||||
|
||||
let paths = stdout.lines().map(PathBuf::from).collect();
|
||||
Ok(paths)
|
||||
}
|
||||
|
||||
/// Find Git repositories
|
||||
pub async fn find_git_repos(
|
||||
deps: &Dependencies,
|
||||
dir: &Path,
|
||||
max_depth: usize,
|
||||
) -> Result<Vec<PathBuf>> {
|
||||
let mut cmd = Command::new(&deps.fd_path);
|
||||
|
||||
cmd.arg("--hidden")
|
||||
.arg("--type")
|
||||
.arg("d")
|
||||
.arg("--max-depth")
|
||||
.arg(max_depth.to_string())
|
||||
.arg("^.git$")
|
||||
.arg(dir)
|
||||
.stdout(Stdio::piped());
|
||||
|
||||
debug!("Finding git repos in {}", dir.display());
|
||||
|
||||
let output = cmd.output().await.map_err(|e| {
|
||||
ProjectFinderError::CommandExecutionFailed(format!("Failed to find git repositories: {e}"))
|
||||
})?;
|
||||
|
||||
if !output.status.success() {
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
warn!("fd command failed: {}", stderr);
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
|
||||
let stdout = String::from_utf8(output.stdout).map_err(ProjectFinderError::Utf8Error)?;
|
||||
|
||||
let paths = stdout
|
||||
.lines()
|
||||
// Convert .git directories to their parent (the actual repo root)
|
||||
.filter_map(|line| {
|
||||
let path = PathBuf::from(line);
|
||||
path.parent().map(std::path::Path::to_path_buf)
|
||||
})
|
||||
.collect();
|
||||
|
||||
Ok(paths)
|
||||
}
|
||||
|
||||
/// Run grep on a file to check for a pattern
|
||||
pub async fn grep_file(deps: &Dependencies, file: &Path, pattern: &str) -> Result<bool> {
|
||||
let mut cmd = Command::new(&deps.rg_path);
|
||||
|
||||
cmd.arg("-q") // quiet mode, just return exit code
|
||||
.arg(pattern)
|
||||
.arg(file);
|
||||
|
||||
let status = cmd.status().await.map_err(|e| {
|
||||
ProjectFinderError::CommandExecutionFailed(format!("Failed to execute ripgrep: {e}"))
|
||||
})?;
|
||||
|
||||
Ok(status.success())
|
||||
}
|
||||
21
src/config.rs
Normal file
21
src/config.rs
Normal file
@ -0,0 +1,21 @@
|
||||
use clap::Parser;
|
||||
|
||||
#[derive(Debug, Parser, Clone)]
|
||||
#[clap(
|
||||
author,
|
||||
version,
|
||||
about = "Find coding projects in specified directories"
|
||||
)]
|
||||
pub struct Config {
|
||||
/// Directories to search for projects
|
||||
#[clap(default_value = ".")]
|
||||
pub paths: Vec<String>,
|
||||
|
||||
/// Maximum search depth
|
||||
#[clap(short, long, default_value = "5")]
|
||||
pub depth: usize,
|
||||
|
||||
/// Show verbose output
|
||||
#[clap(short, long)]
|
||||
pub verbose: bool,
|
||||
}
|
||||
41
src/dependencies.rs
Normal file
41
src/dependencies.rs
Normal file
@ -0,0 +1,41 @@
|
||||
use crate::errors::{ProjectFinderError, Result};
|
||||
use tracing::info;
|
||||
use which::which;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Dependencies {
|
||||
pub fd_path: String,
|
||||
pub rg_path: String,
|
||||
}
|
||||
|
||||
impl Dependencies {
|
||||
pub fn new(fd_path: impl Into<String>, rg_path: impl Into<String>) -> Self {
|
||||
Self {
|
||||
fd_path: fd_path.into(),
|
||||
rg_path: rg_path.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn check() -> Result<Self> {
|
||||
info!("Checking dependencies...");
|
||||
|
||||
let fd_path = which("fd").map_err(|_| {
|
||||
ProjectFinderError::DependencyNotFound(
|
||||
"fd - install from https://github.com/sharkdp/fd".into(),
|
||||
)
|
||||
})?;
|
||||
|
||||
let rg_path = which("rg").map_err(|_| {
|
||||
ProjectFinderError::DependencyNotFound(
|
||||
"ripgrep (rg) - install from https://github.com/BurntSushi/ripgrep".into(),
|
||||
)
|
||||
})?;
|
||||
info!("Found fd at: {}", fd_path.display());
|
||||
info!("Found rupgrep at: {}", rg_path.display());
|
||||
|
||||
Ok(Self::new(
|
||||
fd_path.to_string_lossy(),
|
||||
rg_path.to_string_lossy(),
|
||||
))
|
||||
}
|
||||
}
|
||||
22
src/errors.rs
Normal file
22
src/errors.rs
Normal file
@ -0,0 +1,22 @@
|
||||
use std::{path::PathBuf, string::FromUtf8Error};
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ProjectFinderError {
|
||||
#[error("Dependency not found: {0}. Please install it and try again.")]
|
||||
DependencyNotFound(String),
|
||||
|
||||
#[error("Failed to execute command: {0}")]
|
||||
CommandExecutionFailed(String),
|
||||
|
||||
#[error("Path not found: {0}")]
|
||||
PathNotFound(PathBuf),
|
||||
|
||||
#[error("IO error: {0}")]
|
||||
IoError(#[from] std::io::Error),
|
||||
|
||||
#[error("Invalid UTF-8: {0}")]
|
||||
Utf8Error(#[from] FromUtf8Error),
|
||||
}
|
||||
|
||||
pub type Result<T> = std::result::Result<T, ProjectFinderError>;
|
||||
334
src/finder.rs
Normal file
334
src/finder.rs
Normal file
@ -0,0 +1,334 @@
|
||||
use crate::{
|
||||
commands::{find_files, find_git_repos, grep_file},
|
||||
config::Config,
|
||||
dependencies::Dependencies,
|
||||
errors::{ProjectFinderError, Result},
|
||||
};
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
path::{Path, PathBuf},
|
||||
sync::Arc,
|
||||
};
|
||||
use tokio::sync::Mutex;
|
||||
use tracing::{debug, info};
|
||||
|
||||
type ProjectSet = Arc<Mutex<HashSet<PathBuf>>>;
|
||||
type WorkspaceCache = Arc<Mutex<HashMap<PathBuf, bool>>>;
|
||||
type RootCache = Arc<Mutex<HashMap<(PathBuf, String), PathBuf>>>;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum MarkerType {
|
||||
PackageJson,
|
||||
CargoToml,
|
||||
DenoJson,
|
||||
BuildFile(String),
|
||||
OtherConfig(String),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ProjectFinder {
|
||||
config: Config,
|
||||
deps: Dependencies,
|
||||
discovered_projects: ProjectSet,
|
||||
workspace_cache: WorkspaceCache,
|
||||
root_cache: RootCache,
|
||||
}
|
||||
|
||||
impl ProjectFinder {
|
||||
pub fn new(config: Config, deps: Dependencies) -> Self {
|
||||
Self {
|
||||
config,
|
||||
deps,
|
||||
discovered_projects: Arc::new(Mutex::new(HashSet::new())),
|
||||
workspace_cache: Arc::new(Mutex::new(HashMap::new())),
|
||||
root_cache: Arc::new(Mutex::new(HashMap::new())),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn find_projects(&self) -> Result<Vec<PathBuf>> {
|
||||
// Process each search directory
|
||||
let mut handles = vec![];
|
||||
|
||||
for path in &self.config.paths {
|
||||
let path_buf = PathBuf::from(path);
|
||||
if !path_buf.is_dir() {
|
||||
return Err(ProjectFinderError::PathNotFound(path_buf));
|
||||
}
|
||||
|
||||
if self.config.verbose {
|
||||
info!("Searching in: {}", path);
|
||||
}
|
||||
|
||||
let finder_clone = self.clone();
|
||||
let path_clone = path_buf.clone();
|
||||
|
||||
// Spawn a task for each directory
|
||||
let handle =
|
||||
tokio::spawn(async move { finder_clone.process_directory(&path_clone).await });
|
||||
|
||||
handles.push(handle);
|
||||
}
|
||||
|
||||
// Wait for all tasks to complete
|
||||
for handle in handles {
|
||||
match handle.await {
|
||||
Ok(result) => {
|
||||
// Propagate internal errors
|
||||
if let Err(e) = result {
|
||||
debug!("Task failed: {}", e);
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
debug!("Task join error: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return sorted results
|
||||
let mut projects: Vec<PathBuf> = {
|
||||
let projects_guard = self.discovered_projects.lock().await;
|
||||
projects_guard.iter().cloned().collect()
|
||||
};
|
||||
|
||||
projects.sort();
|
||||
Ok(projects)
|
||||
}
|
||||
|
||||
async fn process_directory(&self, dir: &Path) -> Result<()> {
|
||||
// First find all git repositories (usually the most reliable project indicators)
|
||||
let git_repos = find_git_repos(&self.deps, dir, self.config.depth).await?;
|
||||
|
||||
{
|
||||
let mut projects = self.discovered_projects.lock().await;
|
||||
projects.extend(git_repos);
|
||||
}
|
||||
|
||||
// Find relevant marker files
|
||||
let marker_patterns = [
|
||||
"package.json",
|
||||
"pnpm-workspace.yaml",
|
||||
"lerna.json",
|
||||
"Cargo.toml",
|
||||
"go.mod",
|
||||
"pyproject.toml",
|
||||
"CMakeLists.txt",
|
||||
"Makefile",
|
||||
"justfile",
|
||||
"Justfile",
|
||||
"deno.json",
|
||||
"deno.jsonc",
|
||||
"bunfig.toml",
|
||||
];
|
||||
|
||||
for pattern in &marker_patterns {
|
||||
let paths = find_files(&self.deps, dir, pattern, self.config.depth).await?;
|
||||
|
||||
for path in paths {
|
||||
if let Some(parent_dir) = path.parent() {
|
||||
self.process_marker(parent_dir, pattern).await?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn process_marker(&self, dir: &Path, marker_name: &str) -> Result<()> {
|
||||
// Determine marker type
|
||||
let marker_type = match marker_name {
|
||||
"package.json" => MarkerType::PackageJson,
|
||||
"Cargo.toml" => MarkerType::CargoToml,
|
||||
"deno.json" | "deno.jsonc" => MarkerType::DenoJson,
|
||||
"Makefile" | "CMakeLists.txt" | "justfile" | "Justfile" => {
|
||||
MarkerType::BuildFile(marker_name.to_string())
|
||||
}
|
||||
_ => MarkerType::OtherConfig(marker_name.to_string()),
|
||||
};
|
||||
|
||||
// Find project root
|
||||
let project_root = self.find_project_root(dir, &marker_type).await?;
|
||||
|
||||
// Check if it's a subdirectory of an already discovered project
|
||||
let mut should_add = true;
|
||||
{
|
||||
let projects = self.discovered_projects.lock().await;
|
||||
for known_project in projects.iter() {
|
||||
if project_root.starts_with(known_project) && project_root != *known_project {
|
||||
should_add = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if should_add {
|
||||
let mut projects = self.discovered_projects.lock().await;
|
||||
projects.insert(project_root);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn find_project_root(&self, dir: &Path, marker_type: &MarkerType) -> Result<PathBuf> {
|
||||
// Check cache
|
||||
let cache_key = (dir.to_path_buf(), format!("{marker_type:?}"));
|
||||
{
|
||||
let cache = self.root_cache.lock().await;
|
||||
if let Some(root) = cache.get(&cache_key) {
|
||||
return Ok(root.clone());
|
||||
}
|
||||
}
|
||||
|
||||
let mut result = dir.to_path_buf();
|
||||
|
||||
match marker_type {
|
||||
MarkerType::PackageJson | MarkerType::DenoJson => {
|
||||
// Check for workspace roots
|
||||
let mut current = dir.to_path_buf();
|
||||
while let Some(parent) = current.parent() {
|
||||
if parent.as_os_str().is_empty() {
|
||||
break;
|
||||
}
|
||||
|
||||
if self.is_workspace_root(parent).await? {
|
||||
result = parent.to_path_buf();
|
||||
break;
|
||||
}
|
||||
|
||||
if parent.join(".git").is_dir() {
|
||||
result = parent.to_path_buf();
|
||||
break;
|
||||
}
|
||||
|
||||
current = parent.to_path_buf();
|
||||
}
|
||||
}
|
||||
|
||||
MarkerType::CargoToml => {
|
||||
// Check for Cargo workspace
|
||||
let mut current = dir.to_path_buf();
|
||||
while let Some(parent) = current.parent() {
|
||||
if parent.as_os_str().is_empty() {
|
||||
break;
|
||||
}
|
||||
|
||||
let cargo_toml = parent.join("Cargo.toml");
|
||||
if cargo_toml.exists()
|
||||
&& grep_file(&self.deps, &cargo_toml, r"^\[workspace\]").await?
|
||||
{
|
||||
result = parent.to_path_buf();
|
||||
break;
|
||||
}
|
||||
|
||||
if parent.join(".git").is_dir() {
|
||||
result = parent.to_path_buf();
|
||||
break;
|
||||
}
|
||||
|
||||
current = parent.to_path_buf();
|
||||
}
|
||||
}
|
||||
|
||||
MarkerType::BuildFile(name) => {
|
||||
// For build system files, find the highest one that's still in the same git repo
|
||||
let mut highest_dir = dir.to_path_buf();
|
||||
let mut current = dir.to_path_buf();
|
||||
|
||||
while let Some(parent) = current.parent() {
|
||||
if parent.as_os_str().is_empty() {
|
||||
break;
|
||||
}
|
||||
|
||||
if parent.join(name).exists() {
|
||||
highest_dir = parent.to_path_buf();
|
||||
}
|
||||
|
||||
if parent.join(".git").is_dir() {
|
||||
result = parent.to_path_buf();
|
||||
break;
|
||||
}
|
||||
|
||||
current = parent.to_path_buf();
|
||||
}
|
||||
|
||||
if result == dir.to_path_buf() {
|
||||
result = highest_dir;
|
||||
}
|
||||
}
|
||||
|
||||
MarkerType::OtherConfig(_) => {
|
||||
// For other file types, just look for git repos
|
||||
let mut current = dir.to_path_buf();
|
||||
while let Some(parent) = current.parent() {
|
||||
if parent.as_os_str().is_empty() {
|
||||
break;
|
||||
}
|
||||
|
||||
if parent.join(".git").is_dir() {
|
||||
result = parent.to_path_buf();
|
||||
break;
|
||||
}
|
||||
|
||||
current = parent.to_path_buf();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Cache the result
|
||||
self.root_cache
|
||||
.lock()
|
||||
.await
|
||||
.insert(cache_key, result.clone());
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
async fn is_workspace_root(&self, dir: &Path) -> Result<bool> {
|
||||
// Check cache
|
||||
{
|
||||
let cache = self.workspace_cache.lock().await;
|
||||
if let Some(&result) = cache.get(dir) {
|
||||
return Ok(result);
|
||||
}
|
||||
}
|
||||
|
||||
// Define workspace patterns to check
|
||||
let workspace_patterns = [
|
||||
(dir.join("package.json"), r#""workspaces""#),
|
||||
(dir.join("deno.json"), r#""workspaces""#),
|
||||
(dir.join("deno.jsonc"), r#""workspaces""#),
|
||||
(dir.join("bunfig.toml"), r"workspaces"),
|
||||
];
|
||||
|
||||
// Files that indicate workspaces just by existing
|
||||
let workspace_files = [dir.join("pnpm-workspace.yaml"), dir.join("lerna.json")];
|
||||
|
||||
// Check for workspace by pattern matching
|
||||
for (file, pattern) in &workspace_patterns {
|
||||
if file.exists() && grep_file(&self.deps, file, pattern).await? {
|
||||
self.workspace_cache
|
||||
.lock()
|
||||
.await
|
||||
.insert(dir.to_path_buf(), true);
|
||||
return Ok(true);
|
||||
}
|
||||
}
|
||||
|
||||
// Check for workspace by file existence
|
||||
for file in &workspace_files {
|
||||
if file.exists() {
|
||||
self.workspace_cache
|
||||
.lock()
|
||||
.await
|
||||
.insert(dir.to_path_buf(), true);
|
||||
return Ok(true);
|
||||
}
|
||||
}
|
||||
|
||||
// No workspace found
|
||||
self.workspace_cache
|
||||
.lock()
|
||||
.await
|
||||
.insert(dir.to_path_buf(), false);
|
||||
Ok(false)
|
||||
}
|
||||
}
|
||||
67
src/main.rs
67
src/main.rs
@ -1,3 +1,66 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
mod commands;
|
||||
mod config;
|
||||
mod dependencies;
|
||||
mod errors;
|
||||
mod finder;
|
||||
|
||||
use clap::Parser;
|
||||
use config::Config;
|
||||
use dependencies::Dependencies;
|
||||
use finder::ProjectFinder;
|
||||
use std::process::exit;
|
||||
use tracing::{Level, error};
|
||||
use tracing_subscriber::FmtSubscriber;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
// Parse CLI arguments
|
||||
let config = Config::parse();
|
||||
|
||||
// Setup logging
|
||||
let log_level = if config.verbose {
|
||||
Level::INFO
|
||||
} else {
|
||||
Level::ERROR
|
||||
};
|
||||
let subscriber = FmtSubscriber::builder().with_max_level(log_level).finish();
|
||||
|
||||
if let Err(e) = tracing::subscriber::set_global_default(subscriber) {
|
||||
eprintln!("Failed to set up logging: {e}");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Check for required dependencies
|
||||
let deps = match Dependencies::check() {
|
||||
Ok(deps) => deps,
|
||||
Err(e) => {
|
||||
error!("{e}");
|
||||
eprintln!("Error: {e}");
|
||||
eprintln!(
|
||||
"This tool requires both 'fd' and 'ripgrep' (rg) to be installed and available in your PATH."
|
||||
);
|
||||
eprintln!("Please install the missing dependencies and try again.");
|
||||
eprintln!("\nInstallation instructions:");
|
||||
eprintln!(" fd: https://github.com/sharkdp/fd#installation");
|
||||
eprintln!(" ripgrep: https://github.com/BurntSushi/ripgrep#installation");
|
||||
exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
// Create finder and search for projects
|
||||
let finder = ProjectFinder::new(config, deps);
|
||||
|
||||
match finder.find_projects().await {
|
||||
Ok(projects) => {
|
||||
// Output results
|
||||
for project in projects {
|
||||
println!("{}", project.display());
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to find projects: {e}");
|
||||
eprintln!("Error: {e}");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user