Skip to content

Commit

Permalink
Fully implement spacetimedb-update
Browse files Browse the repository at this point in the history
  • Loading branch information
coolreader18 committed Feb 4, 2025
1 parent fbb5c9e commit 05186de
Show file tree
Hide file tree
Showing 30 changed files with 1,088 additions and 464 deletions.
356 changes: 306 additions & 50 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ members = [
"crates/sdk/tests/connect_disconnect_client",
"tools/upgrade-version",
]
default-members = ["crates/cli"]
default-members = ["crates/cli", "crates/standalone", "crates/update"]
# cargo feature graph resolver. v3 is default in edition2024 but workspace
# manifests don't have editions.
resolver = "3"
Expand Down Expand Up @@ -147,6 +147,7 @@ crossbeam-channel = "0.5"
cursive = { version = "0.20", default-features = false, features = ["crossterm-backend"] }
decorum = { version = "0.3.1", default-features = false, features = ["std"] }
derive_more = "0.99"
dialoguer = { version = "0.11", default-features = false }
dirs = "5.0.1"
duct = "0.13.5"
either = "1.9"
Expand Down Expand Up @@ -174,12 +175,13 @@ hyper = "1.0"
hyper-util = { version = "0.1", features = ["tokio"] }
imara-diff = "0.1.3"
indexmap = "2.0.0"
indicatif = "0.16"
indicatif = "0.17"
insta = { version = "1.21.0", features = ["toml"] }
is-terminal = "0.4"
itertools = "0.12"
itoa = "1"
jsonwebtoken = { package = "spacetimedb-jsonwebtoken", version = "9.3.0" }
junction = "1"
lazy_static = "1.4.0"
log = "0.4.17"
memchr = "2"
Expand Down
10 changes: 5 additions & 5 deletions crates/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ mod errors;
mod subcommands;
mod tasks;
pub mod util;
pub mod version;

use std::process::ExitCode;

use clap::{ArgMatches, Command};

pub use config::Config;
use spacetimedb_paths::SpacetimePaths;
use spacetimedb_paths::{RootDir, SpacetimePaths};
pub use subcommands::*;
pub use tasks::build;

pub fn get_subcommands() -> Vec<Command> {
vec![
version::cli(),
publish::cli(),
delete::cli(),
logs::cli(),
Expand All @@ -35,20 +35,20 @@ pub fn get_subcommands() -> Vec<Command> {
init::cli(),
build::cli(),
server::cli(),
upgrade::cli(),
subscribe::cli(),
start::cli(),
subcommands::version::cli(),
]
}

pub async fn exec_subcommand(
config: Config,
paths: &SpacetimePaths,
root_dir: Option<&RootDir>,
cmd: &str,
args: &ArgMatches,
) -> anyhow::Result<ExitCode> {
match cmd {
"version" => version::exec(config, args).await,
"call" => call::exec(config, args).await,
"describe" => describe::exec(config, args).await,
"energy" => energy::exec(config, args).await,
Expand All @@ -66,7 +66,7 @@ pub async fn exec_subcommand(
"start" => return start::exec(paths, args).await,
"login" => login::exec(config, args).await,
"logout" => logout::exec(config, args).await,
"upgrade" => upgrade::exec(config, args).await,
"version" => return subcommands::version::exec(paths, root_dir, args).await,
unknown => Err(anyhow::anyhow!("Invalid subcommand: {}", unknown)),
}
.map(|()| ExitCode::SUCCESS)
Expand Down
7 changes: 5 additions & 2 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ async fn main() -> anyhow::Result<ExitCode> {
let matches = get_command().get_matches();
let (cmd, subcommand_args) = matches.subcommand().unwrap();

let paths = match matches.get_one::<RootDir>("root_dir") {
let root_dir = matches.get_one::<RootDir>("root_dir");
let paths = match root_dir {
Some(dir) => SpacetimePaths::from_root_dir(dir),
None => SpacetimePaths::platform_defaults()?,
};
Expand All @@ -27,11 +28,13 @@ async fn main() -> anyhow::Result<ExitCode> {
.unwrap_or_else(|| paths.cli_config_dir.cli_toml());
let config = Config::load(cli_toml)?;

exec_subcommand(config, &paths, cmd, subcommand_args).await
exec_subcommand(config, &paths, root_dir, cmd, subcommand_args).await
}

fn get_command() -> Command {
Command::new("spacetime")
.version(version::CLI_VERSION)
.long_version(version::long_version())
.arg_required_else_help(true)
.subcommand_required(true)
.arg(
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/subcommands/generate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub async fn exec(config: Config, args: &clap::ArgMatches) -> anyhow::Result<()>
build::exec_with_argstring(config.clone(), project_path, build_options).await?
};
let spinner = indicatif::ProgressBar::new_spinner();
spinner.enable_steady_tick(60);
spinner.enable_steady_tick(std::time::Duration::from_millis(60));
spinner.set_message("Compiling wasm...");
let module = compile_wasm(&wasm_path)?;
spinner.set_message("Extracting schema from wasm...");
Expand Down
1 change: 0 additions & 1 deletion crates/cli/src/subcommands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ pub mod server;
pub mod sql;
pub mod start;
pub mod subscribe;
pub mod upgrade;
pub mod version;
2 changes: 1 addition & 1 deletion crates/cli/src/subcommands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub async fn exec(paths: &SpacetimePaths, args: &ArgMatches) -> anyhow::Result<E
/// include our child process. If the child terminates then we'll reap them in Cargo
/// pretty quickly, and if the child handles the signal then we won't terminate
/// (and we shouldn't!) until the process itself later exits.
fn exec_replace(cmd: &mut Command) -> io::Result<ExitCode> {
pub(crate) fn exec_replace(cmd: &mut Command) -> io::Result<ExitCode> {
#[cfg(unix)]
{
use std::os::unix::process::CommandExt;
Expand Down
222 changes: 0 additions & 222 deletions crates/cli/src/subcommands/upgrade.rs

This file was deleted.

Loading

0 comments on commit 05186de

Please sign in to comment.