Skip to content
This repository has been archived by the owner on Dec 21, 2024. It is now read-only.

Commit

Permalink
chore: reorg package in prep for toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanFlurry committed Jul 13, 2024
1 parent 992f329 commit b6da4f7
Show file tree
Hide file tree
Showing 95 changed files with 109 additions and 114 deletions.
34 changes: 15 additions & 19 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[workspace]
members = [
"core",
"cli", "toolchain",
"rivet-toolchain-core",
"rivet-cli",
]

# Config for 'cargo dist'
Expand Down
3 changes: 1 addition & 2 deletions cli/Cargo.toml → rivet-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ async-posthog = { git = "https://github.com/rivet-gg/posthog-rs.git", rev = "ef4
async-stream = "0.3.3"
chrono = "0.4.21"
clap = { version = "3.2.16", features = ["derive", "env"] }
cli-core = { path = "../core", package = "rivet-cli-core" }
cli-toolchain = { path = "../core", package = "rivet-toolchain" }
toolchain-core = { path = "../rivet-toolchain-core", package = "rivet-toolchain-core" }
config = { git = "https://github.com/AngelOnFira/config-rs", rev = "04e61354912543e23e70b6851a3f4b03ce69471c", default-features = false, features = ["yaml", "toml", "json"] }
console = "0.15"
ctrlc = { version = "3.2", features = ["termination"] }
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use clap::Parser;
use cli_core::rivet_api::apis;
use toolchain_core::rivet_api::apis;
use global_error::prelude::*;
use tabled::Tabled;

Expand All @@ -12,7 +12,7 @@ pub enum SubCommand {
}

impl SubCommand {
pub async fn execute(&self, ctx: &cli_core::Ctx) -> GlobalResult<()> {
pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> {
match self {
SubCommand::List => {
let custom_avatars_res = unwrap!(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::path::PathBuf;

use clap::Parser;
use cli_core::rivet_api::apis;
use toolchain_core::rivet_api::apis;
use global_error::prelude::*;
use uuid::Uuid;

Expand Down Expand Up @@ -64,7 +64,7 @@ pub struct Opts {
}

pub async fn provision_database(
ctx: &cli_core::Ctx,
ctx: &toolchain_core::Ctx,
project_id: Uuid,
env_id: Uuid,
) -> GlobalResult<()> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{collections::HashMap, path::PathBuf, sync::Arc};

use clap::Parser;
use cli_core::rivet_api::{apis, models};
use toolchain_core::rivet_api::{apis, models};
use futures_util::{StreamExt, TryStreamExt};
use global_error::prelude::*;
use serde::Deserialize;
Expand All @@ -28,7 +28,7 @@ pub struct Opts {
}

impl Opts {
pub async fn execute(&self, ctx: &cli_core::Ctx) -> GlobalResult<()> {
pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> {
let project = get_or_create_project(ctx).await?;
let project_id_str = project.project_id.to_string();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use clap::Parser;
use cli_core::rivet_api::{apis, models};
use toolchain_core::rivet_api::{apis, models};
use global_error::prelude::*;

#[derive(Parser)]
Expand All @@ -16,7 +16,7 @@ pub struct Opts {
}

impl Opts {
pub async fn execute(&self, ctx: &cli_core::Ctx) -> GlobalResult<()> {
pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> {
let project_res = apis::ee_cloud_games_projects_api::ee_cloud_games_projects_get(
&ctx.openapi_config_cloud,
&ctx.game_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub enum SubCommand {
}

impl SubCommand {
pub async fn execute(&self, ctx: &cli_core::Ctx) -> GlobalResult<()> {
pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> {
match self {
SubCommand::Create(opts) => opts.execute(ctx).await,
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{collections::HashMap, io::Write, path::PathBuf, str::FromStr};

use clap::Parser;
use cli_core::rivet_api::{apis, models};
use toolchain_core::rivet_api::{apis, models};
use global_error::prelude::*;
use tempfile::NamedTempFile;
use tokio::process::Command;
Expand Down Expand Up @@ -31,7 +31,7 @@ pub enum SubCommand {
}

impl SubCommand {
pub async fn execute(&self, ctx: &cli_core::Ctx) -> GlobalResult<()> {
pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> {
match self {
SubCommand::Deploy(opts) => opts.execute(&ctx).await,
SubCommand::Environment { command } => command.execute(&ctx).await,
Expand All @@ -43,7 +43,7 @@ impl SubCommand {
* Gets or auto-creates a backend project for the game.
*/
pub async fn get_or_create_project(
ctx: &cli_core::Ctx,
ctx: &toolchain_core::Ctx,
) -> GlobalResult<Box<models::EeBackendProject>> {
let project_res = apis::ee_cloud_games_projects_api::ee_cloud_games_projects_get(
&ctx.openapi_config_cloud,
Expand All @@ -61,7 +61,7 @@ pub async fn get_or_create_project(
}

pub async fn passthrough(
ctx: Option<&cli_core::Ctx>,
ctx: Option<&toolchain_core::Ctx>,
db_command: Option<database::PassthroughSubCommand>,
) -> GlobalResult<()> {
let mut opengb_env = HashMap::new();
Expand Down
8 changes: 4 additions & 4 deletions cli/src/commands/cdn.rs → rivet-cli/src/commands/cdn.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use clap::Parser;
use cli_core::rivet_api::{apis, models};
use toolchain_core::rivet_api::{apis, models};
use futures_util::{StreamExt, TryStreamExt};
use global_error::prelude::*;
use serde::Serialize;
Expand Down Expand Up @@ -33,7 +33,7 @@ pub struct PushOpts {
}

impl SubCommand {
pub async fn execute(&self, ctx: &cli_core::Ctx) -> GlobalResult<()> {
pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> {
match self {
SubCommand::Push(push_opts) => {
let output = push(ctx, push_opts).await?;
Expand All @@ -54,7 +54,7 @@ pub struct PushOutput {
pub site_id: Uuid,
}

pub async fn push(ctx: &cli_core::Ctx, push_opts: &PushOpts) -> GlobalResult<PushOutput> {
pub async fn push(ctx: &toolchain_core::Ctx, push_opts: &PushOpts) -> GlobalResult<PushOutput> {
let reqwest_client = Arc::new(reqwest::Client::new());

let upload_path = env::current_dir()?.join(&push_opts.path);
Expand Down Expand Up @@ -205,7 +205,7 @@ pub struct BuildPushOpts {
}

pub async fn build_and_push(
ctx: &cli_core::Ctx,
ctx: &toolchain_core::Ctx,
push_opts: &BuildPushOpts,
) -> GlobalResult<PushOutput> {
eprintln!();
Expand Down
14 changes: 7 additions & 7 deletions cli/src/commands/ci.rs → rivet-cli/src/commands/ci.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use clap::Parser;
use cli_core::rivet_api::models;
use toolchain_core::rivet_api::models;
use global_error::prelude::*;
use std::collections::HashMap;
use tokio::fs;
Expand All @@ -16,7 +16,7 @@ pub enum SubCommand {
}

impl SubCommand {
pub async fn execute(&self, ctx: &cli_core::Ctx) -> GlobalResult<()> {
pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> {
match self {
SubCommand::Generate { command } => command.execute(ctx).await,
}
Expand All @@ -30,7 +30,7 @@ pub enum GenerateOpts {
}

impl GenerateOpts {
pub async fn execute(&self, ctx: &cli_core::Ctx) -> GlobalResult<()> {
pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> {
match self {
GenerateOpts::GitHub(opts) => gen_github(ctx, opts).await,
}
Expand All @@ -47,7 +47,7 @@ pub struct GenerateGitHubOpts {
allow_idle_lobbies: bool,
}

async fn gen_github(ctx: &cli_core::Ctx, opts: &GenerateGitHubOpts) -> GlobalResult<()> {
async fn gen_github(ctx: &toolchain_core::Ctx, opts: &GenerateGitHubOpts) -> GlobalResult<()> {
let relative_path = opts
.path
.clone()
Expand All @@ -71,7 +71,7 @@ async fn gen_github(ctx: &cli_core::Ctx, opts: &GenerateGitHubOpts) -> GlobalRes

// TODO: Strings in this workflow are not appropriately escaped
async fn gen_github_workflow(
ctx: &cli_core::Ctx,
ctx: &toolchain_core::Ctx,
opts: &GenerateGitHubOpts,
) -> GlobalResult<String> {
let mut version = config::read_config(Vec::new(), None).await?;
Expand Down Expand Up @@ -163,7 +163,7 @@ async fn gen_github_workflow(
Ok(workflow)
}

fn common_substitute(ctx: &cli_core::Ctx, input: &str) -> String {
fn common_substitute(ctx: &toolchain_core::Ctx, input: &str) -> String {
input
.replace(
"__RIVET_CLI_VERSION__",
Expand All @@ -187,7 +187,7 @@ fn validate_idle_lobbies(
}

fn append_dockerfile(
ctx: &cli_core::Ctx,
ctx: &toolchain_core::Ctx,
workflow: &mut String,
needs_jobs: &mut Vec<String>,
overrides: &mut Vec<String>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use clap::Parser;
use cli_core::rivet_api::{apis, models};
use toolchain_core::rivet_api::{apis, models};
use global_error::prelude::*;
use serde::{Deserialize, Serialize};
use std::collections::HashSet;
Expand All @@ -13,7 +13,7 @@ pub enum SubCommand {
}

impl SubCommand {
pub async fn execute(&self, ctx: &cli_core::Ctx) -> GlobalResult<()> {
pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> {
match self {
SubCommand::Validate(opts) => {
let errors = opts.execute(ctx).await?;
Expand Down Expand Up @@ -48,7 +48,7 @@ pub struct ValidateOpts {
}

impl ValidateOpts {
pub async fn execute(&self, ctx: &cli_core::Ctx) -> GlobalResult<Vec<models::ValidationError>> {
pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<Vec<models::ValidationError>> {
let overrides = parse_config_override_args(&self.overrides)?;
let mut rivet_config =
read_config(overrides, self.namespace.as_ref().map(String::as_str)).await?;
Expand Down
14 changes: 7 additions & 7 deletions cli/src/commands/deploy.rs → rivet-cli/src/commands/deploy.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use clap::Parser;
use cli_core::rivet_api::{apis, models};
use toolchain_core::rivet_api::{apis, models};
use global_error::prelude::*;
use serde::Serialize;
use serde_json::json;
Expand Down Expand Up @@ -67,7 +67,7 @@ pub struct Opts {
}

impl Opts {
pub async fn execute(&self, ctx: &cli_core::Ctx) -> GlobalResult<()> {
pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> {
// Derive namespace
let namespace = match (
self.namespace.as_ref().or(self.namespace_flag.as_ref()),
Expand Down Expand Up @@ -133,7 +133,7 @@ impl Opts {
/// Developers should override config properties instead. For example: `rivet deploy -o matchmaker.docker.image_id=xxxx -o
/// cdn.path=xxxx`
pub async fn build_and_push_compat(
ctx: &cli_core::Ctx,
ctx: &toolchain_core::Ctx,
overrides: &mut Vec<(String, serde_json::Value)>,
build_tag: &Option<String>,
build_name: &Option<String>,
Expand Down Expand Up @@ -195,7 +195,7 @@ pub struct DeployOutput {

/// Deploys a new Rivet version.
pub async fn deploy(
ctx: &cli_core::Ctx,
ctx: &toolchain_core::Ctx,
display_name: Option<&str>,
overrides: Vec<(String, serde_json::Value)>,
namespace_name_id: Option<&str>,
Expand Down Expand Up @@ -312,7 +312,7 @@ pub async fn deploy(

/// Builds the Docker image and CDN site if needed.
pub async fn build_config_dependencies(
ctx: &cli_core::Ctx,
ctx: &toolchain_core::Ctx,
namespace: Option<&str>,
version: &mut models::CloudVersionConfig,
display_name: &str,
Expand Down Expand Up @@ -368,7 +368,7 @@ pub async fn build_config_dependencies(
///
/// If none are true, `None` is returned.
pub async fn build_and_push_image(
ctx: &cli_core::Ctx,
ctx: &toolchain_core::Ctx,
display_name: &str,
docker: &mut Box<models::CloudVersionMatchmakerGameModeRuntimeDocker>,
format: Option<&struct_fmt::Format>,
Expand Down Expand Up @@ -417,7 +417,7 @@ pub async fn build_and_push_image(
}
}
pub async fn build_and_push_site(
ctx: &cli_core::Ctx,
ctx: &toolchain_core::Ctx,
namespace: Option<&str>,
display_name: &str,
cdn: &mut Box<models::CloudVersionCdnConfig>,
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/dev.rs → rivet-cli/src/commands/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub enum SubCommand {
}

impl SubCommand {
pub async fn execute(&self, ctx: &cli_core::Ctx) -> GlobalResult<()> {
pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> {
match self {
SubCommand::CreateDevToken(opts) => {
rivet_term::status::warn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub struct BuildImageOutput {

/// Builds an image and archives it to a path.
pub async fn build_image(
ctx: &cli_core::Ctx,
ctx: &toolchain_core::Ctx,
dockerfile: &Path,
build_kind: super::BuildKind,
build_compression: super::BuildCompression,
Expand Down
Loading

0 comments on commit b6da4f7

Please sign in to comment.