Skip to content

Commit 1bdba57

Browse files
authored
Initial scaffold for rover dev rewrite (#2228)
1 parent 3980226 commit 1bdba57

27 files changed

+93
-60
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ default = ["composition-js"]
4545
# notably, it is disabled for x86_64-unknown-linux-musl builds
4646
# because of this GitHub issue: https://github.com/denoland/deno/issues/3711
4747
composition-js = []
48+
dev-next = []
4849

4950
### cross-workspace dependencies
5051
# these dependencies can be used by any other workspace crate by specifying the dependency like so:

src/command/dev/compose.rs src/command/dev/legacy/compose.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use apollo_federation_types::config::{FederationVersion, SupergraphConfig};
66
use camino::Utf8PathBuf;
77
use rover_std::{errln, Fs};
88

9-
use crate::command::dev::do_dev::log_err_and_continue;
9+
use crate::command::dev::legacy::do_dev::log_err_and_continue;
1010
use crate::command::supergraph::compose::{Compose, CompositionOutput};
1111
use crate::options::PluginOpts;
1212
use crate::utils::client::StudioClientConfig;

src/command/dev/do_dev.rs src/command/dev/legacy/do_dev.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ use futures::stream::StreamExt;
66
use futures::FutureExt;
77
use rover_std::warnln;
88

9-
use crate::command::dev::protocol::FollowerMessage;
9+
use crate::command::dev::{legacy::protocol::FollowerMessage, Dev};
1010
use crate::utils::client::StudioClientConfig;
1111
use crate::utils::supergraph_config::get_supergraph_config;
1212
use crate::{RoverError, RoverOutput, RoverResult};
1313

1414
use super::protocol::{FollowerChannel, FollowerMessenger, LeaderChannel, LeaderSession};
1515
use super::router::RouterConfigHandler;
16-
use super::Dev;
1716

1817
pub fn log_err_and_continue(err: RoverError) -> RoverError {
1918
let _ = err.print();

src/command/dev/introspect.rs src/command/dev/legacy/introspect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use anyhow::anyhow;
44
use reqwest::Client;
55
use rover_std::Style;
66

7-
use crate::command::dev::protocol::{SubgraphSdl, SubgraphUrl};
7+
use crate::command::dev::legacy::protocol::{SubgraphSdl, SubgraphUrl};
88
use crate::command::graph::Introspect as GraphIntrospect;
99
use crate::command::subgraph::Introspect as SubgraphIntrospect;
1010
use crate::options::IntrospectOpts;

src/command/dev/legacy/mod.rs

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#[cfg(feature = "composition-js")]
2+
mod compose;
3+
4+
#[cfg(feature = "composition-js")]
5+
mod do_dev;
6+
7+
#[cfg(feature = "composition-js")]
8+
mod introspect;
9+
10+
#[cfg(feature = "composition-js")]
11+
mod protocol;
12+
13+
#[cfg(feature = "composition-js")]
14+
mod router;
15+
16+
#[cfg(feature = "composition-js")]
17+
mod schema;
18+
19+
#[cfg(feature = "composition-js")]
20+
mod netstat;
21+
22+
#[cfg(not(feature = "composition-js"))]
23+
mod no_dev;
24+
25+
#[cfg(feature = "composition-js")]
26+
mod watcher;

src/command/dev/netstat.rs src/command/dev/legacy/netstat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{
55
};
66
use url::Host;
77

8-
use crate::command::dev::protocol::SubgraphUrl;
8+
use crate::command::dev::legacy::protocol::SubgraphUrl;
99

1010
pub fn normalize_loopback_urls(url: &SubgraphUrl) -> Vec<SubgraphUrl> {
1111
let hosts = match url.host() {

src/command/dev/no_dev.rs src/command/dev/legacy/no_dev.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
use super::Dev;
2-
use crate::{utils::client::StudioClientConfig, RoverError, RoverOutput, RoverResult};
31
use anyhow::anyhow;
42
use camino::Utf8PathBuf;
53

4+
use crate::{
5+
command::dev::Dev, utils::client::StudioClientConfig, RoverError, RoverOutput, RoverResult,
6+
};
7+
68
impl Dev {
79
pub async fn run(
810
&self,

src/command/dev/protocol/follower/message.rs src/command/dev/legacy/protocol/follower/message.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use apollo_federation_types::javascript::SubgraphDefinition;
33
use serde::{Deserialize, Serialize};
44
use std::fmt::Debug;
55

6-
use crate::command::dev::protocol::{entry_from_definition, SubgraphEntry, SubgraphName};
6+
use crate::command::dev::legacy::protocol::{entry_from_definition, SubgraphEntry, SubgraphName};
77
use crate::{RoverError, RoverResult, PKG_VERSION};
88

99
#[derive(Serialize, Deserialize, Debug, Clone)]

src/command/dev/protocol/follower/messenger.rs src/command/dev/legacy/protocol/follower/messenger.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use apollo_federation_types::javascript::SubgraphDefinition;
55
use crossbeam_channel::{Receiver, Sender};
66
use interprocess::local_socket::traits::Stream;
77

8-
use crate::command::dev::protocol::{
8+
use crate::command::dev::legacy::protocol::{
99
create_socket_name, socket_read, socket_write, FollowerMessage, LeaderMessageKind,
1010
SubgraphKeys, SubgraphName,
1111
};

src/command/dev/protocol/leader.rs src/command/dev/legacy/protocol/leader.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ use tracing::{info, warn};
2121

2222
use crate::{
2323
command::dev::{
24-
compose::ComposeRunner,
25-
do_dev::log_err_and_continue,
26-
router::{RouterConfigHandler, RouterRunner},
24+
legacy::{
25+
compose::ComposeRunner,
26+
do_dev::log_err_and_continue,
27+
router::{RouterConfigHandler, RouterRunner},
28+
},
2729
OVERRIDE_DEV_COMPOSITION_VERSION,
2830
},
2931
options::PluginOpts,
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/command/dev/router/command.rs src/command/dev/legacy/router/command.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rover_std::warnln;
1111

1212
use crate::options::ProfileOpt;
1313
use crate::utils::client::StudioClientConfig;
14-
use crate::{command::dev::do_dev::log_err_and_continue, RoverError, RoverResult};
14+
use crate::{command::dev::legacy::do_dev::log_err_and_continue, RoverError, RoverResult};
1515

1616
#[derive(Debug)]
1717
pub struct BackgroundTask {

src/command/dev/router/config.rs src/command/dev/legacy/router/config.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rover_std::{warnln, Fs};
1313

1414
use crate::utils::expansion::expand;
1515
use crate::{
16-
command::dev::{do_dev::log_err_and_continue, SupergraphOpts},
16+
command::dev::{legacy::do_dev::log_err_and_continue, SupergraphOpts},
1717
RoverError, RoverResult,
1818
};
1919

@@ -295,7 +295,7 @@ mod tests {
295295

296296
use rstest::rstest;
297297

298-
use crate::command::dev::router::RouterConfigHandler;
298+
use crate::command::dev::legacy::router::RouterConfigHandler;
299299

300300
#[rstest]
301301
#[cfg_attr(windows, case("\\\\.\\pipe\\supergraph-127.0.0.1:4000.sock"))]
File renamed without changes.

src/command/dev/router/runner.rs src/command/dev/legacy/router/runner.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ use std::net::SocketAddr;
1111
use std::time::{Duration, Instant};
1212

1313
use crate::command::dev::{
14-
do_dev::log_err_and_continue,
15-
router::{BackgroundTask, BackgroundTaskLog},
14+
legacy::{
15+
do_dev::log_err_and_continue,
16+
router::{BackgroundTask, BackgroundTaskLog},
17+
},
1618
OVERRIDE_DEV_ROUTER_VERSION,
1719
};
1820
use crate::command::install::Plugin;

src/command/dev/schema.rs src/command/dev/legacy/schema.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ use rover_client::blocking::StudioClient;
99
use crate::options::ProfileOpt;
1010
use crate::{
1111
command::dev::{
12-
netstat::normalize_loopback_urls, protocol::FollowerMessenger,
13-
watcher::SubgraphSchemaWatcher, SupergraphOpts,
12+
legacy::{
13+
netstat::normalize_loopback_urls, protocol::FollowerMessenger,
14+
watcher::SubgraphSchemaWatcher,
15+
},
16+
SupergraphOpts,
1417
},
1518
options::OptionalSubgraphOpts,
1619
utils::client::StudioClientConfig,

src/command/dev/watcher.rs src/command/dev/legacy/watcher.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rover_client::shared::GraphRef;
1616
use rover_std::{errln, Fs};
1717

1818
use crate::{
19-
command::dev::{
19+
command::dev::legacy::{
2020
introspect::{IntrospectRunnerKind, UnknownIntrospectRunner},
2121
protocol::{FollowerMessenger, SubgraphKey},
2222
},

src/command/dev/mod.rs

+9-30
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,18 @@ use apollo_federation_types::config::FederationVersion;
44
use camino::Utf8PathBuf;
55
use clap::Parser;
66
use derive_getters::Getters;
7-
use serde::Serialize;
8-
97
use rover_client::shared::GraphRef;
8+
use serde::Serialize;
109

11-
use crate::options::{OptionalSubgraphOpts, PluginOpts};
12-
use crate::utils::parsers::FileDescriptorType;
13-
14-
#[cfg(feature = "composition-js")]
15-
mod compose;
16-
17-
#[cfg(feature = "composition-js")]
18-
mod do_dev;
19-
20-
#[cfg(feature = "composition-js")]
21-
mod introspect;
22-
23-
#[cfg(feature = "composition-js")]
24-
mod protocol;
25-
26-
#[cfg(feature = "composition-js")]
27-
mod router;
28-
29-
#[cfg(feature = "composition-js")]
30-
mod schema;
31-
32-
#[cfg(feature = "composition-js")]
33-
mod netstat;
34-
35-
#[cfg(not(feature = "composition-js"))]
36-
mod no_dev;
10+
use crate::{
11+
options::{OptionalSubgraphOpts, PluginOpts},
12+
utils::parsers::FileDescriptorType,
13+
};
3714

38-
#[cfg(feature = "composition-js")]
39-
mod watcher;
15+
#[cfg(not(feature = "dev-next"))]
16+
pub mod legacy;
17+
#[cfg(feature = "dev-next")]
18+
pub mod next;
4019

4120
#[derive(Debug, Serialize, Parser)]
4221
pub struct Dev {

src/command/dev/next/mod.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use camino::Utf8PathBuf;
2+
3+
use crate::{command::Dev, utils::client::StudioClientConfig, RoverOutput, RoverResult};
4+
5+
impl Dev {
6+
pub async fn run(
7+
&self,
8+
_override_install_path: Option<Utf8PathBuf>,
9+
_client_config: StudioClientConfig,
10+
) -> RoverResult<RoverOutput> {
11+
todo!()
12+
}
13+
}

src/command/graph/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ mod lint;
66
mod publish;
77

88
use clap::Parser;
9+
#[cfg(not(feature = "dev-next"))]
910
pub use introspect::Introspect;
1011
use serde::Serialize;
1112

src/command/subgraph/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ mod lint;
66
mod list;
77
mod publish;
88

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

1112
use clap::Parser;

src/command/supergraph/compose/do_compose.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ use std::{
66
};
77

88
use anyhow::{anyhow, Context};
9+
#[cfg(not(feature = "dev-next"))]
10+
use apollo_federation_types::config::FederationVersion::LatestFedTwo;
911
use apollo_federation_types::{
10-
config::{FederationVersion, FederationVersion::LatestFedTwo, PluginVersion, SupergraphConfig},
12+
config::{FederationVersion, PluginVersion, SupergraphConfig},
1113
rover::BuildResult,
1214
};
1315
use camino::Utf8PathBuf;
@@ -69,6 +71,7 @@ pub struct SupergraphComposeOpts {
6971
}
7072

7173
impl Compose {
74+
#[cfg(not(feature = "dev-next"))]
7275
pub fn new(compose_opts: PluginOpts) -> Self {
7376
Self {
7477
opts: SupergraphComposeOpts {

src/options/compose.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::options::LicenseAccepter;
44
use clap::Parser;
55
use serde::Serialize;
66

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

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

25-
#[cfg(feature = "composition-js")]
25+
#[cfg(all(feature = "composition-js", not(feature = "dev-next")))]
2626
impl PluginOpts {
2727
pub fn prompt_for_license_accept(&self, client_config: &StudioClientConfig) -> RoverResult<()> {
2828
self.elv2_license_accepter

src/options/subgraph.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1+
#[cfg(not(feature = "dev-next"))]
12
use std::io::{self, IsTerminal};
23

3-
#[cfg(feature = "composition-js")]
4+
#[cfg(all(feature = "composition-js", not(feature = "dev-next")))]
45
use anyhow::{Context, Result};
56
use camino::Utf8PathBuf;
67
use clap::{self, Parser};
7-
#[cfg(feature = "composition-js")]
8+
#[cfg(all(feature = "composition-js", not(feature = "dev-next")))]
89
use clap::{error::ErrorKind as ClapErrorKind, CommandFactory};
9-
#[cfg(feature = "composition-js")]
10+
#[cfg(all(feature = "composition-js", not(feature = "dev-next")))]
1011
use dialoguer::Input;
11-
#[cfg(feature = "composition-js")]
12+
#[cfg(all(feature = "composition-js", not(feature = "dev-next")))]
1213
use reqwest::Url;
1314
use serde::{Deserialize, Serialize};
1415

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

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

2122
#[derive(Debug, Clone, Serialize, Deserialize, Parser)]
@@ -69,7 +70,7 @@ pub struct OptionalSubgraphOpts {
6970
pub subgraph_retries: u64,
7071
}
7172

72-
#[cfg(feature = "composition-js")]
73+
#[cfg(all(feature = "composition-js", not(feature = "dev-next")))]
7374
impl OptionalSubgraphOpts {
7475
pub fn prompt_for_name(&self) -> Result<String> {
7576
if let Some(name) = &self.subgraph_name {

0 commit comments

Comments
 (0)