Skip to content

Commit

Permalink
Deprecate the use of emojis (#2034)
Browse files Browse the repository at this point in the history
## Description

As we move towards rover v1, this PR removes the use of emojis
throughout every command in favour of text based output only.
  • Loading branch information
loshz authored Aug 8, 2024
1 parent d3bc90b commit 1d3a838
Show file tree
Hide file tree
Showing 19 changed files with 141 additions and 283 deletions.
220 changes: 92 additions & 128 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Rover

> ✨ 🤖 🐶 the new CLI for apollo
>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)
Expand Down
2 changes: 1 addition & 1 deletion crates/rover-std/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# `rover-std`

`rover-std` provides common utilities that inform Rover's CLI style. You'll find multiple top level exports here that provide wrappers around common functionality like reading/writing files, using emojis, coloring output text, and prompting for user input.
`rover-std` provides common utilities that inform Rover's CLI style. You'll find multiple top level exports here that provide wrappers around common functionality like reading/writing files, using coloring output text, and prompting for user input.
63 changes: 0 additions & 63 deletions crates/rover-std/src/emoji.rs

This file was deleted.

17 changes: 5 additions & 12 deletions crates/rover-std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use notify::event::ModifyKind;
use notify::{EventKind, RecursiveMode, Watcher};
use notify_debouncer_full::new_debouncer;

use crate::{Emoji, RoverStdError};
use crate::RoverStdError;

/// Interact with a file system
#[derive(Default, Copy, Clone)]
Expand Down Expand Up @@ -265,11 +265,7 @@ impl Fs {
.expect("thread pool built successfully");
let path = path.as_ref().to_path_buf();
tp.spawn(move || {
eprintln!(
"{}watching {} for changes",
Emoji::Watch,
path.as_std_path().display()
);
eprintln!("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,
Expand Down Expand Up @@ -322,23 +318,20 @@ type WatchSender = Sender<Result<(), RoverStdError>>;
fn handle_notify_error(tx: &WatchSender, path: &Path, err: notify::Error) {
match &err.kind {
notify::ErrorKind::PathNotFound => eprintln!(
"{} could not watch \"{}\" for changes: file not found",
Emoji::Warn,
"could not watch \"{}\" for changes: file not found",
path.display()
),
notify::ErrorKind::MaxFilesWatch => {
eprintln!(
"{} 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",
Emoji::Warn,
"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()
);
}
notify::ErrorKind::Generic(_)
| notify::ErrorKind::Io(_)
| notify::ErrorKind::WatchNotFound
| notify::ErrorKind::InvalidConfig(_) => eprintln!(
"{} an unexpected error occured while watching {} for changes",
Emoji::Warn,
"an unexpected error occured while watching {} for changes",
path.display()
),
}
Expand Down
2 changes: 0 additions & 2 deletions crates/rover-std/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
mod emoji;
mod error;
mod fs;
mod style;
mod url;

pub mod prompt;
pub use emoji::Emoji;
pub use error::RoverStdError;
pub use fs::Fs;
pub use style::is_no_color_set;
Expand Down
1 change: 0 additions & 1 deletion docs/source/configuring.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,5 +350,4 @@ If present, an environment variable's value takes precedence over all other meth
| `APOLLO_VCS_BRANCH` | The name of the version-controlled branch. See [Git context](#git-context). |
| `APOLLO_VCS_COMMIT` | The long identifier (SHA in Git) of the commit. See [Git context](#git-context). |
| `APOLLO_VCS_AUTHOR` | The name and email of a commit's author (e.g., `Jane Doe <[email protected]>`). See [Git context](#git-context). |
| `NO_EMOJI` | Set to `1` if you don't want Rover to print emojis. |
| `NO_COLOR` | Set to `1` if you don't want Rover to print color. |
4 changes: 2 additions & 2 deletions src/command/dev/compose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{Emoji, Fs};
use rover_std::Fs;

use crate::command::dev::do_dev::log_err_and_continue;
use crate::command::supergraph::compose::{Compose, CompositionOutput};
Expand Down Expand Up @@ -107,7 +107,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", Emoji::Skull);
eprintln!("composition failed, killing the router");
Ok(fs::remove_file(&self.write_path)
.with_context(|| format!("could not remove {}", &self.write_path))?)
} else {
Expand Down
13 changes: 6 additions & 7 deletions src/command/dev/do_dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ use apollo_federation_types::config::FederationVersion;
use camino::Utf8PathBuf;
use crossbeam_channel::bounded as sync_channel;

use rover_std::Emoji;

use crate::command::dev::protocol::FollowerMessage;
use crate::utils::client::StudioClientConfig;
use crate::utils::supergraph_config::get_supergraph_config;
Expand Down Expand Up @@ -65,7 +63,9 @@ impl Dev {
&supergraph_config,
router_config_handler,
)? {
eprintln!("{0}Do not run this command in production! {0}It is intended for local development.", Emoji::Warn);
eprintln!(
"Do not run this command in production! It is intended for local development."
);
let (ready_sender, ready_receiver) = sync_channel(1);
let follower_messenger = FollowerMessenger::from_main_session(
follower_channel.clone().sender,
Expand All @@ -75,8 +75,7 @@ impl Dev {
tp.spawn(move || {
ctrlc::set_handler(move || {
eprintln!(
"\n{}shutting down the `rover dev` session and all attached processes...",
Emoji::Stop
"\nshutting down the `rover dev` session and all attached processes..."
);
let _ = follower_channel
.sender
Expand Down Expand Up @@ -148,15 +147,15 @@ impl Dev {
let health_messenger = follower_messenger.clone();
tp.spawn(move || {
let _ = health_messenger.health_check().map_err(|_| {
eprintln!("{}shutting down...", Emoji::Stop);
eprintln!("shutting down...");
std::process::exit(1);
});
});

// set up the ctrl+c handler to notify the main session to remove the killed subgraph
let kill_name = subgraph_refresher.get_name();
ctrlc::set_handler(move || {
eprintln!("\n{}shutting down...", Emoji::Stop);
eprintln!("\nshutting down...");
let _ = follower_messenger
.remove_subgraph(&kill_name)
.map_err(log_err_and_continue);
Expand Down
13 changes: 4 additions & 9 deletions src/command/dev/protocol/follower/message.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use anyhow::anyhow;
use apollo_federation_types::build::SubgraphDefinition;
use rover_std::Emoji;
use serde::{Deserialize, Serialize};
use std::fmt::Debug;

Expand Down Expand Up @@ -99,30 +98,26 @@ impl FollowerMessage {
FollowerMessageKind::AddSubgraph { subgraph_entry } => {
if self.is_from_main_session() {
eprintln!(
"{}starting a session with the '{}' subgraph",
Emoji::Start,
"starting a session with the '{}' subgraph",
&subgraph_entry.0 .0
);
} else {
eprintln!(
"{}adding the '{}' subgraph to the session",
Emoji::New,
"adding the '{}' subgraph to the session",
&subgraph_entry.0 .0
);
}
}
FollowerMessageKind::UpdateSubgraph { subgraph_entry } => {
eprintln!(
"{}updating the schema for the '{}' subgraph in the session",
Emoji::Reload,
"updating the schema for the '{}' subgraph in the session",
&subgraph_entry.0 .0
);
}
FollowerMessageKind::RemoveSubgraph { subgraph_name } => {
if self.is_from_main_session() {
eprintln!(
"{}removing the '{}' subgraph from this session",
Emoji::Reload,
"removing the '{}' subgraph from this session",
&subgraph_name
);
} else {
Expand Down
4 changes: 1 addition & 3 deletions src/command/dev/protocol/leader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ use interprocess::local_socket::ListenerOptions;
use serde::{Deserialize, Serialize};
use tracing::{info, warn};

use rover_std::Emoji;

use crate::{
command::dev::{
compose::ComposeRunner,
Expand Down Expand Up @@ -517,7 +515,7 @@ impl LeaderMessageKind {
eprintln!("{}", error);
}
LeaderMessageKind::CompositionSuccess { action } => {
eprintln!("{}successfully composed after {}", Emoji::Success, &action);
eprintln!("successfully composed after {}", &action);
}
LeaderMessageKind::LeaderSessionInfo { subgraphs } => {
let subgraphs = match subgraphs.len() {
Expand Down
15 changes: 7 additions & 8 deletions src/command/dev/router/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use std::{
use anyhow::{anyhow, Context};
use crossbeam_channel::Sender;
use rover_client::operations::config::who_am_i::{self, Actor, ConfigWhoAmIInput};
use rover_std::Emoji;

use crate::options::ProfileOpt;
use crate::utils::client::StudioClientConfig;
Expand Down Expand Up @@ -53,24 +52,24 @@ impl BackgroundTask {
if let Ok(apollo_graph_ref) = var("APOLLO_GRAPH_REF") {
command.env("APOLLO_GRAPH_REF", apollo_graph_ref);
if let Some(api_key) = 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}", Emoji::Warn);
eprintln!("APOLLO_GRAPH_REF is set, but credentials could not be loaded. \
Enterprise features within the router will not function. {err}");
}).ok().and_then(|client| {
who_am_i::run(ConfigWhoAmIInput {}, &client).map_or_else(|err| {
eprintln!("{} Could not determine the type of configured credentials, \
Router may fail to start if Enterprise features are enabled. {err}", Emoji::Warn);
eprintln!("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!(
"{} APOLLO_GRAPH_REF is set, but the key provided is not a graph key. \
"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.", Emoji::Warn
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", Emoji::Note);
eprintln!("you can configure a graph key by following the instructions at https://www.apollographql.com/docs/graphos/api-keys/#graph-api-keys");
None
}
}
Expand Down
9 changes: 3 additions & 6 deletions src/command/dev/router/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use camino::Utf8PathBuf;
use crossbeam_channel::{unbounded, Receiver};
use serde_json::json;

use rover_std::{Emoji, Fs};
use rover_std::Fs;

use crate::utils::expansion::expand;
use crate::{
Expand Down Expand Up @@ -93,7 +93,7 @@ impl RouterConfigHandler {
.expect("could not watch router config");
let _ = Fs::write_file(&self.tmp_router_config_path, &config_state.config)
.map_err(|e| log_err_and_continue(e.into()));
eprintln!("{}successfully updated router config", Emoji::Success);
eprintln!("successfully updated router config");
*self
.config_state
.lock()
Expand Down Expand Up @@ -258,10 +258,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.",
Emoji::Action
);
eprintln!("{path} does not exist, creating a router config from CLI options.");
Fs::write_file(path, &yaml_string)?;
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/command/dev/router/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use camino::Utf8PathBuf;
use crossbeam_channel::bounded;
use reqwest::blocking::Client;
use reqwest::Url;
use rover_std::{Emoji, Style};
use rover_std::Style;
use semver::Version;

use std::net::SocketAddr;
Expand Down Expand Up @@ -117,8 +117,7 @@ impl RouterRunner {

if ready {
eprintln!(
"{}your supergraph is running! head to http://{}{} to query your supergraph",
Emoji::Rocket,
"your supergraph is running! head to http://{}{} to query your supergraph",
&self
.router_socket_addr
.to_string()
Expand Down
Loading

0 comments on commit 1d3a838

Please sign in to comment.