-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started work on link. Got prompt working
- Loading branch information
1 parent
f1a9fab
commit 77fecaa
Showing
6 changed files
with
87 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use anyhow::{anyhow, Result}; | ||
use dialoguer::Confirm; | ||
use dirs_next::home_dir; | ||
|
||
use crate::{ | ||
commands::CommandBase, | ||
ui::{BOLD, CYAN, GREY, UNDERLINE}, | ||
}; | ||
|
||
pub fn link(base: CommandBase) -> Result<()> { | ||
let homedir_path = home_dir().ok_or_else(|| anyhow!("could not find home directory."))?; | ||
let homedir = homedir_path.to_string_lossy(); | ||
println!(">>> Remote Caching"); | ||
println!(); | ||
println!(" Remote Caching shares your cached Turborepo task outputs and logs across"); | ||
println!(" all your team’s Vercel projects. It also can share outputs"); | ||
println!(" with other services that enable Remote Caching, like CI/CD systems."); | ||
println!(" This results in faster build times and deployments for your team."); | ||
println!( | ||
" For more info, see {}", | ||
UNDERLINE.apply_to("https://turbo.build/repo/docs/core-concepts/remote-caching") | ||
); | ||
println!(); | ||
|
||
let repo_root_with_tilde = base.repo_root.to_string_lossy().replacen(&*homedir, "~", 1); | ||
|
||
if !should_link(&base, &repo_root_with_tilde)? { | ||
return Err(anyhow!("canceled")); | ||
} | ||
|
||
if base.user_config()?.token.is_none() { | ||
return Err(anyhow!( | ||
"User not found. Please login to Turborepo first by running {}.", | ||
BOLD.apply_to("`npx turbo login`") | ||
)); | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
fn should_link(base: &CommandBase, location: &str) -> Result<bool> { | ||
let prompt = format!( | ||
"{}{} {}", | ||
BOLD.apply_to(GREY.apply_to("? ")), | ||
BOLD.apply_to("Would you like to enable Remote Caching for"), | ||
base.ui.apply(BOLD.apply_to(CYAN.apply_to(location))) | ||
); | ||
|
||
Ok(Confirm::new().with_prompt(prompt).interact()?) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters