Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions codegenerator/cli/src/cli_args/clap_definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ pub enum LocalCommandTypes {
/// Local Envio database commands
#[command(subcommand)]
DbMigrate(DbMigrateSubcommands),
/// Local Envio environment commands
#[command(subcommand)]
Podman(LocalPodmanSubcommands),
}

#[derive(Subcommand, Debug, Clone)]
Expand All @@ -116,6 +119,14 @@ pub enum LocalDockerSubcommands {
Down,
}

#[derive(Subcommand, Debug, Clone)]
pub enum LocalPodmanSubcommands {
///Create podman containers required for local environment
Up,
///Delete existing podman containers on local environment
Down,
}

#[derive(Subcommand, Debug)]
pub enum DbMigrateSubcommands {
///Migrate latest schema to database
Expand Down
25 changes: 25 additions & 0 deletions codegenerator/cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,31 @@ pub mod docker {
}
}

pub mod podman {

use super::execute_command;
use crate::config_parsing::system_config::SystemConfig;

pub async fn podman_compose_up_d(
config: &SystemConfig,
) -> anyhow::Result<std::process::ExitStatus> {
let cmd = "podman";
let args = vec!["compose", "up", "-d"];
let current_dir = &config.parsed_project_paths.generated;

execute_command(cmd, args, current_dir).await
}
pub async fn podman_compose_down_v(
config: &SystemConfig,
) -> anyhow::Result<std::process::ExitStatus> {
let cmd = "podman";
let args = vec!["compose", "down", "-v"];
let current_dir = &config.parsed_project_paths.generated;

execute_command(cmd, args, current_dir).await
}
}

pub mod db_migrate {
use anyhow::{anyhow, Context};

Expand Down
13 changes: 12 additions & 1 deletion codegenerator/cli/src/executor/local.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::{
cli_args::clap_definitions::{DbMigrateSubcommands, LocalCommandTypes, LocalDockerSubcommands},
cli_args::clap_definitions::{
DbMigrateSubcommands, LocalCommandTypes, LocalDockerSubcommands, LocalPodmanSubcommands,
},
commands,
config_parsing::system_config::SystemConfig,
persisted_state::PersistedState,
Expand All @@ -23,6 +25,15 @@ pub async fn run_local(
commands::docker::docker_compose_down_v(&config).await?;
}
},
LocalCommandTypes::Podman(subcommand) => match subcommand {
LocalPodmanSubcommands::Up => {
commands::podman::podman_compose_up_d(&config).await?;
}
LocalPodmanSubcommands::Down => {
commands::podman::podman_compose_down_v(&config).await?;
}
},

LocalCommandTypes::DbMigrate(subcommand) => {
//Use a closure just so running local dow doesn't need to construct persisted state
let get_persisted_state = || -> Result<PersistedState> {
Expand Down
2 changes: 2 additions & 0 deletions scenarios/test_codegen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"codegen": "cargo run --manifest-path ../../codegenerator/cli/Cargo.toml -- codegen",
"docker-up": "cargo run --manifest-path ../../codegenerator/cli/Cargo.toml -- local docker up",
"docker-down": "cargo run --manifest-path ../../codegenerator/cli/Cargo.toml -- local docker down",
"podman-up": "cargo run --manifest-path ../../codegenerator/cli/Cargo.toml -- local podman up",
"podman-down": "cargo run --manifest-path ../../codegenerator/cli/Cargo.toml -- local podman down",
"db-setup": "cargo run --manifest-path ../../codegenerator/cli/Cargo.toml -- local db-migrate setup",
"start": "ts-node ./generated/src/Index.res.js"
},
Expand Down