Skip to content

Commit e6775eb

Browse files
authored
Finish spacetimedb-update functionality (#2126)
1 parent 75ab91d commit e6775eb

30 files changed

+1089
-465
lines changed

Cargo.lock

+307-51
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+4-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ members = [
4444
"crates/sdk/tests/connect_disconnect_client",
4545
"tools/upgrade-version",
4646
]
47-
default-members = ["crates/cli"]
47+
default-members = ["crates/cli", "crates/standalone", "crates/update"]
4848
# cargo feature graph resolver. v3 is default in edition2024 but workspace
4949
# manifests don't have editions.
5050
resolver = "3"
@@ -149,6 +149,7 @@ crossbeam-channel = "0.5"
149149
cursive = { version = "0.20", default-features = false, features = ["crossterm-backend"] }
150150
decorum = { version = "0.3.1", default-features = false, features = ["std"] }
151151
derive_more = "0.99"
152+
dialoguer = { version = "0.11", default-features = false }
152153
dirs = "5.0.1"
153154
duct = "0.13.5"
154155
either = "1.9"
@@ -176,12 +177,13 @@ hyper = "1.0"
176177
hyper-util = { version = "0.1", features = ["tokio"] }
177178
imara-diff = "0.1.3"
178179
indexmap = "2.0.0"
179-
indicatif = "0.16"
180+
indicatif = "0.17"
180181
insta = { version = "1.21.0", features = ["toml"] }
181182
is-terminal = "0.4"
182183
itertools = "0.12"
183184
itoa = "1"
184185
jsonwebtoken = { package = "spacetimedb-jsonwebtoken", version = "9.3.0" }
186+
junction = "1"
185187
lazy_static = "1.4.0"
186188
log = "0.4.17"
187189
memchr = "2"

crates/cli/src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ mod errors;
77
mod subcommands;
88
mod tasks;
99
pub mod util;
10+
pub mod version;
1011

1112
use std::process::ExitCode;
1213

1314
use clap::{ArgMatches, Command};
1415

1516
pub use config::Config;
16-
use spacetimedb_paths::SpacetimePaths;
17+
use spacetimedb_paths::{RootDir, SpacetimePaths};
1718
pub use subcommands::*;
1819
pub use tasks::build;
1920

2021
pub fn get_subcommands() -> Vec<Command> {
2122
vec![
22-
version::cli(),
2323
publish::cli(),
2424
delete::cli(),
2525
logs::cli(),
@@ -35,20 +35,20 @@ pub fn get_subcommands() -> Vec<Command> {
3535
init::cli(),
3636
build::cli(),
3737
server::cli(),
38-
upgrade::cli(),
3938
subscribe::cli(),
4039
start::cli(),
40+
subcommands::version::cli(),
4141
]
4242
}
4343

4444
pub async fn exec_subcommand(
4545
config: Config,
4646
paths: &SpacetimePaths,
47+
root_dir: Option<&RootDir>,
4748
cmd: &str,
4849
args: &ArgMatches,
4950
) -> anyhow::Result<ExitCode> {
5051
match cmd {
51-
"version" => version::exec(config, args).await,
5252
"call" => call::exec(config, args).await,
5353
"describe" => describe::exec(config, args).await,
5454
"energy" => energy::exec(config, args).await,
@@ -66,7 +66,7 @@ pub async fn exec_subcommand(
6666
"start" => return start::exec(paths, args).await,
6767
"login" => login::exec(config, args).await,
6868
"logout" => logout::exec(config, args).await,
69-
"upgrade" => upgrade::exec(config, args).await,
69+
"version" => return subcommands::version::exec(paths, root_dir, args).await,
7070
unknown => Err(anyhow::anyhow!("Invalid subcommand: {}", unknown)),
7171
}
7272
.map(|()| ExitCode::SUCCESS)

crates/cli/src/main.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ async fn main() -> anyhow::Result<ExitCode> {
1717
let matches = get_command().get_matches();
1818
let (cmd, subcommand_args) = matches.subcommand().unwrap();
1919

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

30-
exec_subcommand(config, &paths, cmd, subcommand_args).await
31+
exec_subcommand(config, &paths, root_dir, cmd, subcommand_args).await
3132
}
3233

3334
fn get_command() -> Command {
3435
Command::new("spacetime")
36+
.version(version::CLI_VERSION)
37+
.long_version(version::long_version())
3538
.arg_required_else_help(true)
3639
.subcommand_required(true)
3740
.arg(

crates/cli/src/subcommands/generate/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ pub async fn exec(config: Config, args: &clap::ArgMatches) -> anyhow::Result<()>
126126
build::exec_with_argstring(config.clone(), project_path, build_options).await?
127127
};
128128
let spinner = indicatif::ProgressBar::new_spinner();
129-
spinner.enable_steady_tick(60);
129+
spinner.enable_steady_tick(std::time::Duration::from_millis(60));
130130
spinner.set_message("Compiling wasm...");
131131
let module = compile_wasm(&wasm_path)?;
132132
spinner.set_message("Extracting schema from wasm...");

crates/cli/src/subcommands/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,4 @@ pub mod server;
1616
pub mod sql;
1717
pub mod start;
1818
pub mod subscribe;
19-
pub mod upgrade;
2019
pub mod version;

crates/cli/src/subcommands/start.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub async fn exec(paths: &SpacetimePaths, args: &ArgMatches) -> anyhow::Result<E
7979
/// include our child process. If the child terminates then we'll reap them in Cargo
8080
/// pretty quickly, and if the child handles the signal then we won't terminate
8181
/// (and we shouldn't!) until the process itself later exits.
82-
fn exec_replace(cmd: &mut Command) -> io::Result<ExitCode> {
82+
pub(crate) fn exec_replace(cmd: &mut Command) -> io::Result<ExitCode> {
8383
#[cfg(unix)]
8484
{
8585
use std::os::unix::process::CommandExt;

crates/cli/src/subcommands/upgrade.rs

-222
This file was deleted.

0 commit comments

Comments
 (0)