From 2daf82be566f8034f4320f135667432abcaa57b1 Mon Sep 17 00:00:00 2001 From: Thumus Date: Fri, 23 Aug 2024 02:04:59 +0200 Subject: [PATCH] add(features) + refactor(unlink + bulk_delete): Features to compile everything from hand + unlink and bulk_delete simplify --- Cargo.lock | 808 ++++++++++++++++++++++++---- Cargo.toml | 44 +- src/ci.rs | 21 - src/commands.rs | 100 +++- src/commands/add.rs | 6 +- src/commands/bulk_delete.rs | 28 +- src/commands/delete.rs | 4 +- src/commands/{create.rs => init.rs} | 4 +- src/commands/install.rs | 4 +- src/commands/link.rs | 4 +- src/commands/publish.rs | 4 +- src/commands/unlink.rs | 115 ++-- src/main.rs | 84 ++- src/utils.rs | 13 +- src/utils/macros.rs | 33 +- src/utils/specs.rs | 4 - src/utils/state.rs | 3 + 17 files changed, 999 insertions(+), 280 deletions(-) delete mode 100644 src/ci.rs rename src/commands/{create.rs => init.rs} (99%) diff --git a/Cargo.lock b/Cargo.lock index c3f5cb5..abb9703 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +dependencies = [ + "gimli", +] + [[package]] name = "adler" version = "1.0.2" @@ -29,6 +38,12 @@ 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" @@ -96,6 +111,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "arc-swap" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" + [[package]] name = "arrayref" version = "0.3.8" @@ -108,6 +129,17 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +[[package]] +name = "async-trait" +version = "0.1.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "autocfg" version = "1.3.0" @@ -120,6 +152,27 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b7e4c2464d97fe331d41de9d5db0def0a96f4d823b8b32a2efd503578988973" +[[package]] +name = "backtrace" +version = "0.3.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + [[package]] name = "base64" version = "0.22.1" @@ -218,6 +271,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" +[[package]] +name = "bytes" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" + [[package]] name = "cc" version = "1.1.7" @@ -252,6 +311,19 @@ version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7588475145507237ded760e52bf2f1085495245502033756d28ea72ade0e498b" +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "num-traits", + "serde", + "windows-targets 0.52.6", +] + [[package]] name = "ciborium" version = "0.2.2" @@ -308,7 +380,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.1", + "strsim", ] [[package]] @@ -329,7 +401,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.72", + "syn", ] [[package]] @@ -376,7 +448,7 @@ checksum = "c8936e42f9b4f5bdfaf23700609ac1f11cb03ad4c1ec128a4ee4fd0903e228db" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn", ] [[package]] @@ -473,7 +545,7 @@ dependencies = [ "bitflags 1.3.2", "crossterm_winapi", "libc", - "mio", + "mio 0.8.11", "parking_lot", "signal-hook", "signal-hook-mio", @@ -516,41 +588,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "darling" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim 0.10.0", - "syn 1.0.109", -] - -[[package]] -name = "darling_macro" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" -dependencies = [ - "darling_core", - "quote", - "syn 1.0.109", -] - [[package]] name = "data-url" version = "0.3.1" @@ -595,7 +632,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn", ] [[package]] @@ -657,7 +694,7 @@ checksum = "0d28318a75d4aead5c4db25382e8ef717932d0346600cacae6357eb5941bc5ff" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn", ] [[package]] @@ -798,6 +835,95 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-executor" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-macro" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + [[package]] name = "getrandom" version = "0.2.15" @@ -805,8 +931,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi", + "wasm-bindgen", ] [[package]] @@ -819,6 +947,12 @@ dependencies = [ "weezl", ] +[[package]] +name = "gimli" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" + [[package]] name = "git2" version = "0.19.0" @@ -893,6 +1027,123 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" + +[[package]] +name = "hyper" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c" +dependencies = [ + "futures-util", + "http", + "hyper", + "hyper-util", + "log", + "rustls", + "rustls-native-certs", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", +] + +[[package]] +name = "hyper-timeout" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3203a961e5c83b6f5498933e78b6b263e208c197b63e9c6c53cc82ffd3f63793" +dependencies = [ + "hyper", + "hyper-util", + "pin-project-lite", + "tokio", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "pin-project-lite", + "socket2", + "tokio", + "tower", + "tower-service", + "tracing", +] + [[package]] name = "hypher" version = "0.1.5" @@ -1044,7 +1295,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn", ] [[package]] @@ -1070,12 +1321,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f739ee737260d955e330bc83fdeaaf1631f7fb7ed218761d3c04bb13bb7d79df" -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - [[package]] name = "idna" version = "0.5.0" @@ -1163,6 +1408,16 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "iri-string" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f5f6c2df22c009ac44f6f1499308e7a3ac7ba42cd2378475cc691510e1eef1b" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "is_debug" version = "1.0.1" @@ -1199,6 +1454,21 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "jsonwebtoken" +version = "9.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ae10193d25051e74945f1ea2d0b42e03cc3b890f7e4cc5faa44997d808193f" +dependencies = [ + "base64 0.21.7", + "js-sys", + "pem", + "ring", + "serde", + "serde_json", + "simple_asn1", +] + [[package]] name = "kamadak-exif" version = "0.5.5" @@ -1371,6 +1641,18 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "mio" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +dependencies = [ + "hermit-abi", + "libc", + "wasi", + "windows-sys 0.52.0", +] + [[package]] name = "multi-stash" version = "0.2.0" @@ -1443,7 +1725,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn", ] [[package]] @@ -1479,6 +1761,54 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e25be21376a772d15f97ae789845340a9651d3c4246ff5ebb6a2b35f9c37bd31" +[[package]] +name = "object" +version = "0.36.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9" +dependencies = [ + "memchr", +] + +[[package]] +name = "octocrab" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9305e4c99543ecd0f42bd659c9e9d6ca7115fe5e37d5c85a7277b1db0d4c4101" +dependencies = [ + "arc-swap", + "async-trait", + "base64 0.22.1", + "bytes", + "cfg-if", + "chrono", + "either", + "futures", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-timeout", + "hyper-util", + "jsonwebtoken", + "once_cell", + "percent-encoding", + "pin-project", + "secrecy", + "serde", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "snafu", + "tokio", + "tower", + "tower-http", + "tracing", + "url", +] + [[package]] name = "once_cell" version = "1.19.0" @@ -1508,7 +1838,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn", ] [[package]] @@ -1572,7 +1902,7 @@ dependencies = [ "by_address", "proc-macro2", "quote", - "syn 2.0.72", + "syn", ] [[package]] @@ -1604,6 +1934,16 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +[[package]] +name = "pem" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" +dependencies = [ + "base64 0.22.1", + "serde", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -1640,7 +1980,7 @@ dependencies = [ "phf_shared", "proc-macro2", "quote", - "syn 2.0.72", + "syn", ] [[package]] @@ -1658,12 +1998,38 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" +[[package]] +name = "pin-project" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "pin-project-lite" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + [[package]] name = "pkg-config" version = "0.3.30" @@ -1676,7 +2042,7 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42cf17e9a1800f5f396bc67d193dc9411b59012a5876445ef450d449881e1016" dependencies = [ - "base64", + "base64 0.22.1", "indexmap", "quick-xml 0.32.0", "serde", @@ -1874,12 +2240,33 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.52.0", +] + [[package]] name = "roxmltree" version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97" +[[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.34" @@ -1893,6 +2280,60 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rustls" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" +dependencies = [ + "log", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-native-certs" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04182dffc9091a404e0fc069ea5cd60e5b866c3adf881eff99a32d048242dffa" +dependencies = [ + "openssl-probe", + "rustls-pemfile", + "rustls-pki-types", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pemfile" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" +dependencies = [ + "base64 0.22.1", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" + +[[package]] +name = "rustls-webpki" +version = "0.102.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e6b52d4fda176fd835fdc55a835d4a89b8499cad995885a21149d5ad62f852e" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "rustversion" version = "1.0.17" @@ -1945,6 +2386,15 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "secrecy" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bd1c54ea06cfd2f6b63219704de0b9b4f72dcc2b8fdef820be6cd799780e91e" +dependencies = [ + "zeroize", +] + [[package]] name = "security-framework" version = "2.11.1" @@ -1994,7 +2444,7 @@ checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn", ] [[package]] @@ -2010,34 +2460,34 @@ dependencies = [ ] [[package]] -name = "serde_spanned" -version = "0.6.7" +name = "serde_path_to_error" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" +checksum = "af99884400da37c88f5e9146b7f1fd0fbcae8f6eec4e9da38b67d05486f814a6" dependencies = [ + "itoa", "serde", ] [[package]] -name = "serde_with" -version = "1.14.0" +name = "serde_spanned" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678b5a069e50bf00ecd22d0cd8ddf7c236f68581b03db652061ed5eb13a312ff" +checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" dependencies = [ "serde", - "serde_with_macros", ] [[package]] -name = "serde_with_macros" -version = "1.5.2" +name = "serde_urlencoded" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e182d6ec6f05393cc0e5ed1bf81ad6db3a8feedf8ee515ecdd369809bcce8082" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 1.0.109", + "form_urlencoded", + "itoa", + "ryu", + "serde", ] [[package]] @@ -2092,7 +2542,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd" dependencies = [ "libc", - "mio", + "mio 0.8.11", "signal-hook", ] @@ -2111,6 +2561,18 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" +[[package]] +name = "simple_asn1" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" +dependencies = [ + "num-bigint", + "num-traits", + "thiserror", + "time", +] + [[package]] name = "simplecss" version = "0.2.1" @@ -2132,6 +2594,15 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + [[package]] name = "slotmap" version = "1.0.7" @@ -2147,6 +2618,37 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +[[package]] +name = "snafu" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b835cb902660db3415a672d862905e791e54d306c6e8189168c7f3d9ae1c79d" +dependencies = [ + "snafu-derive", +] + +[[package]] +name = "snafu-derive" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d1e02fca405f6280643174a50c942219f0bbf4dbf7d480f1dd864d6f211ae5" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "socket2" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "spdx" version = "0.10.6" @@ -2201,12 +2703,6 @@ dependencies = [ "serde", ] -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - [[package]] name = "strsim" version = "0.11.1" @@ -2232,9 +2728,15 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.72", + "syn", ] +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + [[package]] name = "svgtypes" version = "0.15.1" @@ -2245,17 +2747,6 @@ dependencies = [ "siphasher 1.0.1", ] -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.72" @@ -2275,7 +2766,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn", ] [[package]] @@ -2347,7 +2838,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn", ] [[package]] @@ -2430,6 +2921,44 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +[[package]] +name = "tokio" +version = "1.39.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5" +dependencies = [ + "backtrace", + "libc", + "mio 1.0.2", + "pin-project-lite", + "socket2", + "windows-sys 0.52.0", +] + +[[package]] +name = "tokio-rustls" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" +dependencies = [ + "rustls", + "rustls-pki-types", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + [[package]] name = "toml" version = "0.8.19" @@ -2464,12 +2993,62 @@ dependencies = [ "winnow", ] +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-http" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" +dependencies = [ + "bitflags 2.6.0", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "iri-string", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + [[package]] name = "tracing" version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ + "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -2483,7 +3062,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn", ] [[package]] @@ -2521,6 +3100,12 @@ dependencies = [ "tracing-log", ] +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + [[package]] name = "ttf-parser" version = "0.21.1" @@ -2642,7 +3227,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.72", + "syn", ] [[package]] @@ -2838,13 +3423,19 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9df2af067a7953e9c3831320f35c1cc0600c30d44d9f7a12b01db1cd88d6b47" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "ureq" version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b74fc6b57825be3373f7054754755f03ac3a8f5d70015ccad699ba2029956f4a" dependencies = [ - "base64", + "base64 0.22.1", "flate2", "log", "native-tls", @@ -2872,7 +3463,7 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b84ea542ae85c715f07b082438a4231c3760539d902e11d093847a0b22963032" dependencies = [ - "base64", + "base64 0.22.1", "data-url", "flate2", "fontdb", @@ -2915,15 +3506,13 @@ dependencies = [ "git2", "ignore", "inquire", + "octocrab", "openssl", "regex", "semver", "serde", - "serde_json", - "serde_with", "shadow-rs", "spdx", - "strum", "toml", "tracing", "tracing-subscriber", @@ -2960,6 +3549,15 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -2987,7 +3585,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.72", + "syn", "wasm-bindgen-shared", ] @@ -3009,7 +3607,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3324,7 +3922,7 @@ checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn", "synstructure", ] @@ -3346,7 +3944,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn", ] [[package]] @@ -3366,10 +3964,16 @@ checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn", "synstructure", ] +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + [[package]] name = "zerotrie" version = "0.1.3" @@ -3402,7 +4006,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index a27828d..d40f90a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,26 +8,24 @@ edition = "2021" [dependencies] dirs = "5.0" -serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } -serde_with = "1.0" toml = { version = "^0.8.14", features = ["display"] } -inquire = "0.6.2" +inquire = { version = "0.6.2", optional=true } semver = { version = "1.0.18", features = ["serde"] } -spdx = { version = "0.10.2", features = ["text"] } +spdx = { version = "0.10.2", features = ["text"], optional = true } clap = { version = "4.4.2", features = ["derive"] } -git2 = "^0.19.0" -strum = { version = "0.26.2", features = ["derive"] } +git2 = { version = "^0.19.0", optional = true } typst-project = { git = "https://github.com/tingerrr/typst-project", rev = "8462942ef0c783acf339e715b5e24b2dba423de1" } -openssl = { version = "0.10", features = ["vendored"] } +openssl = { version = "0.10", features = ["vendored"] } # ? tracing = { version = "0.1.40", features = ["attributes"] } tracing-subscriber = "0.3.18" -clap_complete = "4.5.12" +clap_complete = { version = "4.5.12", optional = true } shadow-rs = "0.31.1" typst-kit = { git = "https://github.com/typst/typst" } -typst-syntax = { git = "https://github.com/typst/typst" } -regex = "1.10.6" -ignore = "0.4.22" +typst-syntax = { git = "https://github.com/typst/typst", optional = true } +regex = { version = "1.10.6", optional = true } +ignore = { version = "0.4.22", optional = true } +octocrab = { version = "0.39.0", optional = true } [build-dependencies] shadow-rs = "0.31.1" @@ -37,14 +35,26 @@ name = "utpm" path = "src/main.rs" build = "build.rs" -[[bin]] -name = "utpm-ci" -path = "src/ci.rs" -build = "build.rs" - [features] -ci = [] +default = ["full"] nightly = [] +full = ["workspace", "packages", "generate"] +add = ["install"] +bulk_delete = ["unlink"] +clone = ["dep:regex", "dep:git2", "dep:typst-syntax"] +init = ["dep:spdx", "dep:inquire"] +delete = [] +generate = ["dep:clap_complete"] +install = ["link", "dep:git2"] +link = [] +list = [] +path = [] +publish = ["dep:git2", "dep:octocrab", "dep:ignore"] +tree = [] +unlink = ["dep:inquire", "dep:regex"] +workspace = ["link", "init", "install", "add", "delete", "publish", "clone"] +packages = ["tree", "list", "path", "unlink", "bulk_delete"] + # For future dependencies check and other things, it will be usefull # Reduce size diff --git a/src/ci.rs b/src/ci.rs deleted file mode 100644 index ccee3ce..0000000 --- a/src/ci.rs +++ /dev/null @@ -1,21 +0,0 @@ -use shadow_rs::shadow; -use std::env; -shadow!(build); -use commands::InstallArgs; - -#[allow(unused)] -mod commands; - -#[allow(unused)] -mod utils; - -/// Simple version of a ci installer -fn main() { - let args: Vec = env::args().collect(); - let force = args.contains(&"--force".to_string()) || args.contains(&"-f".to_string()); - let install = InstallArgs { url: None, force }; - match commands::install::run(&install) { - Err(err) => println!("{}", err.to_string()), - Ok(_) => println!("Everything is good to go!"), - } -} diff --git a/src/commands.rs b/src/commands.rs index 3563be0..903e54a 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1,29 +1,47 @@ // Linker +#[cfg(feature = "add")] pub mod add; +#[cfg(feature = "bulk_delete")] pub mod bulk_delete; +#[cfg(feature = "clone")] pub mod clone; -pub mod create; +#[cfg(feature = "delete")] pub mod delete; +#[cfg(feature = "generate")] pub mod generate; +#[cfg(feature = "init")] +pub mod init; +#[cfg(feature = "install")] pub mod install; +#[cfg(feature = "link")] pub mod link; +#[cfg(feature = "list")] pub mod list; +#[cfg(feature = "path")] pub mod package_path; +#[cfg(feature = "publish")] pub mod publish; +#[cfg(feature = "tree")] pub mod tree; +#[cfg(feature = "unlink")] pub mod unlink; +#[cfg(any(feature = "clone", feature = "publish"))] use std::path::PathBuf; use clap::{Parser, Subcommand}; +#[cfg(feature = "generate")] use clap_complete::Shell; use tracing::level_filters::LevelFilter; + +#[cfg(feature = "init")] use typst_project::manifest::{categories::Category, disciplines::Discipline}; use crate::build; #[derive(Parser, Clone, Debug, PartialEq)] -pub struct CreateInitArgs { +#[cfg(feature = "init")] +pub struct InitArgs { /// Desactivate interactive session #[arg(short = 'm', long, requires = "ni")] cli: bool, @@ -106,6 +124,7 @@ pub struct CreateInitArgs { } #[derive(Parser, Clone, Debug, PartialEq)] +#[cfg(feature = "link")] pub struct LinkArgs { /// Force the copy of the dir / creation of the symlink #[arg(short, long)] @@ -117,6 +136,7 @@ pub struct LinkArgs { } #[derive(Parser, Clone, Debug, PartialEq)] +#[cfg(any(feature = "list", feature = "tree"))] pub struct ListTreeArgs { /// Will list all packages including @preview #[arg(short, long)] @@ -128,6 +148,7 @@ pub struct ListTreeArgs { } #[derive(Parser, Clone, Debug, PartialEq)] +#[cfg(feature = "publish")] pub struct PublishArgs { #[arg()] path: Option, @@ -157,6 +178,7 @@ pub struct PublishArgs { } #[derive(Parser, Clone, Debug, PartialEq)] +#[cfg(feature = "generate")] pub struct GenerateArgs { /// The type of your shell #[arg(value_enum)] @@ -164,6 +186,7 @@ pub struct GenerateArgs { } #[derive(Parser, Clone, Debug, PartialEq)] +#[cfg(feature = "clone")] pub struct CloneArgs { /// The name of the package you want to clone #[arg()] @@ -191,21 +214,10 @@ pub struct CloneArgs { } #[derive(Parser, Clone, Debug, PartialEq)] +#[cfg(feature = "unlink")] pub struct UnlinkArgs { /// The name of the package - name: Option, - - /// Namespace, where your packages are install (default local) - #[arg(short, long)] - namespace: Option, - - /// Do you want to delete the namespace or not - #[arg(short, long)] - delete_namespace: bool, - - /// The version you want to delete, if nothing has been provided it will be the whole package - #[arg(short, long)] - version: Option, + package: String, /// Confirm the deletion of a dir #[arg(short, long)] @@ -213,6 +225,7 @@ pub struct UnlinkArgs { } #[derive(Parser, Clone, Debug, PartialEq)] +#[cfg(feature = "bulk_delete")] pub struct BulkDeleteArgs { /// Names of your packages, use version with this syntax: mypackage:1.0.0 #[clap(value_delimiter = ',')] @@ -224,6 +237,7 @@ pub struct BulkDeleteArgs { } #[derive(Parser, Clone, Debug, PartialEq)] +#[cfg(feature = "install")] pub struct InstallArgs { /// If you want to install a specific package #[arg(num_args = 1..)] @@ -235,12 +249,14 @@ pub struct InstallArgs { } #[derive(Parser, Clone, Debug, PartialEq)] +#[cfg(feature = "delete")] pub struct DeleteArgs { /// URIs to remove. pub uri: Vec, } #[derive(Parser, Clone, Debug, PartialEq)] +#[cfg(feature = "add")] pub struct AddArgs { /// The url or path of your repository. pub uri: Vec, @@ -248,60 +264,84 @@ pub struct AddArgs { /// Commands to use packages related to typst #[derive(Subcommand, Debug, PartialEq)] +#[cfg(any( + feature = "tree", + feature = "list", + feature = "path", + feature = "unlink", + feature = "bulk_delete" +))] pub enum Packages { /// List all of packages from your dir, in a form of a tree #[command(visible_alias = "t")] + #[cfg(feature = "tree")] Tree(ListTreeArgs), /// List all of packages from your dir, in a form of a list #[command(visible_alias = "l")] + #[cfg(feature = "list")] List(ListTreeArgs), /// Display path to typst packages folder #[command(visible_alias = "p")] + #[cfg(feature = "path")] Path, /// Delete package previously install with utpm #[command(visible_alias = "u")] + #[cfg(feature = "unlink")] Unlink(UnlinkArgs), #[command(visible_alias = "bd")] + #[cfg(feature = "bulk_delete")] BulkDelete(BulkDeleteArgs), } /// Commands to create, edit, delete your workspace for your package. #[derive(Subcommand, Debug, PartialEq)] +#[cfg(any( + feature = "link", + feature = "init", + feature = "install", + feature = "add", + feature = "delete", + feature = "init", + feature = "publish", + feature = "clone" +))] pub enum Workspace { /// Link your project to your dirs #[command(visible_alias = "l")] + #[cfg(feature = "link")] Link(LinkArgs), - /// Create a file for your project (typst.toml) - /// (deprecated, use `utpm workspace init`) - #[command(visible_alias = "c")] - Create(CreateInitArgs), - /// Install all dependencies from the `typst.toml` #[command(visible_alias = "i")] + #[cfg(feature = "install")] Install(InstallArgs), /// Add dependencies and then install them #[command(visible_alias = "a")] + #[cfg(feature = "add")] Add(AddArgs), /// Delete dependencies #[command(visible_alias = "d")] + #[cfg(feature = "delete")] Delete(DeleteArgs), /// Create your workspace to start a typst package - Init(CreateInitArgs), + #[cfg(feature = "init")] + Init(InitArgs), /// WIP #[command(visible_alias = "p")] + #[cfg(feature = "publish")] Publish(PublishArgs), /// WIP #[command()] + #[cfg(feature = "clone")] Clone(CloneArgs), } @@ -309,14 +349,32 @@ pub enum Workspace { pub enum Commands { #[command(subcommand)] #[command(visible_alias = "ws")] + #[cfg(any( + feature = "link", + feature = "init", + feature = "install", + feature = "add", + feature = "delete", + feature = "init", + feature = "publish", + feature = "clone" + ))] Workspace(Workspace), #[command(subcommand)] #[command(visible_alias = "pkg")] + #[cfg(any( + feature = "tree", + feature = "list", + feature = "path", + feature = "unlink", + feature = "bulk_delete" + ))] Packages(Packages), /// Generate shell completion #[command(visible_alias = "gen")] + #[cfg(feature = "generate")] Generate(GenerateArgs), } diff --git a/src/commands/add.rs b/src/commands/add.rs index b4feb69..8424a36 100644 --- a/src/commands/add.rs +++ b/src/commands/add.rs @@ -5,7 +5,7 @@ use tracing::{debug, instrument, trace}; use typst_project::manifest::{tool::Tool, Manifest}; use crate::{ - manifest, + load_manifest, utils::{ paths::get_current_dir, specs::Extra, @@ -18,7 +18,7 @@ use super::{install, AddArgs, InstallArgs}; #[instrument] pub fn run(cmd: &mut AddArgs) -> Result { - let mut config: Manifest = manifest!(); + let mut config: Manifest = load_manifest!(); if cmd.uri.len() == 0 { debug!("0 URI found in cmd.uri"); return Err(Error::new( @@ -39,7 +39,7 @@ pub fn run(cmd: &mut AddArgs) -> Result { for e in &cmd.uri { match dependencies.iter().position(|x| x == e) { Some(_) => { - trace!("{} dependency already in the manifest, skipping", e); + trace!("{} dependency already in the load_manifest skipping", e); } None => { trace!("{} added", e); diff --git a/src/commands/bulk_delete.rs b/src/commands/bulk_delete.rs index 20857bb..451f064 100644 --- a/src/commands/bulk_delete.rs +++ b/src/commands/bulk_delete.rs @@ -1,4 +1,4 @@ -use tracing::{error, instrument}; +use tracing::{error, info, instrument}; use crate::utils::state::{Error, Result}; @@ -6,28 +6,18 @@ use super::{unlink, BulkDeleteArgs, UnlinkArgs}; #[instrument] pub fn run(cmd: &BulkDeleteArgs) -> Result { - //todo: regex let mut vec: Vec = Vec::new(); for name in &cmd.names { - let name_and_version = name - .split(":") - .map(|a| a.to_string()) - .collect::>(); - let ulnk = UnlinkArgs { - delete_namespace: false, - name: Some(name_and_version[0].to_owned()), + match unlink::run(&UnlinkArgs { + package: name.into(), yes: true, - namespace: cmd.namespace.to_owned(), - version: if name_and_version.len() > 1 { - Some(semver::Version::parse(name_and_version[1].as_str())?) - } else { - None - }, - }; - match unlink::run(&ulnk) { - Ok(_) => (), + }) { + Ok(_) => { + info!("- {name} deleted"); + } Err(err) => { - error!("{}", err); + info!("X {name} not found"); + error!("{err}"); vec.push(err); } }; diff --git a/src/commands/delete.rs b/src/commands/delete.rs index 936e050..c7790be 100644 --- a/src/commands/delete.rs +++ b/src/commands/delete.rs @@ -5,7 +5,7 @@ use tracing::instrument; use typst_project::manifest::Manifest; use crate::{ - manifest, + load_manifest, utils::{ paths::get_current_dir, specs::Extra, @@ -18,7 +18,7 @@ use super::DeleteArgs; #[instrument(skip(cmd))] pub fn run(cmd: &mut DeleteArgs) -> Result { - let mut config = manifest!(); + let mut config = load_manifest!(); if let Some(mut tool) = config.clone().tool { if let Some(ex) = tool.keys.get("utpm") { diff --git a/src/commands/create.rs b/src/commands/init.rs similarity index 99% rename from src/commands/create.rs rename to src/commands/init.rs index 9cc644e..67e5060 100644 --- a/src/commands/create.rs +++ b/src/commands/init.rs @@ -33,10 +33,10 @@ use crate::{ write_manifest, }; -use super::CreateInitArgs; +use super::InitArgs; #[instrument(skip(cmd))] -pub fn run(cmd: &mut CreateInitArgs) -> Result { +pub fn run(cmd: &mut InitArgs) -> Result { let curr = get_current_dir()?; info!("Current dir: {}", curr); let typ = curr.clone() + MANIFEST_FILE; diff --git a/src/commands/install.rs b/src/commands/install.rs index d0b9180..007833d 100644 --- a/src/commands/install.rs +++ b/src/commands/install.rs @@ -2,7 +2,7 @@ use std::{env, fs, path::Path}; use crate::{ commands::LinkArgs, - manifest, + load_manifest, utils::{ copy_dir_all, paths::{ @@ -94,7 +94,7 @@ pub fn init(cmd: &InstallArgs, i: usize) -> Result { println!("{}", format!("x {}", origin)); return Ok(false); } - let file = manifest!(&path); + let file = load_manifest!(&path); let utpm = if let Some(value) = file.tool { value.get_section("utpm")?.unwrap_or(Extra::default()) } else { diff --git a/src/commands/link.rs b/src/commands/link.rs index f0f7a06..9697314 100644 --- a/src/commands/link.rs +++ b/src/commands/link.rs @@ -3,7 +3,7 @@ use tracing::instrument; use typst_project::manifest::Manifest; use crate::{ - manifest, + load_manifest, utils::{ copy_dir_all, paths::{c_packages, check_path_dir, d_packages, get_current_dir}, @@ -19,7 +19,7 @@ use super::LinkArgs; pub fn run(cmd: &LinkArgs, path: Option, pt: bool) -> Result { let curr = path.unwrap_or(get_current_dir()?); - let config = manifest!(&curr); + let config = load_manifest!(&curr); let namespace = if let Some(value) = config.tool { value .get_section("utpm")? diff --git a/src/commands/publish.rs b/src/commands/publish.rs index f3a08ac..f027488 100644 --- a/src/commands/publish.rs +++ b/src/commands/publish.rs @@ -7,7 +7,7 @@ use std::fs::{copy, create_dir_all}; use std::path::{Path, PathBuf}; use std::result::Result as R; -use crate::manifest; +use crate::load_manifest; use crate::utils::paths::{ check_path_file, default_typst_packages, get_ssh_dir, has_content, TYPST_PACKAGE_URL, }; @@ -24,7 +24,7 @@ use ignore::WalkBuilder; #[instrument(skip(cmd))] pub fn run(cmd: &PublishArgs) -> Result { //todo: github create fork if not exist, link to local packages, create PR, git push (VIA GITHUB AHAHAHHA), - let config: Manifest = manifest!(); + let config: Manifest = load_manifest!(); info!("Manifest load"); diff --git a/src/commands/unlink.rs b/src/commands/unlink.rs index 76b5b0f..9be8b59 100644 --- a/src/commands/unlink.rs +++ b/src/commands/unlink.rs @@ -1,88 +1,53 @@ use inquire::Confirm; use std::fs; -use tracing::instrument; - -use crate::utils::{ - paths::d_packages, - state::{Error, ErrorKind, Result}, +use tracing::{info, instrument}; + +use crate::{ + format_package, + utils::{ + paths::{c_packages, d_packages}, + regex_namespace, regex_package, regex_packagename, + state::{Error, ErrorKind, Result}, + }, }; use super::UnlinkArgs; #[instrument(skip(cmd))] pub fn run(cmd: &UnlinkArgs) -> Result { - let mut new_namespace = String::from("local"); - if let Some(nspace) = &cmd.namespace { - new_namespace = nspace.to_owned(); + let packages = &cmd.package; + + // RegEx + let re_all = regex_package(); + let re_name = regex_packagename(); + let re_namespace = regex_namespace(); + let path: String; + if let Some(cap) = re_all.captures(packages.as_str()) { + let (_, [namespace, package, major, minor, patch]) = cap.extract(); + path = format_package!(namespace, package, major, minor, patch); + } else if let Some(cap) = re_name.captures(packages.as_str()) { + let (_, [namespace, package]) = cap.extract(); + path = format_package!(namespace, package); + } else if let Some(cap) = re_namespace.captures(packages.as_str()) { + let (_, [namespace]) = cap.extract(); + path = format_package!(namespace); + } else { + return Err(Error::empty(ErrorKind::PackageNotValid)); } - if let Some(ver) = &cmd.version { - if cmd.name.is_none() { - return Err(Error::empty(ErrorKind::Namespace)); - } - let ans = if !(cmd.yes) { - Confirm::new("Are you sure to delete this? This is irreversible.") - .with_help_message( - format!( - "You want to erase {}/{}", - cmd.name.clone().unwrap(), - ver.to_string() - ) - .as_str(), - ) - .prompt() - } else { - Ok(true) - }; - - let bool = ans?; - if !bool { - return Ok(false); - } - - fs::remove_dir_all( - d_packages()? - + format!( - "/{}/{}/{}", - new_namespace, - cmd.name.clone().unwrap(), - ver.to_string() - ) - .as_str(), - )?; - } else if cmd.delete_namespace { - let ans = if !(cmd.yes) { - Confirm::new("Are you sure to delete this? This is irreversible.") - .with_help_message( - format!("You want to erase @{new_namespace}, the namespace").as_str(), - ) - .prompt() - } else { - Ok(true) - }; - let bool = ans?; - if !bool { - return Ok(false); + if !cmd.yes { + match Confirm::new("Are you sure to delete this? This is irreversible.") + .with_help_message(format!("You want to delete {packages}").as_str()) + .prompt() + { + Ok(_) => { + fs::remove_dir_all(path)?; + Ok(true) + } + Err(_) => Ok(false), } - - fs::remove_dir_all(d_packages()? + format!("/{new_namespace}").as_str())?; - } else if let Some(nm) = &cmd.name { - let ans = if !(cmd.yes) { - Confirm::new("Are you sure to delete this? This is irreversible.") - .with_help_message(format!("You want to erase {}", nm).as_str()) - .prompt() - } else { - Ok(true) - }; - - let bool = ans?; - if !bool { - return Ok(false); - } - - fs::remove_dir_all(d_packages()? + format!("/{}/{}", new_namespace, nm).as_str())?; + } else { + fs::remove_dir_all(path)?; + Ok(true) } - println!("{}", "Removed!"); - - Ok(true) } diff --git a/src/main.rs b/src/main.rs index 9afa66f..79e5d01 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,10 +7,53 @@ pub mod utils; use std::{env, str::FromStr}; use clap::Parser; -use commands::{ - add, bulk_delete, clone, create, delete, generate, install, link, list, package_path, publish, - tree, unlink, Cli, Commands, Packages, Workspace, -}; +#[cfg(feature = "add")] +use commands::add; +#[cfg(feature = "bulk_delete")] +use commands::bulk_delete; +#[cfg(feature = "clone")] +use commands::clone; +#[cfg(feature = "delete")] +use commands::delete; +#[cfg(feature = "generate")] +use commands::generate; +#[cfg(feature = "init")] +use commands::init; +#[cfg(feature = "install")] +use commands::install; +#[cfg(feature = "link")] +use commands::link; +#[cfg(feature = "list")] +use commands::list; +#[cfg(feature = "path")] +use commands::package_path; +#[cfg(feature = "publish")] +use commands::publish; +#[cfg(feature = "tree")] +use commands::tree; +#[cfg(feature = "unlink")] +use commands::unlink; +#[cfg(any( + feature = "tree", + feature = "list", + feature = "path", + feature = "unlink", + feature = "bulk_delete" +))] +use commands::Packages; +//todo: workspace +#[cfg(any( + feature = "link", + feature = "init", + feature = "install", + feature = "add", + feature = "delete", + feature = "init", + feature = "publish", + feature = "clone" +))] +use commands::Workspace; +use commands::{Cli, Commands}; use utils::state::Error; @@ -42,24 +85,53 @@ fn main() { .init(); let res: Result = match &x.command { + #[cfg(any( + feature = "link", + feature = "init", + feature = "install", + feature = "add", + feature = "delete", + feature = "init", + feature = "publish", + feature = "clone" + ))] Commands::Workspace(w) => match w { + #[cfg(feature = "link")] Workspace::Link(cmd) => link::run(cmd, None, true), - Workspace::Create(cmd) => create::run(&mut cmd.clone()), + #[cfg(feature = "install")] Workspace::Install(cmd) => install::run(cmd), + #[cfg(feature = "add")] Workspace::Add(cmd) => add::run(&mut cmd.clone()), + #[cfg(feature = "delete")] Workspace::Delete(cmd) => delete::run(&mut cmd.clone()), - Workspace::Init(cmd) => create::run(&mut cmd.clone()), + #[cfg(feature = "init")] + Workspace::Init(cmd) => init::run(&mut cmd.clone()), + #[cfg(feature = "publish")] Workspace::Publish(cmd) => publish::run(cmd), + #[cfg(feature = "clone")] Workspace::Clone(cmd) => clone::run(cmd), }, + #[cfg(any( + feature = "tree", + feature = "list", + feature = "path", + feature = "unlink", + feature = "bulk_delete" + ))] Commands::Packages(p) => match p { // Maybe a move command to change namespace? Or name or version + #[cfg(feature = "tree")] Packages::Tree(cmd) => tree::run(cmd), + #[cfg(feature = "list")] Packages::List(cmd) => list::run(cmd), + #[cfg(feature = "path")] Packages::Path => package_path::run(), + #[cfg(feature = "unlink")] Packages::Unlink(cmd) => unlink::run(cmd), + #[cfg(feature = "bulk_delete")] Packages::BulkDelete(cmd) => bulk_delete::run(cmd), }, + #[cfg(feature = "generate")] Commands::Generate(cmd) => generate::run(cmd), }; diff --git a/src/utils.rs b/src/utils.rs index 66f0aab..3ae5177 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -2,6 +2,7 @@ use std::{fs, path::Path}; use std::io; +#[cfg(any(feature = "clone", feature = "publish", feature = "unlink"))] use regex::Regex; use typst_kit::download::{DownloadState, Progress}; @@ -47,8 +48,18 @@ pub fn symlink_all( symlink_dir(origin, new_path) } +#[cfg(any(feature = "clone", feature = "publish", feature = "unlink"))] pub fn regex_package() -> Regex { - Regex::new(r"@([a-z]+)\/([a-z]+(?:\-[a-z]+)?)\:(\d+)\.(\d+)\.(\d+)").unwrap() + Regex::new(r"^@([a-z]+)\/([a-z]+(?:\-[a-z]+)?)\:(\d+)\.(\d+)\.(\d+)$").unwrap() +} +#[cfg(any(feature = "unlink"))] +pub fn regex_namespace() -> Regex { + Regex::new(r"^@([a-z]+)$").unwrap() +} + +#[cfg(any(feature = "unlink"))] +pub fn regex_packagename() -> Regex { + Regex::new(r"^@([a-z]+)\/([a-z]+(?:\-[a-z]+)?)$").unwrap() } //todo: impl diff --git a/src/utils/macros.rs b/src/utils/macros.rs index e1719ac..438789b 100644 --- a/src/utils/macros.rs +++ b/src/utils/macros.rs @@ -1,5 +1,5 @@ #[macro_export] -macro_rules! manifest { +macro_rules! load_manifest { () => { match Manifest::try_find(get_current_dir()?)? { Some(val) => Ok(val), @@ -25,3 +25,34 @@ macro_rules! write_manifest { fs::write("./typst.toml", tomlfy)? }; } + +#[macro_export] +macro_rules! format_package { + ($namespace:expr) => {{ + (format!( + "{}/{}", + if $namespace == "preview" { + info!("preview found, cache dir use"); + c_packages()? + } else { + info!("no preview found, data dir use"); + d_packages()? + }, + $namespace + )) + }}; + + ($namespace:expr, $package:expr) => {{ + (format!("{}/{}", format_package!($namespace), $package)) + }}; + + ($namespace:ident, $package:ident, $major:ident, $minor:ident, $patch:ident) => {{ + (format!( + "{}/{}.{}.{}", + format_package!($namespace, $package), + $major, + $minor, + $patch + )) + }}; +} diff --git a/src/utils/specs.rs b/src/utils/specs.rs index 7791341..a370198 100644 --- a/src/utils/specs.rs +++ b/src/utils/specs.rs @@ -25,7 +25,3 @@ impl Extra { } } } - -// #[derive(Debug, ValueEnum, Serialize, Deserialize, Clone, PartialEq, Eq, EnumString)] -// #[strum(serialize_all = "lowercase")] -// #[clap(rename_all = "lower")] diff --git a/src/utils/state.rs b/src/utils/state.rs index 64d3661..08e080e 100644 --- a/src/utils/state.rs +++ b/src/utils/state.rs @@ -129,7 +129,9 @@ macro_rules! impl_from { }; } impl_from!(semver::Error => SemVer); +#[cfg(any(feature = "install", feature = "clone", feature = "publish"))] impl_from!(git2::Error => Git); +#[cfg(any(feature = "init", feature = "unlink"))] impl_from!(inquire::InquireError => Questions); impl_from!(IError => IO); impl_from!(typst_project::manifest::Error => General); @@ -142,4 +144,5 @@ impl_from!(typst_project::manifest::license::ParseLicenseError => License); impl_from!(toml::ser::Error => Serialize); impl_from!(toml::de::Error => Deserialize); +#[cfg(any(feature = "publish"))] impl_from!(ignore::Error => General);