fix: add ansi support and remove emoji
This commit is contained in:
Generated
+10
@@ -620,6 +620,15 @@ dependencies = [
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "enable-ansi-support"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea7457668b3da8a4b702f3d79e131aa3e81cd7e81cc95fb2d54fce9f182ecc77"
|
||||
dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "enum_dispatch"
|
||||
version = "0.3.13"
|
||||
@@ -2360,6 +2369,7 @@ dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
"colored",
|
||||
"enable-ansi-support",
|
||||
"home",
|
||||
"russh",
|
||||
"russh-sftp",
|
||||
|
||||
@@ -14,6 +14,7 @@ edition = "2024"
|
||||
anyhow = "1.0.104"
|
||||
clap = { version = "4.6.6", features = ["derive"] }
|
||||
colored = "3.1.1"
|
||||
enable-ansi-support = "0.3.1"
|
||||
home = "0.5.12"
|
||||
russh = { version = "0.62.7", default-features = false, features = [
|
||||
"ring",
|
||||
|
||||
@@ -28,10 +28,10 @@ xboctploy demo # задеплоить проект demo
|
||||
|
||||
```txt
|
||||
deploying 'demo'
|
||||
🟢 [Local] running: npm run build... Success! (1.2s)
|
||||
🔵 [SFTP] transferring dist to /var/www/pages... Done! (14 file(s), 231.5 KiB) (829ms)
|
||||
🟡 [Remote] running: pm2 restart pages... Success! (102ms)
|
||||
🎉 Deploy successful! (total 2.3s)
|
||||
[Local] running: npm run build... Success! (1.2s)
|
||||
[SFTP] transferring dist to /var/www/pages... Done! (14 file(s), 231.5 KiB) (829ms)
|
||||
[Remote] running: pm2 restart pages... Success! (102ms)
|
||||
Deploy successful! (total 2.3s)
|
||||
```
|
||||
|
||||
## Конфигурация
|
||||
|
||||
+10
-14
@@ -33,11 +33,11 @@ pub fn deploy(name: &str, project: &Project, dry_run: bool) -> Result<()> {
|
||||
for cmd in local_cmds {
|
||||
let step = Instant::now();
|
||||
if let Err(err) = local::execute(cmd, &project.workdir, &project.env) {
|
||||
fail_line("🟢 [Local]", &format!("running: {cmd}..."), err.to_string());
|
||||
fail_line("[Local]", &format!("running: {cmd}..."), err.to_string());
|
||||
return Err(err);
|
||||
}
|
||||
success_line(
|
||||
"🟢 [Local]",
|
||||
"[Local]",
|
||||
&format!("running: {cmd}..."),
|
||||
"Success!",
|
||||
step.elapsed(),
|
||||
@@ -59,13 +59,13 @@ pub fn deploy(name: &str, project: &Project, dry_run: bool) -> Result<()> {
|
||||
let label = format!("transferring {} to {}...", rule.source.display(), target);
|
||||
match result {
|
||||
Ok(stats) => success_line(
|
||||
"🔵 [SFTP]",
|
||||
"[SFTP]",
|
||||
&label,
|
||||
&format!("Done! ({stats})"),
|
||||
step.elapsed(),
|
||||
),
|
||||
Err(err) => {
|
||||
fail_line("🔵 [SFTP]", &label, err.to_string());
|
||||
fail_line("[SFTP]", &label, err.to_string());
|
||||
return Err(err);
|
||||
}
|
||||
}
|
||||
@@ -74,15 +74,11 @@ pub fn deploy(name: &str, project: &Project, dry_run: bool) -> Result<()> {
|
||||
for cmd in remote_cmds {
|
||||
let step = Instant::now();
|
||||
if let Err(err) = session.exec(cmd) {
|
||||
fail_line(
|
||||
"🟡 [Remote]",
|
||||
&format!("running: {cmd}..."),
|
||||
err.to_string(),
|
||||
);
|
||||
fail_line("[Remote]", &format!("running: {cmd}..."), err.to_string());
|
||||
return Err(err);
|
||||
}
|
||||
success_line(
|
||||
"🟡 [Remote]",
|
||||
"[Remote]",
|
||||
&format!("running: {cmd}..."),
|
||||
"Success!",
|
||||
step.elapsed(),
|
||||
@@ -91,7 +87,7 @@ pub fn deploy(name: &str, project: &Project, dry_run: bool) -> Result<()> {
|
||||
}
|
||||
|
||||
println!(
|
||||
"🎉 {} (total {})",
|
||||
"{} (total {})",
|
||||
"Deploy successful!".green().bold(),
|
||||
fmt_dur(total.elapsed())
|
||||
);
|
||||
@@ -101,17 +97,17 @@ pub fn deploy(name: &str, project: &Project, dry_run: bool) -> Result<()> {
|
||||
fn print_plan(project: &Project, local_cmds: &[String], remote_cmds: &[String]) {
|
||||
println!("dry-run plan:");
|
||||
for cmd in local_cmds {
|
||||
println!(" 🟢 [Local] {cmd}");
|
||||
println!(" [Local] {cmd}");
|
||||
}
|
||||
for rule in &project.sync {
|
||||
println!(
|
||||
" 🔵 [SFTP] {} -> {}",
|
||||
" [SFTP] {} -> {}",
|
||||
rule.source.display(),
|
||||
rule.target.display()
|
||||
);
|
||||
}
|
||||
for cmd in remote_cmds {
|
||||
println!(" 🟡 [Remote] {cmd}");
|
||||
println!(" [Remote] {cmd}");
|
||||
}
|
||||
println!("{}", "nothing executed".dimmed());
|
||||
}
|
||||
|
||||
@@ -12,6 +12,11 @@ use clap::Parser;
|
||||
use colored::Colorize;
|
||||
|
||||
fn main() -> ExitCode {
|
||||
#[cfg(windows)]
|
||||
if enable_ansi_support::enable_ansi_support().is_err() {
|
||||
colored::control::set_override(false);
|
||||
}
|
||||
|
||||
let cli = cli::Cli::parse();
|
||||
match run(&cli) {
|
||||
Ok(()) => ExitCode::SUCCESS,
|
||||
|
||||
Reference in New Issue
Block a user