From f066a0d1d06efaa465eae0a68d4c60e658442223 Mon Sep 17 00:00:00 2001 From: Mahesh Bandara Wijerathna Date: Fri, 19 Apr 2024 07:06:49 +0530 Subject: [PATCH] Separate Rust sources into packages using a Cargo workspace Doing this avoids packing unnecessary dependencies into each binary and makes the project structure much cleaner. --- .cargo/config.toml | 8 +- Cargo.lock | 236 ++++++++++++--------- Cargo.toml | 63 ++---- backend/Cargo.toml | 43 ++++ build.rs => backend/build.rs | 2 +- backend/src/app_util.rs | 4 +- backend/src/bin_util.rs | 2 + backend/src/fs_util.rs | 2 +- backend/src/lib.rs | 2 - backend/src/{bin/ufcr => }/main.rs | 2 +- backend/src/net_util.rs | 2 + backend/src/rt_util.rs | 2 + backend/src/ws_util.rs | 2 + pack/Cargo.toml | 17 ++ {backend/src/bin/pack => pack/src}/main.rs | 0 package.json | 2 +- ufcr_libs/Cargo.toml | 12 ++ ufcr_libs/src/lib.rs | 6 + {backend => ufcr_libs}/src/log_util.rs | 8 +- 19 files changed, 243 insertions(+), 172 deletions(-) create mode 100644 backend/Cargo.toml rename build.rs => backend/build.rs (91%) rename backend/src/{bin/ufcr => }/main.rs (97%) create mode 100644 pack/Cargo.toml rename {backend/src/bin/pack => pack/src}/main.rs (100%) create mode 100644 ufcr_libs/Cargo.toml create mode 100644 ufcr_libs/src/lib.rs rename {backend => ufcr_libs}/src/log_util.rs (81%) diff --git a/.cargo/config.toml b/.cargo/config.toml index f97463e..75d400b 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -2,7 +2,7 @@ rustflags = ["-C", "target-feature=+crt-static"] [alias] -build-win32 = 'build --release --bin ufc-ripper --features=exe_res' -build-linux = 'build --release --bin ufc-ripper' -pack-win32 = 'run --release --bin pack -- --platform win32' -pack-linux = 'run --release --bin pack -- --platform linux' +build-win32 = 'build --release --package ufc-ripper --features=exe_res' +build-linux = 'build --release --package ufc-ripper' +pack-win32 = 'run --release --package pack -- --platform win32' +pack-linux = 'run --release --package pack -- --platform linux' diff --git a/Cargo.lock b/Cargo.lock index 6b99d1a..28d33ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -93,9 +93,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" +checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" [[package]] name = "arc-swap" @@ -105,9 +105,9 @@ checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" [[package]] name = "async-trait" -version = "0.1.77" +version = "0.1.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" +checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", @@ -116,15 +116,15 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" [[package]] name = "axum" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1236b4b292f6c4d6dc34604bb5120d85c3fe1d1aa596bd5cc52ca054d13e7b9e" +checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" dependencies = [ "async-trait", "axum-core", @@ -146,7 +146,7 @@ dependencies = [ "serde_json", "serde_path_to_error", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 1.0.1", "tokio", "tower", "tower-layer", @@ -169,7 +169,7 @@ dependencies = [ "mime", "pin-project-lite", "rustversion", - "sync_wrapper", + "sync_wrapper 0.1.2", "tower-layer", "tower-service", "tracing", @@ -191,9 +191,9 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" dependencies = [ "addr2line", "cc", @@ -218,15 +218,9 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "block-buffer" @@ -239,9 +233,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.15.4" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "byteorder" @@ -278,9 +272,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.90" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "17f6e324229dc011159fcc089755d1e2e216a90d43a7dea6853ca740b84f35e7" dependencies = [ "jobserver", "libc", @@ -294,16 +288,16 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.37" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "wasm-bindgen", - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -628,9 +622,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" dependencies = [ "cfg-if", "libc", @@ -645,9 +639,9 @@ checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "h2" -version = "0.4.2" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31d030e59af851932b72ceebadf4a2b5986dba4c3b99dd2493f8273a0f151943" +checksum = "816ec7294445779408f36fe57bc5b7fc1cf59664059096c65f905c1c61f58069" dependencies = [ "bytes", "fnv", @@ -743,9 +737,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "1.2.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "186548d73ac615b32a73aafe38fb4f56c0d340e110e5a200bcadbaf2e199263a" +checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" dependencies = [ "bytes", "futures-channel", @@ -834,9 +828,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.5" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown", @@ -878,15 +872,15 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jobserver" -version = "0.1.28" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" +checksum = "685a7d121ee3f65ae4fddd72b25a04bb36b6af81bc0828f7d5434c0fe60fa3a2" dependencies = [ "libc", ] @@ -912,6 +906,16 @@ version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags", + "libc", +] + [[package]] name = "log" version = "0.4.21" @@ -926,9 +930,9 @@ checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "mime" @@ -1023,6 +1027,18 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "pack" +version = "2.2.0" +dependencies = [ + "anyhow", + "clap", + "fs_extra", + "ufcr_libs", + "zip", + "zip-extensions", +] + [[package]] name = "password-hash" version = "0.4.2" @@ -1098,9 +1114,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -1128,18 +1144,18 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -1174,23 +1190,14 @@ dependencies = [ "getrandom", ] -[[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_users" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ "getrandom", - "redox_syscall", + "libredox", "thiserror", ] @@ -1229,7 +1236,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 0.1.2", "tokio", "tokio-rustls", "tokio-util", @@ -1342,9 +1349,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" [[package]] name = "ryu" @@ -1369,18 +1376,18 @@ checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" -version = "1.0.197" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" dependencies = [ "proc-macro2", "quote", @@ -1389,9 +1396,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.114" +version = "1.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" dependencies = [ "itoa", "ryu", @@ -1480,9 +1487,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" @@ -1534,9 +1541,9 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "syn" -version = "2.0.52" +version = "2.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" dependencies = [ "proc-macro2", "quote", @@ -1549,6 +1556,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" + [[package]] name = "thiserror" version = "1.0.58" @@ -1571,9 +1584,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.34" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "num-conv", @@ -1605,9 +1618,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.36.0" +version = "1.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" +checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" dependencies = [ "backtrace", "bytes", @@ -1725,7 +1738,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" dependencies = [ - "bitflags 2.4.2", + "bitflags", "bytes", "futures-util", "http", @@ -1816,10 +1829,8 @@ dependencies = [ "axum", "axum-embed", "bytes", - "clap", "colored", "form_urlencoded", - "fs_extra", "futures-util", "once_cell", "open", @@ -1833,10 +1844,16 @@ dependencies = [ "socketioxide", "tokio", "tower-http", + "ufcr_libs", "uuid", "winresource", - "zip", - "zip-extensions", +] + +[[package]] +name = "ufcr_libs" +version = "2.2.0" +dependencies = [ + "colored", ] [[package]] @@ -2074,7 +2091,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -2092,7 +2109,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -2112,17 +2129,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ - "windows_aarch64_gnullvm 0.52.4", - "windows_aarch64_msvc 0.52.4", - "windows_i686_gnu 0.52.4", - "windows_i686_msvc 0.52.4", - "windows_x86_64_gnu 0.52.4", - "windows_x86_64_gnullvm 0.52.4", - "windows_x86_64_msvc 0.52.4", + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", ] [[package]] @@ -2133,9 +2151,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" @@ -2145,9 +2163,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" @@ -2157,9 +2175,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.4" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" @@ -2169,9 +2193,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" @@ -2181,9 +2205,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" @@ -2193,9 +2217,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" @@ -2205,9 +2229,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "winnow" diff --git a/Cargo.toml b/Cargo.toml index a5cc3f5..2fa8916 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,57 +1,18 @@ -[package] -name = "ufc-ripper" +[workspace] +members = [ + "backend", + "pack", + "ufcr_libs" +] +default-members = [ + "backend" +] +resolver = "2" + +[workspace.package] version = "2.2.0" -description = "Video downloader tool for UFC Fight Pass" authors = ["Mahesh Bandara Wijerathna "] license = "MIT" repository = "https://github.com/m4heshd/ufc-ripper" edition = "2021" publish = false - -[[bin]] -name = "ufc-ripper" -path = "backend/src/bin/ufcr/main.rs" - -[[bin]] -name = "pack" -path = "backend/src/bin/pack/main.rs" - -[lib] -name = "ufcr_libs" -path = "backend/src/lib.rs" - -[profile.release] -lto = "fat" - -[features] -exe_res = [] - -[dependencies] -anyhow = "1.0.81" -arc-swap = "1.7.1" -axum = "0.7.4" -axum-embed = "0.1.0" -bytes = "1.6.0" -clap = { version = "4.5.4", features = ["derive"] } -colored = "2.1.0" -form_urlencoded = "1.2.1" -fs_extra = "1.3.0" -futures-util = "0.3.30" -once_cell = "1.19.0" -open = "5.1.2" -path-absolutize = "3.1.1" -regex-lite = "0.1.5" -reqwest = { version = "0.12.3", default-features = false, features = ["json", "stream", "rustls-tls"] } -rust-embed = { version = "8.3.0", features = ["interpolate-folder-path"] } -semver = "1.0.22" -serde = { version = "1.0.197", features = ["derive"] } -serde_json = "1.0.114" -socketioxide = "0.12.0" -tokio = { version = "1.36.0", features = ["rt", "rt-multi-thread", "macros", "process"] } -tower-http = { version = "0.5.2", features = ["fs", "cors"] } -uuid = { version = "1.8.0", features = ["v4", "fast-rng"] } -zip = "0.6.6" -zip-extensions = { git = "https://github.com/m4heshd/zip-extensions-rs.git", branch = "mappable-file-options" } - -[build-dependencies] -winresource = "0.1.17" diff --git a/backend/Cargo.toml b/backend/Cargo.toml new file mode 100644 index 0000000..a4f2bec --- /dev/null +++ b/backend/Cargo.toml @@ -0,0 +1,43 @@ +[package] +name = "ufc-ripper" +description = "Video downloader tool for UFC Fight Pass" +version.workspace = true +authors.workspace = true +license.workspace = true +repository.workspace = true +edition.workspace = true +publish.workspace = true + +[lib] +name = "ufcr_util" +path = "src/lib.rs" + +[features] +exe_res = [] + +[dependencies] +anyhow = "1.0.81" +arc-swap = "1.7.1" +axum = "0.7.4" +axum-embed = "0.1.0" +bytes = "1.6.0" +colored = "2.1.0" +form_urlencoded = "1.2.1" +futures-util = "0.3.30" +once_cell = "1.19.0" +open = "5.1.2" +path-absolutize = "3.1.1" +regex-lite = "0.1.5" +reqwest = { version = "0.12.3", default-features = false, features = ["json", "stream", "rustls-tls"] } +rust-embed = { version = "8.3.0", features = ["interpolate-folder-path"] } +semver = "1.0.22" +serde = { version = "1.0.197", features = ["derive"] } +serde_json = "1.0.114" +socketioxide = "0.12.0" +tokio = { version = "1.36.0", features = ["rt", "rt-multi-thread", "macros", "process"] } +tower-http = { version = "0.5.2", features = ["fs", "cors"] } +ufcr_libs = { path = "../ufcr_libs" } +uuid = { version = "1.8.0", features = ["v4", "fast-rng"] } + +[build-dependencies] +winresource = "0.1.17" diff --git a/build.rs b/backend/build.rs similarity index 91% rename from build.rs rename to backend/build.rs index d449fc5..763a511 100644 --- a/build.rs +++ b/backend/build.rs @@ -12,7 +12,7 @@ fn main() { let mut res = WindowsResource::new(); - res.set_icon("project-res/images/ufc-ripper-icon.ico") + res.set_icon("../project-res/images/ufc-ripper-icon.ico") .set("ProductName", "UFC Ripper") .set("FileDescription", "UFC Ripper") .set( diff --git a/backend/src/app_util.rs b/backend/src/app_util.rs index bdc4a79..4f92770 100644 --- a/backend/src/app_util.rs +++ b/backend/src/app_util.rs @@ -54,7 +54,9 @@ pub fn get_app_root_dir() -> PathBuf { let err_msg = "Failed to determine the application's root directory"; if cfg!(debug_assertions) { - PathBuf::from(".") + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .parent() + .unwrap_or_quit(err_msg) .absolutize() .unwrap_or_quit(err_msg) .to_path_buf() diff --git a/backend/src/bin_util.rs b/backend/src/bin_util.rs index 1698990..2349865 100644 --- a/backend/src/bin_util.rs +++ b/backend/src/bin_util.rs @@ -18,6 +18,8 @@ use tokio::{ time::Instant, }; +use ufcr_libs::log_err; + use crate::{ app_util::get_app_root_dir, config_util::{get_config, inc_file_number, is_debug, UFCRConfig}, diff --git a/backend/src/fs_util.rs b/backend/src/fs_util.rs index e07b004..928c64d 100644 --- a/backend/src/fs_util.rs +++ b/backend/src/fs_util.rs @@ -15,7 +15,7 @@ use crate::{ // Structs /// Holds all the static files for UFC Ripper GUI that will be served using axum. #[derive(RustEmbed, Clone)] -#[folder = "$CARGO_MANIFEST_DIR/dist/"] +#[folder = "$CARGO_MANIFEST_DIR/../dist/"] pub struct WebAssets; /// Reads the config.json file from the disk and returns the content as `String`. diff --git a/backend/src/lib.rs b/backend/src/lib.rs index b8c059b..20a1a75 100644 --- a/backend/src/lib.rs +++ b/backend/src/lib.rs @@ -1,6 +1,4 @@ // Module exports -#[macro_use] -pub mod log_util; pub mod app_util; mod bin_util; pub mod config_util; diff --git a/backend/src/bin/ufcr/main.rs b/backend/src/main.rs similarity index 97% rename from backend/src/bin/ufcr/main.rs rename to backend/src/main.rs index a4a8980..c26ea4b 100644 --- a/backend/src/bin/ufcr/main.rs +++ b/backend/src/main.rs @@ -1,5 +1,5 @@ // Libs -use ufcr_libs::{ +use ufcr_util::{ app_util::is_container, config_util::{is_debug, load_config}, net_util::init_server, diff --git a/backend/src/net_util.rs b/backend/src/net_util.rs index 0fd11f0..533c200 100644 --- a/backend/src/net_util.rs +++ b/backend/src/net_util.rs @@ -13,6 +13,8 @@ use serde_json::{json, value::Index, Value}; use tokio::net::TcpListener; use tower_http::cors::{Any, CorsLayer}; +use ufcr_libs::{log_err, log_success}; + use crate::{ app_util::{get_app_metadata, get_os_id, is_container}, bin_util::BINS, diff --git a/backend/src/rt_util.rs b/backend/src/rt_util.rs index d7f292a..7694204 100644 --- a/backend/src/rt_util.rs +++ b/backend/src/rt_util.rs @@ -5,6 +5,8 @@ use std::{ panic::{panic_any, set_hook as set_panic_hook}, }; +use ufcr_libs::{log_err, log_warn}; + // Enums /// Defines an exit type to determine if the exit event is an unknown panic or intentional. pub enum ExitType { diff --git a/backend/src/ws_util.rs b/backend/src/ws_util.rs index 134fc45..b12d6d4 100644 --- a/backend/src/ws_util.rs +++ b/backend/src/ws_util.rs @@ -13,6 +13,8 @@ use socketioxide::{ SocketIo, SocketIoBuilder, }; +use ufcr_libs::{log_err, log_info}; + use crate::{ app_util::{check_app_update, get_app_metadata}, bin_util::{cancel_download, get_vod_formats, start_download, validate_bins}, diff --git a/pack/Cargo.toml b/pack/Cargo.toml new file mode 100644 index 0000000..5b9d6eb --- /dev/null +++ b/pack/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "pack" +description = "Packager for UFC Ripper" +version.workspace = true +authors.workspace = true +license.workspace = true +repository.workspace = true +edition.workspace = true +publish.workspace = true + +[dependencies] +anyhow = "1.0.81" +clap = { version = "4.5.4", features = ["derive"] } +fs_extra = "1.3.0" +ufcr_libs = { path = "../ufcr_libs" } +zip = "0.6.6" +zip-extensions = { git = "https://github.com/m4heshd/zip-extensions-rs.git", branch = "mappable-file-options" } \ No newline at end of file diff --git a/backend/src/bin/pack/main.rs b/pack/src/main.rs similarity index 100% rename from backend/src/bin/pack/main.rs rename to pack/src/main.rs diff --git a/package.json b/package.json index 6669d38..a1f4fa0 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "license": "MIT", "private": true, "scripts": { - "dev:backend": "cargo run --color=always --bin ufc-ripper", + "dev:backend": "cargo run --color=always --package ufc-ripper", "dev": "vite", "test": "npm run build && cargo test", "build:backend:win32": "npm run build && cargo build-win32", diff --git a/ufcr_libs/Cargo.toml b/ufcr_libs/Cargo.toml new file mode 100644 index 0000000..77f0065 --- /dev/null +++ b/ufcr_libs/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "ufcr_libs" +description = "UFC Ripper's shared libraries" +version.workspace = true +authors.workspace = true +license.workspace = true +repository.workspace = true +edition.workspace = true +publish.workspace = true + +[dependencies] +colored = "2.1.0" \ No newline at end of file diff --git a/ufcr_libs/src/lib.rs b/ufcr_libs/src/lib.rs new file mode 100644 index 0000000..970550b --- /dev/null +++ b/ufcr_libs/src/lib.rs @@ -0,0 +1,6 @@ +// Libs +pub use ::colored::Colorize; + +// Module exports +#[macro_use] +pub mod log_util; \ No newline at end of file diff --git a/backend/src/log_util.rs b/ufcr_libs/src/log_util.rs similarity index 81% rename from backend/src/log_util.rs rename to ufcr_libs/src/log_util.rs index 10c68c6..b3f9931 100644 --- a/backend/src/log_util.rs +++ b/ufcr_libs/src/log_util.rs @@ -3,7 +3,7 @@ #[macro_export] macro_rules! log_info { ($($arg:tt)*) => { - println!("{}", colored::Colorize::bright_cyan( + println!("{}", $crate::Colorize::bright_cyan( format!($($arg)*).as_str() )) }; @@ -13,7 +13,7 @@ macro_rules! log_info { #[macro_export] macro_rules! log_success { ($($arg:tt)*) => { - println!("{}", colored::Colorize::bright_green( + println!("{}", $crate::Colorize::bright_green( format!($($arg)*).as_str() )) }; @@ -23,7 +23,7 @@ macro_rules! log_success { #[macro_export] macro_rules! log_warn { ($($arg:tt)*) => { - println!("{}", colored::Colorize::bright_yellow( + println!("{}", $crate::Colorize::bright_yellow( format!($($arg)*).as_str() )) }; @@ -33,7 +33,7 @@ macro_rules! log_warn { #[macro_export] macro_rules! log_err { ($($arg:tt)*) => { - eprintln!("{}", colored::Colorize::bright_red( + eprintln!("{}", $crate::Colorize::bright_red( format!($($arg)*).as_str() )) };