Skip to content

Commit

Permalink
Merge branch 'unstable' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
markcda committed Jan 8, 2025
2 parents c38c685 + 01e4a55 commit fe01e13
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 7 deletions.
10 changes: 7 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "deployer"
version = "0.3.1"
version = "0.3.2"
edition = "2024"

[dependencies]
Expand All @@ -10,17 +10,21 @@ 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"
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"]
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions deploy-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
21 changes: 21 additions & 0 deletions src/build.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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]) }
}
3 changes: 3 additions & 0 deletions src/i18n/en.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
3 changes: 3 additions & 0 deletions src/i18n/ru.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,6 @@ tr!(PATH, "путь");
tr!(RELATIVE_PATH, "Введите относительный путь:");
tr!(INCORRECT_PATH, "Некорректный путь! Сущность должна располагаться в папке сборки!");
tr!(INCORRECT_AF_INPL_PATH, "Некорректный путь размещения артефакта! Артефакт сборки должен быть размещён внутри папки `artifacts`!");

// Build clean
tr!(CLEANED, "Очищено");
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -122,6 +123,7 @@ fn main() {
// Чтение конфигов
let mut globals = read::<DeployerGlobalConfig>(&config_folder, GLOBAL_CONF);
let mut config = read::<DeployerProjectOptions>(&get_current_working_dir().unwrap(), PROJECT_CONF);
if config == Default::default() { config = read::<DeployerProjectOptions>(&get_current_working_dir().unwrap(), HIDDEN_PROJECT_CONF); }
let mut builds = read::<Builds>(&cache_folder, BUILD_CACHE_LIST);

match args.r#type {
Expand Down

0 comments on commit fe01e13

Please sign in to comment.