diff --git a/README.md b/README.md index 2af63c65b..f85b928ab 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,4 @@ # Rover - ->The new CLI for apollo - [![CircleCI Tests](https://circleci.com/gh/apollographql/rover.svg?style=svg)](https://app.circleci.com/pipelines/github/apollographql/rover?branch=main) [![GitHub Release Downloads](https://shields.io/github/downloads/apollographql/rover/total.svg)](https://github.com/apollographql/rover/releases/latest) diff --git a/crates/rover-std/src/fs.rs b/crates/rover-std/src/fs.rs index cee54c889..61ee86327 100644 --- a/crates/rover-std/src/fs.rs +++ b/crates/rover-std/src/fs.rs @@ -7,7 +7,7 @@ use std::{ time::Duration, }; -use crate::RoverStdError; +use crate::{errln, infoln, RoverStdError}; use anyhow::{anyhow, Context}; use camino::{ReadDirUtf8, Utf8Path, Utf8PathBuf}; use notify::event::ModifyKind; @@ -258,7 +258,7 @@ impl Fs { { let path = path.as_ref().to_path_buf(); tokio::task::spawn_blocking(move || { - eprintln!("watching {} for changes", path.as_std_path().display()); + infoln!("Watching {} for changes", path.as_std_path().display()); let path = path.as_std_path(); let (fs_tx, fs_rx) = channel(); // Spawn a debouncer so we don't detect single rather than multiple writes in quick succession, @@ -310,12 +310,12 @@ type WatchSender = UnboundedSender>; /// User-friendly error messages for `notify::Error` in `watch_file` fn handle_notify_error(tx: &WatchSender, path: &Path, err: notify::Error) { match &err.kind { - notify::ErrorKind::PathNotFound => eprintln!( + notify::ErrorKind::PathNotFound => errln!( "could not watch \"{}\" for changes: file not found", path.display() ), notify::ErrorKind::MaxFilesWatch => { - eprintln!( + errln!( "could not watch \"{}\" for changes: total number of inotify watches reached, consider increasing the number of allowed inotify watches or stopping processed that watch many files", path.display() ); @@ -323,7 +323,7 @@ fn handle_notify_error(tx: &WatchSender, path: &Path, err: notify::Error) { notify::ErrorKind::Generic(_) | notify::ErrorKind::Io(_) | notify::ErrorKind::WatchNotFound - | notify::ErrorKind::InvalidConfig(_) => eprintln!( + | notify::ErrorKind::InvalidConfig(_) => errln!( "an unexpected error occured while watching {} for changes", path.display() ), diff --git a/crates/rover-std/src/print.rs b/crates/rover-std/src/print.rs index c36426d4e..ff9d7d04e 100644 --- a/crates/rover-std/src/print.rs +++ b/crates/rover-std/src/print.rs @@ -1,12 +1,12 @@ -/// Prints to the standard output, with a newline. +/// Prints to the standard error, with a newline. /// -/// Equivalent to the [`println!`] macro except that an info prefix is +/// Equivalent to the [`eprintln!`] macro except that an info prefix is /// printed before the message. #[macro_export] macro_rules! infoln { ($($t:tt)*) => {{ - print!("{} ", $crate::Style::InfoPrefix.paint("==>")); - println!($($t)*); + eprint!("{} ", $crate::Style::InfoPrefix.paint("==>")); + eprintln!($($t)*); }}; } @@ -17,7 +17,7 @@ macro_rules! infoln { #[macro_export] macro_rules! warnln { ($($t:tt)*) => {{ - eprint!("{}: ", $crate::Style::WarningPrefix.paint("warning")); + eprint!("{} ", $crate::Style::WarningPrefix.paint("warning:")); eprintln!($($t)*); }}; } @@ -29,7 +29,7 @@ macro_rules! warnln { #[macro_export] macro_rules! errln { ($($t:tt)*) => {{ - eprint!("{}: ", $crate::Style::ErrorPrefix.paint("error")); + eprint!("{} ", $crate::Style::ErrorPrefix.paint("error:")); eprintln!($($t)*); }}; } diff --git a/src/command/dev/compose.rs b/src/command/dev/compose.rs index 22de88644..27d49d1ba 100644 --- a/src/command/dev/compose.rs +++ b/src/command/dev/compose.rs @@ -4,7 +4,7 @@ use std::io::prelude::*; use anyhow::{Context, Error}; use apollo_federation_types::config::{FederationVersion, SupergraphConfig}; use camino::Utf8PathBuf; -use rover_std::Fs; +use rover_std::{errln, Fs}; use crate::command::dev::do_dev::log_err_and_continue; use crate::command::supergraph::compose::{Compose, CompositionOutput}; @@ -114,7 +114,7 @@ impl ComposeRunner { fn remove_supergraph_schema(&self) -> RoverResult<()> { if Fs::assert_path_exists(&self.write_path).is_ok() { - eprintln!("composition failed, killing the router"); + errln!("composition failed, killing the router"); Ok(fs::remove_file(&self.write_path) .with_context(|| format!("could not remove {}", &self.write_path))?) } else { diff --git a/src/command/dev/do_dev.rs b/src/command/dev/do_dev.rs index 1615e3699..dc07577cc 100644 --- a/src/command/dev/do_dev.rs +++ b/src/command/dev/do_dev.rs @@ -4,6 +4,7 @@ use futures::channel::mpsc::channel; use futures::future::join_all; use futures::stream::StreamExt; use futures::FutureExt; +use rover_std::warnln; use crate::command::dev::protocol::FollowerMessage; use crate::utils::client::StudioClientConfig; @@ -57,8 +58,8 @@ impl Dev { ) .await? { - eprintln!( - "Do not run this command in production! It is intended for local development." + warnln!( + "Do not run this command in production! It is intended for local development only." ); let (ready_sender, mut ready_receiver) = channel(1); let follower_messenger = FollowerMessenger::from_main_session( diff --git a/src/command/dev/router/command.rs b/src/command/dev/router/command.rs index 7bad1a72e..9fa0f8e6b 100644 --- a/src/command/dev/router/command.rs +++ b/src/command/dev/router/command.rs @@ -7,6 +7,7 @@ use std::{ use anyhow::{anyhow, Context}; use crossbeam_channel::Sender; use rover_client::operations::config::who_am_i::{self, Actor, ConfigWhoAmIInput}; +use rover_std::warnln; use crate::options::ProfileOpt; use crate::utils::client::StudioClientConfig; @@ -54,27 +55,24 @@ impl BackgroundTask { if let Ok(client) = client_config .get_authenticated_client(profile_opt) .map_err(|err| { - eprintln!( - "APOLLO_GRAPH_REF is set, but credentials could not be loaded. \ - Enterprise features within the router will not function. {err}" + warnln!( + "APOLLO_GRAPH_REF is set, but credentials could not be loaded. Enterprise features within the router will not function: {err}" ); }) { if let Some(api_key) = who_am_i::run(ConfigWhoAmIInput {}, &client).await.map_or_else(|err| { - eprintln!("Could not determine the type of configured credentials, \ - Router may fail to start if Enterprise features are enabled. {err}"); + warnln!("Could not determine the type of configured credentials, Router may fail to start if Enterprise features are enabled: {err}"); Some(client.credential.api_key.clone()) }, |identity| { match identity.key_actor_type { Actor::GRAPH => Some(client.credential.api_key.clone()), _ => { - eprintln!( + warnln!( "APOLLO_GRAPH_REF is set, but the key provided is not a graph key. \ Enterprise features within the router will not function. \ Either select a `--profile` that is configured with a graph-specific \ - key, or provide one via the APOLLO_KEY environment variable." - ); - eprintln!("you can configure a graph key by following the instructions at https://www.apollographql.com/docs/graphos/api-keys/#graph-api-keys"); + key, or provide one via the APOLLO_KEY environment variable. \ + You can configure a graph key by following the instructions at https://www.apollographql.com/docs/graphos/api-keys/#graph-api-keys"); None } } diff --git a/src/command/dev/router/config.rs b/src/command/dev/router/config.rs index d8cb8be0a..37aaf1980 100644 --- a/src/command/dev/router/config.rs +++ b/src/command/dev/router/config.rs @@ -8,7 +8,7 @@ use camino::Utf8PathBuf; use crossbeam_channel::{unbounded, Receiver}; use serde_json::json; -use rover_std::Fs; +use rover_std::{warnln, Fs}; use crate::utils::expansion::expand; use crate::{ @@ -251,7 +251,7 @@ impl RouterConfigReader { if let Some(path) = &self.input_config_path { if Fs::assert_path_exists(path).is_err() { - eprintln!("{path} does not exist, creating a router config from CLI options."); + warnln!("{path} does not exist, creating a router config from CLI options."); Fs::write_file(path, &yaml_string)?; } } diff --git a/src/command/dev/router/runner.rs b/src/command/dev/router/runner.rs index 4c27338ef..4e61d8a30 100644 --- a/src/command/dev/router/runner.rs +++ b/src/command/dev/router/runner.rs @@ -4,7 +4,7 @@ use camino::Utf8PathBuf; use crossbeam_channel::bounded; use reqwest::Client; use reqwest::Url; -use rover_std::Style; +use rover_std::{infoln, Style}; use semver::Version; use std::net::SocketAddr; @@ -129,7 +129,7 @@ impl RouterRunner { } if ready { - eprintln!( + infoln!( "your supergraph is running! head to http://{}{} to query your supergraph", &self .router_socket_addr diff --git a/src/command/dev/watcher.rs b/src/command/dev/watcher.rs index ea15cc3da..623dc6d31 100644 --- a/src/command/dev/watcher.rs +++ b/src/command/dev/watcher.rs @@ -12,7 +12,7 @@ use rover_client::blocking::StudioClient; use rover_client::operations::subgraph::fetch; use rover_client::operations::subgraph::fetch::SubgraphFetchInput; use rover_client::shared::GraphRef; -use rover_std::Fs; +use rover_std::{errln, Fs}; use crate::{ command::dev::{ @@ -246,8 +246,8 @@ impl SubgraphSchemaWatcher { // if self.subgraph_retry_countdown > 0 { self.subgraph_retry_countdown -= 1; - eprintln!("error detected communicating with subgraph '{}', schema changes will not be reflected.\nWill retry but subgraph logs should be inspected", &self.subgraph_key.0); - eprintln!("Error: {:}", e); + errln!("error detected communicating with subgraph '{}', schema changes will not be reflected.\nWill retry but subgraph logs should be inspected", &self.subgraph_key.0); + errln!("{:}", e); Some(e.to_string()) } else { eprintln!(