diff --git a/Cargo.lock b/Cargo.lock index 781fe6ad..4277a883 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -28,18 +28,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - [[package]] name = "aho-corasick" version = "1.1.2" @@ -49,12 +37,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "allocator-api2" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" - [[package]] name = "android-tzdata" version = "0.1.1" @@ -82,12 +64,6 @@ version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" -[[package]] -name = "arraydeque" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236" - [[package]] name = "assert_cmd" version = "2.0.12" @@ -336,21 +312,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "config" -version = "0.14.0" -source = "git+https://github.com/AngelOnFira/config-rs?rev=04e61354912543e23e70b6851a3f4b03ce69471c#04e61354912543e23e70b6851a3f4b03ce69471c" -dependencies = [ - "encoding_rs_io", - "lazy_static", - "nom", - "pathdiff", - "serde", - "serde_json", - "toml 0.8.13", - "yaml-rust2", -] - [[package]] name = "console" version = "0.15.7" @@ -607,15 +568,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "encoding_rs_io" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cc3c5651fb62ab8aa3103998dade57efdd028544bd300516baa31840c252a83" -dependencies = [ - "encoding_rs", -] - [[package]] name = "enum-iterator" version = "1.4.1" @@ -877,7 +829,7 @@ checksum = "1cf2fb99fac0b821a4e61c61abff076324bb0e5c3b4a83815bbc3518a38971ad" dependencies = [ "serde", "serde_json", - "toml 0.5.11", + "toml", "yaml-rust", ] @@ -906,7 +858,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash 0.7.7", + "ahash", ] [[package]] @@ -914,19 +866,6 @@ name = "hashbrown" version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" -dependencies = [ - "ahash 0.8.11", - "allocator-api2", -] - -[[package]] -name = "hashlink" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" -dependencies = [ - "hashbrown 0.14.3", -] [[package]] name = "heck" @@ -1372,12 +1311,6 @@ dependencies = [ "unicase", ] -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - [[package]] name = "miniz_oxide" version = "0.7.1" @@ -1433,16 +1366,6 @@ dependencies = [ "libc", ] -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr", - "minimal-lexical", -] - [[package]] name = "ntapi" version = "0.4.1" @@ -1612,12 +1535,6 @@ dependencies = [ "windows-targets 0.48.5", ] -[[package]] -name = "pathdiff" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" - [[package]] name = "percent-encoding" version = "2.3.1" @@ -1923,13 +1840,11 @@ dependencies = [ name = "rivet-cli" version = "1.4.0" dependencies = [ - "anyhow", "assert_cmd", "async-posthog", "async-stream", "chrono", "clap", - "config", "console", "ctrlc", "dirs", @@ -1946,11 +1861,9 @@ dependencies = [ "regex", "reqwest", "rivet-term", - "rivet-toolchain-core", "sentry", "serde", "serde_json", - "serde_yaml", "strum", "sysinfo", "tabled", @@ -1962,7 +1875,6 @@ dependencies = [ "typed-path", "url", "uuid", - "vergen", "webbrowser", "which", "winapi", @@ -1983,19 +1895,54 @@ dependencies = [ ] [[package]] -name = "rivet-toolchain-core" -version = "0.0.1" +name = "rivet-toolchain" +version = "0.1.0" dependencies = [ "anyhow", + "assert_cmd", + "async-posthog", + "async-stream", + "chrono", + "console", + "ctrlc", + "dirs", + "fs_extra", + "futures-util", + "global-error", "home", + "humansize", + "ignore", + "indicatif", + "lz4", + "mime_guess", + "nix", "openssl", + "rand", + "regex", + "reqwest", "rivet-api-ee", + "rivet-term", + "sentry", "serde", "serde_json", + "strum", + "sysinfo", + "tabled", + "tar", + "tempfile", + "term_size", "thiserror", "tokio", + "tokio-util", "tower", + "typed-path", + "url", + "uuid", "vergen", + "webbrowser", + "which", + "winapi", + "zip", ] [[package]] @@ -2271,15 +2218,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_spanned" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" -dependencies = [ - "serde", -] - [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -2320,19 +2258,6 @@ dependencies = [ "syn 2.0.39", ] -[[package]] -name = "serde_yaml" -version = "0.9.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cc7a1570e38322cfe4154732e5110f887ea57e22b76f4bfd32b5bdd3368666c" -dependencies = [ - "indexmap 2.1.0", - "itoa", - "ryu", - "serde", - "unsafe-libyaml", -] - [[package]] name = "signal-hook-registry" version = "1.4.1" @@ -2696,40 +2621,6 @@ dependencies = [ "serde", ] -[[package]] -name = "toml" -version = "0.8.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4e43f8cc456c9704c851ae29c67e17ef65d2c30017c17a9765b89c382dc8bba" -dependencies = [ - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit", -] - -[[package]] -name = "toml_datetime" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" -dependencies = [ - "serde", -] - -[[package]] -name = "toml_edit" -version = "0.22.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c" -dependencies = [ - "indexmap 2.1.0", - "serde", - "serde_spanned", - "toml_datetime", - "winnow", -] - [[package]] name = "tower" version = "0.4.13" @@ -2840,12 +2731,6 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" -[[package]] -name = "unsafe-libyaml" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" - [[package]] name = "untrusted" version = "0.9.0" @@ -3335,15 +3220,6 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" -[[package]] -name = "winnow" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d" -dependencies = [ - "memchr", -] - [[package]] name = "winreg" version = "0.50.0" @@ -3374,37 +3250,6 @@ dependencies = [ "linked-hash-map", ] -[[package]] -name = "yaml-rust2" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "498f4d102a79ea1c9d4dd27573c0fc96ad74c023e8da38484e47883076da25fb" -dependencies = [ - "arraydeque", - "encoding_rs", - "hashlink", -] - -[[package]] -name = "zerocopy" -version = "0.7.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - [[package]] name = "zip" version = "0.5.13" diff --git a/Cargo.toml b/Cargo.toml index c85f59eb..6b338c22 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [workspace] members = [ - "rivet-toolchain-core", "rivet-cli", + "rivet-toolchain", ] # Config for 'cargo dist' diff --git a/rivet-cli/Cargo.toml b/rivet-cli/Cargo.toml index a6b9bb61..34f9ed29 100644 --- a/rivet-cli/Cargo.toml +++ b/rivet-cli/Cargo.toml @@ -19,8 +19,6 @@ 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"] } -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"] } dirs = "5.0" @@ -39,7 +37,6 @@ rivet-term = { git = "https://github.com/rivet-gg/rivet-term.git", rev = "f70f76 sentry = "0.32" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -serde_yaml = "0.9" strum = { version = "0.24", features = ["derive"] } sysinfo = "0.30.0" tabled = "0.8.0" @@ -64,7 +61,3 @@ winapi = { version = "0.3.9", features = ["processthreadsapi", "winnt"] } [dev-dependencies] assert_cmd = "2.0" -[build-dependencies] -anyhow = "1.0" -vergen = { version = "7.5", default_features = false, features = ["build", "git", "rustc", "cargo"] } - diff --git a/rivet-cli/src/commands/avatar.rs b/rivet-cli/src/commands/avatar.rs index 21751cc1..3cedab6b 100644 --- a/rivet-cli/src/commands/avatar.rs +++ b/rivet-cli/src/commands/avatar.rs @@ -1,5 +1,5 @@ use clap::Parser; -use toolchain_core::rivet_api::apis; +use toolchain::rivet_api::apis; use global_error::prelude::*; use tabled::Tabled; @@ -12,7 +12,7 @@ pub enum SubCommand { } impl SubCommand { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult<()> { match self { SubCommand::List => { let custom_avatars_res = unwrap!( diff --git a/rivet-cli/src/commands/backend/database.rs b/rivet-cli/src/commands/backend/database.rs index e66981ed..e195a47f 100644 --- a/rivet-cli/src/commands/backend/database.rs +++ b/rivet-cli/src/commands/backend/database.rs @@ -1,7 +1,7 @@ use std::path::PathBuf; use clap::Parser; -use toolchain_core::rivet_api::apis; +use toolchain::rivet_api::apis; use global_error::prelude::*; use uuid::Uuid; @@ -64,7 +64,7 @@ pub struct Opts { } pub async fn provision_database( - ctx: &toolchain_core::Ctx, + ctx: &toolchain::Ctx, project_id: Uuid, env_id: Uuid, ) -> GlobalResult<()> { diff --git a/rivet-cli/src/commands/backend/deploy.rs b/rivet-cli/src/commands/backend/deploy.rs index 7b8da27c..7a377d34 100644 --- a/rivet-cli/src/commands/backend/deploy.rs +++ b/rivet-cli/src/commands/backend/deploy.rs @@ -1,7 +1,7 @@ use std::{collections::HashMap, path::PathBuf, sync::Arc}; use clap::Parser; -use toolchain_core::rivet_api::{apis, models}; +use toolchain::rivet_api::{apis, models}; use futures_util::{StreamExt, TryStreamExt}; use global_error::prelude::*; use serde::Deserialize; @@ -28,7 +28,7 @@ pub struct Opts { } impl Opts { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult<()> { let project = get_or_create_project(ctx).await?; let project_id_str = project.project_id.to_string(); diff --git a/rivet-cli/src/commands/backend/environment/create.rs b/rivet-cli/src/commands/backend/environment/create.rs index f862798e..cef5766c 100644 --- a/rivet-cli/src/commands/backend/environment/create.rs +++ b/rivet-cli/src/commands/backend/environment/create.rs @@ -1,5 +1,5 @@ use clap::Parser; -use toolchain_core::rivet_api::{apis, models}; +use toolchain::rivet_api::{apis, models}; use global_error::prelude::*; #[derive(Parser)] @@ -16,7 +16,7 @@ pub struct Opts { } impl Opts { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult<()> { let project_res = apis::ee_cloud_games_projects_api::ee_cloud_games_projects_get( &ctx.openapi_config_cloud, &ctx.game_id, diff --git a/rivet-cli/src/commands/backend/environment/mod.rs b/rivet-cli/src/commands/backend/environment/mod.rs index 8d4bbe70..87f59dd1 100644 --- a/rivet-cli/src/commands/backend/environment/mod.rs +++ b/rivet-cli/src/commands/backend/environment/mod.rs @@ -9,7 +9,7 @@ pub enum SubCommand { } impl SubCommand { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult<()> { match self { SubCommand::Create(opts) => opts.execute(ctx).await, } diff --git a/rivet-cli/src/commands/backend/mod.rs b/rivet-cli/src/commands/backend/mod.rs index 397cf207..e089f9af 100644 --- a/rivet-cli/src/commands/backend/mod.rs +++ b/rivet-cli/src/commands/backend/mod.rs @@ -1,7 +1,7 @@ use std::{collections::HashMap, io::Write, path::PathBuf, str::FromStr}; use clap::Parser; -use toolchain_core::rivet_api::{apis, models}; +use toolchain::rivet_api::{apis, models}; use global_error::prelude::*; use tempfile::NamedTempFile; use tokio::process::Command; @@ -31,7 +31,7 @@ pub enum SubCommand { } impl SubCommand { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult<()> { match self { SubCommand::Deploy(opts) => opts.execute(&ctx).await, SubCommand::Environment { command } => command.execute(&ctx).await, @@ -43,7 +43,7 @@ impl SubCommand { * Gets or auto-creates a backend project for the game. */ pub async fn get_or_create_project( - ctx: &toolchain_core::Ctx, + ctx: &toolchain::Ctx, ) -> GlobalResult> { let project_res = apis::ee_cloud_games_projects_api::ee_cloud_games_projects_get( &ctx.openapi_config_cloud, @@ -61,7 +61,7 @@ pub async fn get_or_create_project( } pub async fn passthrough( - ctx: Option<&toolchain_core::Ctx>, + ctx: Option<&toolchain::Ctx>, db_command: Option, ) -> GlobalResult<()> { let mut opengb_env = HashMap::new(); diff --git a/rivet-cli/src/commands/cdn.rs b/rivet-cli/src/commands/cdn.rs index 2f34acd1..6164f039 100644 --- a/rivet-cli/src/commands/cdn.rs +++ b/rivet-cli/src/commands/cdn.rs @@ -1,5 +1,5 @@ use clap::Parser; -use toolchain_core::rivet_api::{apis, models}; +use toolchain::rivet_api::{apis, models}; use futures_util::{StreamExt, TryStreamExt}; use global_error::prelude::*; use serde::Serialize; @@ -33,7 +33,7 @@ pub struct PushOpts { } impl SubCommand { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult<()> { match self { SubCommand::Push(push_opts) => { let output = push(ctx, push_opts).await?; @@ -54,7 +54,7 @@ pub struct PushOutput { pub site_id: Uuid, } -pub async fn push(ctx: &toolchain_core::Ctx, push_opts: &PushOpts) -> GlobalResult { +pub async fn push(ctx: &toolchain::Ctx, push_opts: &PushOpts) -> GlobalResult { let reqwest_client = Arc::new(reqwest::Client::new()); let upload_path = env::current_dir()?.join(&push_opts.path); @@ -205,7 +205,7 @@ pub struct BuildPushOpts { } pub async fn build_and_push( - ctx: &toolchain_core::Ctx, + ctx: &toolchain::Ctx, push_opts: &BuildPushOpts, ) -> GlobalResult { eprintln!(); diff --git a/rivet-cli/src/commands/ci.rs b/rivet-cli/src/commands/ci.rs index fbbc7981..8ca4cf7d 100644 --- a/rivet-cli/src/commands/ci.rs +++ b/rivet-cli/src/commands/ci.rs @@ -1,5 +1,5 @@ use clap::Parser; -use toolchain_core::rivet_api::models; +use toolchain::rivet_api::models; use global_error::prelude::*; use std::collections::HashMap; use tokio::fs; @@ -16,7 +16,7 @@ pub enum SubCommand { } impl SubCommand { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult<()> { match self { SubCommand::Generate { command } => command.execute(ctx).await, } @@ -30,7 +30,7 @@ pub enum GenerateOpts { } impl GenerateOpts { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult<()> { match self { GenerateOpts::GitHub(opts) => gen_github(ctx, opts).await, } @@ -47,7 +47,7 @@ pub struct GenerateGitHubOpts { allow_idle_lobbies: bool, } -async fn gen_github(ctx: &toolchain_core::Ctx, opts: &GenerateGitHubOpts) -> GlobalResult<()> { +async fn gen_github(ctx: &toolchain::Ctx, opts: &GenerateGitHubOpts) -> GlobalResult<()> { let relative_path = opts .path .clone() @@ -71,7 +71,7 @@ async fn gen_github(ctx: &toolchain_core::Ctx, opts: &GenerateGitHubOpts) -> Glo // TODO: Strings in this workflow are not appropriately escaped async fn gen_github_workflow( - ctx: &toolchain_core::Ctx, + ctx: &toolchain::Ctx, opts: &GenerateGitHubOpts, ) -> GlobalResult { let mut version = config::read_config(Vec::new(), None).await?; @@ -163,7 +163,7 @@ async fn gen_github_workflow( Ok(workflow) } -fn common_substitute(ctx: &toolchain_core::Ctx, input: &str) -> String { +fn common_substitute(ctx: &toolchain::Ctx, input: &str) -> String { input .replace( "__RIVET_CLI_VERSION__", @@ -187,7 +187,7 @@ fn validate_idle_lobbies( } fn append_dockerfile( - ctx: &toolchain_core::Ctx, + ctx: &toolchain::Ctx, workflow: &mut String, needs_jobs: &mut Vec, overrides: &mut Vec, diff --git a/rivet-cli/src/commands/config.rs b/rivet-cli/src/commands/config.rs index f67da456..78eb5054 100644 --- a/rivet-cli/src/commands/config.rs +++ b/rivet-cli/src/commands/config.rs @@ -1,5 +1,5 @@ use clap::Parser; -use toolchain_core::rivet_api::{apis, models}; +use toolchain::rivet_api::{apis, models}; use global_error::prelude::*; use serde::{Deserialize, Serialize}; use std::collections::HashSet; @@ -13,7 +13,7 @@ pub enum SubCommand { } impl SubCommand { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult<()> { match self { SubCommand::Validate(opts) => { let errors = opts.execute(ctx).await?; @@ -48,7 +48,7 @@ pub struct ValidateOpts { } impl ValidateOpts { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult> { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult> { let overrides = parse_config_override_args(&self.overrides)?; let mut rivet_config = read_config(overrides, self.namespace.as_ref().map(String::as_str)).await?; diff --git a/rivet-cli/src/commands/deploy.rs b/rivet-cli/src/commands/deploy.rs index 584413b6..854a7838 100644 --- a/rivet-cli/src/commands/deploy.rs +++ b/rivet-cli/src/commands/deploy.rs @@ -1,5 +1,5 @@ use clap::Parser; -use toolchain_core::rivet_api::{apis, models}; +use toolchain::rivet_api::{apis, models}; use global_error::prelude::*; use serde::Serialize; use serde_json::json; @@ -67,7 +67,7 @@ pub struct Opts { } impl Opts { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult<()> { // Derive namespace let namespace = match ( self.namespace.as_ref().or(self.namespace_flag.as_ref()), @@ -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: &toolchain_core::Ctx, + ctx: &toolchain::Ctx, overrides: &mut Vec<(String, serde_json::Value)>, build_tag: &Option, build_name: &Option, @@ -195,7 +195,7 @@ pub struct DeployOutput { /// Deploys a new Rivet version. pub async fn deploy( - ctx: &toolchain_core::Ctx, + ctx: &toolchain::Ctx, display_name: Option<&str>, overrides: Vec<(String, serde_json::Value)>, namespace_name_id: Option<&str>, @@ -312,7 +312,7 @@ pub async fn deploy( /// Builds the Docker image and CDN site if needed. pub async fn build_config_dependencies( - ctx: &toolchain_core::Ctx, + ctx: &toolchain::Ctx, namespace: Option<&str>, version: &mut models::CloudVersionConfig, display_name: &str, @@ -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: &toolchain_core::Ctx, + ctx: &toolchain::Ctx, display_name: &str, docker: &mut Box, format: Option<&struct_fmt::Format>, @@ -417,7 +417,7 @@ pub async fn build_and_push_image( } } pub async fn build_and_push_site( - ctx: &toolchain_core::Ctx, + ctx: &toolchain::Ctx, namespace: Option<&str>, display_name: &str, cdn: &mut Box, diff --git a/rivet-cli/src/commands/dev.rs b/rivet-cli/src/commands/dev.rs index 3d236e08..be915d3f 100644 --- a/rivet-cli/src/commands/dev.rs +++ b/rivet-cli/src/commands/dev.rs @@ -9,7 +9,7 @@ pub enum SubCommand { } impl SubCommand { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult<()> { match self { SubCommand::CreateDevToken(opts) => { rivet_term::status::warn( diff --git a/rivet-cli/src/commands/docker/build.rs b/rivet-cli/src/commands/docker/build.rs index 07ef43a6..6d86fe01 100644 --- a/rivet-cli/src/commands/docker/build.rs +++ b/rivet-cli/src/commands/docker/build.rs @@ -53,7 +53,7 @@ pub struct BuildImageOutput { /// Builds an image and archives it to a path. pub async fn build_image( - ctx: &toolchain_core::Ctx, + ctx: &toolchain::Ctx, dockerfile: &Path, build_kind: super::BuildKind, build_compression: super::BuildCompression, diff --git a/rivet-cli/src/commands/docker/mod.rs b/rivet-cli/src/commands/docker/mod.rs index b3f4c165..ec829343 100644 --- a/rivet-cli/src/commands/docker/mod.rs +++ b/rivet-cli/src/commands/docker/mod.rs @@ -50,7 +50,7 @@ pub struct BuildPushOpts { } impl SubCommand { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult<()> { match self { SubCommand::Push(push_opts) => { let output = push(ctx, push_opts).await?; @@ -133,7 +133,7 @@ impl BuildCompression { } } -pub async fn push(ctx: &toolchain_core::Ctx, push_opts: &PushOpts) -> GlobalResult { +pub async fn push(ctx: &toolchain::Ctx, push_opts: &PushOpts) -> GlobalResult { // Re-tag image with unique tag let unique_image_tag = generate_unique_image_tag(); let mut tag_cmd = tokio::process::Command::new("docker"); @@ -165,7 +165,7 @@ pub async fn push(ctx: &toolchain_core::Ctx, push_opts: &PushOpts) -> GlobalResu } pub async fn build_and_push( - ctx: &toolchain_core::Ctx, + ctx: &toolchain::Ctx, push_opts: &BuildPushOpts, ) -> GlobalResult { // Build image diff --git a/rivet-cli/src/commands/docker/push.rs b/rivet-cli/src/commands/docker/push.rs index eb645479..2635d9dc 100644 --- a/rivet-cli/src/commands/docker/push.rs +++ b/rivet-cli/src/commands/docker/push.rs @@ -1,4 +1,4 @@ -use toolchain_core::rivet_api::{apis, models}; +use toolchain::rivet_api::{apis, models}; use futures_util::stream::{StreamExt, TryStreamExt}; use global_error::prelude::*; use serde::Serialize; @@ -32,7 +32,7 @@ pub struct PushOutput { pub image_id: Uuid, } -pub async fn push_tar(ctx: &toolchain_core::Ctx, push_opts: &PushOpts) -> GlobalResult { +pub async fn push_tar(ctx: &toolchain::Ctx, push_opts: &PushOpts) -> GlobalResult { let reqwest_client = Arc::new(reqwest::Client::new()); // Inspect the image diff --git a/rivet-cli/src/commands/engine/mod.rs b/rivet-cli/src/commands/engine/mod.rs index 1bdfb1e9..949182da 100644 --- a/rivet-cli/src/commands/engine/mod.rs +++ b/rivet-cli/src/commands/engine/mod.rs @@ -12,7 +12,7 @@ pub enum SubCommand { } impl SubCommand { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult<()> { match self { SubCommand::Unreal { command } => command.execute(ctx).await, } diff --git a/rivet-cli/src/commands/engine/unreal.rs b/rivet-cli/src/commands/engine/unreal.rs index 3910abda..ea117ddd 100644 --- a/rivet-cli/src/commands/engine/unreal.rs +++ b/rivet-cli/src/commands/engine/unreal.rs @@ -15,7 +15,7 @@ pub enum SubCommand { } impl SubCommand { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult<()> { match self { SubCommand::StartServer => { let pwd = std::env::current_dir()?; diff --git a/rivet-cli/src/commands/exec.rs b/rivet-cli/src/commands/exec.rs index 1bdadfbb..b3d6ab58 100644 --- a/rivet-cli/src/commands/exec.rs +++ b/rivet-cli/src/commands/exec.rs @@ -22,7 +22,7 @@ pub struct Opts { } impl Opts { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult<()> { // Determine token let token = match (self.dev, self.server) { (true, true) => { diff --git a/rivet-cli/src/commands/game.rs b/rivet-cli/src/commands/game.rs index 06bcce7b..da2fa9bb 100644 --- a/rivet-cli/src/commands/game.rs +++ b/rivet-cli/src/commands/game.rs @@ -1,5 +1,5 @@ use clap::Parser; -use toolchain_core::rivet_api::apis; +use toolchain::rivet_api::apis; use global_error::prelude::*; use serde::Serialize; @@ -19,7 +19,7 @@ pub enum SubCommand { } impl SubCommand { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult<()> { match self { SubCommand::Get { format } => { let game_res = unwrap!( @@ -49,6 +49,6 @@ impl SubCommand { } } -pub fn dashboard_url(ctx: &toolchain_core::Ctx, game_id: &str) -> String { +pub fn dashboard_url(ctx: &toolchain::Ctx, game_id: &str) -> String { format!("{}/developer/games/{game_id}", ctx.bootstrap.origins.hub) } diff --git a/rivet-cli/src/commands/init.rs b/rivet-cli/src/commands/init.rs index 3bb72329..a5dcccff 100644 --- a/rivet-cli/src/commands/init.rs +++ b/rivet-cli/src/commands/init.rs @@ -1,5 +1,5 @@ use clap::Parser; -use toolchain_core::{ +use toolchain::{ ctx, rivet_api::{apis, models}, Ctx, @@ -155,7 +155,7 @@ async fn init_ctx_and_token( global_config::read_project(|x| x.tokens.cloud.clone()).await? }; let ctx = if let Some(token) = token { - toolchain_core::ctx::init(override_endpoint.clone(), token).await? + toolchain::ctx::init(override_endpoint.clone(), token).await? } else { read_token(term, override_endpoint.clone()).await? }; @@ -314,7 +314,7 @@ pub async fn create_config_default(engine: &Engine) -> GlobalResult { Ok(created_config) } -async fn read_token(term: &Term, override_endpoint: Option) -> GlobalResult { +async fn read_token(term: &Term, override_endpoint: Option) -> GlobalResult { // Create OpenAPI configuration without bearer token to send link request let openapi_config_cloud_unauthed = apis::configuration::Configuration { base_path: override_endpoint @@ -389,7 +389,7 @@ async fn read_token(term: &Term, override_endpoint: Option) -> GlobalRes }; // Create new context - let new_ctx = toolchain_core::ctx::init( + let new_ctx = toolchain::ctx::init( override_endpoint, // Exclude overridden access token to check the token token.clone(), diff --git a/rivet-cli/src/commands/ns.rs b/rivet-cli/src/commands/ns.rs index 039c9dda..56f832c1 100644 --- a/rivet-cli/src/commands/ns.rs +++ b/rivet-cli/src/commands/ns.rs @@ -1,5 +1,5 @@ use clap::Parser; -use toolchain_core::rivet_api::{apis, models}; +use toolchain::rivet_api::{apis, models}; use global_error::prelude::*; use serde::Serialize; use tabled::Tabled; @@ -52,7 +52,7 @@ pub enum SubCommand { } impl SubCommand { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult<()> { match self { SubCommand::List => { let game_res = unwrap!( @@ -207,7 +207,7 @@ impl SubCommand { } async fn print_ns( - ctx: &toolchain_core::Ctx, + ctx: &toolchain::Ctx, format: &struct_fmt::Format, namespace_id: &str, ) -> GlobalResult<()> { @@ -241,7 +241,7 @@ async fn print_ns( Ok(()) } -pub fn dashboard_url(ctx: &toolchain_core::Ctx, game_id: &str, ns_id: &str) -> String { +pub fn dashboard_url(ctx: &toolchain::Ctx, game_id: &str, ns_id: &str) -> String { format!( "{}/developer/games/{game_id}/namespaces/{ns_id}", ctx.bootstrap.origins.hub diff --git a/rivet-cli/src/commands/run.rs b/rivet-cli/src/commands/run.rs index ea08836b..2ce07cb3 100644 --- a/rivet-cli/src/commands/run.rs +++ b/rivet-cli/src/commands/run.rs @@ -22,7 +22,7 @@ pub struct Opts { } impl Opts { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult<()> { // Read script let config = crate::commands::config::read_config( Vec::new(), diff --git a/rivet-cli/src/commands/sidekick/deploy.rs b/rivet-cli/src/commands/sidekick/deploy.rs index e85a2915..cc7c38e1 100644 --- a/rivet-cli/src/commands/sidekick/deploy.rs +++ b/rivet-cli/src/commands/sidekick/deploy.rs @@ -34,7 +34,7 @@ pub struct Output {} impl SideKickHandler for Output {} impl Opts { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult { // Parse overrides let mut overrides = parse_config_override_args(&self.overrides)?; diff --git a/rivet-cli/src/commands/sidekick/get_bootstrap_data.rs b/rivet-cli/src/commands/sidekick/get_bootstrap_data.rs index b8e987f7..e4bd5110 100644 --- a/rivet-cli/src/commands/sidekick/get_bootstrap_data.rs +++ b/rivet-cli/src/commands/sidekick/get_bootstrap_data.rs @@ -18,7 +18,7 @@ pub struct Output { impl SideKickHandler for Output {} impl Opts { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult { Ok(Output { token: ctx.access_token.clone(), api_endpoint: ctx.api_endpoint.clone(), diff --git a/rivet-cli/src/commands/sidekick/get_link.rs b/rivet-cli/src/commands/sidekick/get_link.rs index 4999e0a7..54653270 100644 --- a/rivet-cli/src/commands/sidekick/get_link.rs +++ b/rivet-cli/src/commands/sidekick/get_link.rs @@ -1,5 +1,5 @@ use clap::Parser; -use toolchain_core::{ctx, rivet_api::apis}; +use toolchain::{ctx, rivet_api::apis}; use global_error::prelude::*; use serde::Serialize; diff --git a/rivet-cli/src/commands/sidekick/get_lobbies_link.rs b/rivet-cli/src/commands/sidekick/get_lobbies_link.rs index 2e2cbd71..481f8a1d 100644 --- a/rivet-cli/src/commands/sidekick/get_lobbies_link.rs +++ b/rivet-cli/src/commands/sidekick/get_lobbies_link.rs @@ -18,7 +18,7 @@ pub struct Output { impl SideKickHandler for Output {} impl Opts { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult { let mut url = get_namespace_url(self.namespace.clone(), ctx).await?; url.path_segments_mut().unwrap().push("lobbies"); Ok(Output { diff --git a/rivet-cli/src/commands/sidekick/get_logs_link.rs b/rivet-cli/src/commands/sidekick/get_logs_link.rs index 93875690..63582091 100644 --- a/rivet-cli/src/commands/sidekick/get_logs_link.rs +++ b/rivet-cli/src/commands/sidekick/get_logs_link.rs @@ -18,7 +18,7 @@ pub struct Output { impl SideKickHandler for Output {} impl Opts { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult { let mut url = get_namespace_url(self.namespace.clone(), ctx).await?; url.path_segments_mut().unwrap().push("logs"); Ok(Output { diff --git a/rivet-cli/src/commands/sidekick/get_namespace_dev_token.rs b/rivet-cli/src/commands/sidekick/get_namespace_dev_token.rs index 7f71894d..963f6e4c 100644 --- a/rivet-cli/src/commands/sidekick/get_namespace_dev_token.rs +++ b/rivet-cli/src/commands/sidekick/get_namespace_dev_token.rs @@ -23,7 +23,7 @@ pub struct Output { impl SideKickHandler for Output {} impl Opts { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult { let token = commands::token::create::dev::execute( ctx, &commands::token::create::dev::Opts { diff --git a/rivet-cli/src/commands/sidekick/get_namespace_pub_token.rs b/rivet-cli/src/commands/sidekick/get_namespace_pub_token.rs index 50f27255..c979e146 100644 --- a/rivet-cli/src/commands/sidekick/get_namespace_pub_token.rs +++ b/rivet-cli/src/commands/sidekick/get_namespace_pub_token.rs @@ -23,7 +23,7 @@ pub struct Output { impl SideKickHandler for Output {} impl Opts { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult { let token = commands::token::create::pub_ns::execute( ctx, &commands::token::create::pub_ns::Opts { diff --git a/rivet-cli/src/commands/sidekick/get_versions_link.rs b/rivet-cli/src/commands/sidekick/get_versions_link.rs index 52e6dc78..14dd2e84 100644 --- a/rivet-cli/src/commands/sidekick/get_versions_link.rs +++ b/rivet-cli/src/commands/sidekick/get_versions_link.rs @@ -18,7 +18,7 @@ pub struct Output { impl SideKickHandler for Output {} impl Opts { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult { let mut url = get_namespace_url(self.namespace.clone(), ctx).await?; url.path_segments_mut().unwrap().push("versions"); Ok(Output { diff --git a/rivet-cli/src/commands/sidekick/mod.rs b/rivet-cli/src/commands/sidekick/mod.rs index d2e713bb..8b117d90 100644 --- a/rivet-cli/src/commands/sidekick/mod.rs +++ b/rivet-cli/src/commands/sidekick/mod.rs @@ -149,7 +149,7 @@ impl SubCommand { pub async fn execute( &self, - ctx: &toolchain_core::Ctx, + ctx: &toolchain::Ctx, _term: &Term, show_terminal: bool, inside_terminal: bool, diff --git a/rivet-cli/src/commands/sidekick/unlink.rs b/rivet-cli/src/commands/sidekick/unlink.rs index ad965e24..531fca12 100644 --- a/rivet-cli/src/commands/sidekick/unlink.rs +++ b/rivet-cli/src/commands/sidekick/unlink.rs @@ -15,7 +15,7 @@ pub struct Output {} impl SideKickHandler for Output {} impl Opts { - pub async fn execute(&self, _ctx: &toolchain_core::Ctx) -> GlobalResult { + pub async fn execute(&self, _ctx: &toolchain::Ctx) -> GlobalResult { commands::unlink::unlink().await?; Ok(Output {}) diff --git a/rivet-cli/src/commands/sidekick/util.rs b/rivet-cli/src/commands/sidekick/util.rs index 56cf9001..dde0933a 100644 --- a/rivet-cli/src/commands/sidekick/util.rs +++ b/rivet-cli/src/commands/sidekick/util.rs @@ -3,7 +3,7 @@ use url::Url; pub async fn get_namespace_url( namespace: String, - ctx: &std::sync::Arc, + ctx: &std::sync::Arc, ) -> GlobalResult { // Build the URL from the game ID and the namespace let mut url = unwrap!(Url::parse(&format!( diff --git a/rivet-cli/src/commands/sidekick/wait_for_login.rs b/rivet-cli/src/commands/sidekick/wait_for_login.rs index 20892e09..4b81cabb 100644 --- a/rivet-cli/src/commands/sidekick/wait_for_login.rs +++ b/rivet-cli/src/commands/sidekick/wait_for_login.rs @@ -1,5 +1,5 @@ use clap::Parser; -use toolchain_core::{ctx, rivet_api::apis}; +use toolchain::{ctx, rivet_api::apis}; use global_error::prelude::*; use serde::Serialize; @@ -58,7 +58,7 @@ impl Opts { }; // Create new context - let new_ctx = toolchain_core::ctx::init( + let new_ctx = toolchain::ctx::init( api_endpoint, // Exclude overridden access token to check the token token.clone(), diff --git a/rivet-cli/src/commands/token/create/dev.rs b/rivet-cli/src/commands/token/create/dev.rs index e5f79618..c999245d 100644 --- a/rivet-cli/src/commands/token/create/dev.rs +++ b/rivet-cli/src/commands/token/create/dev.rs @@ -1,7 +1,7 @@ use std::io::Write; use clap::Parser; -use toolchain_core::rivet_api::{apis, models}; +use toolchain::rivet_api::{apis, models}; use global_error::prelude::*; use serde::Serialize; use std::collections::HashMap; @@ -16,7 +16,7 @@ pub struct Opts { } impl Opts { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult<()> { let output = execute(ctx, self).await?; print!("{}", output.token); @@ -32,7 +32,7 @@ pub struct Output { pub token: String, } -pub async fn execute(ctx: &toolchain_core::Ctx, opts: &Opts) -> GlobalResult { +pub async fn execute(ctx: &toolchain::Ctx, opts: &Opts) -> GlobalResult { let ns_name_id = opts .namespace .as_ref() @@ -183,7 +183,7 @@ async fn read_config( } } -async fn fetch_namespace_id(ctx: &toolchain_core::Ctx, ns_name_id: &str) -> GlobalResult { +async fn fetch_namespace_id(ctx: &toolchain::Ctx, ns_name_id: &str) -> GlobalResult { let game_res = unwrap!( apis::cloud_games_api::cloud_games_get_game_by_id( &ctx.openapi_config_cloud, diff --git a/rivet-cli/src/commands/token/create/mod.rs b/rivet-cli/src/commands/token/create/mod.rs index be8fa86b..7875c0e7 100644 --- a/rivet-cli/src/commands/token/create/mod.rs +++ b/rivet-cli/src/commands/token/create/mod.rs @@ -20,7 +20,7 @@ pub enum SubCommand { } impl SubCommand { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult<()> { match self { SubCommand::Development(opts) => opts.execute(ctx).await, SubCommand::Public(opts) => opts.execute(ctx).await, diff --git a/rivet-cli/src/commands/token/create/pub_ns.rs b/rivet-cli/src/commands/token/create/pub_ns.rs index 3bda09da..bd744e19 100644 --- a/rivet-cli/src/commands/token/create/pub_ns.rs +++ b/rivet-cli/src/commands/token/create/pub_ns.rs @@ -1,7 +1,7 @@ use std::io::Write; use clap::Parser; -use toolchain_core::rivet_api::apis; +use toolchain::rivet_api::apis; use global_error::prelude::*; use serde::Serialize; @@ -15,7 +15,7 @@ pub struct Opts { } impl Opts { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult<()> { let output = execute(ctx, self).await?; print!("{}", output.token); @@ -31,7 +31,7 @@ pub struct Output { pub token: String, } -pub async fn execute(ctx: &toolchain_core::Ctx, opts: &Opts) -> GlobalResult { +pub async fn execute(ctx: &toolchain::Ctx, opts: &Opts) -> GlobalResult { let ns_name_id = opts .namespace .as_ref() @@ -81,7 +81,7 @@ pub async fn execute(ctx: &toolchain_core::Ctx, opts: &Opts) -> GlobalResult GlobalResult { +async fn fetch_namespace_id(ctx: &toolchain::Ctx, ns_name_id: &str) -> GlobalResult { let game_res = unwrap!( apis::cloud_games_api::cloud_games_get_game_by_id( &ctx.openapi_config_cloud, diff --git a/rivet-cli/src/commands/token/mod.rs b/rivet-cli/src/commands/token/mod.rs index ee4617d5..7a77cb99 100644 --- a/rivet-cli/src/commands/token/mod.rs +++ b/rivet-cli/src/commands/token/mod.rs @@ -12,7 +12,7 @@ pub enum SubCommand { } impl SubCommand { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult<()> { match self { SubCommand::Create { command } => command.execute(ctx).await, } diff --git a/rivet-cli/src/commands/version.rs b/rivet-cli/src/commands/version.rs index 9a58a8f3..e1583d1b 100644 --- a/rivet-cli/src/commands/version.rs +++ b/rivet-cli/src/commands/version.rs @@ -1,5 +1,5 @@ use clap::Parser; -use toolchain_core::rivet_api::apis; +use toolchain::rivet_api::apis; use global_error::prelude::*; use tabled::Tabled; @@ -34,7 +34,7 @@ pub enum SubCommand { } impl SubCommand { - pub async fn execute(&self, ctx: &toolchain_core::Ctx) -> GlobalResult<()> { + pub async fn execute(&self, ctx: &toolchain::Ctx) -> GlobalResult<()> { match self { SubCommand::List => { let game_res = unwrap!( @@ -110,7 +110,7 @@ impl SubCommand { } /// Prints information about a game version -async fn print_version(ctx: &toolchain_core::Ctx, version_id: &str) -> GlobalResult<()> { +async fn print_version(ctx: &toolchain::Ctx, version_id: &str) -> GlobalResult<()> { let version_res = unwrap!( apis::cloud_games_versions_api::cloud_games_versions_get_game_version_by_id( &ctx.openapi_config_cloud, @@ -126,7 +126,7 @@ async fn print_version(ctx: &toolchain_core::Ctx, version_id: &str) -> GlobalRes Ok(()) } -pub fn dashboard_url(ctx: &toolchain_core::Ctx, game_id: &str, version_id: &str) -> String { +pub fn dashboard_url(ctx: &toolchain::Ctx, game_id: &str, version_id: &str) -> String { format!( "{}/developer/games/{game_id}/versions/{version_id}", ctx.bootstrap.origins.hub, diff --git a/rivet-cli/src/main.rs b/rivet-cli/src/main.rs index 8dc80a5c..05c70eb4 100644 --- a/rivet-cli/src/main.rs +++ b/rivet-cli/src/main.rs @@ -404,7 +404,7 @@ async fn read_opts() -> GlobalResult { async fn build_ctx( api_endpoint: Option, token: Option, -) -> GlobalResult { +) -> GlobalResult { let Some(token) = token else { if !os::is_linux_and_root() { rivet_term::status::error("Unauthenticated", "Run `rivet init` to authenticate"); @@ -420,7 +420,7 @@ async fn build_ctx( bail!("rivet token not found") }; - Ok(toolchain_core::ctx::init(api_endpoint, token).await?) + Ok(toolchain::ctx::init(api_endpoint, token).await?) } async fn opengb_passthrough() -> GlobalResult { diff --git a/rivet-cli/src/util/mod.rs b/rivet-cli/src/util/mod.rs index 6018862c..99778ba9 100644 --- a/rivet-cli/src/util/mod.rs +++ b/rivet-cli/src/util/mod.rs @@ -1,15 +1,3 @@ -pub mod api; -pub mod cmd; -pub mod download; -pub mod global_config; -pub mod lz4; -pub mod show_term; -pub mod os; -pub mod paths; pub mod struct_fmt; -pub mod telemetry; pub mod term; pub mod text; -pub mod upload; -pub mod users; -pub mod version_config; diff --git a/rivet-cli/src/util/upload.rs b/rivet-cli/src/util/upload.rs deleted file mode 100644 index 7fae88e7..00000000 --- a/rivet-cli/src/util/upload.rs +++ /dev/null @@ -1,253 +0,0 @@ -use std::{ - path::{Component, Path, PathBuf}, - time::{Duration, Instant}, -}; - -use toolchain_core::rivet_api::models; -use console::style; -use futures_util::stream::StreamExt; -use global_error::prelude::*; -use tokio::{ - fs::File, - io::{AsyncReadExt, AsyncSeekExt}, -}; -use tokio_util::io::ReaderStream; - -use crate::util::term; - -/// Prepared file that will be uploaded to S3. -#[derive(Clone)] -pub struct UploadFile { - pub absolute_path: PathBuf, - pub prepared: models::UploadPrepareFile, -} - -pub fn format_file_size(bytes: u64) -> GlobalResult { - use humansize::FileSize; - - let size = format!( - "{}", - unwrap!(bytes.file_size(humansize::file_size_opts::BINARY).ok()) - ); - Ok(size) -} - -/// Lists all files in a directory and returns the data required to upload them. -pub fn prepare_upload_dir(base_path: &Path) -> GlobalResult> { - let mut files = Vec::::new(); - - // Walk files while respecting .rivet-cdn-ignore - let walk = ignore::WalkBuilder::new(base_path) - .standard_filters(false) - .add_custom_ignore_filename(".rivet-cdn-ignore") - .parents(true) - .build(); - for entry in walk { - let entry = entry?; - let file_meta = entry.metadata()?; - - if file_meta.is_file() { - let file_path = entry.path(); - - files.push(prepare_upload_file( - file_path, - file_path.strip_prefix(base_path)?, - file_meta, - )?); - } - } - - Ok(files) -} - -pub fn prepare_upload_file, Q: AsRef>( - absolute_path: P, - upload_path: Q, - metadata: std::fs::Metadata, -) -> GlobalResult { - let absolute_path = absolute_path.as_ref(); - - // Convert path to Unix-style string - let path_str = upload_path - .as_ref() - .components() - .filter_map(|c| match c { - Component::Normal(name) => name.to_str().map(str::to_string), - _ => None, - }) - .collect::>() - .join("/"); - - // Attempt to guess the MIME type - let content_type = mime_guess::from_path(&absolute_path) - .first_raw() - .map(str::to_string); - - Ok(UploadFile { - absolute_path: absolute_path.to_path_buf(), - prepared: models::UploadPrepareFile { - path: path_str, - content_type, - content_length: metadata.len() as i64, - }, - }) -} - -/// Uploads a file to a given URL. -pub async fn upload_file( - reqwest_client: &reqwest::Client, - presigned_req: &models::UploadPresignedRequest, - file_path: impl AsRef, - content_type: Option, - main_pb: term::EitherProgressBar, -) -> GlobalResult<()> { - let content_type = content_type.map(|x| x.to_string()); - let path = presigned_req.path.clone(); - - let is_tty = console::Term::buffered_stderr().is_term(); - let mut pb_added = false; - let pb = match &main_pb { - term::EitherProgressBar::Single(pb) => pb.clone(), - term::EitherProgressBar::Multi(_) => term::progress_bar(), - }; - - // Try the upload multiple times since DigitalOcean spaces is incredibly - // buggy and spotty internet connections may cause issues. This is - // especially important since we have files that we need to batch upload, so - // one failing request is bad. - let mut attempts = 0; - let (upload_time, total_size) = 'upload: loop { - let pb = pb.clone(); - - // Read file - let mut file = File::open(file_path.as_ref()).await?; - let file_meta = file.metadata().await?; - let file_len = file_meta.len(); - - let total_size = presigned_req.content_length as u64; - let is_multipart = total_size != file_len; - - let msg = if is_multipart { - format!("{path} {}", style("[CHUNK]").dim().blue(),) - } else { - path.clone() - }; - - // Add progress bar - match &main_pb { - term::EitherProgressBar::Single(_) => {} - term::EitherProgressBar::Multi(mpb) => { - pb.reset(); - pb.set_style(term::pb_style_file()); - pb.set_message(msg); - pb.set_length(total_size); - - // Hack to fix weird bug with `MultiProgress` where it renders an empty progress bar and leaves - // it there - if !pb_added { - pb.set_draw_target(indicatif::ProgressDrawTarget::stderr()); - mpb.add(pb.clone()); - - pb_added = true; - - if !is_tty { - eprintln!("Uploading {path} ({})", format_file_size(total_size)?); - } - } - } - } - - // Create a reader for the slice of the file we need to read - file.seek(tokio::io::SeekFrom::Start(presigned_req.byte_offset as u64)) - .await?; - let handle = file.take(presigned_req.content_length as u64); - - // Default buffer size is optimized for memory usage. Increase buffer for perf. - let mut reader_stream = ReaderStream::with_capacity(handle, 1024 * 1024); - - let start = Instant::now(); - - // Process the stream with upload progress - let pb2 = pb.clone(); - let async_stream = async_stream::stream! { - while let Some(chunk) = reader_stream.next().await { - if let Ok(chunk) = &chunk { - pb2.inc(chunk.len() as u64); - } - - yield chunk; - } - }; - - let body = reqwest::Body::wrap_stream(async_stream); - - // Upload file - let mut req = reqwest_client - .put(&presigned_req.url) - .header("content-length", presigned_req.content_length); - if let Some(content_type) = &content_type { - req = req.header("content-type", content_type.to_string()); - } - let res = req.body(body).send().await?; - if res.status().is_success() { - let upload_time = start.elapsed(); - break 'upload (upload_time, total_size); - } else { - if attempts > 4 { - let response_status = res.status(); - let response_text = res.text().await?; - let text = format!( - "failed to upload file: {}\n{:?}", - response_status, response_text - ); - bail!(&text); - } else { - attempts += 1; - - let status = res.status(); - let body_text = unwrap!(res.text().await); - - pb.set_style(term::pb_style_error()); - pb.set_message(format!( - "{}{}{} {path} {retry_and_body}", - style("[").bold().red(), - style(status).bold().red(), - style("]").bold().red(), - path = style(&path).red(), - retry_and_body = - style(format!("will retry (attempt #{attempts}): {body_text:?}")) - .dim() - .red(), - )); - - if !is_tty { - eprintln!( - "Error uploading {path} [{status}] (attempt #{attempts}): {body_text:?}", - ); - } - - tokio::time::sleep(Duration::from_secs(5)).await; - continue 'upload; - } - } - }; - - match &main_pb { - term::EitherProgressBar::Single(pb) => { - pb.set_message(format!("Uploaded {path}")); - } - term::EitherProgressBar::Multi(_) => { - pb.set_position(total_size); - pb.finish(); - } - } - - if !is_tty { - eprintln!( - "Finished uploading {path} ({:.3}s)", - upload_time.as_secs_f64() - ); - } - - Ok(()) -} diff --git a/rivet-cli/src/util/version_config.rs b/rivet-cli/src/util/version_config.rs deleted file mode 100644 index 26ab23ac..00000000 --- a/rivet-cli/src/util/version_config.rs +++ /dev/null @@ -1,126 +0,0 @@ -use std::{ - convert::{TryFrom, TryInto}, - str::FromStr, -}; - -use toolchain_core::rivet_api::models; -use global_error::prelude::*; -use serde_json::json; - -use crate::util::text; - -pub enum Engine { - Unity, - Unreal, - Godot, - Html5, - Custom, -} - -impl FromStr for Engine { - type Err = GlobalError; - - fn from_str(s: &str) -> GlobalResult { - match s.to_lowercase().as_str() { - "unity" => Ok(Engine::Unity), - "unreal" => Ok(Engine::Unreal), - "godot" => Ok(Engine::Godot), - "html5" => Ok(Engine::Html5), - "custom" => Ok(Engine::Custom), - _ => bail!("Invalid engine"), - } - } -} - -impl Engine { - pub fn learn_url(&self) -> String { - match self { - Engine::Unity => "https://rivet.gg/learn/unity".to_string(), - Engine::Unreal { .. } => "https://rivet.gg/learn/unreal".to_string(), - Engine::Godot => "https://rivet.gg/learn/godot".to_string(), - Engine::Html5 => "https://rivet.gg/learn/html5".to_string(), - Engine::Custom => "https://rivet.gg/learn/custom".to_string(), - } - } -} - -impl TryInto for &Engine { - type Error = GlobalError; - fn try_into(self) -> Result { - match self { - Engine::Unity => Ok(models::CloudVersionEngineConfig { - unity: Some(json!({})), - ..Default::default() - }), - Engine::Unreal => { - bail!("cannot write engine for unreal") - } - Engine::Godot => Ok(models::CloudVersionEngineConfig { - godot: Some(json!({})), - ..Default::default() - }), - Engine::Html5 => Ok(models::CloudVersionEngineConfig { - html5: Some(json!({})), - ..Default::default() - }), - Engine::Custom => Ok(models::CloudVersionEngineConfig { - custom: Some(json!({})), - ..Default::default() - }), - } - } -} - -impl TryFrom<&models::CloudVersionEngineConfig> for Engine { - type Error = GlobalError; - fn try_from(engine: &models::CloudVersionEngineConfig) -> Result { - if engine.unity.is_some() { - Ok(Engine::Unity) - } else if engine.unreal.is_some() { - bail!("cannot write engine for unreal") - } else if engine.godot.is_some() { - Ok(Engine::Godot) - } else if engine.html5.is_some() { - Ok(Engine::Html5) - } else if engine.custom.is_some() { - Ok(Engine::Custom) - } else { - bail!("no engine specified") - } - } -} - -/// Generate a rivet.yaml file -pub fn generate(engine: &Engine, write_engine: bool) -> GlobalResult { - let mut version_config = String::new(); - - // Render JSON spec - version_config - .push_str("# yaml-language-server: $schema=https://rivet.gg/rivet.schema.json\n\n"); - - // Render info box - let info_width = 78; // Standard 80 width - 2 for "# " - let box_str = text::render_box_padded(&format!("\nThis configuration file is empty.\n\nGet started: {learn_url}\nReference: https://rivet.gg/docs/general/config\n", learn_url = engine.learn_url()), 4); - let box_str = text::center_text(&box_str, info_width); - let box_str = box_str.trim_end(); - let commented_info = box_str - .lines() - .map(|x| format!("# {x}")) - .collect::>() - .join("\n"); - version_config.push_str(&commented_info); - version_config.push_str("\n\n"); - - // Add engine config - if write_engine { - let partial_config = crate::commands::config::CloudVersionConfigPartial { - engine: Some(Box::new(engine.try_into()?)), - }; - let engine_yaml = serde_yaml::to_string(&partial_config)?; - version_config.push_str(&engine_yaml); - } - - version_config.push_str("\n"); - - Ok(version_config) -} diff --git a/rivet-cli/tpl/unreal_config/.dockerignore b/rivet-cli/tpl/unreal_config/.dockerignore deleted file mode 100644 index bc769bdc..00000000 --- a/rivet-cli/tpl/unreal_config/.dockerignore +++ /dev/null @@ -1,122 +0,0 @@ -# Created by https://www.toptal.com/developers/gitignore/api/unrealengine,git -# Edit at https://www.toptal.com/developers/gitignore?templates=unrealengine,git - -### Git ### -# Created by git for backups. To disable backups in Git: -# $ git config --global mergetool.keepBackup false -*.orig - -# Created by git when using merge tools for conflicts -*.BACKUP.* -*.BASE.* -*.LOCAL.* -*.REMOTE.* -*_BACKUP_*.txt -*_BASE_*.txt -*_LOCAL_*.txt -*_REMOTE_*.txt - -### UnrealEngine ### -# Visual Studio 2015 user specific files -.vs/ - -# Compiled Object files -*.slo -*.lo -*.o -*.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries -*.so -*.dylib -*.dll - -# Fortran module files -*.mod - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Executables -*.exe -*.out -*.app -*.ipa - -# These project files can be generated by the engine -*.xcodeproj -*.xcworkspace -*.sln -*.suo -*.opensdf -*.sdf -*.VC.db -*.VC.opendb - -# Precompiled Assets -SourceArt/**/*.png -SourceArt/**/*.tga - -# Binary Files -Binaries/* -Plugins/*/Binaries/* - -# Builds -Build/* - -# Whitelist PakBlacklist-.txt files -!Build/*/ -Build/*/** -!Build/*/PakBlacklist*.txt - -# Don't ignore icon files in Build -!Build/**/*.ico - -# Built data for maps -*_BuiltData.uasset - -# Configuration files generated by the Editor -Saved/* - -# Compiled source files for the engine to use -Intermediate/* -Plugins/*/Intermediate/* - -# Cache files for the editor to use -DerivedDataCache/* - -### UnrealEngine Patch ### -# Don't ignore icon and splash images for mobile app -!Build/IOS/Resources/ -Build/IOS/Resources/* -!Build/IOS/Resources/Graphics/ -Build/IOS/Resources/Graphics/* -!Build/IOS/Resources/Graphics/*.png -!Build/Android/res/ -Build/Android/res/* -!Build/Android/res/*/ -Build/Android/res/*/* -!Build/Android/res/*/*.png -# Ignore plugins binaries on deep subfolders -Plugins/**/Binaries/* -Plugins/**/Intermediate/* - -# End of https://www.toptal.com/developers/gitignore/api/unrealengine,git - -### Rivet ### -.rivet/ -.env -rivet.toml -rivet.*.toml - -### Docker ### -.dockerignore -Dockerfile -*.Dockerfile diff --git a/rivet-cli/tpl/unreal_config/config-prod.yaml b/rivet-cli/tpl/unreal_config/config-prod.yaml deleted file mode 100644 index 79701062..00000000 --- a/rivet-cli/tpl/unreal_config/config-prod.yaml +++ /dev/null @@ -1,8 +0,0 @@ -# Overrides configuration parameters for the production environment. -# -# See `rivet.yaml` for the main config. - -# Use the shipping builds instead of debug builds -matchmaker: - docker: - dockerfile: server.shipping.Dockerfile diff --git a/rivet-cli/tpl/unreal_config/config.yaml b/rivet-cli/tpl/unreal_config/config.yaml deleted file mode 100644 index 3bb96215..00000000 --- a/rivet-cli/tpl/unreal_config/config.yaml +++ /dev/null @@ -1,33 +0,0 @@ -engine: - unreal: - game_module: __GAME_MODULE__ - -# How the game lobbies run and how players connect to the game. -# -# https://rivet.gg/docs/matchmaker -matchmaker: - # How many players can join a specific lobby. - # - # Read more about matchmaking: https://rivet.gg/docs/matchmaker/concepts/finding-lobby - max_players: 32 - - # The hardware to provide for lobbies. - # - # Available tiers: https://rivet.gg/docs/dynamic-servers/concepts/available-tiers - tier: basic-1d1 - - # What game modes are available. - # - # Properties like `max_players`, `tier`, `dockerfile`, `regions`, and more can - # be overridden for specific game modes. - game_modes: - default: {} - - # Runtime configuration for running the Unreal game server. - docker: - dockerfile: server.debug.Dockerfile - ports: - default: - port: 7777 - protocol: udp - diff --git a/rivet-cli/tpl/unreal_config/server.debug.Dockerfile b/rivet-cli/tpl/unreal_config/server.debug.Dockerfile deleted file mode 100644 index a16243e2..00000000 --- a/rivet-cli/tpl/unreal_config/server.debug.Dockerfile +++ /dev/null @@ -1,34 +0,0 @@ -# Used for testing the game server on Rivet with logging & debug information enabled. - -FROM ghcr.io/epicgames/unreal-engine:dev-5.2.1 as builder - -# Copy source code -COPY --chown=ue4:ue4 . /project - -# Debug -RUN rm -rf /project/Build /project/Saved /project/Intermediate /project/Binaries && \ - /home/ue4/UnrealEngine/Engine/Build/BatchFiles/RunUAT.sh BuildCookRun \ - -Server -NoClient -ServerConfig=DebugGame \ - '-Project=/project/__UPROJECT_PATH__' \ - -UTF8Output -AllMaps -NoP4 -Build -Cook -Stage -Pak -Package -Archive \ - -ArchiveDirectory=/project/Packaged \ - -Platform=Linux - -# Copy files from builder -FROM debian:11-slim - -# Install expect package for 'unbuffer' utility, `xdg-user-dir` to fix Unreal error -RUN apt-get update && apt-get upgrade -y && apt install -y expect xdg-user-dirs - -# Create user -RUN useradd nonroot -USER nonroot - -# Copy packaged game server -COPY --from=builder --chown=nonroot:nonroot /project/Packaged/LinuxServer /home/nonroot/project - -# Expose the game server port -EXPOSE 7777/udp - -# Run the game server -ENTRYPOINT ["unbuffer", "/home/nonroot/project/__GAME_MODULE__/Binaries/Linux/__GAME_MODULE__Server", "__GAME_MODULE__", "-server", "-log"] diff --git a/rivet-cli/tpl/unreal_config/server.development.Dockerfile b/rivet-cli/tpl/unreal_config/server.development.Dockerfile deleted file mode 100644 index 04e824de..00000000 --- a/rivet-cli/tpl/unreal_config/server.development.Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -# Used for testing the game server locally. -# -# The Rivet CLI will mount the project to `/project`. - -FROM ghcr.io/epicgames/unreal-engine:dev-5.2.1 - -CMD echo '=== Building ===' && \ - /home/ue4/UnrealEngine/Engine/Build/BatchFiles/RunUAT.sh BuildCookRun \ - -Server -NoClient -ServerConfig=Development \ - '-Project=/project/__UPROJECT_PATH__' \ - -UTF8Output -NoDebugInfo -AllMaps -NoP4 -Build -Cook -Stage -Pak -Package -Archive \ - -ArchiveDirectory=/project/Build/LinuxServer/Packaged \ - -Platform=Linux \ - && \ - echo '=== Running ===' && \ - /project/Build/LinuxServer/Packaged/__GAME_MODULE__Server.sh -server -log diff --git a/rivet-cli/tpl/unreal_config/server.shipping.Dockerfile b/rivet-cli/tpl/unreal_config/server.shipping.Dockerfile deleted file mode 100644 index 7a88668a..00000000 --- a/rivet-cli/tpl/unreal_config/server.shipping.Dockerfile +++ /dev/null @@ -1,34 +0,0 @@ -# Used for shipping an optimized game server for production. - -FROM ghcr.io/epicgames/unreal-engine:dev-5.2.1 as builder - -# Copy source code -COPY --chown=ue4:ue4 . /project - -# Clean & build dedicated server for Linux -RUN rm -rf /project/Build /project/Saved /project/Intermediate /project/Binaries && \ - /home/ue4/UnrealEngine/Engine/Build/BatchFiles/RunUAT.sh BuildCookRun \ - -Server -NoClient -ServerConfig=Shipping \ - '-Project=/project/__UPROJECT_PATH__' \ - -NoDebugInfo -UTF8Output -AllMaps -NoP4 -Build -Cook -Stage -Pak -Package -Archive \ - -ArchiveDirectory=/project/Packaged \ - -Platform=Linux - -# Copy files from builder -FROM debian:11-slim - -# Install expect package for 'unbuffer' utility, `xdg-user-dir` to fix Unreal error -RUN apt-get update && apt-get upgrade -y && apt install -y expect xdg-user-dirs - -# Create user -RUN useradd nonroot -USER nonroot - -# Copy packaged game server -COPY --from=builder --chown=nonroot:nonroot /project/Packaged/LinuxServer /home/nonroot/project - -# Expose the game server port -EXPOSE 7777/udp - -# Run the game server -ENTRYPOINT ["unbuffer", "/home/nonroot/project/__GAME_MODULE__/Binaries/Linux/__GAME_MODULE__Server-Linux-Shipping", "__GAME_MODULE__", "-server"] diff --git a/rivet-toolchain-core/Cargo.toml b/rivet-toolchain-core/Cargo.toml deleted file mode 100644 index fea74efc..00000000 --- a/rivet-toolchain-core/Cargo.toml +++ /dev/null @@ -1,25 +0,0 @@ -[package] -name = "rivet-toolchain-core" -version = "0.0.1" -authors = ["Rivet Gaming, LLC "] -edition = "2018" -license = "MIT" -description = "Managed game servers, matchmaking, and DDoS mitigation that lets you focus on building your game." -homepage = "https://rivet.gg" -repository = "https://github.com/rivet-gg/cli" -build = "build.rs" - -[dependencies] -home = "0.5.3" -openssl = { version = "*", features = ["vendored"] } # Required for cross compilation, see https://github.com/sfackler/rust-openssl/issues/603#issuecomment-822619837 -rivet-api = { package = "rivet-api-ee", path = "../sdks/rust" } -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0.83" -thiserror = "1.0" -tokio = { version = "1.27", default-features = false } -tower = "0.4.12" - -[build-dependencies] -anyhow = "1.0" -vergen = { version = "7.5", default_features = false, features = ["build", "git"] } - diff --git a/rivet-toolchain-core/build.rs b/rivet-toolchain-core/build.rs deleted file mode 100644 index 1e7a2722..00000000 --- a/rivet-toolchain-core/build.rs +++ /dev/null @@ -1,8 +0,0 @@ -use anyhow::Result; -use vergen::{vergen, Config}; - -fn main() -> Result<()> { - let mut config = Config::default(); - *config.git_mut().sha_kind_mut() = vergen::ShaKind::Both; - vergen(config) -} diff --git a/rivet-toolchain-core/src/error.rs b/rivet-toolchain-core/src/error.rs deleted file mode 100644 index 049d8b00..00000000 --- a/rivet-toolchain-core/src/error.rs +++ /dev/null @@ -1,54 +0,0 @@ -#[derive(Debug, thiserror::Error)] -pub enum Error { - #[error("not authenticated")] - NotAuthenticated, - - #[error("io: {source}")] - Io { - #[from] - source: tokio::io::Error, - }, - - #[error("could not find home dir")] - CouldNotFindHomeDir, - - #[error("invalid global config: {source}")] - InvalidGlobalConfig { source: serde_json::Error }, - - #[error("internal: {message}")] - Internal { message: String }, - - #[error("invalid agent kind")] - InvalidAgentKind, - - #[error("region does not exist: {region_id}")] - RegionDoesNotExist { region_id: String }, - - #[error("inspect fail: {source}")] - InspectFail { - source: rivet_api::apis::Error, - }, - - #[error("config {key}: {message}")] - Config { key: String, message: String }, - - #[error("bootstrap fail: {source}")] - BootstrapFail { - source: rivet_api::apis::Error, - }, -} - -impl Error { - pub fn internal(message: impl ToString) -> Error { - Error::Internal { - message: message.to_string(), - } - } - - pub fn config(key: impl ToString, message: impl ToString) -> Error { - Error::Config { - key: key.to_string(), - message: message.to_string(), - } - } -} diff --git a/rivet-toolchain-core/src/lib.rs b/rivet-toolchain-core/src/lib.rs deleted file mode 100644 index 788c9cd2..00000000 --- a/rivet-toolchain-core/src/lib.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod ctx; -pub mod error; - -pub use ctx::Ctx; -pub use rivet_api; diff --git a/rivet-toolchain/Cargo.toml b/rivet-toolchain/Cargo.toml new file mode 100644 index 00000000..acae56a6 --- /dev/null +++ b/rivet-toolchain/Cargo.toml @@ -0,0 +1,62 @@ +[package] +name = "rivet-toolchain" +version = "0.1.0" +edition = "2021" + +[dependencies] +# Disable less common file formats. Preserve TOML for backwards compatibility. +# This is pointing to a fork that contains a fix for Byte-order marks on Windows. +async-posthog = { git = "https://github.com/rivet-gg/posthog-rs.git", rev = "ef4e80e" } +async-stream = "0.3.3" +chrono = "0.4.21" +console = "0.15" +ctrlc = { version = "3.2", features = ["termination"] } +dirs = "5.0" +fs_extra = "1.2.0" +futures-util = "0.3" +global-error = { git = "https://github.com/rivet-gg/rivet.git", rev = "22baf31efa3ffcdad65ecc72ce25425ab61b9c6f" } +home = "0.5.3" +humansize = "1.1" +ignore = "0.4" +indicatif = "0.17" +lz4 = "1.24" +mime_guess = "2.0" +openssl = { version = "*", features = ["vendored"] } # Required for cross compilation, see https://github.com/sfackler/rust-openssl/issues/603#issuecomment-822619837 +rand = "0.8" +regex = "1.10" +reqwest = { version = "0.11", features = ["stream", "blocking"] } +rivet-api = { package = "rivet-api-ee", path = "../sdks/rust" } +rivet-term = { git = "https://github.com/rivet-gg/rivet-term.git", rev = "f70f76f63eba12e535e53db1b436d5297edf979a" } +sentry = "0.32" +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +strum = { version = "0.24", features = ["derive"] } +sysinfo = "0.30.0" +tabled = "0.8.0" +tar = "0.4.40" +tempfile = "3.2" +term_size = "0.3.2" +thiserror = "1.0" +tokio = { version = "1.27", default-features = false, features = ["fs", "macros", "process", "rt"] } +tokio-util = { version = "0.7", default-features = false, features = ["io-util"] } +tower = "0.4.12" +typed-path = "0.7.0" +url = "2.5.0" +uuid = { version = "1.3", features = ["v4"] } +webbrowser = "0.8.7" +which = "5.0.0" +zip = "0.5" + +[target.'cfg(unix)'.dependencies] +nix = { version = "0.27", default-features = false, features = ["user", "signal"] } + +[target.'cfg(windows)'.dependencies] +winapi = { version = "0.3.9", features = ["processthreadsapi", "winnt"] } + +[dev-dependencies] +assert_cmd = "2.0" + +[build-dependencies] +anyhow = "1.0" +vergen = { version = "7.5", default_features = false, features = ["build", "git", "rustc", "cargo"] } + diff --git a/rivet-cli/build.rs b/rivet-toolchain/build.rs similarity index 100% rename from rivet-cli/build.rs rename to rivet-toolchain/build.rs diff --git a/rivet-cli/src/util/global_config.rs b/rivet-toolchain/src/config/global.rs similarity index 95% rename from rivet-cli/src/util/global_config.rs rename to rivet-toolchain/src/config/global.rs index 0cb75173..882ab93a 100644 --- a/rivet-cli/src/util/global_config.rs +++ b/rivet-toolchain/src/config/global.rs @@ -1,7 +1,7 @@ use std::{collections::HashMap, path::PathBuf}; -use toolchain_core::rivet_api::models; use global_error::prelude::*; +use rivet_api::models; use serde::{Deserialize, Serialize}; use tokio::{ fs, @@ -9,7 +9,7 @@ use tokio::{ }; use uuid::Uuid; -use super::paths; +use crate::paths; /// Configuration stored globally on the file system. #[derive(Default, Serialize, Deserialize)] @@ -18,7 +18,7 @@ pub struct GlobalConfig { pub project_roots: HashMap, } -/// Config stored in .rivet/config.yaml. Used to store persistent data. +/// Config stored in .rivet/config.json. Used to store persistent data. #[derive(Default, Serialize, Deserialize)] pub struct ProjectMeta { #[serde(default)] @@ -104,7 +104,7 @@ async fn get_or_init() -> GlobalResult<&'static Mutex> { let path = paths::global_config_file()?; let config = match fs::read_to_string(&path).await { - Ok(config) => serde_yaml::from_str(&config).map_err(Into::::into)?, + Ok(config) => serde_json::from_str(&config).map_err(Into::::into)?, Err(err) if err.kind() == std::io::ErrorKind::NotFound => GlobalConfig::default(), Err(err) => return Err(err.into()), }; @@ -119,7 +119,7 @@ async fn get_or_init() -> GlobalResult<&'static Mutex> { /// Use `mutate` to make changes to the config publicly. async fn write(config: &GlobalConfig) -> GlobalResult<()> { fs::create_dir_all(paths::global_config_dir()?).await?; - fs::write(paths::global_config_file()?, serde_yaml::to_string(config)?).await?; + fs::write(paths::global_config_file()?, serde_json::to_string(config)?).await?; Ok(()) } diff --git a/rivet-toolchain/src/config/mod.rs b/rivet-toolchain/src/config/mod.rs new file mode 100644 index 00000000..cdcd83a1 --- /dev/null +++ b/rivet-toolchain/src/config/mod.rs @@ -0,0 +1 @@ +pub mod global; diff --git a/rivet-toolchain-core/src/ctx.rs b/rivet-toolchain/src/ctx.rs similarity index 70% rename from rivet-toolchain-core/src/ctx.rs rename to rivet-toolchain/src/ctx.rs index 7cf2183b..d98c0598 100644 --- a/rivet-toolchain-core/src/ctx.rs +++ b/rivet-toolchain/src/ctx.rs @@ -1,7 +1,8 @@ +use global_error::prelude::*; use rivet_api::apis; use std::{env, sync::Arc}; -use crate::error::Error; +use crate::config; pub const VERSION: &str = concat!( env!("VERGEN_BUILD_SEMVER"), @@ -29,7 +30,15 @@ pub struct CtxInner { pub openapi_config_cloud: apis::configuration::Configuration, } -pub async fn init(api_endpoint: Option, access_token: String) -> Result { +pub async fn load() -> GlobalResult { + let (api_endpoint, token) = + config::global::read_project(|x| (x.cluster.api_endpoint.clone(), x.tokens.cloud.clone())) + .await?; + let token = unwrap!(token); + init(api_endpoint, token).await +} + +pub async fn init(api_endpoint: Option, access_token: String) -> GlobalResult { let api_endpoint = api_endpoint .clone() .unwrap_or_else(|| DEFAULT_API_ENDPOINT.to_string()); @@ -48,21 +57,23 @@ pub async fn init(api_endpoint: Option, access_token: String) -> Result< rivet_api::models::CloudBootstrapResponse, ) = tokio::try_join!( async { - apis::cloud_auth_api::cloud_auth_inspect(&openapi_config_cloud) - .await - .map_err(|e| Error::InspectFail { source: e }) + GlobalResult::Ok(unwrap!( + apis::cloud_auth_api::cloud_auth_inspect(&openapi_config_cloud).await, + "inspect failed" + )) }, async { - apis::cloud_api::cloud_bootstrap(&openapi_config_cloud) - .await - .map_err(|e| Error::BootstrapFail { source: e }) + GlobalResult::Ok(unwrap!( + apis::cloud_api::cloud_bootstrap(&openapi_config_cloud).await, + "bootstrap failed" + )) } )?; let game_id = if let Some(game_cloud) = inspect_response.agent.game_cloud { game_cloud.game_id } else { - return Err(Error::InvalidAgentKind); + bail!("invalid agent kind") }; Ok(Arc::new(CtxInner { diff --git a/rivet-toolchain/src/lib.rs b/rivet-toolchain/src/lib.rs new file mode 100644 index 00000000..f8f87327 --- /dev/null +++ b/rivet-toolchain/src/lib.rs @@ -0,0 +1,8 @@ +pub mod config; +pub mod ctx; +pub mod paths; +pub mod tasks; +pub mod util; + +pub use ctx::Ctx; +pub use rivet_api; diff --git a/rivet-cli/src/util/paths.rs b/rivet-toolchain/src/paths.rs similarity index 86% rename from rivet-cli/src/util/paths.rs rename to rivet-toolchain/src/paths.rs index c66d3819..a469ba7e 100644 --- a/rivet-cli/src/util/paths.rs +++ b/rivet-toolchain/src/paths.rs @@ -10,5 +10,5 @@ pub fn global_config_dir() -> GlobalResult { } pub fn global_config_file() -> GlobalResult { - Ok(global_config_dir()?.join("config.yaml")) + Ok(global_config_dir()?.join("config.json")) } diff --git a/rivet-toolchain/src/tasks/bootstrap.rs b/rivet-toolchain/src/tasks/bootstrap.rs new file mode 100644 index 00000000..e9795b8e --- /dev/null +++ b/rivet-toolchain/src/tasks/bootstrap.rs @@ -0,0 +1,17 @@ +use global_error::prelude::*; +use serde::Serialize; + +#[derive(Serialize)] +pub struct Output { + pub token: String, + pub api_endpoint: String, + pub game_id: String, +} + +pub async fn bootstrap(ctx: &crate::Ctx) -> GlobalResult { + Ok(Output { + token: ctx.access_token.clone(), + api_endpoint: ctx.api_endpoint.clone(), + game_id: ctx.game_id.clone(), + }) +} diff --git a/rivet-toolchain/src/tasks/mod.rs b/rivet-toolchain/src/tasks/mod.rs new file mode 100644 index 00000000..4c8bab29 --- /dev/null +++ b/rivet-toolchain/src/tasks/mod.rs @@ -0,0 +1 @@ +pub mod bootstrap; diff --git a/rivet-cli/src/util/api.rs b/rivet-toolchain/src/util/api.rs similarity index 100% rename from rivet-cli/src/util/api.rs rename to rivet-toolchain/src/util/api.rs diff --git a/rivet-cli/src/util/cmd.rs b/rivet-toolchain/src/util/cmd.rs similarity index 53% rename from rivet-cli/src/util/cmd.rs rename to rivet-toolchain/src/util/cmd.rs index 10fdda14..a36f91b4 100644 --- a/rivet-cli/src/util/cmd.rs +++ b/rivet-toolchain/src/util/cmd.rs @@ -1,19 +1,15 @@ use global_error::prelude::*; use tokio::process::Command; -use crate::{commands::token, util::term}; - /// Runs a command in a cross-platform compatible way. pub async fn run(command: &str, envs: Vec<(String, String)>) -> GlobalResult<()> { if cfg!(unix) { let mut cmd = Command::new("/bin/sh"); - remove_rivet_env(&mut cmd); cmd.envs(envs).arg("-c").arg(command); let build_status = cmd.status().await?; ensure!(build_status.success(), "command failed"); } else if cfg!(windows) { let mut cmd = Command::new("cmd.exe"); - remove_rivet_env(&mut cmd); cmd.envs(envs).arg("/C").arg(command); let build_status = cmd.status().await?; ensure!(build_status.success(), "command failed"); @@ -24,75 +20,6 @@ pub async fn run(command: &str, envs: Vec<(String, String)>) -> GlobalResult<()> Ok(()) } -/// Token to issue for command -pub enum RunWithRivetToken { - ThisMachine, - RivetServers, -} - -pub struct RunWithRivetOpts<'a> { - pub command: &'a str, - pub env: Vec<(String, String)>, - - /// Namespace to execute against - pub namespace: Option<&'a str>, - - /// Token to issue for command - pub token: RunWithRivetToken, -} - -/// Runs a command with `run_command` and populates `RIVET_API_ENDPOINT` and `RIVET_TOKEN` env vars. -pub async fn run_with_rivet(ctx: &toolchain_core::Ctx, opts: RunWithRivetOpts<'_>) -> GlobalResult<()> { - // Generate token - let token = match opts.token { - RunWithRivetToken::ThisMachine => { - token::create::dev::execute( - ctx, - &token::create::dev::Opts { - namespace: opts.namespace.map(String::from), - }, - ) - .await? - .token - } - RunWithRivetToken::RivetServers => { - token::create::pub_ns::execute( - ctx, - &token::create::pub_ns::Opts { - namespace: opts.namespace.map(String::from), - }, - ) - .await? - .token - } - }; - - // Run command - let mut envs = vec![ - ("RIVET_API_ENDPOINT".into(), ctx.api_endpoint.clone()), - ("RIVET_TOKEN".into(), token), - ]; - if let Some(namespace) = opts.namespace { - envs.push(("RIVET_NAMESPACE".into(), namespace.into())); - } - envs.extend(opts.env); - run(&opts.command, envs).await?; - - Ok(()) -} - -/// Remove environment variables specific to Rivet in order to ensure the child command uses our -/// sanitized environment variables. -/// -/// Specifically: `RIVET_TOKEN` should not be accidentally passed to some commands like the CLI. -fn remove_rivet_env(cmd: &mut Command) { - for (k, _) in std::env::vars() { - if k.starts_with("RIVET_") { - cmd.env_remove(&k); - } - } -} - /// Run a Docker command with full output. pub async fn execute_docker_cmd( mut command: tokio::process::Command, @@ -110,10 +37,7 @@ pub async fn execute_docker_cmd( } Err(err) => { if let std::io::ErrorKind::NotFound = err.kind() { - bail!( - "Docker not installed, install at {}", - term::link("https://docs.docker.com/get-docker/") - ) + bail!("Docker not installed, install at https://docs.docker.com/get-docker/") } else { Err(err.into()) } @@ -139,10 +63,7 @@ pub async fn execute_docker_cmd_silent_fallible( Ok(output) => Ok(output), Err(err) => { if let std::io::ErrorKind::NotFound = err.kind() { - bail!( - "Docker not installed, install at {}", - term::link("https://docs.docker.com/get-docker/") - ) + bail!("Docker not installed, install at https://docs.docker.com/get-docker/") } else { Err(err.into()) } diff --git a/rivet-toolchain/src/util/docker/mod.rs b/rivet-toolchain/src/util/docker/mod.rs new file mode 100644 index 00000000..913bd46b --- /dev/null +++ b/rivet-toolchain/src/util/docker/mod.rs @@ -0,0 +1 @@ +pub mod users; diff --git a/rivet-cli/src/util/users.rs b/rivet-toolchain/src/util/docker/users.rs similarity index 100% rename from rivet-cli/src/util/users.rs rename to rivet-toolchain/src/util/docker/users.rs diff --git a/rivet-cli/src/util/lz4.rs b/rivet-toolchain/src/util/lz4.rs similarity index 100% rename from rivet-cli/src/util/lz4.rs rename to rivet-toolchain/src/util/lz4.rs diff --git a/rivet-toolchain/src/util/mod.rs b/rivet-toolchain/src/util/mod.rs new file mode 100644 index 00000000..6f9a122c --- /dev/null +++ b/rivet-toolchain/src/util/mod.rs @@ -0,0 +1,8 @@ +pub mod api; +pub mod cmd; +pub mod docker; +pub mod lz4; +pub mod net; +pub mod os; +pub mod show_term; +pub mod telemetry; diff --git a/rivet-cli/src/util/download.rs b/rivet-toolchain/src/util/net/download.rs similarity index 100% rename from rivet-cli/src/util/download.rs rename to rivet-toolchain/src/util/net/download.rs diff --git a/rivet-toolchain/src/util/net/mod.rs b/rivet-toolchain/src/util/net/mod.rs new file mode 100644 index 00000000..bba5af39 --- /dev/null +++ b/rivet-toolchain/src/util/net/mod.rs @@ -0,0 +1,2 @@ +pub mod download; +pub mod upload; diff --git a/rivet-toolchain/src/util/net/upload.rs b/rivet-toolchain/src/util/net/upload.rs new file mode 100644 index 00000000..ca26f126 --- /dev/null +++ b/rivet-toolchain/src/util/net/upload.rs @@ -0,0 +1,251 @@ +use std::{ + path::{Component, Path, PathBuf}, + time::{Duration, Instant}, +}; + +use console::style; +use futures_util::stream::StreamExt; +use global_error::prelude::*; +use rivet_api::models; +use tokio::{ + fs::File, + io::{AsyncReadExt, AsyncSeekExt}, +}; +use tokio_util::io::ReaderStream; + +/// Prepared file that will be uploaded to S3. +#[derive(Clone)] +pub struct UploadFile { + pub absolute_path: PathBuf, + pub prepared: models::UploadPrepareFile, +} + +pub fn format_file_size(bytes: u64) -> GlobalResult { + use humansize::FileSize; + + let size = format!( + "{}", + unwrap!(bytes.file_size(humansize::file_size_opts::BINARY).ok()) + ); + Ok(size) +} + +/// Lists all files in a directory and returns the data required to upload them. +pub fn prepare_upload_dir(base_path: &Path) -> GlobalResult> { + let mut files = Vec::::new(); + + // Walk files while respecting .rivet-cdn-ignore + let walk = ignore::WalkBuilder::new(base_path) + .standard_filters(false) + .add_custom_ignore_filename(".rivet-cdn-ignore") + .parents(true) + .build(); + for entry in walk { + let entry = entry?; + let file_meta = entry.metadata()?; + + if file_meta.is_file() { + let file_path = entry.path(); + + files.push(prepare_upload_file( + file_path, + file_path.strip_prefix(base_path)?, + file_meta, + )?); + } + } + + Ok(files) +} + +pub fn prepare_upload_file, Q: AsRef>( + absolute_path: P, + upload_path: Q, + metadata: std::fs::Metadata, +) -> GlobalResult { + let absolute_path = absolute_path.as_ref(); + + // Convert path to Unix-style string + let path_str = upload_path + .as_ref() + .components() + .filter_map(|c| match c { + Component::Normal(name) => name.to_str().map(str::to_string), + _ => None, + }) + .collect::>() + .join("/"); + + // Attempt to guess the MIME type + let content_type = mime_guess::from_path(&absolute_path) + .first_raw() + .map(str::to_string); + + Ok(UploadFile { + absolute_path: absolute_path.to_path_buf(), + prepared: models::UploadPrepareFile { + path: path_str, + content_type, + content_length: metadata.len() as i64, + }, + }) +} + +// /// Uploads a file to a given URL. +// pub async fn upload_file( +// reqwest_client: &reqwest::Client, +// presigned_req: &models::UploadPresignedRequest, +// file_path: impl AsRef, +// content_type: Option, +// main_pb: term::EitherProgressBar, +// ) -> GlobalResult<()> { +// let content_type = content_type.map(|x| x.to_string()); +// let path = presigned_req.path.clone(); +// +// let is_tty = console::Term::buffered_stderr().is_term(); +// let mut pb_added = false; +// let pb = match &main_pb { +// term::EitherProgressBar::Single(pb) => pb.clone(), +// term::EitherProgressBar::Multi(_) => term::progress_bar(), +// }; +// +// // Try the upload multiple times since DigitalOcean spaces is incredibly +// // buggy and spotty internet connections may cause issues. This is +// // especially important since we have files that we need to batch upload, so +// // one failing request is bad. +// let mut attempts = 0; +// let (upload_time, total_size) = 'upload: loop { +// let pb = pb.clone(); +// +// // Read file +// let mut file = File::open(file_path.as_ref()).await?; +// let file_meta = file.metadata().await?; +// let file_len = file_meta.len(); +// +// let total_size = presigned_req.content_length as u64; +// let is_multipart = total_size != file_len; +// +// let msg = if is_multipart { +// format!("{path} {}", style("[CHUNK]").dim().blue(),) +// } else { +// path.clone() +// }; +// +// // Add progress bar +// match &main_pb { +// term::EitherProgressBar::Single(_) => {} +// term::EitherProgressBar::Multi(mpb) => { +// pb.reset(); +// pb.set_style(term::pb_style_file()); +// pb.set_message(msg); +// pb.set_length(total_size); +// +// // Hack to fix weird bug with `MultiProgress` where it renders an empty progress bar and leaves +// // it there +// if !pb_added { +// pb.set_draw_target(indicatif::ProgressDrawTarget::stderr()); +// mpb.add(pb.clone()); +// +// pb_added = true; +// +// if !is_tty { +// eprintln!("Uploading {path} ({})", format_file_size(total_size)?); +// } +// } +// } +// } +// +// // Create a reader for the slice of the file we need to read +// file.seek(tokio::io::SeekFrom::Start(presigned_req.byte_offset as u64)) +// .await?; +// let handle = file.take(presigned_req.content_length as u64); +// +// // Default buffer size is optimized for memory usage. Increase buffer for perf. +// let mut reader_stream = ReaderStream::with_capacity(handle, 1024 * 1024); +// +// let start = Instant::now(); +// +// // Process the stream with upload progress +// let pb2 = pb.clone(); +// let async_stream = async_stream::stream! { +// while let Some(chunk) = reader_stream.next().await { +// if let Ok(chunk) = &chunk { +// pb2.inc(chunk.len() as u64); +// } +// +// yield chunk; +// } +// }; +// +// let body = reqwest::Body::wrap_stream(async_stream); +// +// // Upload file +// let mut req = reqwest_client +// .put(&presigned_req.url) +// .header("content-length", presigned_req.content_length); +// if let Some(content_type) = &content_type { +// req = req.header("content-type", content_type.to_string()); +// } +// let res = req.body(body).send().await?; +// if res.status().is_success() { +// let upload_time = start.elapsed(); +// break 'upload (upload_time, total_size); +// } else { +// if attempts > 4 { +// let response_status = res.status(); +// let response_text = res.text().await?; +// let text = format!( +// "failed to upload file: {}\n{:?}", +// response_status, response_text +// ); +// bail!(&text); +// } else { +// attempts += 1; +// +// let status = res.status(); +// let body_text = unwrap!(res.text().await); +// +// pb.set_style(term::pb_style_error()); +// pb.set_message(format!( +// "{}{}{} {path} {retry_and_body}", +// style("[").bold().red(), +// style(status).bold().red(), +// style("]").bold().red(), +// path = style(&path).red(), +// retry_and_body = +// style(format!("will retry (attempt #{attempts}): {body_text:?}")) +// .dim() +// .red(), +// )); +// +// if !is_tty { +// eprintln!( +// "Error uploading {path} [{status}] (attempt #{attempts}): {body_text:?}", +// ); +// } +// +// tokio::time::sleep(Duration::from_secs(5)).await; +// continue 'upload; +// } +// } +// }; +// +// match &main_pb { +// term::EitherProgressBar::Single(pb) => { +// pb.set_message(format!("Uploaded {path}")); +// } +// term::EitherProgressBar::Multi(_) => { +// pb.set_position(total_size); +// pb.finish(); +// } +// } +// +// if !is_tty { +// eprintln!( +// "Finished uploading {path} ({:.3}s)", +// upload_time.as_secs_f64() +// ); +// } +// +// Ok(()) +// } diff --git a/rivet-cli/src/util/os.rs b/rivet-toolchain/src/util/os.rs similarity index 100% rename from rivet-cli/src/util/os.rs rename to rivet-toolchain/src/util/os.rs diff --git a/rivet-cli/src/util/show_term.rs b/rivet-toolchain/src/util/show_term.rs similarity index 100% rename from rivet-cli/src/util/show_term.rs rename to rivet-toolchain/src/util/show_term.rs diff --git a/rivet-cli/src/util/telemetry.rs b/rivet-toolchain/src/util/telemetry.rs similarity index 93% rename from rivet-cli/src/util/telemetry.rs rename to rivet-toolchain/src/util/telemetry.rs index da67c1a4..e963d692 100644 --- a/rivet-cli/src/util/telemetry.rs +++ b/rivet-toolchain/src/util/telemetry.rs @@ -1,4 +1,3 @@ -use toolchain_core::ctx; use global_error::prelude::*; use serde_json::json; use sysinfo::System; @@ -8,7 +7,7 @@ use tokio::{ time::Duration, }; -use crate::util::global_config; +use crate::{config, ctx}; pub static JOIN_SET: OnceCell>> = OnceCell::const_new(); pub static GAME_ID: OnceCell = OnceCell::const_new(); @@ -50,10 +49,10 @@ pub async fn capture_event GlobalResult< name: &str, mutate: Option, ) -> GlobalResult<()> { - let api_endpoint = global_config::read_project(|x| x.cluster.api_endpoint.clone()) + let api_endpoint = config::global::read_project(|x| x.cluster.api_endpoint.clone()) .await? .unwrap_or_else(|| ctx::DEFAULT_API_ENDPOINT.to_string()); - let telemetry_disabled = global_config::read_project(|x| x.telemetry.disabled).await?; + let telemetry_disabled = config::global::read_project(|x| x.telemetry.disabled).await?; let args = std::env::args().collect::>(); let distinct_id = if let Some(game_id) = game_id { diff --git a/rivet-cli/static/oci-bundle-config.base.json b/rivet-toolchain/static/oci-bundle-config.base.json similarity index 100% rename from rivet-cli/static/oci-bundle-config.base.json rename to rivet-toolchain/static/oci-bundle-config.base.json diff --git a/rivet-cli/tpl/ci/github/foot.yml b/rivet-toolchain/tpl/ci/github/foot.yml similarity index 100% rename from rivet-cli/tpl/ci/github/foot.yml rename to rivet-toolchain/tpl/ci/github/foot.yml diff --git a/rivet-cli/tpl/ci/github/head.yml b/rivet-toolchain/tpl/ci/github/head.yml similarity index 100% rename from rivet-cli/tpl/ci/github/head.yml rename to rivet-toolchain/tpl/ci/github/head.yml diff --git a/rivet-cli/tpl/ci/github/job-cdn.yml b/rivet-toolchain/tpl/ci/github/job-cdn.yml similarity index 100% rename from rivet-cli/tpl/ci/github/job-cdn.yml rename to rivet-toolchain/tpl/ci/github/job-cdn.yml diff --git a/rivet-cli/tpl/ci/github/job-image.yml b/rivet-toolchain/tpl/ci/github/job-image.yml similarity index 100% rename from rivet-cli/tpl/ci/github/job-image.yml rename to rivet-toolchain/tpl/ci/github/job-image.yml