use crate::prelude::*;
use beet_core::prelude::*;
use beet_flow::prelude::*;
use beet_rsx::prelude::*;
#[construct]
pub fn SstCommand(cmd: SstSubcommand) -> impl Bundle {
OnSpawn::observe(
move |ev: On<GetOutcome>,
mut cmd_runner: CommandRunner,
pkg_config: Res<PackageConfig>| {
let config = CommandConfig::new("npx")
.arg("sst")
.arg(cmd.to_cmd())
.arg("--stage")
.arg(pkg_config.stage())
.current_dir(WsPathBuf::default().join("infra").to_string());
cmd_runner.run(ev, config)
},
)
}
impl SstCommand {
pub fn new(cmd: SstSubcommand) -> impl Bundle {
(Name::new("SST Command"), SstCommand { cmd })
}
}
#[allow(unused)]
#[derive(Clone, Debug)]
pub enum SstSubcommand {
Init,
Dev,
Deploy,
Diff,
Add,
Install,
Secret,
Shell,
Remove,
Unlock,
Version,
Upgrade,
Telemetry,
Refresh,
State,
Cert,
Tunnel,
Diagnostic,
}
impl SstSubcommand {
#[allow(unused)]
fn to_cmd(&self) -> &str {
match self {
SstSubcommand::Init => "init",
SstSubcommand::Dev => "dev",
SstSubcommand::Deploy => "deploy",
SstSubcommand::Diff => "diff",
SstSubcommand::Add => "add",
SstSubcommand::Install => "install",
SstSubcommand::Secret => "secret",
SstSubcommand::Shell => "shell",
SstSubcommand::Remove => "remove",
SstSubcommand::Unlock => "unlock",
SstSubcommand::Version => "version",
SstSubcommand::Upgrade => "upgrade",
SstSubcommand::Telemetry => "telemetry",
SstSubcommand::Refresh => "refresh",
SstSubcommand::State => "state",
SstSubcommand::Cert => "cert",
SstSubcommand::Tunnel => "tunnel",
SstSubcommand::Diagnostic => "diagnostic",
}
}
}