From f0641a15163602c9cc8b4fe5b5570cb8467d0f4b Mon Sep 17 00:00:00 2001 From: theMackabu <theMackabu@gmail.com> Date: Mon, 21 Oct 2024 16:42:31 -0700 Subject: [PATCH] update readme + force rebuild flag --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- Maidfile.toml | 6 +++--- README.md | 6 ++++-- crates/maid/client/src/cli/mod.rs | 8 ++++---- crates/maid/client/src/cli/tasks.rs | 8 +++++--- crates/maid/client/src/main.rs | 8 +++++--- crates/maid/client/src/parse/file.rs | 2 +- 8 files changed, 25 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9cfacfb..323fc1d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1279,7 +1279,7 @@ checksum = "d2c6d3c8d7adb9850f41a7797b7a9718784aefeee3d1fe5a84c09243703a49d0" [[package]] name = "maid" -version = "1.2.0" +version = "1.2.1" dependencies = [ "anyhow", "chrono", @@ -1320,7 +1320,7 @@ dependencies = [ [[package]] name = "maid_server" -version = "1.2.0" +version = "1.2.1" dependencies = [ "anyhow", "bollard", diff --git a/Cargo.toml b/Cargo.toml index 3393ff9..7335a40 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ members = [ ] [workspace.package] -version = "1.2.0" +version = "1.2.1" edition = "2021" license = "MIT" repository = "https://github.com/exact-rs/maid" diff --git a/Maidfile.toml b/Maidfile.toml index 034cb7e..cdc6383 100644 --- a/Maidfile.toml +++ b/Maidfile.toml @@ -7,7 +7,7 @@ import = [ [project] name = "maid" -version = "1.2.0" +version = "1.2.1" # build on a remote server [project.server] @@ -20,7 +20,7 @@ BOOL = false STRING = 'test' TYPE = '%{dir.home} %{env.STRING} %{arg.1}' ARR = ['hello', 'world'] -VERSION='1.2.0' +VERSION='1.2.1' [tasks.build] info = "Build binaries" @@ -52,4 +52,4 @@ pull = "bin" [tasks] api_server = { depends = ["build"], script = "./maid_server", path = "bin" } clean = { info = "Clean binary files", script = ["rm -rf bin", "mkdir bin"] } -install = { info = "Move binary file", script = ["sudo cp bin/maid /usr/local/bin", "echo Copied binary!"], depends = ["build"] } \ No newline at end of file +install = { info = "Move binary file", script = ["maid build -q","sudo cp bin/maid /usr/local/bin", "echo Copied binary!"] } \ No newline at end of file diff --git a/README.md b/README.md index a333c69..1d64aab 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +> [!WARNING] +> +> ## This project is going through a full rewrite, any previous version may contain unknown and unfixed bugs. + <p align="center"><img style="width: 300px;" src="https://cdn.justjs.dev/assets/svg/maid_title.svg" /></p> ## @@ -41,5 +45,3 @@ Pre-built binaries for Linux, MacOS, and Windows can be found on the [releases]( - Check if you have cargo (Rust's package manager) installed, just type in `cargo` - If cargo is installed, run `cargo build --release` - Put the executable into one of your PATH entries - - Linux: usually /bin/ or /usr/bin/ - - Windows: C:\Windows\System32 is good for it but don't use windows diff --git a/crates/maid/client/src/cli/mod.rs b/crates/maid/client/src/cli/mod.rs index f6e6b60..6085ff9 100644 --- a/crates/maid/client/src/cli/mod.rs +++ b/crates/maid/client/src/cli/mod.rs @@ -47,14 +47,14 @@ pub fn info(path: &String) { ); } -pub fn exec(task: &str, args: &Vec<String>, path: &String, silent: bool, is_dep: bool, is_remote: bool, log_level: Option<log::Level>) { +pub fn exec(task: &str, args: &Vec<String>, path: &String, silent: bool, is_dep: bool, is_remote: bool, log_level: Option<log::Level>, force: bool) { log::info!("Starting maid {}", env!("CARGO_PKG_VERSION")); if task.is_empty() { if is_remote { tasks::List::remote(path, silent, log_level); } else { - tasks::List::all(path, silent, log_level); + tasks::List::all(path, silent, log_level, force); } } else { let values = helpers::maidfile::merge(path); @@ -89,7 +89,7 @@ pub fn exec(task: &str, args: &Vec<String>, path: &String, silent: bool, is_dep: for (index, item) in deps.iter().enumerate() { pb.set_prefix(format!("[{}/{}]", index + 1, deps.len())); pb.set_message(fmtstr!("{} {item}", "running dependency".bright_yellow())); - exec(&item, args, path, true, true, is_remote, log_level); + exec(&item, args, path, true, true, is_remote, log_level, force); } if !is_dep { @@ -152,7 +152,7 @@ pub fn exec(task: &str, args: &Vec<String>, path: &String, silent: bool, is_dep: Err(err) => crashln!("Cannot read cache config: {err}"), }; - if json.hash == hash && !is_dep { + if json.hash == hash && !is_dep && !force { println!("{}", "skipping task due to cached files".bright_magenta()); for target in cache.target.clone() { diff --git a/crates/maid/client/src/cli/tasks.rs b/crates/maid/client/src/cli/tasks.rs index e679aed..e64569d 100644 --- a/crates/maid/client/src/cli/tasks.rs +++ b/crates/maid/client/src/cli/tasks.rs @@ -21,7 +21,7 @@ pub fn json(path: &String, args: &Vec<String>, hydrate: &bool) { pub struct List; impl List { - pub fn all(path: &String, silent: bool, log_level: Option<log::Level>) { + pub fn all(path: &String, silent: bool, log_level: Option<log::Level>, force: bool) { let values = helpers::maidfile::merge(path); let mut options: Vec<_> = values .tasks @@ -60,8 +60,9 @@ impl List { match Select::new("Select a task to run:", options).prompt() { Ok(task) => { log::debug!("Starting {}", task.name); - cli::exec(&String::from(task.name), &vec![String::from("")], &path, silent, false, false, log_level); + cli::exec(&String::from(task.name), &vec![String::from("")], &path, silent, false, false, log_level, force); } + Err(_) => println!("{}", "Aborting...".white()), } } @@ -99,8 +100,9 @@ impl List { match Select::new("Select a remote task to run:", options).prompt() { Ok(task) => { log::debug!("Starting {}", task.name); - cli::exec(&String::from(task.name), &vec![String::from("")], &path, silent, false, true, log_level); + cli::exec(&String::from(task.name), &vec![String::from("")], &path, silent, false, true, log_level, false); } + Err(_) => println!("{}", "Aborting...".white()), } } diff --git a/crates/maid/client/src/main.rs b/crates/maid/client/src/main.rs index 3f4985a..38cc5f3 100644 --- a/crates/maid/client/src/main.rs +++ b/crates/maid/client/src/main.rs @@ -21,6 +21,8 @@ struct Cli { task: Vec<String>, #[arg(global = true, short, long, default_value_t = String::from("maidfile"), help = "maidfile path")] path: String, + #[arg(short, long, help = "force rebuild")] + force: bool, #[command(subcommand)] command: Option<Commands>, #[clap(flatten)] @@ -88,14 +90,14 @@ fn main() { Butler::Init => cli::butler::init(), Butler::Watch => cli::butler::watch(Path::new("src")), Butler::Update => cli::butler::update(), - Butler::Tasks => cli::tasks::List::all(&cli.path, cli.verbose.is_silent(), cli.verbose.log_level()), + Butler::Tasks => cli::tasks::List::all(&cli.path, cli.verbose.is_silent(), cli.verbose.log_level(), cli.force), }, Some(Commands::Remote { task, server }) => match server { Some(Remote::Connect) => server::cli::connect(&cli.path), Some(Remote::Clean) => server::cli::connect(&cli.path), Some(Remote::List) => cli::tasks::List::remote(&cli.path, cli.verbose.is_silent(), cli.verbose.log_level()), - None => cli::exec(task[0].trim(), &task, &cli.path, cli.verbose.is_silent(), false, true, cli.verbose.log_level()), + None => cli::exec(task[0].trim(), &task, &cli.path, cli.verbose.is_silent(), false, true, cli.verbose.log_level(), false), }, - None => cli::exec(cli.task[0].trim(), &cli.task, &cli.path, cli.verbose.is_silent(), false, false, cli.verbose.log_level()), + None => cli::exec(cli.task[0].trim(), &cli.task, &cli.path, cli.verbose.is_silent(), false, false, cli.verbose.log_level(), cli.force), } } diff --git a/crates/maid/client/src/parse/file.rs b/crates/maid/client/src/parse/file.rs index be57e29..b60ce6b 100644 --- a/crates/maid/client/src/parse/file.rs +++ b/crates/maid/client/src/parse/file.rs @@ -95,7 +95,7 @@ fn read_file(path: PathBuf, kind: &str) -> Maidfile { "toml" => toml::from_str(&contents).map_err(|err| string!(err)), "json" => serde_json::from_str(&contents).map_err(|err| string!(err)), "json5" => json5::from_str(&contents).map_err(|err| string!(err)), - "yaml" => serde_yaml::from_str(&contents).map_err(|err| string!(err)), + "yaml" | "yml" => serde_yaml::from_str(&contents).map_err(|err| string!(err)), _ => { log::warn!("Invalid format"); crashln!("Cannot read maidfile."); -- GitLab