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

Initial scaffold for rover dev rewrite #2228

Merged
merged 6 commits into from
Oct 17, 2024
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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ default = ["composition-js"]
# notably, it is disabled for x86_64-unknown-linux-musl builds
# because of this GitHub issue: https://github.com/denoland/deno/issues/3711
composition-js = []
dev-next = []

### cross-workspace dependencies
# these dependencies can be used by any other workspace crate by specifying the dependency like so:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use apollo_federation_types::config::{FederationVersion, SupergraphConfig};
use camino::Utf8PathBuf;
use rover_std::{errln, Fs};

use crate::command::dev::do_dev::log_err_and_continue;
use crate::command::dev::legacy::do_dev::log_err_and_continue;
use crate::command::supergraph::compose::{Compose, CompositionOutput};
use crate::options::PluginOpts;
use crate::utils::client::StudioClientConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ use futures::stream::StreamExt;
use futures::FutureExt;
use rover_std::warnln;

use crate::command::dev::protocol::FollowerMessage;
use crate::command::dev::{legacy::protocol::FollowerMessage, Dev};
use crate::utils::client::StudioClientConfig;
use crate::utils::supergraph_config::get_supergraph_config;
use crate::{RoverError, RoverOutput, RoverResult};

use super::protocol::{FollowerChannel, FollowerMessenger, LeaderChannel, LeaderSession};
use super::router::RouterConfigHandler;
use super::Dev;

pub fn log_err_and_continue(err: RoverError) -> RoverError {
let _ = err.print();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use anyhow::anyhow;
use reqwest::Client;
use rover_std::Style;

use crate::command::dev::protocol::{SubgraphSdl, SubgraphUrl};
use crate::command::dev::legacy::protocol::{SubgraphSdl, SubgraphUrl};
use crate::command::graph::Introspect as GraphIntrospect;
use crate::command::subgraph::Introspect as SubgraphIntrospect;
use crate::options::IntrospectOpts;
Expand Down
26 changes: 26 additions & 0 deletions src/command/dev/legacy/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#[cfg(feature = "composition-js")]
mod compose;

#[cfg(feature = "composition-js")]
mod do_dev;

#[cfg(feature = "composition-js")]
mod introspect;

#[cfg(feature = "composition-js")]
mod protocol;

#[cfg(feature = "composition-js")]
mod router;

#[cfg(feature = "composition-js")]
mod schema;

#[cfg(feature = "composition-js")]
mod netstat;

#[cfg(not(feature = "composition-js"))]
mod no_dev;

#[cfg(feature = "composition-js")]
mod watcher;
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{
};
use url::Host;

use crate::command::dev::protocol::SubgraphUrl;
use crate::command::dev::legacy::protocol::SubgraphUrl;

pub fn normalize_loopback_urls(url: &SubgraphUrl) -> Vec<SubgraphUrl> {
let hosts = match url.host() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use super::Dev;
use crate::{utils::client::StudioClientConfig, RoverError, RoverOutput, RoverResult};
use anyhow::anyhow;
use camino::Utf8PathBuf;

use crate::{
command::dev::Dev, utils::client::StudioClientConfig, RoverError, RoverOutput, RoverResult,
};

impl Dev {
pub async fn run(
&self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use apollo_federation_types::javascript::SubgraphDefinition;
use serde::{Deserialize, Serialize};
use std::fmt::Debug;

use crate::command::dev::protocol::{entry_from_definition, SubgraphEntry, SubgraphName};
use crate::command::dev::legacy::protocol::{entry_from_definition, SubgraphEntry, SubgraphName};
use crate::{RoverError, RoverResult, PKG_VERSION};

#[derive(Serialize, Deserialize, Debug, Clone)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use apollo_federation_types::javascript::SubgraphDefinition;
use crossbeam_channel::{Receiver, Sender};
use interprocess::local_socket::traits::Stream;

use crate::command::dev::protocol::{
use crate::command::dev::legacy::protocol::{
create_socket_name, socket_read, socket_write, FollowerMessage, LeaderMessageKind,
SubgraphKeys, SubgraphName,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ use tracing::{info, warn};

use crate::{
command::dev::{
compose::ComposeRunner,
do_dev::log_err_and_continue,
router::{RouterConfigHandler, RouterRunner},
legacy::{
compose::ComposeRunner,
do_dev::log_err_and_continue,
router::{RouterConfigHandler, RouterRunner},
},
OVERRIDE_DEV_COMPOSITION_VERSION,
},
options::PluginOpts,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rover_std::warnln;

use crate::options::ProfileOpt;
use crate::utils::client::StudioClientConfig;
use crate::{command::dev::do_dev::log_err_and_continue, RoverError, RoverResult};
use crate::{command::dev::legacy::do_dev::log_err_and_continue, RoverError, RoverResult};

#[derive(Debug)]
pub struct BackgroundTask {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use rover_std::{warnln, Fs};

use crate::utils::expansion::expand;
use crate::{
command::dev::{do_dev::log_err_and_continue, SupergraphOpts},
command::dev::{legacy::do_dev::log_err_and_continue, SupergraphOpts},
RoverError, RoverResult,
};

Expand Down Expand Up @@ -295,7 +295,7 @@ mod tests {

use rstest::rstest;

use crate::command::dev::router::RouterConfigHandler;
use crate::command::dev::legacy::router::RouterConfigHandler;

#[rstest]
#[cfg_attr(windows, case("\\\\.\\pipe\\supergraph-127.0.0.1:4000.sock"))]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ use std::net::SocketAddr;
use std::time::{Duration, Instant};

use crate::command::dev::{
do_dev::log_err_and_continue,
router::{BackgroundTask, BackgroundTaskLog},
legacy::{
do_dev::log_err_and_continue,
router::{BackgroundTask, BackgroundTaskLog},
},
OVERRIDE_DEV_ROUTER_VERSION,
};
use crate::command::install::Plugin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ use rover_client::blocking::StudioClient;
use crate::options::ProfileOpt;
use crate::{
command::dev::{
netstat::normalize_loopback_urls, protocol::FollowerMessenger,
watcher::SubgraphSchemaWatcher, SupergraphOpts,
legacy::{
netstat::normalize_loopback_urls, protocol::FollowerMessenger,
watcher::SubgraphSchemaWatcher,
},
SupergraphOpts,
},
options::OptionalSubgraphOpts,
utils::client::StudioClientConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use rover_client::shared::GraphRef;
use rover_std::{errln, Fs};

use crate::{
command::dev::{
command::dev::legacy::{
introspect::{IntrospectRunnerKind, UnknownIntrospectRunner},
protocol::{FollowerMessenger, SubgraphKey},
},
Expand Down
39 changes: 9 additions & 30 deletions src/command/dev/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,18 @@ use apollo_federation_types::config::FederationVersion;
use camino::Utf8PathBuf;
use clap::Parser;
use derive_getters::Getters;
use serde::Serialize;

use rover_client::shared::GraphRef;
use serde::Serialize;

use crate::options::{OptionalSubgraphOpts, PluginOpts};
use crate::utils::parsers::FileDescriptorType;

#[cfg(feature = "composition-js")]
mod compose;

#[cfg(feature = "composition-js")]
mod do_dev;

#[cfg(feature = "composition-js")]
mod introspect;

#[cfg(feature = "composition-js")]
mod protocol;

#[cfg(feature = "composition-js")]
mod router;

#[cfg(feature = "composition-js")]
mod schema;

#[cfg(feature = "composition-js")]
mod netstat;

#[cfg(not(feature = "composition-js"))]
mod no_dev;
use crate::{
options::{OptionalSubgraphOpts, PluginOpts},
utils::parsers::FileDescriptorType,
};

#[cfg(feature = "composition-js")]
mod watcher;
#[cfg(not(feature = "dev-next"))]
pub mod legacy;
#[cfg(feature = "dev-next")]
pub mod next;

#[derive(Debug, Serialize, Parser)]
pub struct Dev {
Expand Down
13 changes: 13 additions & 0 deletions src/command/dev/next/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use camino::Utf8PathBuf;

use crate::{command::Dev, utils::client::StudioClientConfig, RoverOutput, RoverResult};

impl Dev {
pub async fn run(
&self,
_override_install_path: Option<Utf8PathBuf>,
_client_config: StudioClientConfig,
) -> RoverResult<RoverOutput> {
todo!()
}
}
1 change: 1 addition & 0 deletions src/command/graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ mod lint;
mod publish;

use clap::Parser;
#[cfg(not(feature = "dev-next"))]
pub use introspect::Introspect;
use serde::Serialize;

Expand Down
1 change: 1 addition & 0 deletions src/command/subgraph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ mod lint;
mod list;
mod publish;

#[cfg(not(feature = "dev-next"))]
pub use introspect::Introspect;

use clap::Parser;
Expand Down
5 changes: 4 additions & 1 deletion src/command/supergraph/compose/do_compose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ use std::{
};

use anyhow::{anyhow, Context};
#[cfg(not(feature = "dev-next"))]
use apollo_federation_types::config::FederationVersion::LatestFedTwo;
use apollo_federation_types::{
config::{FederationVersion, FederationVersion::LatestFedTwo, PluginVersion, SupergraphConfig},
config::{FederationVersion, PluginVersion, SupergraphConfig},
rover::BuildResult,
};
use camino::Utf8PathBuf;
Expand Down Expand Up @@ -69,6 +71,7 @@ pub struct SupergraphComposeOpts {
}

impl Compose {
#[cfg(not(feature = "dev-next"))]
pub fn new(compose_opts: PluginOpts) -> Self {
Self {
opts: SupergraphComposeOpts {
Expand Down
4 changes: 2 additions & 2 deletions src/options/compose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::options::LicenseAccepter;
use clap::Parser;
use serde::Serialize;

#[cfg(feature = "composition-js")]
#[cfg(all(feature = "composition-js", not(feature = "dev-next")))]
use crate::{utils::client::StudioClientConfig, RoverResult};

#[derive(Debug, Clone, Serialize, Parser)]
Expand All @@ -22,7 +22,7 @@ pub struct PluginOpts {
pub skip_update: bool,
}

#[cfg(feature = "composition-js")]
#[cfg(all(feature = "composition-js", not(feature = "dev-next")))]
impl PluginOpts {
pub fn prompt_for_license_accept(&self, client_config: &StudioClientConfig) -> RoverResult<()> {
self.elv2_license_accepter
Expand Down
15 changes: 8 additions & 7 deletions src/options/subgraph.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
#[cfg(not(feature = "dev-next"))]
use std::io::{self, IsTerminal};

#[cfg(feature = "composition-js")]
#[cfg(all(feature = "composition-js", not(feature = "dev-next")))]
use anyhow::{Context, Result};
use camino::Utf8PathBuf;
use clap::{self, Parser};
#[cfg(feature = "composition-js")]
#[cfg(all(feature = "composition-js", not(feature = "dev-next")))]
use clap::{error::ErrorKind as ClapErrorKind, CommandFactory};
#[cfg(feature = "composition-js")]
#[cfg(all(feature = "composition-js", not(feature = "dev-next")))]
use dialoguer::Input;
#[cfg(feature = "composition-js")]
#[cfg(all(feature = "composition-js", not(feature = "dev-next")))]
use reqwest::Url;
use serde::{Deserialize, Serialize};

#[cfg(feature = "composition-js")]
#[cfg(all(feature = "composition-js", not(feature = "dev-next")))]
use rover_std::{Fs, Style};

#[cfg(feature = "composition-js")]
#[cfg(all(feature = "composition-js", not(feature = "dev-next")))]
use crate::cli::Rover;

#[derive(Debug, Clone, Serialize, Deserialize, Parser)]
Expand Down Expand Up @@ -69,7 +70,7 @@ pub struct OptionalSubgraphOpts {
pub subgraph_retries: u64,
}

#[cfg(feature = "composition-js")]
#[cfg(all(feature = "composition-js", not(feature = "dev-next")))]
impl OptionalSubgraphOpts {
pub fn prompt_for_name(&self) -> Result<String> {
if let Some(name) = &self.subgraph_name {
Expand Down
Loading