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

feature(turborepo): turborepo-ui crate #5684

Merged
merged 11 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
51 changes: 43 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ turborepo-ffi = { path = "crates/turborepo-ffi" }
turborepo-fs = { path = "crates/turborepo-fs" }
turborepo-lib = { path = "crates/turborepo-lib", default-features = false }
turborepo-lockfiles = { path = "crates/turborepo-lockfiles" }
turborepo-ui = { path = "crates/turborepo-ui" }
turborepo-scm = { path = "crates/turborepo-scm" }
wax = { path = "crates/turborepo-wax" }
vercel-api-mock = { path = "crates/turborepo-vercel-api-mock" }
Expand Down
1 change: 1 addition & 0 deletions crates/turborepo-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ turborepo-cache = { workspace = true }
turborepo-env = { workspace = true }
turborepo-lockfiles = { workspace = true }
turborepo-scm = { workspace = true }
turborepo-ui = { workspace = true }
NicholasLYang marked this conversation as resolved.
Show resolved Hide resolved
wax = { workspace = true }
webbrowser = { workspace = true }
which = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use clap_complete::{generate, Shell};
use serde::Serialize;
use tracing::{debug, error};
use turbopath::AbsoluteSystemPathBuf;
use turborepo_ui::UI;

#[cfg(feature = "run-stub")]
use crate::commands::run;
Expand All @@ -15,7 +16,6 @@ use crate::{
get_version,
shim::{RepoMode, RepoState},
tracing::TurboSubscriber,
ui::UI,
Payload,
};

Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-lib/src/commands/info.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use anyhow::Result;
use turborepo_ui::GREY;

use crate::{
commands::CommandBase,
package_graph::{PackageGraph, WorkspaceName, WorkspaceNode},
package_json::PackageJson,
package_manager::PackageManager,
ui::GREY,
};

pub fn run(base: &mut CommandBase, workspace: Option<&str>) -> Result<()> {
Expand Down
8 changes: 4 additions & 4 deletions crates/turborepo-lib/src/commands/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ use dirs_next::home_dir;
#[cfg(test)]
use rand::Rng;
use turborepo_api_client::{APIClient, CachingStatus, Space, Team};

#[cfg(not(test))]
use crate::ui::CYAN;
use turborepo_ui::CYAN;
use turborepo_ui::{BOLD, GREY, UNDERLINE};

use crate::{
cli::LinkTarget,
commands::CommandBase,
config::{RawTurboJSON, SpacesJson},
ui::{BOLD, GREY, UNDERLINE},
};

#[derive(Clone)]
Expand Down Expand Up @@ -478,13 +478,13 @@ mod test {
use tempfile::{NamedTempFile, TempDir};
use tokio::sync::OnceCell;
use turbopath::AbsoluteSystemPathBuf;
use turborepo_ui::UI;
use vercel_api_mock::start_test_server;

use crate::{
cli::LinkTarget,
commands::{link, CommandBase},
config::{ClientConfigLoader, RawTurboJSON, RepoConfigLoader, UserConfigLoader},
ui::UI,
Args,
};

Expand Down
4 changes: 2 additions & 2 deletions crates/turborepo-lib/src/commands/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ use tokio::sync::OnceCell;
use tracing::debug;
#[cfg(not(test))]
use tracing::warn;
use turborepo_ui::{start_spinner, BOLD, CYAN, GREY, UNDERLINE};

use crate::{
commands::{
link::{verify_caching_enabled, REMOTE_CACHING_INFO, REMOTE_CACHING_URL},
CommandBase,
},
get_version,
ui::{start_spinner, BOLD, CYAN, GREY, UNDERLINE},
};

const DEFAULT_HOST_NAME: &str = "127.0.0.1";
Expand Down Expand Up @@ -305,6 +305,7 @@ mod test {
use tempfile::{tempdir, NamedTempFile};
use tokio::sync::OnceCell;
use turbopath::AbsoluteSystemPathBuf;
use turborepo_ui::UI;
use vercel_api_mock::start_test_server;

use crate::{
Expand All @@ -314,7 +315,6 @@ mod test {
CommandBase,
},
config::{ClientConfigLoader, RepoConfigLoader, UserConfigLoader},
ui::UI,
Args,
};

Expand Down
3 changes: 2 additions & 1 deletion crates/turborepo-lib/src/commands/logout.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use anyhow::Result;
use tracing::error;
use turborepo_ui::GREY;

use crate::{commands::CommandBase, ui::GREY};
use crate::commands::CommandBase;

pub fn logout(base: &mut CommandBase) -> Result<()> {
if let Err(err) = base.user_config_mut()?.set_token(None) {
Expand Down
5 changes: 3 additions & 2 deletions crates/turborepo-lib/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ use sha2::{Digest, Sha256};
use tokio::sync::OnceCell;
use turbopath::AbsoluteSystemPathBuf;
use turborepo_api_client::APIClient;
use turborepo_ui::UI;

use crate::{
config::{
default_user_config_path, get_repo_config_path, ClientConfig, ClientConfigLoader,
RepoConfig, RepoConfigLoader, UserConfig, UserConfigLoader,
},
ui::UI,
Args,
};

Expand Down Expand Up @@ -176,8 +176,9 @@ impl CommandBase {
mod test {
use test_case::test_case;
use turbopath::AbsoluteSystemPathBuf;
use turborepo_ui::UI;

use crate::{get_version, ui::UI};
use crate::get_version;

#[cfg(not(target_os = "windows"))]
#[test_case("/tmp/turborepo", "6e0cfa616f75a61c"; "basic example")]
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-lib/src/commands/prune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ use tracing::trace;
use turbopath::{
AbsoluteSystemPathBuf, AnchoredSystemPath, AnchoredSystemPathBuf, RelativeUnixPath,
};
use turborepo_ui::BOLD;

use super::CommandBase;
use crate::{
config::RawTurboJSON,
package_graph::{PackageGraph, WorkspaceName, WorkspaceNode},
package_json::PackageJson,
ui::BOLD,
};

#[derive(Debug, thiserror::Error)]
Expand Down
3 changes: 2 additions & 1 deletion crates/turborepo-lib/src/commands/unlink.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use std::{fs, fs::File};

use anyhow::{Context, Result};
use turborepo_ui::GREY;

use crate::{cli::LinkTarget, commands::CommandBase, config::RawTurboJSON, ui::GREY};
use crate::{cli::LinkTarget, commands::CommandBase, config::RawTurboJSON};

enum UnlinkSpacesResult {
Unlinked,
Expand Down
3 changes: 2 additions & 1 deletion crates/turborepo-lib/src/daemon/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,10 @@ mod test {

use tokio::select;
use turbopath::AbsoluteSystemPathBuf;
use turborepo_ui::UI;

use super::DaemonServer;
use crate::{commands::CommandBase, ui::UI, Args};
use crate::{commands::CommandBase, Args};

// the windows runner starts a new thread to accept uds requests,
// so we need a multi-threaded runtime
Expand Down
1 change: 0 additions & 1 deletion crates/turborepo-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ mod run;
mod shim;
mod task_graph;
mod tracing;
mod ui;

use ::tracing::error;
use anyhow::Result;
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-lib/src/package_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ use serde::{Deserialize, Serialize};
use thiserror::Error;
use turbopath::{AbsoluteSystemPath, AbsoluteSystemPathBuf, RelativeUnixPath};
use turborepo_lockfiles::Lockfile;
use turborepo_ui::{UI, UNDERLINE};
use wax::{Any, Glob, Pattern};

use crate::{
package_json::PackageJson,
package_manager::{npm::NpmDetector, pnpm::PnpmDetector, yarn::YarnDetector},
ui::{UI, UNDERLINE},
};

#[derive(Debug, Deserialize)]
Expand Down
3 changes: 2 additions & 1 deletion crates/turborepo-lib/src/run/global_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ use anyhow::Result;
use turbopath::{AbsoluteSystemPath, RelativeUnixPathBuf};
use turborepo_env::{BySource, DetailedMap, EnvironmentVariableMap};
use turborepo_lockfiles::Lockfile;
use turborepo_ui::UI;

use crate::{cli::EnvMode, package_json::PackageJson, package_manager::PackageManager, ui::UI};
use crate::{cli::EnvMode, package_json::PackageJson, package_manager::PackageManager};

static DEFAULT_ENV_VARS: [&str; 1] = ["VERCEL_ANALYTICS_ID"];

Expand Down
5 changes: 3 additions & 2 deletions crates/turborepo-lib/src/run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use tracing::{debug, info};
use turborepo_cache::{http::APIAuth, AsyncCache};
use turborepo_env::EnvironmentVariableMap;
use turborepo_scm::SCM;
use turborepo_ui::UI;

use crate::{
commands::CommandBase, config::TurboJson, daemon::DaemonConnector, manager::Manager,
Expand Down Expand Up @@ -61,7 +62,7 @@ impl Run {
}

// There's some warning handling code in Go that I'm ignoring
if self.base.ui.is_ci() && !opts.run_opts.no_daemon {
if UI::is_ci() && !opts.run_opts.no_daemon {
NicholasLYang marked this conversation as resolved.
Show resolved Hide resolved
info!("skipping turbod since we appear to be in a non-interactive context");
} else if !opts.run_opts.no_daemon {
let connector = DaemonConnector {
Expand Down Expand Up @@ -142,13 +143,13 @@ mod test {
use anyhow::Result;
use tempfile::tempdir;
use turbopath::AbsoluteSystemPathBuf;
use turborepo_ui::UI;

use crate::{
cli::{Command, RunArgs},
commands::CommandBase,
get_version,
run::Run,
ui::UI,
Args,
};

Expand Down
3 changes: 2 additions & 1 deletion crates/turborepo-lib/src/shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ use tiny_gradient::{GradientStr, RGB};
use tracing::debug;
use turbo_updater::check_for_updates;
use turbopath::{AbsoluteSystemPath, AbsoluteSystemPathBuf};
use turborepo_ui::UI;

use crate::{
cli, get_version, package_manager::WorkspaceGlobs, spawn_child, tracing::TurboSubscriber,
ui::UI, PackageManager, Payload,
PackageManager, Payload,
};

// all arguments that result in a stdout that much be directly parsable and
Expand Down
3 changes: 1 addition & 2 deletions crates/turborepo-lib/src/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ use tracing_subscriber::{
reload::{self, Error, Handle},
EnvFilter, Layer, Registry,
};

use crate::ui::UI;
use turborepo_ui::UI;

type StdOutLog = Filtered<
tracing_subscriber::fmt::Layer<Registry, DefaultFields, TurboFormatter>,
Expand Down
Loading
Loading