Skip to content

Commit

Permalink
fix(cli): open the correct URL on login (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
QuiiBz committed Oct 21, 2022
1 parent a9c994d commit b7ee4db
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/popular-comics-smile.md
@@ -0,0 +1,5 @@
---
'@lagon/cli': patch
---

Open the configured URL on login
4 changes: 2 additions & 2 deletions packages/cli/src/commands/login.rs
Expand Up @@ -3,7 +3,7 @@ use std::io::{self, Error, ErrorKind};
use dialoguer::{Confirm, Password};
use serde::{Deserialize, Serialize};

use crate::utils::{debug, get_site_url, info, input, print_progress, success, Config, TrpcClient};
use crate::utils::{debug, info, input, print_progress, success, Config, TrpcClient};

#[derive(Deserialize, Debug)]
struct CliResponse {
Expand Down Expand Up @@ -31,7 +31,7 @@ pub async fn login() -> io::Result<()> {
println!();

let end_progress = print_progress("Opening browser...");
let url = get_site_url() + "/cli";
let url = config.site_url.clone() + "/cli";
webbrowser::open(&url).unwrap();
end_progress();

Expand Down
10 changes: 9 additions & 1 deletion packages/cli/src/utils/config.rs
Expand Up @@ -3,7 +3,15 @@ use std::fs;
use std::io;
use std::path::PathBuf;

use super::get_site_url;
#[cfg(debug_assertions)]
fn get_site_url() -> String {
"http://localhost:3000".to_string()
}

#[cfg(not(debug_assertions))]
fn get_site_url() -> String {
"https://dash.lagon.app".to_string()
}

fn get_config_path() -> PathBuf {
dirs::home_dir().unwrap().join(".lagon").join("config.json")
Expand Down
10 changes: 0 additions & 10 deletions packages/cli/src/utils/mod.rs
Expand Up @@ -13,16 +13,6 @@ pub use console::*;
pub use deployments::*;
pub use trpc::*;

#[cfg(debug_assertions)]
pub fn get_site_url() -> String {
"http://localhost:3000".to_string()
}

#[cfg(not(debug_assertions))]
pub fn get_site_url() -> String {
"https://dash.lagon.app".to_string()
}

pub fn validate_code_file(file: &Path) -> io::Result<()> {
if !file.exists() || !file.is_file() {
return Err(Error::new(
Expand Down

0 comments on commit b7ee4db

Please sign in to comment.