From b6666057df05c53a44cb7e764f8ecdfbb515428d Mon Sep 17 00:00:00 2001 From: brianheineman Date: Sun, 25 Aug 2024 20:34:23 -0600 Subject: [PATCH] feat: add automatic update --- Cargo.lock | 568 ++++++++++++++++++++++++++------------- Cargo.toml | 5 +- rsql_cli/Cargo.toml | 3 +- rsql_cli/locales/app.yml | 196 ++++++++++---- rsql_cli/src/update.rs | 77 ++++-- 5 files changed, 591 insertions(+), 258 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 135b3168..c2e9e666 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -672,6 +672,64 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +[[package]] +name = "axoasset" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45e7b7ac1c1cd4fdcaa2f9e704defa9defd996039083d85e17efa5e8eefb3bd2" +dependencies = [ + "camino", + "image", + "miette", + "mime", + "reqwest", + "serde", + "serde_json", + "thiserror", + "url", + "walkdir", +] + +[[package]] +name = "axoprocess" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4de46920588aef95658797996130bacd542436aee090084646521260a74bda7d" +dependencies = [ + "miette", + "thiserror", + "tracing", +] + +[[package]] +name = "axotag" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d888fac0b73e64cbdf36a743fc5a25af5ae955c357535cb420b389bf1e1a6c54" +dependencies = [ + "miette", + "semver", + "thiserror", +] + +[[package]] +name = "axoupdater" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3adfac228780fcf162617739408bd8edeb1ae1d497c95082759c5e607cac1e71" +dependencies = [ + "axoasset", + "axoprocess", + "axotag", + "camino", + "gazenot", + "homedir", + "miette", + "serde", + "tempfile", + "thiserror", +] + [[package]] name = "axum" version = "0.6.20" @@ -717,6 +775,18 @@ dependencies = [ "tower-service", ] +[[package]] +name = "backon" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d67782c3f868daa71d3533538e98a8e13713231969def7536e8039606fc46bf0" +dependencies = [ + "fastrand 2.1.1", + "futures-core", + "pin-project", + "tokio", +] + [[package]] name = "backtrace" version = "0.3.73" @@ -793,7 +863,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "rustc-hash", + "rustc-hash 1.1.0", "shlex", "syn 2.0.76", "which 4.4.2", @@ -1038,6 +1108,15 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "camino" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3" +dependencies = [ + "serde", +] + [[package]] name = "cast" version = "0.3.0" @@ -1496,6 +1575,22 @@ version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +[[package]] +name = "crossterm" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e64e6c0fbe2c17357405f7c758c1ef960fce08bdfb2c03d88d2a18d7e09c4b67" +dependencies = [ + "bitflags 1.3.2", + "crossterm_winapi", + "libc", + "mio 0.8.11", + "parking_lot 0.12.3", + "signal-hook", + "signal-hook-mio", + "winapi", +] + [[package]] name = "crossterm" version = "0.27.0" @@ -1780,6 +1875,12 @@ dependencies = [ "strum 0.25.0", ] +[[package]] +name = "dyn-clone" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" + [[package]] name = "either" version = "1.13.0" @@ -2201,6 +2302,43 @@ dependencies = [ "slab", ] +[[package]] +name = "fuzzy-matcher" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54614a3312934d066701a80f20f15fa3b56d67ac7722b39eea5b4c9dd1d66c94" +dependencies = [ + "thread_local", +] + +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + +[[package]] +name = "gazenot" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7628c2e8e192258187c04c7632aa417b17d4b290b2c233c5f423c51119018db8" +dependencies = [ + "axoasset", + "backon", + "camino", + "miette", + "schemars", + "serde", + "serde_json", + "thiserror", + "tokio", + "tracing", + "url", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -2412,6 +2550,20 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "homedir" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22074da8bba2ef26fc1737ae6c777b5baab5524c2dc403b5c6a76166766ccda5" +dependencies = [ + "cfg-if", + "nix 0.26.4", + "serde", + "widestring", + "windows-sys 0.48.0", + "wmi", +] + [[package]] name = "http" version = "0.2.12" @@ -2569,25 +2721,6 @@ dependencies = [ "webpki-roots", ] -[[package]] -name = "hyper-rustls" -version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c" -dependencies = [ - "futures-util", - "http 1.1.0", - "hyper 1.4.1", - "hyper-util", - "log", - "rustls 0.22.4", - "rustls-native-certs", - "rustls-pki-types", - "tokio", - "tokio-rustls 0.25.0", - "tower-service", -] - [[package]] name = "hyper-rustls" version = "0.27.2" @@ -2603,6 +2736,7 @@ dependencies = [ "tokio", "tokio-rustls 0.26.0", "tower-service", + "webpki-roots", ] [[package]] @@ -2617,19 +2751,6 @@ dependencies = [ "tokio-io-timeout", ] -[[package]] -name = "hyper-timeout" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3203a961e5c83b6f5498933e78b6b263e208c197b63e9c6c53cc82ffd3f63793" -dependencies = [ - "hyper 1.4.1", - "hyper-util", - "pin-project-lite", - "tokio", - "tower-service", -] - [[package]] name = "hyper-tls" version = "0.6.0" @@ -2801,6 +2922,23 @@ dependencies = [ "generic-array", ] +[[package]] +name = "inquire" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fddf93031af70e75410a2511ec04d49e758ed2f26dad3404a934e0fb45cc12a" +dependencies = [ + "bitflags 2.6.0", + "crossterm 0.25.0", + "dyn-clone", + "fuzzy-matcher", + "fxhash", + "newline-converter", + "once_cell", + "unicode-segmentation", + "unicode-width", +] + [[package]] name = "instant" version = "0.1.13" @@ -2830,16 +2968,6 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" -[[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-terminal" version = "0.4.13" @@ -2931,21 +3059,6 @@ dependencies = [ "serde", ] -[[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 = "kv-log-macro" version = "1.0.7" @@ -3115,7 +3228,7 @@ dependencies = [ "tonic", "tonic-web", "tower", - "tower-http 0.4.4", + "tower-http", "tracing", "uuid", "zerocopy", @@ -3342,6 +3455,15 @@ version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +[[package]] +name = "memoffset" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" +dependencies = [ + "autocfg", +] + [[package]] name = "memoffset" version = "0.9.1" @@ -3351,6 +3473,29 @@ dependencies = [ "autocfg", ] +[[package]] +name = "miette" +version = "7.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4edc8853320c2a0dab800fbda86253c8938f6ea88510dc92c5f1ed20e794afc1" +dependencies = [ + "cfg-if", + "miette-derive", + "thiserror", + "unicode-width", +] + +[[package]] +name = "miette-derive" +version = "7.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.76", +] + [[package]] name = "mime" version = "0.3.17" @@ -3449,6 +3594,15 @@ dependencies = [ "tempfile", ] +[[package]] +name = "newline-converter" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b6b097ecb1cbfed438542d16e84fd7ad9b0c76c8a65b7f9039212a3d14dc7f" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "nibble_vec" version = "0.1.0" @@ -3458,6 +3612,19 @@ dependencies = [ "smallvec", ] +[[package]] +name = "nix" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", + "memoffset 0.7.1", + "pin-utils", +] + [[package]] name = "nix" version = "0.28.0" @@ -3480,7 +3647,7 @@ dependencies = [ "cfg-if", "cfg_aliases 0.2.1", "libc", - "memoffset", + "memoffset 0.9.1", ] [[package]] @@ -3742,45 +3909,6 @@ 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 1.1.0", - "http-body 1.0.1", - "http-body-util", - "hyper 1.4.1", - "hyper-rustls 0.26.0", - "hyper-timeout 0.5.1", - "hyper-util", - "jsonwebtoken", - "once_cell", - "percent-encoding", - "pin-project", - "secrecy", - "serde", - "serde_json", - "serde_path_to_error", - "serde_urlencoded", - "snafu", - "tokio", - "tower", - "tower-http 0.5.2", - "tracing", - "url", -] - [[package]] name = "once_cell" version = "1.19.0" @@ -4056,16 +4184,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" -[[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 = "pem-rfc7468" version = "0.7.0" @@ -4588,6 +4706,54 @@ dependencies = [ "serde", ] +[[package]] +name = "quinn" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b22d8e7369034b9a7132bc2008cac12f2013c8132b45e0554e6e20e2617f2156" +dependencies = [ + "bytes", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash 2.0.0", + "rustls 0.23.12", + "socket2 0.5.7", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "quinn-proto" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba92fb39ec7ad06ca2582c0ca834dfeadcaf06ddfc8e635c80aa7e1c05315fdd" +dependencies = [ + "bytes", + "rand", + "ring", + "rustc-hash 2.0.0", + "rustls 0.23.12", + "slab", + "thiserror", + "tinyvec", + "tracing", +] + +[[package]] +name = "quinn-udp" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bffec3605b73c6f1754535084a85229fa8a30f86014e6c81aeec4abb68b0285" +dependencies = [ + "libc", + "once_cell", + "socket2 0.5.7", + "tracing", + "windows-sys 0.52.0", +] + [[package]] name = "quote" version = "1.0.37" @@ -4768,6 +4934,7 @@ dependencies = [ "http-body 1.0.1", "http-body-util", "hyper 1.4.1", + "hyper-rustls 0.27.2", "hyper-tls", "hyper-util", "ipnet", @@ -4778,13 +4945,17 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", + "quinn", + "rustls 0.23.12", "rustls-pemfile", + "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", "sync_wrapper 1.0.1", "tokio", "tokio-native-tls", + "tokio-rustls 0.26.0", "tokio-util", "tower-service", "url", @@ -4792,6 +4963,7 @@ dependencies = [ "wasm-bindgen-futures", "wasm-streams", "web-sys", + "webpki-roots", "windows-registry", ] @@ -4946,12 +5118,13 @@ name = "rsql_cli" version = "0.13.9" dependencies = [ "anyhow", + "axoupdater", "chrono", "clap", "colored", "dotenvy", "indoc", - "octocrab", + "inquire", "os_info", "rsql_core", "rust-i18n", @@ -5190,6 +5363,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc-hash" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" + [[package]] name = "rustix" version = "0.37.27" @@ -5337,6 +5516,30 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "schemars" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" +dependencies = [ + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.76", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -5349,15 +5552,6 @@ version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" -[[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" @@ -5407,6 +5601,17 @@ dependencies = [ "syn 2.0.76", ] +[[package]] +name = "serde_derive_internals" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.76", +] + [[package]] name = "serde_json" version = "1.0.127" @@ -5420,16 +5625,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_path_to_error" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af99884400da37c88f5e9146b7f1fd0fbcae8f6eec4e9da38b67d05486f814a6" -dependencies = [ - "itoa", - "serde", -] - [[package]] name = "serde_repr" version = "0.1.19" @@ -5611,18 +5806,6 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" -[[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 = "siphasher" version = "0.3.11" @@ -5653,27 +5836,6 @@ dependencies = [ "serde", ] -[[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 0.5.0", - "proc-macro2", - "quote", - "syn 2.0.76", -] - [[package]] name = "socket2" version = "0.4.10" @@ -6197,7 +6359,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c12e6e0bf9bc6ac887681aeddabfcc5dbdea20d3f43d6d18f237c34fe942dde" dependencies = [ "async-std", - "crossterm", + "crossterm 0.27.0", "is-terminal", "thiserror", "winapi", @@ -6631,7 +6793,7 @@ dependencies = [ "http 0.2.12", "http-body 0.4.6", "hyper 0.14.30", - "hyper-timeout 0.4.1", + "hyper-timeout", "percent-encoding", "pin-project", "prost", @@ -6662,7 +6824,7 @@ dependencies = [ "pin-project", "tokio-stream", "tonic", - "tower-http 0.4.4", + "tower-http", "tower-layer", "tower-service", "tracing", @@ -6708,26 +6870,6 @@ dependencies = [ "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 1.1.0", - "http-body 1.0.1", - "http-body-util", - "iri-string", - "pin-project-lite", - "tower", - "tower-layer", - "tower-service", - "tracing", -] - [[package]] name = "tower-layer" version = "0.3.3" @@ -6861,7 +7003,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89daebc3e6fd160ac4aa9fc8b3bf71e1f74fbf92367ae71fb83a037e8bf164b9" dependencies = [ - "memoffset", + "memoffset 0.9.1", "tempfile", "winapi", ] @@ -7220,6 +7362,12 @@ dependencies = [ "web-sys", ] +[[package]] +name = "widestring" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311" + [[package]] name = "winapi" version = "0.3.9" @@ -7251,6 +7399,18 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" +dependencies = [ + "windows-core", + "windows-implement", + "windows-interface", + "windows-targets 0.52.6", +] + [[package]] name = "windows-core" version = "0.52.0" @@ -7260,6 +7420,28 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-implement" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12168c33176773b86799be25e2a2ba07c7aab9968b37541f1094dbd7a60c8946" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.76", +] + +[[package]] +name = "windows-interface" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d8dc32e0095a7eeccebd0e3f09e9509365ecb3fc6ac4d6f5f14a3f6392942d1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.76", +] + [[package]] name = "windows-registry" version = "0.2.0" @@ -7480,6 +7662,20 @@ version = "0.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" +[[package]] +name = "wmi" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc2f0a4062ca522aad4705a2948fd4061b3857537990202a8ddd5af21607f79a" +dependencies = [ + "chrono", + "futures", + "log", + "serde", + "thiserror", + "windows", +] + [[package]] name = "wyz" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index ceba89ca..3fe9177a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ version = "0.13.9" [workspace.dependencies] ansi_colours = "1.2.3" +axoupdater = "0.7.0" anyhow = "1.0.86" arboard = "3.4.0" async-trait = "0.1.81" @@ -34,12 +35,12 @@ duckdb = "1.0.0" form_urlencoded = "1.2.1" futures-util = "0.3.30" indexmap = "2.3.0" -indoc = "2.0.5" indicatif = "0.17.8" +indoc = "2.0.5" +inquire = "0.7.5" libsql = "0.5.0" mockall = "0.13.0" num-format = "0.4.4" -octocrab = "0.39.0" os_info = "3.8.2" postgresql_embedded = "0.16.2" quick-xml = "0.36.1" diff --git a/rsql_cli/Cargo.toml b/rsql_cli/Cargo.toml index a0a65a4f..a7cbba89 100644 --- a/rsql_cli/Cargo.toml +++ b/rsql_cli/Cargo.toml @@ -27,11 +27,12 @@ winres = { version = "0.1" } [dependencies] anyhow = { workspace = true } +axoupdater = { workspace = true } chrono = { workspace = true } clap = { workspace = true, features = ["derive", "env"] } colored = { workspace = true } dotenvy = { workspace = true } -octocrab = { workspace = true } +inquire = { workspace = true } os_info = { workspace = true } rsql_core = { path = "../rsql_core", version = "0.13.9", features = ["all"] } rust-i18n = { workspace = true } diff --git a/rsql_cli/locales/app.yml b/rsql_cli/locales/app.yml index 4d5fa6e8..893d056f 100644 --- a/rsql_cli/locales/app.yml +++ b/rsql_cli/locales/app.yml @@ -53,50 +53,152 @@ banner_message: yi: "טיפ '%{help_command}' פֿאַר הילף, '%{quit_command}' צו פֿאַרלאָזן." zh: "输入 '%{help_command}' 获取帮助,输入 '%{quit_command}' 退出。" -newer_version: - en: "A newer version of rsql is available: %{version}" - ar: "الإصدار الأحدث من rsql متوفر: %{version}" - be: "Даступная новая версія rsql: %{version}" - bg: "Налична е по-нова версия на rsql: %{version}" - bn: "rsql এর নতুন সংস্করণ উপলব্ধ: %{version}" - cs: "Je k dispozici novější verze rsql: %{version}" - da: "En nyere version af rsql er tilgængelig: %{version}" - de: "Eine neuere Version von rsql ist verfügbar: %{version}" - el: "Μια νεότερη έκδοση του rsql είναι διαθέσιμη: %{version}" - es: "Hay disponible una versión más reciente de rsql: %{version}" - et: "rsql uus versioon on saadaval: %{version}" - fi: "Uudempi versio rsql:stä on saatavilla: %{version}" - fr: "Une version plus récente de rsql est disponible: %{version}" - ga: "Tá leagan níos nua de rsql ar fáil: %{version}" - he: "גרסה חדשה יותר של rsql זמינה: %{version}" - hi: "rsql का एक नया संस्करण उपलब्ध है: %{version}" - hr: "Dostupna je novija verzija rsql: %{version}" - hu: "Elérhető a rsql újabb verziója: %{version}" - is: "Nýrri útgáfa af rsql er tiltæk: %{version}" - it: "È disponibile una versione più recente di rsql: %{version}" - ja: "rsql の新しいバージョンが利用可能です: %{version}" - jv: "Versi terbaru rsql tersedia: %{version}" - ka: "rsql-ის ახალი ვერსია ხელმისაწვდომია: %{version}" - ko: "rsql의 새로운 버전이 있습니다: %{version}" - lt: "Yra naujesnė rsql versija: %{version}" - lv: "Ir pieejama jaunāka rsql versija: %{version}" - mk: "Постои нова верзија на rsql: %{version}" - ms: "Versi terkini rsql boleh didapati: %{version}" - mt: "Verżjoni ġdida ta 'rsql hija disponibbli: %{version}" - nl: "Een nieuwere versie van rsql is beschikbaar: %{version}" - no: "En nyere versjon av rsql er tilgjengelig: %{version}" - pl: "Dostępna jest nowsza wersja rsql: %{version}" - pt: "Uma versão mais recente do rsql está disponível: %{version}" - ro: "O versiune mai nouă a rsql este disponibilă: %{version}" - ru: "Доступна более новая версия rsql: %{version}" - sk: "Je k dispozícii novšia verzia rsql: %{version}" - sl: "Na voljo je novejša različica rsql: %{version}" - sq: "Një version më i ri i rsql është i disponueshëm: %{version}" - sr: "Доступна је новија верзија rsql: %{version}" - sv: "En nyare version av rsql är tillgänglig: %{version}" - th: "มีเวอร์ชันใหม่ของ rsql ให้ใช้: %{version}" - tr: "rsql'in daha yeni bir sürümü mevcut: %{version}" - uk: "Доступна новіша версія rsql: %{version}" - vi: "Một phiên bản mới của rsql đã có sẵn: %{version}" - yi: "א נייערע ווערסיע פון rsql איז פֿאַרפירן: %{version}" - zh: "rsql 的新版本可用: %{version}" +update_version_prompt: + en: "A newer version of rsql is available, do you want to update?" + ar: "هناك إصدار أحدث من rsql متاح، هل تريد التحديث؟" + be: "Даступная новая версія rsql, ці жадаеце абнавіць?" + bg: "Налична е по-нова версия на rsql, искате ли да актуализирате?" + bn: "rsql এর একটি নতুন সংস্করণ উপলব্ধ, আপনি কি আপডেট করতে চান?" + cs: "Je k dispozici novější verze rsql, chcete aktualizovat?" + da: "En nyere version af rsql er tilgængelig, vil du opdatere?" + de: "Eine neuere Version von rsql ist verfügbar, möchten Sie aktualisieren?" + el: "Μια νεότερη έκδοση του rsql είναι διαθέσιμη, θέλετε να ενημερώσετε;" + es: "Hay una versión más reciente de rsql disponible, ¿desea actualizar?" + et: "Uuem rsql versioon on saadaval, kas soovite seda uuendada?" + fi: "Uudempi versio rsql:stä on saatavilla, haluatko päivittää?" + fr: "Une version plus récente de rsql est disponible, voulez-vous mettre à jour?" + ga: "Tá leagan níos nua de rsql ar fáil, ar mhaith leat a nuashonrú?" + he: "גרסה חדשה יותר של rsql זמינה, האם ברצונך לעדכן?" + hi: "rsql का एक नया संस्करण उपलब्ध है, क्या आप अपडेट करना चाहते हैं?" + hr: "Dostupna je novija verzija rsql, želite li ažurirati?" + hu: "Elérhető egy újabb verzió a rsql-ből, szeretné frissíteni?" + is: "Nýrri útgáfa af rsql er tiltæk, viltu uppfæra?" + it: "È disponibile una versione più recente di rsql, vuoi aggiornare?" + ja: "rsql の新しいバージョンが利用可能です。更新しますか?" + jv: "Versi anyar saka rsql kasedhiya, apakah sampeyan pengin nganyari?" + ka: "rsql-ის ახალი ვერსია ხელმისაწვდომია, გსურთ განახლება?" + ko: "rsql의 새로운 버전이 있습니다. 업데이트하시겠습니까?" + lt: "Yra naujesnė rsql versija, ar norite atnaujinti?" + lv: "Ir pieejama jaunāka rsql versija, vai vēlaties atjaunināt?" + mk: "Постои нова верзија на rsql, дали сакате да ја ажурирате?" + ms: "Versi terkini rsql boleh didapati, adakah anda ingin mengemas kini?" + mt: "Verżjoni iktar riċenti ta 'rsql huwa disponibbli, tixtieq li t-aġġorna?" + nl: "Er is een nieuwere versie van rsql beschikbaar, wilt u bijwerken?" + no: "En nyere versjon av rsql er tilgjengelig, vil du oppdatere?" + pl: "Dostępna jest nowsza wersja rsql, chcesz zaktualizować?" + pt: "Uma versão mais recente do rsql está disponível, deseja atualizar?" + ro: "O versiune mai nouă a rsql este disponibilă, doriți să actualizați?" + ru: "Доступна более новая версия rsql, хотите обновить?" + sk: "Je k dispozícii novšia verzia rsql, chcete aktualizovať?" + sl: "Na voljo je novejša različica rsql, želite posodobiti?" + sq: "Një version më i ri i rsql është i disponueshëm, a dëshironi të përditësoni?" + sr: "Доступна је новија верзија rsql, желите ли да ажурирате?" + sv: "En nyare version av rsql är tillgänglig, vill du uppdatera?" + th: "มีเวอร์ชันใหม่ของ rsql ที่ใช้ได้ คุณต้องการอัปเดตหรือไม่?" + tr: "rsql'in daha yeni bir sürümü mevcut, güncellemek ister misiniz?" + uk: "Доступна новіша версія rsql, чи хочете оновити?" + vi: "Một phiên bản mới của rsql đã có sẵn, bạn có muốn cập nhật không?" + yi: "אַ נייערע ווערסיע פֿון rsql איז פֿאַרפֿירלעך, ווילן איר אַפּדייטן?" + zh: "rsql 有新版本可用,您要更新吗?" + +update_version_prompt_placeholder: + en: "%{yes}|%{no}" + ar: "%{no}|%{yes}" + he: "%{no}|%{yes}" + yi: "%{no}|%{yes}" + +update_version_prompt_error: + en: "Reply with '%{yes}' or '%{no}'" + ar: "الرد بـ '%{yes}' أو '%{no}'" + be: "Адказваць '%{yes}' ці '%{no}'" + bg: "Отговорете с '%{yes}' или '%{no}'" + bn: "'%{yes}' বা '%{no}' দিয়ে উত্তর দিন" + cs: "Odpovězte '%{yes}' nebo '%{no}'" + da: "Svar med '%{yes}' eller '%{no}'" + de: "Antworte mit '%{yes}' oder '%{no}'" + el: "Απαντήστε με '%{yes}' ή '%{no}'" + es: "Responde con '%{yes}' o '%{no}'" + et: "Vastake '%{yes}' või '%{no}'" + fi: "Vastaa '%{yes}' tai '%{no}'" + fr: "Répondez avec '%{yes}' ou '%{no}'" + ga: "Freagairt le '%{yes}' nó '%{no}'" + he: "השב עם '%{yes}' או '%{no}'" + hi: "'%{yes}' या '%{no}' के साथ जवाब दें" + hr: "Odgovorite s '%{yes}' ili '%{no}'" + hu: "Válaszoljon a '%{yes}' vagy '%{no}'" + is: "Svara með '%{yes}' eða '%{no}'" + it: "Rispondi con '%{yes}' o '%{no}'" + ja: "'%{yes}' または '%{no}' で返信してください" + jv: "Jawab karo '%{yes}' utawa '%{no}'" + ka: "პასუხისთვის გამოიყენეთ '%{yes}' ან '%{no}'" + ko: "'%{yes}' 또는 '%{no}'로 답변하세요" + lt: "Atsakykite su '%{yes}' arba '%{no}'" + lv: "Atbildiet ar '%{yes}' vai '%{no}'" + mk: "Одговорете со '%{yes}' или '%{no}'" + ms: "Jawab dengan '%{yes}' atau '%{no}'" + mt: "Irrispondi '%{yes}' jew '%{no}'" + nl: "Antwoord met '%{yes}' of '%{no}'" + no: "Svar med '%{yes}' eller '%{no}'" + pl: "Odpowiedz '%{yes}' lub '%{no}'" + pt: "Responda com '%{yes}' ou '%{no}'" + ro: "Răspundeți cu '%{yes}' sau '%{no}'" + ru: "Ответьте с '%{yes}' или '%{no}'" + sk: "Odpovedajte s '%{yes}' alebo '%{no}'" + sl: "Odgovorite z '%{yes}' ali '%{no}'" + sq: "Përgjigjuni me '%{yes}' ose '%{no}'" + sr: "Одговорите са '%{yes}' или '%{no}'" + sv: "Svara med '%{yes}' eller '%{no}'" + th: "ตอบด้วย '%{yes}' หรือ '%{no}'" + tr: "'%{yes}' veya '%{no}' ile yanıtlayın" + uk: "Відповідь з '%{yes}' або '%{no}'" + vi: "Trả lời với '%{yes}' hoặc '%{no}'" + yi: "אַנטוואָרט מיט '%{yes}' אָדער '%{no}'" + zh: "回复 '%{yes}' 或 '%{no}'" + +updated_version: + en: "Updated to version %{version}" + ar: "تم التحديث إلى الإصدار %{version}" + be: "Абноўлены да версіі %{version}" + bg: "Актуализиран до версия %{version}" + bn: "সংস্করণ %{version} এ আপডেট করা হয়েছে" + cs: "Aktualizováno na verzi %{version}" + da: "Opdateret til version %{version}" + de: "Aktualisiert auf Version %{version}" + el: "Ενημερώθηκε στην έκδοση %{version}" + es: "Actualizado a la versión %{version}" + et: "Uuendatud versioonile %{version}" + fi: "Päivitetty versioon %{version}" + fr: "Mise à jour vers la version %{version}" + ga: "Nuashonraithe go leagan %{version}" + he: "עודכן לגרסה %{version}" + hi: "संस्करण %{version} में अपडेट किया गया" + hr: "Ažurirano na verziju %{version}" + hu: "Frissítve a(z) %{version} verzióra" + is: "Uppfært í útgáfu %{version}" + it: "Aggiornato alla versione %{version}" + ja: "バージョン %{version} に更新されました" + jv: "Dianyari menyang versi %{version}" + ka: "განახლებულია %{version} ვერსიაზე" + ko: "버전 %{version}로 업데이트되었습니다" + lt: "Atnaujinta iki versijos %{version}" + lv: "Atjaunināts līdz versijai %{version}" + mk: "Ажурирано на верзија %{version}" + ms: "Dikemaskini ke versi %{version}" + mt: "Aġġornat għal-verżjoni %{version}" + nl: "Bijgewerkt naar versie %{version}" + no: "Oppdatert til versjon %{version}" + pl: "Zaktualizowano do wersji %{version}" + pt: "Atualizado para a versão %{version}" + ro: "Actualizat la versiunea %{version}" + ru: "Обновлено до версии %{version}" + sk: "Aktualizované na verziu %{version}" + sl: "Posodobljeno na različico %{version}" + sq: "I përditësuar në versionin %{version}" + sr: "Ажурирано на верзију %{version}" + sv: "Uppdaterad till version %{version}" + th: "อัพเดทเป็นเวอร์ชัน %{version}" + tr: "Sürüm %{version} olarak güncellendi" + uk: "Оновлено до версії %{version}" + vi: "Đã cập nhật lên phiên bản %{version}" + yi: "אַפּדייטעד צו ווערסיע %{version}" + zh: "已更新到版本 %{version}" diff --git a/rsql_cli/src/update.rs b/rsql_cli/src/update.rs index f178b5fe..e7d5af7f 100644 --- a/rsql_cli/src/update.rs +++ b/rsql_cli/src/update.rs @@ -1,10 +1,11 @@ use anyhow::Result; +use axoupdater::AxoUpdater; use chrono::{DateTime, Duration, Utc}; +use inquire::ui::RenderConfig; +use inquire::Confirm; use rsql_core::configuration::Configuration; -use semver::Version; use std::fs::{create_dir_all, File}; use std::io::{Read, Write}; -use tracing::debug; const UPDATE_CHECK_FILE: &str = "last_update_check"; @@ -44,30 +45,62 @@ pub async fn check_for_newer_version( return Ok(()); } - let current = Version::parse(&configuration.version)?; - let release = match octocrab::instance() - .repos("theseus-rs", "rsql") - .releases() - .get_latest() - .await - { - Ok(release) => release, - Err(error) => { - debug!("Failed to get latest release: {error:?}"); - return Ok(()); - } - }; - let latest = Version::parse(release.tag_name.trim_start_matches('v'))?; - - if latest > current { + let mut updater = AxoUpdater::new_for("rsql_cli"); + updater.disable_installer_output(); + let receipt = updater.load_receipt()?; + if receipt.is_update_needed().await? { let locale = configuration.locale.as_str(); - let newer_version = t!( - "newer_version", + let no = t!("no", locale = locale).to_lowercase(); + let yes = t!("yes", locale = locale).to_string(); + let update_version_prompt = t!("update_version_prompt", locale = locale); + let update_version_prompt_placeholder = t!( + "update_version_prompt_placeholder", + locale = locale, + yes = yes, + no = no, + ); + let update_version_prompt_error = t!( + "update_version_prompt_error", locale = locale, - version = latest.to_string() + yes = yes, + no = no, ); - writeln!(output, "{newer_version}")?; + let confirm = Confirm { + message: &update_version_prompt, + starting_input: None, + default: Some(true), + placeholder: Some(&*update_version_prompt_placeholder), + help_message: None, + formatter: &|answer| { + if answer { + yes.to_string() + } else { + no.to_string() + } + }, + parser: &|answer| Ok(answer == yes), + error_message: update_version_prompt_error.to_string(), + default_value_formatter: &|default| { + if default { + yes.to_string() + } else { + no.to_string() + } + }, + render_config: RenderConfig::default(), + }; + + if !confirm.prompt()? { + return Ok(()); + } + + let update_result = receipt.run().await?; + if let Some(result) = update_result { + let version = result.new_version; + let updated_version = t!("updated_version", locale = locale, version = version,); + writeln!(output, "{updated_version}")?; + } } Ok(())