Skip to content

Commit e4e643a

Browse files
committed
chore: common util for urls
1 parent f246976 commit e4e643a

File tree

5 files changed

+18
-13
lines changed

5 files changed

+18
-13
lines changed

src/commands/deploy/mod.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use std::path::PathBuf;
66

77
use anyhow::Result;
88
use clap::Parser;
9-
use console::style;
109
use hyper::Method;
1110
use reqwest::multipart::{Form, Part};
1211
use tokio::fs;
@@ -28,6 +27,7 @@ use crate::commands::ignite::util::{create_deployment, rollout, update_deploymen
2827
use crate::commands::projects::util::format_project;
2928
use crate::state::State;
3029
use crate::store::hopfile::HopFile;
30+
use crate::utils::urlify;
3131

3232
const HOP_BUILD_BASE_URL: &str = "https://builder.hop.io/v1";
3333
const HOP_REGISTRY_URL: &str = "registry.hop.io";
@@ -201,7 +201,7 @@ pub async fn handle(options: Options, state: State) -> Result<()> {
201201
if gateway.type_ == GatewayType::External {
202202
log::info!(
203203
"Your deployment will be accesible via {}",
204-
style(gateway.full_url()).underlined().bold()
204+
urlify(&gateway.full_url())
205205
);
206206
}
207207
}
@@ -297,7 +297,7 @@ pub async fn handle(options: Options, state: State) -> Result<()> {
297297
println!();
298298
panic!(
299299
"Push failed, for help contact us on {} and mention the deployment id: {}",
300-
style("https://discord.gg/hop").underlined().bold(),
300+
urlify("https://discord.gg/hop"),
301301
deployment.id
302302
);
303303
}
@@ -321,12 +321,10 @@ pub async fn handle(options: Options, state: State) -> Result<()> {
321321

322322
log::info!(
323323
"Deployed successfuly, you can find it at: {}",
324-
style(format!(
324+
urlify(&format!(
325325
"{}{}?project={}",
326326
WEB_DEPLOYMENTS_URL, deployment.id, project.namespace
327327
))
328-
.underlined()
329-
.bold()
330328
);
331329

332330
Ok(())

src/commands/gateways/create.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use anyhow::{ensure, Result};
22
use clap::Parser;
3-
use console::style;
43

54
use super::types::{GatewayProtocol, GatewayType};
65
use crate::commands::gateways::types::GatewayConfig;
76
use crate::commands::gateways::util::{create_gateway, update_gateway_config};
87
use crate::commands::ignite::util::{format_deployments, get_all_deployments};
98
use crate::state::State;
9+
use crate::utils::urlify;
1010

1111
#[derive(Debug, Parser, Default, PartialEq)]
1212
pub struct GatewayOptions {
@@ -72,7 +72,7 @@ pub async fn handle(options: Options, state: State) -> Result<()> {
7272
if gateway.type_ == GatewayType::External {
7373
log::info!(
7474
"You can now access your app at {}",
75-
style(gateway.full_url()).underlined().bold()
75+
urlify(&gateway.full_url())
7676
);
7777
}
7878

src/commands/ignite/create.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use anyhow::Result;
22
use clap::Parser;
3-
use console::style;
43

54
use super::types::{Env, RamSizes, ScalingStrategy};
65
use crate::commands::containers::types::ContainerType;
76
use crate::commands::containers::utils::create_containers;
87
use crate::commands::ignite::types::Deployment;
98
use crate::commands::ignite::util::{create_deployment, update_deployment_config};
109
use crate::state::State;
10+
use crate::utils::urlify;
1111

1212
pub const WEB_DEPLOYMENTS_URL: &str = "https://console.hop.io/ignite/deployment/";
1313

@@ -115,12 +115,10 @@ pub async fn handle(options: Options, state: State) -> Result<()> {
115115

116116
log::info!(
117117
"Deployed successfuly, you can find it at: {}",
118-
style(format!(
118+
urlify(&format!(
119119
"{}{}?project={}",
120120
WEB_DEPLOYMENTS_URL, deployment.id, project.namespace
121121
))
122-
.underlined()
123-
.bold()
124122
);
125123

126124
Ok(())

src/commands/update/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pub mod util;
44

55
use anyhow::Result;
66
use clap::Parser;
7+
use tokio::fs;
78

89
use self::types::Version;
910
use self::util::{
@@ -42,7 +43,10 @@ pub async fn handle(options: Options, mut state: State) -> Result<()> {
4243
.expect("Failed to download");
4344

4445
// unpack the new release
45-
let unpacked = unpack(packed_temp).await?;
46+
let unpacked = unpack(packed_temp.clone()).await?;
47+
48+
// remove the tarball since it's no longer needed
49+
fs::remove_file(packed_temp).await?;
4650

4751
let mut non_elevated_args: Vec<String> = vec![];
4852
let mut elevated_args: Vec<String> = vec![];

src/utils.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::{
55
};
66

77
use chrono::{DateTime, Utc};
8+
use console::style;
89
use fern::colors::{Color, ColoredLevelConfig};
910
use log::{Level, LevelFilter};
1011
use ms::{__to_string__, ms};
@@ -147,3 +148,7 @@ pub async fn in_path(program: &str) -> bool {
147148

148149
false
149150
}
151+
152+
pub fn urlify(s: &str) -> String {
153+
style(s).bold().underlined().to_string()
154+
}

0 commit comments

Comments
 (0)