use crate::commands::list::{require_puerto_project, run_list};
use crate::commands::new::extract_template;
use crate::commands::validate;
use crate::generators::conflict::OverwritePolicy;
use crate::puerto_toml::ValueObjectDefinition;
use crate::{puerto_toml, scaffold, snippets};
use cargo_generate::{GenerateArgs, TemplatePath, Vcs, generate};
use std::fs;
use std::path::{Path, PathBuf};
fn temp_dir(name: &str) -> PathBuf {
std::env::temp_dir().join(format!("puerto_test_{name}"))
}
fn cleanup(path: &Path) {
let _ = fs::remove_dir_all(path);
}
fn generate_project(name: &str, destination: &Path) -> Result<PathBuf, Box<dyn std::error::Error>> {
let tmp = extract_template()?;
let args = GenerateArgs {
template_path: TemplatePath {
path: Some(tmp.path().to_string_lossy().into_owned()),
..Default::default()
},
name: Some(name.to_string()),
destination: Some(destination.to_path_buf()),
vcs: Some(Vcs::None),
no_workspace: true,
..Default::default()
};
let output_dir = generate(args)?;
drop(tmp);
Ok(output_dir)
}
fn task_command(output: &Path) -> std::process::Command {
let bin = ["go-task", "task"]
.into_iter()
.find(|bin| {
std::process::Command::new(bin)
.arg("--version")
.output()
.is_ok_and(|o| o.status.success())
})
.expect("Task (go-task or task) is not on the PATH");
let mut command = std::process::Command::new(bin);
command
.current_dir(output)
.env("NO_COLOR", "1")
.stdin(std::process::Stdio::null());
command
}
fn output_of(mut command: std::process::Command) -> (bool, String) {
let out = command.output().unwrap();
let text = format!(
"{}{}",
String::from_utf8_lossy(&out.stdout),
String::from_utf8_lossy(&out.stderr)
);
(out.status.success(), text)
}
fn wiring(base: &Path) -> String {
let read = |rel: &str| fs::read_to_string(base.join(rel)).unwrap_or_default();
let mut contexts: Vec<PathBuf> = fs::read_dir(base.join("presentacion/cableado/src"))
.into_iter()
.flatten()
.flatten()
.map(|e| e.path().join("casos.rs"))
.filter(|p| p.exists())
.collect();
contexts.sort();
let casos: String = contexts
.iter()
.map(|p| fs::read_to_string(p).unwrap_or_default())
.collect();
format!(
"{}\n{casos}\n{}",
read("presentacion/cableado/src/lib.rs"),
read("presentacion/api/src/generado/bootstrap.rs")
)
}
mod account_cycle;
mod aforo_gaps;
mod auth;
mod auth_e2e;
mod bootstrap_gen;
mod canasta_gaps;
mod cli_surface;
mod compile_matrix;
mod composite_value_objects;
mod conventions;
mod diagnostics;
mod domain_events;
mod en_vivo;
mod extension;
mod field_args;
mod files;
mod generated_output;
mod history;
mod ide_snippets;
mod inmemory_repository;
mod layered_generators;
mod mail;
mod mail_e2e;
mod manifest_validation;
mod migrations;
mod new_project;
mod notification;
mod owner;
mod paged_lists;
mod patchers;
mod references;
mod repository_errors;
mod runtime_crates;
mod scaffolding;
mod scheduled_tasks;
mod server_fields;
mod simulate;
mod startup_errors;
mod taskfile;
mod transitions;
mod tui;
mod typed_fields;
mod typed_ids;
mod update;
mod use_cases;
mod user_references;
mod value_objects;
mod walkthrough_fixes;
mod web_blocks;
mod web_slice;
mod worker;
mod worker_e2e;
use compile_matrix::{assert_generated_project_is_clean, scenario_workspace, test_database_server};
use new_project::new_project_non_interactive;
use scaffolding::{scaffold_test_field, setup_puerto_stubs, setup_puerto_stubs_with_project_db};
use use_cases::setup_use_case_stubs;