Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): open the correct URL on login #202

Merged
merged 1 commit into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/popular-comics-smile.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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