From a2aa661f6335253cc4656f22152f89a534804648 Mon Sep 17 00:00:00 2001 From: Tsiry Sandratraina Date: Tue, 20 Aug 2024 22:53:48 +0000 Subject: [PATCH 1/3] feat: add new terminal ui --- Cargo.lock | 439 ++++++++++++++++++++++++++++++++++++- crates/cli/src/cmd/call.rs | 2 +- crates/ext/Cargo.toml | 1 + crates/ext/src/lib.rs | 125 ++++++++++- 4 files changed, 556 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3bd6e3e..b1be0fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -154,7 +154,7 @@ dependencies = [ "actix-utils", "futures-core", "futures-util", - "mio", + "mio 1.0.2", "socket2", "tokio", "tracing", @@ -1620,6 +1620,31 @@ version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +[[package]] +name = "crossterm" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2102ea4f781910f8a5b98dd061f4c2023f479ce7bb1236330099ceb5a93cf17" +dependencies = [ + "bitflags 1.3.2", + "crossterm_winapi", + "libc", + "mio 0.8.11", + "parking_lot", + "signal-hook 0.3.17", + "signal-hook-mio", + "winapi", +] + +[[package]] +name = "crossterm_winapi" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" +dependencies = [ + "winapi", +] + [[package]] name = "crypto-bigint" version = "0.4.9" @@ -1662,6 +1687,16 @@ dependencies = [ "subtle", ] +[[package]] +name = "csscolorparser" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb2a7d3066da2de787b7f032c736763eb7ae5d355f81a68bab2675a96008b0bf" +dependencies = [ + "lab", + "phf 0.11.2", +] + [[package]] name = "darling" version = "0.20.10" @@ -1706,6 +1741,12 @@ dependencies = [ "uuid", ] +[[package]] +name = "deltae" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5729f5117e208430e437df2f4843f5e5952997175992d1414f94c57d61e270b4" + [[package]] name = "der" version = "0.6.1" @@ -2097,6 +2138,23 @@ dependencies = [ "subtle", ] +[[package]] +name = "filedescriptor" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7199d965852c3bac31f779ef99cbb4537f80e952e2d6aa0ffeb30cce00f4f46e" +dependencies = [ + "libc", + "thiserror", + "winapi", +] + +[[package]] +name = "finl_unicode" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6" + [[package]] name = "fix-hidden-lifetime-bug" version = "0.2.7" @@ -2117,6 +2175,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + [[package]] name = "flate2" version = "1.0.31" @@ -2212,6 +2276,7 @@ dependencies = [ "regex", "sha2 0.10.8", "sha256", + "superconsole", "tokio", "users", ] @@ -3144,6 +3209,12 @@ dependencies = [ "simple_asn1", ] +[[package]] +name = "lab" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf36173d4167ed999940f804952e6b08197cae5ad5d572eb4db150ce8ad5d58f" + [[package]] name = "language-tags" version = "0.3.2" @@ -3342,6 +3413,21 @@ dependencies = [ "rustix", ] +[[package]] +name = "memmem" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a64a92489e2744ce060c349162be1c5f33c6969234104dbd99ddb5feb08b8c15" + +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + [[package]] name = "memoffset" version = "0.9.1" @@ -3385,6 +3471,18 @@ dependencies = [ "adler", ] +[[package]] +name = "mio" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +dependencies = [ + "libc", + "log 0.4.22", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys 0.48.0", +] + [[package]] name = "mio" version = "1.0.2" @@ -3442,6 +3540,28 @@ dependencies = [ "fluentci-types 0.1.8", ] +[[package]] +name = "nix" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", + "memoffset 0.6.5", +] + +[[package]] +name = "nom" +version = "5.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08959a387a676302eebf4ddbcbc611da04285579f76f88ee0506c63b1a61dd4b" +dependencies = [ + "memchr", + "version_check", +] + [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -3469,6 +3589,17 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +[[package]] +name = "num-derive" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "num-integer" version = "0.1.46" @@ -3695,6 +3826,15 @@ dependencies = [ "num-traits", ] +[[package]] +name = "ordered-float" +version = "3.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1e1c390732d15f1d48471625cd92d154e66db2c56645e29a9cd26f4699f72dc" +dependencies = [ + "num-traits", +] + [[package]] name = "ordered-float" version = "4.2.2" @@ -3842,6 +3982,76 @@ dependencies = [ "sha2 0.10.8", ] +[[package]] +name = "phf" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" +dependencies = [ + "phf_shared 0.10.0", +] + +[[package]] +name = "phf" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" +dependencies = [ + "phf_macros", + "phf_shared 0.11.2", +] + +[[package]] +name = "phf_codegen" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8d39688d359e6b34654d328e262234662d16cc0f60ec8dcbe5e718709342a5a" +dependencies = [ + "phf_generator", + "phf_shared 0.11.2", +] + +[[package]] +name = "phf_generator" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" +dependencies = [ + "phf_shared 0.11.2", + "rand 0.8.5", +] + +[[package]] +name = "phf_macros" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" +dependencies = [ + "phf_generator", + "phf_shared 0.11.2", + "proc-macro2", + "quote", + "syn 2.0.75", +] + +[[package]] +name = "phf_shared" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" +dependencies = [ + "siphasher", +] + +[[package]] +name = "phf_shared" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" +dependencies = [ + "siphasher", +] + [[package]] name = "pin-project" version = "1.1.5" @@ -4489,7 +4699,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver", + "semver 1.0.23", ] [[package]] @@ -4693,12 +4903,30 @@ dependencies = [ "libc", ] +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser", +] + [[package]] name = "semver" version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + [[package]] name = "serde" version = "1.0.208" @@ -4858,6 +5086,37 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "signal-hook" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e31d442c16f047a671b5a71e2161d6e68814012b7f5379d269ebd915fac2729" +dependencies = [ + "libc", + "signal-hook-registry", +] + +[[package]] +name = "signal-hook" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" +dependencies = [ + "libc", + "signal-hook-registry", +] + +[[package]] +name = "signal-hook-mio" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd" +dependencies = [ + "libc", + "mio 0.8.11", + "signal-hook 0.3.17", +] + [[package]] name = "signal-hook-registry" version = "1.4.2" @@ -4888,6 +5147,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "siphasher" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" + [[package]] name = "slab" version = "0.4.9" @@ -5002,6 +5267,22 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" +[[package]] +name = "superconsole" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20777fe7e41fb5125474b25d165835c59acd7d756454beae8ad27bbc585896b6" +dependencies = [ + "anyhow", + "crossbeam-channel", + "crossbeam-epoch", + "crossterm", + "itertools 0.10.5", + "termwiz", + "thiserror", + "unicode-segmentation", +] + [[package]] name = "syn" version = "1.0.109" @@ -5101,6 +5382,70 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "terminfo" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da31aef70da0f6352dbcb462683eb4dd2bfad01cf3fc96cf204547b9a839a585" +dependencies = [ + "dirs 4.0.0", + "fnv", + "nom", + "phf 0.11.2", + "phf_codegen", +] + +[[package]] +name = "termios" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "411c5bf740737c7918b8b1fe232dca4dc9f8e754b8ad5e20966814001ed0ac6b" +dependencies = [ + "libc", +] + +[[package]] +name = "termwiz" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25e302bfaa2555ca7fb55eee19051ad43e510153b19cb880d6da5acb65a72ab9" +dependencies = [ + "anyhow", + "base64 0.13.1", + "bitflags 1.3.2", + "cfg-if", + "filedescriptor", + "finl_unicode", + "fixedbitset", + "hex", + "lazy_static", + "libc", + "log 0.4.22", + "memmem", + "nix 0.24.3", + "num-derive", + "num-traits", + "ordered-float 3.9.2", + "pest", + "pest_derive", + "phf 0.10.1", + "regex", + "semver 0.11.0", + "sha2 0.9.9", + "signal-hook 0.1.17", + "siphasher", + "terminfo", + "termios", + "thiserror", + "ucd-trie", + "unicode-segmentation", + "vtparse", + "wezterm-bidi", + "wezterm-color-types", + "wezterm-dynamic 0.1.0", + "winapi", +] + [[package]] name = "textwrap" version = "0.16.1" @@ -5216,7 +5561,7 @@ dependencies = [ "backtrace", "bytes", "libc", - "mio", + "mio 1.0.2", "parking_lot", "pin-project-lite", "signal-hook-registry", @@ -5545,6 +5890,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-segmentation" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" + [[package]] name = "unicode-width" version = "0.1.13" @@ -5630,6 +5981,12 @@ dependencies = [ "log 0.4.22", ] +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "uuid" version = "1.10.0" @@ -5679,6 +6036,15 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c3082ca00d5a5ef149bb8b555a72ae84c9c59f7250f013ac822ac2e49b19c64" +[[package]] +name = "vtparse" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d9b2acfb050df409c972a37d3b8e08cdea3bddb0c09db9d53137e504cfabed0" +dependencies = [ + "utf8parse", +] + [[package]] name = "waker-fn" version = "1.2.0" @@ -5840,7 +6206,7 @@ dependencies = [ "bitflags 2.6.0", "hashbrown 0.14.5", "indexmap 2.4.0", - "semver", + "semver 1.0.23", "serde", ] @@ -5877,7 +6243,7 @@ dependencies = [ "log 0.4.22", "mach2", "memfd", - "memoffset", + "memoffset 0.9.1", "object", "once_cell", "paste", @@ -5885,7 +6251,7 @@ dependencies = [ "psm", "rayon", "rustix", - "semver", + "semver 1.0.23", "serde", "serde_derive", "serde_json", @@ -6173,6 +6539,65 @@ dependencies = [ "rustls-pki-types", ] +[[package]] +name = "wezterm-bidi" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0a6e355560527dd2d1cf7890652f4f09bb3433b6aadade4c9b5ed76de5f3ec" +dependencies = [ + "log 0.4.22", + "wezterm-dynamic 0.2.0", +] + +[[package]] +name = "wezterm-color-types" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6e7a483dd2785ba72705c51e8b1be18300302db2a78368dac9bc8773857777" +dependencies = [ + "csscolorparser", + "deltae", + "lazy_static", + "wezterm-dynamic 0.1.0", +] + +[[package]] +name = "wezterm-dynamic" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75e78c0cc60a76de5d93f9dad05651105351e151b6446ab305514945d7588aa" +dependencies = [ + "log 0.4.22", + "ordered-float 3.9.2", + "strsim 0.10.0", + "thiserror", + "wezterm-dynamic-derive", +] + +[[package]] +name = "wezterm-dynamic" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfb128bacfa86734e07681fb6068e34c144698e84ee022d6e009145d1abb77b5" +dependencies = [ + "log 0.4.22", + "ordered-float 4.2.2", + "strsim 0.10.0", + "thiserror", + "wezterm-dynamic-derive", +] + +[[package]] +name = "wezterm-dynamic-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c9f5ef318442d07b3d071f9f43ea40b80992f87faee14bb4d017b6991c307f0" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "wiggle" version = "22.0.0" @@ -6478,7 +6903,7 @@ dependencies = [ "id-arena", "indexmap 2.4.0", "log 0.4.22", - "semver", + "semver 1.0.23", "serde", "serde_derive", "serde_json", diff --git a/crates/cli/src/cmd/call.rs b/crates/cli/src/cmd/call.rs index 4f40c38..b63bd5a 100644 --- a/crates/cli/src/cmd/call.rs +++ b/crates/cli/src/cmd/call.rs @@ -143,7 +143,7 @@ pub fn call(module: &str, command: &str) -> Result<(), Error> { let args = command.split_whitespace().skip(1).collect::>(); let args = args.join(" "); match plugin.call::<&str, &str>(func, &args) { - Ok(res) => println!("{}", res), + Ok(_) => {} Err(err) => { println!("{}", err); std::process::exit(1); diff --git a/crates/ext/Cargo.toml b/crates/ext/Cargo.toml index 9b45bc0..4698d01 100644 --- a/crates/ext/Cargo.toml +++ b/crates/ext/Cargo.toml @@ -27,5 +27,6 @@ owo-colors = "4.0.0" regex = "1.10.3" sha2 = "0.10.8" sha256 = "1.5.0" +superconsole = "0.2.0" tokio = {version = "1.36.0", features = ["tokio-macros", "macros", "rt", "rt-multi-thread"]} users = "0.11.0" diff --git a/crates/ext/src/lib.rs b/crates/ext/src/lib.rs index 68aa229..c9fda56 100644 --- a/crates/ext/src/lib.rs +++ b/crates/ext/src/lib.rs @@ -1,12 +1,18 @@ use std::{ + env, io::{BufRead, BufReader}, process::{Command, ExitStatus, Stdio}, sync::mpsc::{self, Receiver, Sender}, thread, + time::Instant, }; use anyhow::Error; use fluentci_types::Output; +use owo_colors::OwoColorize; +use superconsole::{ + style::Stylize, Component, Dimensions, DrawMode, Line, Lines, Span, SuperConsole, +}; pub mod archive; pub mod cache; @@ -74,18 +80,82 @@ pub fn exec( let namespace = cmd.to_string().clone(); thread::spawn(move || { + if let Some(mut console) = SuperConsole::new() { + if env::var("FLUENTCI_CONSOLE").unwrap_or_default() == "0" { + let mut stdout = String::new(); + while let Ok(line) = stdout_rx.recv() { + println!("{}", line); + match fluentci_logging::info(&line, &namespace) { + Ok(_) => {} + Err(_) => {} + } + stdout.push_str(&line); + stdout.push_str("\n"); + } + + if out_clone == Output::Stdout && last_cmd { + match tx_clone.send(stdout) { + Ok(_) => {} + Err(_) => {} + } + } + return; + } + let created = Instant::now(); + let mut stdout = String::new(); + let mut lines = vec![]; + while let Ok(line) = stdout_rx.recv() { + lines.push(line.clone()); + if lines.len() > 15 { + lines.remove(0); + } + + console + .render(&Log { + command: &namespace, + lines: lines.clone(), + created, + now: Instant::now(), + }) + .unwrap(); + match fluentci_logging::info(&line, &namespace) { + Ok(_) => {} + Err(e) => { + println!("Error: {}", e); + } + } + stdout.push_str(&line); + stdout.push_str("\n"); + } + + console + .finalize(&Log { + command: &namespace, + lines: vec![], + created, + now: Instant::now(), + }) + .unwrap(); + if out_clone == Output::Stdout && last_cmd { + match tx_clone.send(stdout) { + Ok(_) => {} + Err(_) => {} + } + } + return; + } + let mut stdout = String::new(); while let Ok(line) = stdout_rx.recv() { println!("{}", line); match fluentci_logging::info(&line, &namespace) { Ok(_) => {} - Err(e) => { - println!("Error: {}", e); - } + Err(_) => {} } stdout.push_str(&line); stdout.push_str("\n"); } + if out_clone == Output::Stdout && last_cmd { match tx_clone.send(stdout) { Ok(_) => {} @@ -131,3 +201,52 @@ pub fn exec( child.wait().map_err(Error::from) } + +struct Log<'a> { + command: &'a str, + lines: Vec, + created: Instant, + now: Instant, +} + +impl<'a> Component for Log<'a> { + fn draw_unchecked(&self, _dimensions: Dimensions, mode: DrawMode) -> anyhow::Result { + Ok(match mode { + DrawMode::Normal => { + let elapsed = self.now.duration_since(self.created).as_millis(); + let mut lines: Vec = self + .lines + .iter() + .map(|l| vec![l.clone()].try_into().unwrap()) + .collect(); + lines.push( + vec![format!( + "Executing {} {}{}", + self.command.bright_purple(), + (elapsed as f64 / 1000.0).to_string().magenta(), + "s".magenta() + )] + .try_into() + .unwrap(), + ); + Lines(lines) + } + DrawMode::Final => { + const FINISHED: &str = " Finished "; + let finished = Span::new_styled(FINISHED.to_owned().green().bold())?; + let completion = format!( + "{} in {}{}", + self.command.bright_purple(), + (self.now.duration_since(self.created).as_millis() as f64 / 1000.0) + .to_string() + .magenta(), + "s".magenta() + ); + Lines(vec![Line::from_iter([ + finished, + Span::new_unstyled(&completion)?, + ])]) + } + }) + } +} From c790d87c6da096a38c8d43edbec3388167f47631 Mon Sep 17 00:00:00 2001 From: Tsiry Sandratraina Date: Tue, 20 Aug 2024 23:01:42 +0000 Subject: [PATCH 2/3] bump version code print error --- Cargo.lock | 14 +++++++------- README.md | 4 ++-- crates/cli/Cargo.toml | 10 +++++----- crates/common/Cargo.toml | 6 +++--- crates/core/Cargo.toml | 4 ++-- crates/ext/Cargo.toml | 2 +- crates/ext/src/lib.rs | 4 +++- crates/graphql/Cargo.toml | 8 ++++---- crates/server/Cargo.toml | 8 ++++---- crates/shared/Cargo.toml | 8 ++++---- 10 files changed, 35 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b1be0fa..295bd0a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2201,7 +2201,7 @@ dependencies = [ [[package]] name = "fluentci-common" -version = "0.2.7" +version = "0.2.8" dependencies = [ "anyhow", "dirs 5.0.1", @@ -2216,7 +2216,7 @@ dependencies = [ [[package]] name = "fluentci-core" -version = "0.3.6" +version = "0.3.7" dependencies = [ "anyhow", "chrono", @@ -2241,7 +2241,7 @@ dependencies = [ [[package]] name = "fluentci-engine" -version = "0.4.8" +version = "0.4.9" dependencies = [ "anyhow", "clap", @@ -2259,7 +2259,7 @@ dependencies = [ [[package]] name = "fluentci-ext" -version = "0.2.5" +version = "0.2.6" dependencies = [ "anyhow", "async-trait", @@ -2283,7 +2283,7 @@ dependencies = [ [[package]] name = "fluentci-graphql" -version = "0.3.7" +version = "0.3.8" dependencies = [ "anyhow", "async-graphql", @@ -2357,7 +2357,7 @@ dependencies = [ [[package]] name = "fluentci-server" -version = "0.3.7" +version = "0.3.8" dependencies = [ "actix-cors", "actix-web", @@ -2374,7 +2374,7 @@ dependencies = [ [[package]] name = "fluentci-shared" -version = "0.2.7" +version = "0.2.8" dependencies = [ "anyhow", "extism", diff --git a/README.md b/README.md index 01f6b83..02546ce 100644 --- a/README.md +++ b/README.md @@ -59,8 +59,8 @@ cargo run -p fluentci-engine -- serve ## 📦 Downloads -- `Mac`: arm64: [fluentci-engine_v0.4.8_aarch64-apple-darwin.tar.gz](https://github.com/fluentci-io/fluentci-engine/releases/download/v0.4.8/fluentci-engine_v0.4.8_aarch64-apple-darwin.tar.gz) intel: [fluentci-engine_v0.4.8_x86_64-apple-darwin.tar.gz](https://github.com/fluentci-io/fluentci-engine/releases/download/v0.4.8/fluentci-engine_v0.4.8_x86_64-apple-darwin.tar.gz) -- `Linux`: intel: [fluentci-engine_v0.4.8_x86_64-unknown-linux-gnu.tar.gz](https://github.com/fluentci-io/fluentci-engine/releases/download/v0.4.8/fluentci-engine_v0.4.8_x86_64-unknown-linux-gnu.tar.gz) arm64: [fluentci-engine_v0.4.8_aarch64-unknown-linux-gnu.tar.gz](https://github.com/fluentci-io/fluentci-engine/releases/download/v0.4.8/fluentci-engine_v0.4.8_aarch64-unknown-linux-gnu.tar.gz) +- `Mac`: arm64: [fluentci-engine_v0.4.9_aarch64-apple-darwin.tar.gz](https://github.com/fluentci-io/fluentci-engine/releases/download/v0.4.9/fluentci-engine_v0.4.9_aarch64-apple-darwin.tar.gz) intel: [fluentci-engine_v0.4.9_x86_64-apple-darwin.tar.gz](https://github.com/fluentci-io/fluentci-engine/releases/download/v0.4.9/fluentci-engine_v0.4.9_x86_64-apple-darwin.tar.gz) +- `Linux`: intel: [fluentci-engine_v0.4.9_x86_64-unknown-linux-gnu.tar.gz](https://github.com/fluentci-io/fluentci-engine/releases/download/v0.4.9/fluentci-engine_v0.4.9_x86_64-unknown-linux-gnu.tar.gz) arm64: [fluentci-engine_v0.4.9_aarch64-unknown-linux-gnu.tar.gz](https://github.com/fluentci-io/fluentci-engine/releases/download/v0.4.9/fluentci-engine_v0.4.9_aarch64-unknown-linux-gnu.tar.gz) ## 📚 Documentation diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index da9d2da..e66146b 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -8,7 +8,7 @@ license = "MPL-2.0" name = "fluentci-engine" readme = "../../README.md" repository = "https://github.com/fluentci-io/fluentci-engine" -version = "0.4.8" +version = "0.4.9" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -16,10 +16,10 @@ version = "0.4.8" anyhow = "1.0.81" clap = "3.2.20" extism = "1.2.0" -fluentci-core = {path = "../core", version = "0.3.6"} -fluentci-ext = {path = "../ext", version = "0.2.5"} -fluentci-server = {path = "../server", version = "0.3.7"} -fluentci-shared = {path = "../shared", version = "0.2.7"} +fluentci-core = {path = "../core", version = "0.3.7"} +fluentci-ext = {path = "../ext", version = "0.2.6"} +fluentci-server = {path = "../server", version = "0.3.8"} +fluentci-shared = {path = "../shared", version = "0.2.8"} get-port = "4.0.0" md5 = "0.7.0" regex = "1.10.3" diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 0f31767..43db5fd 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -7,15 +7,15 @@ keywords = ["nix", "environment", "ci", "wasm", "devops"] license = "MPL-2.0" name = "fluentci-common" repository = "https://github.com/fluentci-io/fluentci-engine" -version = "0.2.7" +version = "0.2.8" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] anyhow = "1.0.81" dirs = "5.0.1" -fluentci-core = {path = "../core", version = "0.3.6"} -fluentci-ext = {path = "../ext", version = "0.2.5"} +fluentci-core = {path = "../core", version = "0.3.7"} +fluentci-ext = {path = "../ext", version = "0.2.6"} fluentci-secrets = {path = "../secrets", version = "0.1.0"} fluentci-types = {path = "../types", version = "0.1.8"} regex = "1.10.4" diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index 22ddb5f..a4d2fae 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -7,7 +7,7 @@ keywords = ["nix", "environment", "ci", "wasm", "devops"] license = "MPL-2.0" name = "fluentci-core" repository = "https://github.com/fluentci-io/fluentci-engine" -version = "0.3.6" +version = "0.3.7" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -15,7 +15,7 @@ version = "0.3.6" anyhow = "1.0.81" chrono = "0.4.35" dirs = "5.0.1" -fluentci-ext = {path = "../ext", version = "0.2.5"} +fluentci-ext = {path = "../ext", version = "0.2.6"} fluentci-logging = {path = "../logging", version = "0.1.0"} fluentci-secrets = {path = "../secrets", version = "0.1.0"} fluentci-types = {path = "../types", version = "0.1.8"} diff --git a/crates/ext/Cargo.toml b/crates/ext/Cargo.toml index 4698d01..1baf8b8 100644 --- a/crates/ext/Cargo.toml +++ b/crates/ext/Cargo.toml @@ -7,7 +7,7 @@ keywords = ["nix", "environment", "ci", "wasm", "devops"] license = "MPL-2.0" name = "fluentci-ext" repository = "https://github.com/fluentci-io/fluentci-engine" -version = "0.2.5" +version = "0.2.6" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/ext/src/lib.rs b/crates/ext/src/lib.rs index c9fda56..3c45e39 100644 --- a/crates/ext/src/lib.rs +++ b/crates/ext/src/lib.rs @@ -150,7 +150,9 @@ pub fn exec( println!("{}", line); match fluentci_logging::info(&line, &namespace) { Ok(_) => {} - Err(_) => {} + Err(e) => { + println!("Error: {}", e); + } } stdout.push_str(&line); stdout.push_str("\n"); diff --git a/crates/graphql/Cargo.toml b/crates/graphql/Cargo.toml index 8b2828f..65b0968 100644 --- a/crates/graphql/Cargo.toml +++ b/crates/graphql/Cargo.toml @@ -7,7 +7,7 @@ keywords = ["nix", "environment", "ci", "wasm", "devops"] license = "MPL-2.0" name = "fluentci-graphql" repository = "https://github.com/fluentci-io/fluentci-engine" -version = "0.3.7" +version = "0.3.8" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -16,9 +16,9 @@ anyhow = "1.0.80" async-graphql = "7.0.2" async-graphql-actix-web = "7.0.2" dirs = "5.0.1" -fluentci-common = {path = "../common", version = "0.2.7"} -fluentci-core = {path = "../core", version = "0.3.6"} -fluentci-ext = {path = "../ext", version = "0.2.5"} +fluentci-common = {path = "../common", version = "0.2.8"} +fluentci-core = {path = "../core", version = "0.3.7"} +fluentci-ext = {path = "../ext", version = "0.2.6"} fluentci-secrets = {path = "../secrets", version = "0.1.0"} fluentci-types = {path = "../types", version = "0.1.8"} regex = "1.10.3" diff --git a/crates/server/Cargo.toml b/crates/server/Cargo.toml index 6457a31..a23970a 100644 --- a/crates/server/Cargo.toml +++ b/crates/server/Cargo.toml @@ -7,7 +7,7 @@ keywords = ["nix", "environment", "ci", "wasm", "devops"] license = "MPL-2.0" name = "fluentci-server" repository = "https://github.com/fluentci-io/fluentci-engine" -version = "0.3.7" +version = "0.3.8" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -17,9 +17,9 @@ actix-web = "4.5.1" anyhow = "1.0.81" async-graphql = "7.0.2" async-graphql-actix-web = "7.0.2" -fluentci-core = {path = "../core", version = "0.3.6"} -fluentci-ext = {path = "../ext", version = "0.2.5"} -fluentci-graphql = {path = "../graphql", version = "0.3.7"} +fluentci-core = {path = "../core", version = "0.3.7"} +fluentci-ext = {path = "../ext", version = "0.2.6"} +fluentci-graphql = {path = "../graphql", version = "0.3.8"} mime_guess = "2.0.4" owo-colors = "4.0.0" tokio = "1.36.0" diff --git a/crates/shared/Cargo.toml b/crates/shared/Cargo.toml index f4b6850..7cf0c89 100644 --- a/crates/shared/Cargo.toml +++ b/crates/shared/Cargo.toml @@ -7,7 +7,7 @@ keywords = ["nix", "environment", "ci", "wasm", "devops"] license = "MPL-2.0" name = "fluentci-shared" repository = "https://github.com/fluentci-io/fluentci-engine" -version = "0.2.7" +version = "0.2.8" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -15,9 +15,9 @@ version = "0.2.7" anyhow = "1.0.82" extism = "1.2.0" extism-pdk = "1.1.0" -fluentci-common = {path = "../common", version = "0.2.7"} -fluentci-core = {path = "../core", version = "0.3.6"} -fluentci-ext = {path = "../ext", version = "0.2.5"} +fluentci-common = {path = "../common", version = "0.2.8"} +fluentci-core = {path = "../core", version = "0.3.7"} +fluentci-ext = {path = "../ext", version = "0.2.6"} fluentci-secrets = {path = "../secrets", version = "0.1.0"} fluentci-types = {path = "../types", version = "0.1.8"} serde = {version = "1.0.197", features = ["serde_derive", "derive"]} From 61f8e5dfe8625c065d67e1a4b6f82c9708cd0830 Mon Sep 17 00:00:00 2001 From: Tsiry Sandratraina Date: Wed, 21 Aug 2024 00:26:52 +0000 Subject: [PATCH 3/3] improve terminal ui --- crates/ext/src/lib.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/crates/ext/src/lib.rs b/crates/ext/src/lib.rs index 3c45e39..72f070e 100644 --- a/crates/ext/src/lib.rs +++ b/crates/ext/src/lib.rs @@ -106,7 +106,7 @@ pub fn exec( let mut lines = vec![]; while let Ok(line) = stdout_rx.recv() { lines.push(line.clone()); - if lines.len() > 15 { + if lines.len() > 20 { lines.remove(0); } @@ -215,7 +215,6 @@ impl<'a> Component for Log<'a> { fn draw_unchecked(&self, _dimensions: Dimensions, mode: DrawMode) -> anyhow::Result { Ok(match mode { DrawMode::Normal => { - let elapsed = self.now.duration_since(self.created).as_millis(); let mut lines: Vec = self .lines .iter() @@ -223,10 +222,9 @@ impl<'a> Component for Log<'a> { .collect(); lines.push( vec![format!( - "Executing {} {}{}", + " {} {}", + "Executing".bright_green().bold(), self.command.bright_purple(), - (elapsed as f64 / 1000.0).to_string().magenta(), - "s".magenta() )] .try_into() .unwrap(), @@ -241,8 +239,8 @@ impl<'a> Component for Log<'a> { self.command.bright_purple(), (self.now.duration_since(self.created).as_millis() as f64 / 1000.0) .to_string() - .magenta(), - "s".magenta() + .bright_blue(), + "s".bright_blue() ); Lines(vec![Line::from_iter([ finished,