From 99574bdaf87191cb4c7355b2f0022717064363c9 Mon Sep 17 00:00:00 2001 From: Klimenty Titov Date: Mon, 6 Jan 2025 11:51:36 +0300 Subject: [PATCH 1/5] Add support of hidden Deployer's project configs --- README.md | 4 ++++ src/main.rs | 2 ++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index de27a51..e89d23e 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,8 @@ That's it! Now you have `/home/username/.cargo/bin/deployer` binary. Modify the ## Usage +All project configuration store in `deploy-config.json` or `.deploy-config.json` file. + First of all, let's create a simple action. ```bash @@ -291,6 +293,8 @@ Deployer will consider you to specify some things (e.g., targets - for this proj Having only `deploy-config.json` inside your project's root, you can share your build/deploy configurations. +If you want to hide your configuration, you can rename it to `.deploy-config.json` manually. + At the end, let's build the project! ```bash diff --git a/src/main.rs b/src/main.rs index 51c44ba..363c200 100644 --- a/src/main.rs +++ b/src/main.rs @@ -47,6 +47,7 @@ use mimalloc::MiMalloc; static GLOBAL: MiMalloc = MiMalloc; static PROJECT_CONF: &str = "deploy-config.json"; +static HIDDEN_PROJECT_CONF: &str = ".deploy-config.json"; static GLOBAL_CONF: &str = "deploy-global.json"; static BUILD_CACHE_LIST: &str = "deploy-builds.json"; @@ -122,6 +123,7 @@ fn main() { // Чтение конфигов let mut globals = read::(&config_folder, GLOBAL_CONF); let mut config = read::(&get_current_working_dir().unwrap(), PROJECT_CONF); + if config == Default::default() { config = read::(&get_current_working_dir().unwrap(), HIDDEN_PROJECT_CONF); } let mut builds = read::(&cache_folder, BUILD_CACHE_LIST); match args.r#type { From 1aae9de7f0d4c120642e1c42d1b8dbd500d71055 Mon Sep 17 00:00:00 2001 From: Klimenty Titov Date: Mon, 6 Jan 2025 15:46:57 +0300 Subject: [PATCH 2/5] Update `smart-patcher` and made their features optional --- Cargo.toml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 056364b..3181c42 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,11 +16,14 @@ regex = "1.11" safe-path = "0.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -smart-patcher = { git = "https://github.com/impulse-sw/smart-patcher", tag = "0.1.2" } +smart-patcher = { git = "https://github.com/impulse-sw/smart-patcher", tag = "0.1.3", default-features = false } strip-ansi-escapes = "0.2" uuid = { version = "1.11", features = ["v4", "fast-rng"] } [features] -default = ["i18n-ru"] +default = ["i18n-ru", "python", "lua", "rhai"] tests = [] i18n-ru = [] +python = ["smart-patcher/python"] +lua = ["smart-patcher/lua"] +rhai = ["smart-patcher/rhai"] From ce1832b2c1993192f8fbd670464c91d981570853 Mon Sep 17 00:00:00 2001 From: Klimenty Titov Date: Wed, 8 Jan 2025 12:03:35 +0300 Subject: [PATCH 3/5] Update build config --- deploy-config.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/deploy-config.json b/deploy-config.json index 9a0ac1a..7b51de4 100644 --- a/deploy-config.json +++ b/deploy-config.json @@ -44,7 +44,7 @@ ], "commands": [ { - "bash_c": "cargo clippy --no-default-features", + "bash_c": "cargo clippy --no-default-features --features=python,lua,rhai", "ignore_fails": false, "show_success_output": true, "show_bash_c": true, @@ -69,7 +69,7 @@ ], "commands": [ { - "bash_c": "cargo build --release --no-default-features", + "bash_c": "cargo build --release --no-default-features --features=python,lua,rhai", "ignore_fails": false, "show_success_output": false, "show_bash_c": true, @@ -200,7 +200,7 @@ ], "commands": [ { - "bash_c": "cargo clippy --no-default-features --features=i18n-ru", + "bash_c": "cargo clippy --no-default-features --features=i18n-ru,python,lua,rhai", "ignore_fails": false, "show_success_output": true, "show_bash_c": true, @@ -225,7 +225,7 @@ ], "commands": [ { - "bash_c": "cargo build --release --no-default-features --features=i18n-ru", + "bash_c": "cargo build --release --no-default-features --features=i18n-ru,python,lua,rhai", "ignore_fails": false, "show_success_output": false, "show_bash_c": true, From fdba9e8b296431836bc9470e6481067dbf6aa5b2 Mon Sep 17 00:00:00 2001 From: Klimenty Titov Date: Wed, 8 Jan 2025 14:25:40 +0300 Subject: [PATCH 4/5] Add cleanup size print --- Cargo.toml | 1 + src/build.rs | 21 +++++++++++++++++++++ src/i18n/en.rs | 3 +++ src/i18n/ru.rs | 3 +++ 4 files changed, 28 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 3181c42..73debad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ clap = { version = "4.5", features = ["derive"] } colored = "2" ctrlc = "3.4" dirs = "5.0" +fs_extra = "1.2" inquire = { git = "https://github.com/markcda/inquire.git", branch = "feat/reorder-values", features = ["reorder"] } mimalloc = "0.1.43" regex = "1.11" diff --git a/src/build.rs b/src/build.rs index ecfc081..f9a491d 100644 --- a/src/build.rs +++ b/src/build.rs @@ -1,4 +1,5 @@ use colored::Colorize; +use fs_extra::dir::get_size; use serde::{Deserialize, Serialize}; use std::path::{Path, PathBuf}; use uuid::Uuid; @@ -245,8 +246,11 @@ pub(crate) fn clean_builds( path.push(cache_dir); path.push(CACHE_DIR); + let mut total: u64 = 0; + if let Some(project_builds) = builds.projects.iter_mut().find(|p| p.name.as_str().eq(config.project_name.as_str())) { for folder in project_builds.builds.iter().map(|b| b.folder.clone()) { + total += get_size(&folder)?; let _ = std::fs::remove_dir_all(folder); } project_builds.builds.clear(); @@ -256,9 +260,26 @@ pub(crate) fn clean_builds( let curr_dir = std::env::current_dir()?; let artifacts_dir = curr_dir.join(ARTIFACTS_DIR); if artifacts_dir.as_path().exists() { + total += get_size(&artifacts_dir)?; let _ = std::fs::remove_dir_all(artifacts_dir); } } + println!("{}: {}", i18n::CLEANED, format_size(total)); + Ok(()) } + +fn format_size(size: u64) -> String { + const UNITS: [&str; 6] = ["B", "KB", "MB", "GB", "TB", "PB"]; + let mut size = size as f64; + let mut unit_index = 0; + + while size >= 1024.0 && unit_index < UNITS.len() - 1 { + size /= 1024.0; + unit_index += 1; + } + + if unit_index == 0 { format!("{} {}", size as u64, UNITS[unit_index]) } + else { format!("{:.1} {}", size, UNITS[unit_index]) } +} diff --git a/src/i18n/en.rs b/src/i18n/en.rs index 047c4de..c2f6913 100644 --- a/src/i18n/en.rs +++ b/src/i18n/en.rs @@ -289,3 +289,6 @@ tr!(PATH, "path"); tr!(RELATIVE_PATH, "Enter the relative path:"); tr!(INCORRECT_PATH, "Incorrect path! Entity must be placed inside build folder!"); tr!(INCORRECT_AF_INPL_PATH, "Incorrect artifact's inplacement path! Artifact must be inplaced inside `artifacts` folder!"); + +// Build clean +tr!(CLEANED, "Cleaned"); diff --git a/src/i18n/ru.rs b/src/i18n/ru.rs index d6c4cfc..56a8cdb 100644 --- a/src/i18n/ru.rs +++ b/src/i18n/ru.rs @@ -289,3 +289,6 @@ tr!(PATH, "путь"); tr!(RELATIVE_PATH, "Введите относительный путь:"); tr!(INCORRECT_PATH, "Некорректный путь! Сущность должна располагаться в папке сборки!"); tr!(INCORRECT_AF_INPL_PATH, "Некорректный путь размещения артефакта! Артефакт сборки должен быть размещён внутри папки `artifacts`!"); + +// Build clean +tr!(CLEANED, "Очищено"); From 01e4a559342c78d03c8b6ec1a5e353d480c57448 Mon Sep 17 00:00:00 2001 From: Klimenty Titov Date: Wed, 8 Jan 2025 14:26:29 +0300 Subject: [PATCH 5/5] Bump to `0.3.2` --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 73debad..0893b0c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "deployer" -version = "0.3.1" +version = "0.3.2" edition = "2024" [dependencies]