diff --git a/Cargo.toml b/Cargo.toml index b1fe081..66cf44e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-auto" -version = "2024.422.15" +version = "2024.422.132" authors = ["bestia.dev"] homepage = "https://bestia.dev" edition = "2021" diff --git a/README.md b/README.md index ddfa20f..20729f2 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [//]: # (auto_cargo_toml_to_md start) **Automation tasks coded in Rust language for the workflow of Rust projects** -***version: 2024.422.15 date: 2024-04-22 author: [bestia.dev](https://bestia.dev) repository: [GitHub](https://github.com/automation-tasks-rs/cargo-auto)*** +***version: 2024.422.132 date: 2024-04-22 author: [bestia.dev](https://bestia.dev) repository: [GitHub](https://github.com/automation-tasks-rs/cargo-auto)*** ![maintained](https://img.shields.io/badge/maintained-green) ![ready-for-use](https://img.shields.io/badge/ready_for_use-green) @@ -28,11 +28,11 @@ ![cargo-auto](https://bestia.dev/webpage_hit_counter/get_svg_image/959103982.svg) [//]: # (auto_lines_of_code start) -[![Lines in Rust code](https://img.shields.io/badge/Lines_in_Rust-3142-green.svg)](https://github.com/automation-tasks-rs/cargo-auto/) -[![Lines in Doc comments](https://img.shields.io/badge/Lines_in_Doc_comments-1191-blue.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +[![Lines in Rust code](https://img.shields.io/badge/Lines_in_Rust-3141-green.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +[![Lines in Doc comments](https://img.shields.io/badge/Lines_in_Doc_comments-1950-blue.svg)](https://github.com/automation-tasks-rs/cargo-auto/) [![Lines in Comments](https://img.shields.io/badge/Lines_in_comments-704-purple.svg)](https://github.com/automation-tasks-rs/cargo-auto/) [![Lines in examples](https://img.shields.io/badge/Lines_in_examples-0-yellow.svg)](https://github.com/automation-tasks-rs/cargo-auto/) -[![Lines in tests](https://img.shields.io/badge/Lines_in_tests-10869-orange.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +[![Lines in tests](https://img.shields.io/badge/Lines_in_tests-10898-orange.svg)](https://github.com/automation-tasks-rs/cargo-auto/) [//]: # (auto_lines_of_code end) diff --git a/RELEASES.md b/RELEASES.md index dca742f..c1d421b 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -10,6 +10,8 @@ The TODO section is part of the [README.md](https://github.com/automation-tasks- ## Unreleased +- auto + ## Version 2024.419.1824 (2024-04-19) - no log file for tracing diff --git a/automation_tasks_rs/.gitignore b/automation_tasks_rs/.gitignore index f7b48ab..4aa0e28 100644 --- a/automation_tasks_rs/.gitignore +++ b/automation_tasks_rs/.gitignore @@ -6,3 +6,4 @@ Cargo.lock # not needed in commits, but also not a problem if they are committed /.file_hashes.json +/.old_metadata.json diff --git a/automation_tasks_rs/src/main.rs b/automation_tasks_rs/src/main.rs index 2ccf50d..98af9d8 100644 --- a/automation_tasks_rs/src/main.rs +++ b/automation_tasks_rs/src/main.rs @@ -277,7 +277,7 @@ fn task_release() { {YELLOW}1. Check if the template `new_cli` is working. Open a new terminal in VSCode and run:{RESET} {GREEN}cd ~/rustprojects{RESET} -{GREEN}./cargo-auto/target/release/{package_name} new_cli hello_world bestia.dev;{RESET} +{GREEN}./cargo-auto/target/release/{package_name} new_cli hello_world bestia-dev;{RESET} {GREEN}code hello_world{RESET} {YELLOW}In the new VSCODE window terminal, first change in Cargo.toml/repository from "github_owner" to your github username.{RESET} {YELLOW} Then try the workflow: cargo auto build, cargo auto release, cargo auto doc,... all to the end.{RESET} @@ -286,7 +286,7 @@ fn task_release() { {YELLOW}2. Check if the template `new_wasm` is working. Open a new terminal in VSCode and run:{RESET} {GREEN}cd ~/rustprojects{RESET} -{GREEN}./cargo-auto/target/release/{package_name} new_wasm hello_world bestia.dev luciano_bestia;{RESET} +{GREEN}./cargo-auto/target/release/{package_name} new_wasm hello_world bestia-dev bestia.dev luciano_bestia;{RESET} {GREEN}code hello_world{RESET} {YELLOW}In the new VSCODE window terminal, first change in Cargo.toml/repository from "github_owner" to your github username.{RESET} {YELLOW} Then try the workflow: cargo auto build, cargo auto release, cargo auto doc,... all to the end.{RESET} diff --git a/src/bin/cargo-auto/main.rs b/src/bin/cargo-auto/main.rs index 8f714d6..ad069e3 100644 --- a/src/bin/cargo-auto/main.rs +++ b/src/bin/cargo-auto/main.rs @@ -6,7 +6,7 @@ //! # cargo-auto //! //! **Automation tasks coded in Rust language for the workflow of Rust projects** -//! ***version: 2024.419.1824 date: 2024-04-19 author: [bestia.dev](https://bestia.dev) repository: [GitHub](https://github.com/automation-tasks-rs/cargo-auto)*** +//! ***version: 2024.422.132 date: 2024-04-22 author: [bestia.dev](https://bestia.dev) repository: [GitHub](https://github.com/automation-tasks-rs/cargo-auto)*** //! //! ![maintained](https://img.shields.io/badge/maintained-green) //! ![ready-for-use](https://img.shields.io/badge/ready_for_use-green) @@ -26,11 +26,11 @@ //! [![Newest docs](https://img.shields.io/badge/newest_docs-blue.svg)](https://automation-tasks-rs.github.io/cargo-auto/cargo_auto/index.html) //! ![cargo-auto](https://bestia.dev/webpage_hit_counter/get_svg_image/959103982.svg) //! -//! [![Lines in Rust code](https://img.shields.io/badge/Lines_in_Rust-3106-green.svg)](https://github.com/automation-tasks-rs/cargo-auto/) -//! [![Lines in Doc comments](https://img.shields.io/badge/Lines_in_Doc_comments-1191-blue.svg)](https://github.com/automation-tasks-rs/cargo-auto/) -//! [![Lines in Comments](https://img.shields.io/badge/Lines_in_comments-699-purple.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +//! [![Lines in Rust code](https://img.shields.io/badge/Lines_in_Rust-3141-green.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +//! [![Lines in Doc comments](https://img.shields.io/badge/Lines_in_Doc_comments-1950-blue.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +//! [![Lines in Comments](https://img.shields.io/badge/Lines_in_comments-704-purple.svg)](https://github.com/automation-tasks-rs/cargo-auto/) //! [![Lines in examples](https://img.shields.io/badge/Lines_in_examples-0-yellow.svg)](https://github.com/automation-tasks-rs/cargo-auto/) -//! [![Lines in tests](https://img.shields.io/badge/Lines_in_tests-10704-orange.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +//! [![Lines in tests](https://img.shields.io/badge/Lines_in_tests-10898-orange.svg)](https://github.com/automation-tasks-rs/cargo-auto/) //! //! Hashtags: #maintained #ready-for-use #rustlang #automation #workflow //! My projects on GitHub are more like a tutorial than a finished product: [bestia-dev tutorials](https://github.com/bestia-dev/tutorials_rust_wasm). diff --git a/src/lib.rs b/src/lib.rs index c1896ca..71b480f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,7 @@ //! # cargo-auto //! //! **Automation tasks coded in Rust language for the workflow of Rust projects** -//! ***version: 2024.419.1824 date: 2024-04-19 author: [bestia.dev](https://bestia.dev) repository: [GitHub](https://github.com/automation-tasks-rs/cargo-auto)*** +//! ***version: 2024.422.132 date: 2024-04-22 author: [bestia.dev](https://bestia.dev) repository: [GitHub](https://github.com/automation-tasks-rs/cargo-auto)*** //! //! ![maintained](https://img.shields.io/badge/maintained-green) //! ![ready-for-use](https://img.shields.io/badge/ready_for_use-green) @@ -26,11 +26,11 @@ //! [![Newest docs](https://img.shields.io/badge/newest_docs-blue.svg)](https://automation-tasks-rs.github.io/cargo-auto/cargo_auto/index.html) //! ![cargo-auto](https://bestia.dev/webpage_hit_counter/get_svg_image/959103982.svg) //! -//! [![Lines in Rust code](https://img.shields.io/badge/Lines_in_Rust-3106-green.svg)](https://github.com/automation-tasks-rs/cargo-auto/) -//! [![Lines in Doc comments](https://img.shields.io/badge/Lines_in_Doc_comments-1191-blue.svg)](https://github.com/automation-tasks-rs/cargo-auto/) -//! [![Lines in Comments](https://img.shields.io/badge/Lines_in_comments-699-purple.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +//! [![Lines in Rust code](https://img.shields.io/badge/Lines_in_Rust-3141-green.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +//! [![Lines in Doc comments](https://img.shields.io/badge/Lines_in_Doc_comments-1950-blue.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +//! [![Lines in Comments](https://img.shields.io/badge/Lines_in_comments-704-purple.svg)](https://github.com/automation-tasks-rs/cargo-auto/) //! [![Lines in examples](https://img.shields.io/badge/Lines_in_examples-0-yellow.svg)](https://github.com/automation-tasks-rs/cargo-auto/) -//! [![Lines in tests](https://img.shields.io/badge/Lines_in_tests-10704-orange.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +//! [![Lines in tests](https://img.shields.io/badge/Lines_in_tests-10898-orange.svg)](https://github.com/automation-tasks-rs/cargo-auto/) //! //! Hashtags: #maintained #ready-for-use #rustlang #automation #workflow //! My projects on GitHub are more like a tutorial than a finished product: [bestia-dev tutorials](https://github.com/bestia-dev/tutorials_rust_wasm). diff --git a/src/template_new_auto_mod.rs b/src/template_new_auto_mod.rs index 74104cf..0912f06 100644 --- a/src/template_new_auto_mod.rs +++ b/src/template_new_auto_mod.rs @@ -783,18 +783,7 @@ pub(crate) mod ssh_mod { ) } - let identity_private_file_path_expanded = cargo_auto_encrypt_secret_lib::file_path_home_expand(identity_private_file_path); - if !camino::Utf8Path::new(&identity_private_file_path_expanded).exists() { - eprintln!("{RED}Identity file {identity_private_file_path_expanded} that contains the SSH private key does not exist! {RESET}"); - eprintln!(" {YELLOW}Create the SSH key manually in bash with this command:{RESET}"); - if identity_private_file_path_expanded.as_str().contains("github_api") { - eprintln!(r#"{GREEN}ssh-keygen -t ed25519 -f \"{identity_private_file_path_expanded}\" -C \"github api token\"{RESET}"#); - } else if identity_private_file_path_expanded.as_str().contains("github_api") { - eprintln!(r#"{GREEN}ssh-keygen -t ed25519 -f \"{identity_private_file_path_expanded}\" -C \"crates io token\"{RESET}"#); - } - eprintln!(" "); - panic!("{RED}Error: File {identity_private_file_path_expanded} does not exist! {RESET}"); - } + let identity_private_file_path_expanded = expand_path_check_private_key_exists(identity_private_file_path); let fingerprint_from_file = cargo_auto_encrypt_secret_lib::get_fingerprint_from_file(&identity_private_file_path_expanded); @@ -829,6 +818,24 @@ pub(crate) mod ssh_mod { } } } + /// Expand path and check if identity file exists + /// + /// Inform the user how to generate identity file. + pub fn expand_path_check_private_key_exists(identity_private_file_path: &camino::Utf8Path) -> camino::Utf8PathBuf { + let identity_private_file_path_expanded = cargo_auto_encrypt_secret_lib::file_path_home_expand(identity_private_file_path); + if !camino::Utf8Path::new(&identity_private_file_path_expanded).exists() { + eprintln!("{RED}Identity file {identity_private_file_path_expanded} that contains the SSH private key does not exist! {RESET}"); + eprintln!(" {YELLOW}Create the SSH key manually in bash with this command:{RESET}"); + if identity_private_file_path_expanded.as_str().contains("github_api") { + eprintln!(r#"{GREEN}ssh-keygen -t ed25519 -f "{identity_private_file_path_expanded}" -C "github api token"{RESET}"#); + } else if identity_private_file_path_expanded.as_str().contains("crates_io") { + eprintln!(r#"{GREEN}ssh-keygen -t ed25519 -f "{identity_private_file_path_expanded}" -C "crates io token"{RESET}"#); + } + eprintln!(" "); + panic!("{RED}Error: File {identity_private_file_path_expanded} does not exist! {RESET}"); + } + identity_private_file_path_expanded + } } pub(crate) mod github_mod { @@ -912,7 +919,9 @@ pub(crate) mod github_mod { let encrypted_string_file_path = camino::Utf8Path::new("~/.ssh/github_api_token_encrypted.txt"); let encrypted_string_file_path_expanded = cargo_auto_encrypt_secret_lib::file_path_home_expand(encrypted_string_file_path); - let identity_file_path = camino::Utf8Path::new("~/.ssh/github_api_token_ssh_1"); + let identity_private_file_path = camino::Utf8Path::new("~/.ssh/github_api_token_ssh_1"); + let _identity_private_file_path_expanded = crate::secrets_always_local_mod::ssh_mod::expand_path_check_private_key_exists(identity_private_file_path); + if !encrypted_string_file_path_expanded.exists() { // ask interactive println!(" {BLUE}Do you want to store the GitHub API token encrypted with an SSH key? (y/n){RESET}"); @@ -924,7 +933,7 @@ pub(crate) mod github_mod { // get the passphrase and token interactively let mut ssh_context = super::ssh_mod::SshContext::new(); // encrypt and save the encrypted token - cargo_auto_encrypt_secret_lib::encrypt_with_ssh_interactive_save_file(&mut ssh_context, identity_file_path, encrypted_string_file_path); + cargo_auto_encrypt_secret_lib::encrypt_with_ssh_interactive_save_file(&mut ssh_context, identity_private_file_path, encrypted_string_file_path); // read the token and decrypt, return GitHubClient read_token_and_decrypt_return_github_client(ssh_context, encrypted_string_file_path) } @@ -1100,7 +1109,10 @@ pub(crate) mod crate_io_mod { let encrypted_string_file_path = camino::Utf8Path::new("~/.ssh/crates_io_token_encrypted.txt"); let encrypted_string_file_path_expanded = cargo_auto_encrypt_secret_lib::file_path_home_expand(encrypted_string_file_path); - let identity_file_path = camino::Utf8Path::new("~/.ssh/crates_io_token_ssh_1"); + let identity_private_file_path = camino::Utf8Path::new("~/.ssh/crates_io_token_ssh_1"); + + let _identity_private_file_path_expanded = crate::secrets_always_local_mod::ssh_mod::expand_path_check_private_key_exists(identity_private_file_path); + if !encrypted_string_file_path_expanded.exists() { // ask interactive println!(" {BLUE}Do you want to store the crates.io token encrypted with an SSH key? (y/n){RESET}"); @@ -1112,7 +1124,7 @@ pub(crate) mod crate_io_mod { // get the passphrase and token interactively let mut ssh_context = super::ssh_mod::SshContext::new(); // encrypt and save the encrypted token - cargo_auto_encrypt_secret_lib::encrypt_with_ssh_interactive_save_file(&mut ssh_context, identity_file_path, encrypted_string_file_path); + cargo_auto_encrypt_secret_lib::encrypt_with_ssh_interactive_save_file(&mut ssh_context, identity_private_file_path, encrypted_string_file_path); // read the token and decrypt, return CratesIoClient read_token_and_decrypt_return_crate_io_client(ssh_context, encrypted_string_file_path) } diff --git a/src/template_new_cli_mod.rs b/src/template_new_cli_mod.rs index 3bafc35..dcf595e 100644 --- a/src/template_new_cli_mod.rs +++ b/src/template_new_cli_mod.rs @@ -803,18 +803,7 @@ pub(crate) mod ssh_mod { ) } - let identity_private_file_path_expanded = cargo_auto_encrypt_secret_lib::file_path_home_expand(identity_private_file_path); - if !camino::Utf8Path::new(&identity_private_file_path_expanded).exists() { - eprintln!("{RED}Identity file {identity_private_file_path_expanded} that contains the SSH private key does not exist! {RESET}"); - eprintln!(" {YELLOW}Create the SSH key manually in bash with this command:{RESET}"); - if identity_private_file_path_expanded.as_str().contains("github_api") { - eprintln!(r#"{GREEN}ssh-keygen -t ed25519 -f \"{identity_private_file_path_expanded}\" -C \"github api token\"{RESET}"#); - } else if identity_private_file_path_expanded.as_str().contains("github_api") { - eprintln!(r#"{GREEN}ssh-keygen -t ed25519 -f \"{identity_private_file_path_expanded}\" -C \"crates io token\"{RESET}"#); - } - eprintln!(" "); - panic!("{RED}Error: File {identity_private_file_path_expanded} does not exist! {RESET}"); - } + let identity_private_file_path_expanded = expand_path_check_private_key_exists(identity_private_file_path); let fingerprint_from_file = cargo_auto_encrypt_secret_lib::get_fingerprint_from_file(&identity_private_file_path_expanded); @@ -849,6 +838,24 @@ pub(crate) mod ssh_mod { } } } + /// Expand path and check if identity file exists + /// + /// Inform the user how to generate identity file. + pub fn expand_path_check_private_key_exists(identity_private_file_path: &camino::Utf8Path) -> camino::Utf8PathBuf { + let identity_private_file_path_expanded = cargo_auto_encrypt_secret_lib::file_path_home_expand(identity_private_file_path); + if !camino::Utf8Path::new(&identity_private_file_path_expanded).exists() { + eprintln!("{RED}Identity file {identity_private_file_path_expanded} that contains the SSH private key does not exist! {RESET}"); + eprintln!(" {YELLOW}Create the SSH key manually in bash with this command:{RESET}"); + if identity_private_file_path_expanded.as_str().contains("github_api") { + eprintln!(r#"{GREEN}ssh-keygen -t ed25519 -f "{identity_private_file_path_expanded}" -C "github api token"{RESET}"#); + } else if identity_private_file_path_expanded.as_str().contains("crates_io") { + eprintln!(r#"{GREEN}ssh-keygen -t ed25519 -f "{identity_private_file_path_expanded}" -C "crates io token"{RESET}"#); + } + eprintln!(" "); + panic!("{RED}Error: File {identity_private_file_path_expanded} does not exist! {RESET}"); + } + identity_private_file_path_expanded + } } pub(crate) mod github_mod { @@ -932,7 +939,9 @@ pub(crate) mod github_mod { let encrypted_string_file_path = camino::Utf8Path::new("~/.ssh/github_api_token_encrypted.txt"); let encrypted_string_file_path_expanded = cargo_auto_encrypt_secret_lib::file_path_home_expand(encrypted_string_file_path); - let identity_file_path = camino::Utf8Path::new("~/.ssh/github_api_token_ssh_1"); + let identity_private_file_path = camino::Utf8Path::new("~/.ssh/github_api_token_ssh_1"); + let _identity_private_file_path_expanded = crate::secrets_always_local_mod::ssh_mod::expand_path_check_private_key_exists(identity_private_file_path); + if !encrypted_string_file_path_expanded.exists() { // ask interactive println!(" {BLUE}Do you want to store the GitHub API token encrypted with an SSH key? (y/n){RESET}"); @@ -944,7 +953,7 @@ pub(crate) mod github_mod { // get the passphrase and token interactively let mut ssh_context = super::ssh_mod::SshContext::new(); // encrypt and save the encrypted token - cargo_auto_encrypt_secret_lib::encrypt_with_ssh_interactive_save_file(&mut ssh_context, identity_file_path, encrypted_string_file_path); + cargo_auto_encrypt_secret_lib::encrypt_with_ssh_interactive_save_file(&mut ssh_context, identity_private_file_path, encrypted_string_file_path); // read the token and decrypt, return GitHubClient read_token_and_decrypt_return_github_client(ssh_context, encrypted_string_file_path) } @@ -1120,7 +1129,10 @@ pub(crate) mod crate_io_mod { let encrypted_string_file_path = camino::Utf8Path::new("~/.ssh/crates_io_token_encrypted.txt"); let encrypted_string_file_path_expanded = cargo_auto_encrypt_secret_lib::file_path_home_expand(encrypted_string_file_path); - let identity_file_path = camino::Utf8Path::new("~/.ssh/crates_io_token_ssh_1"); + let identity_private_file_path = camino::Utf8Path::new("~/.ssh/crates_io_token_ssh_1"); + + let _identity_private_file_path_expanded = crate::secrets_always_local_mod::ssh_mod::expand_path_check_private_key_exists(identity_private_file_path); + if !encrypted_string_file_path_expanded.exists() { // ask interactive println!(" {BLUE}Do you want to store the crates.io token encrypted with an SSH key? (y/n){RESET}"); @@ -1132,7 +1144,7 @@ pub(crate) mod crate_io_mod { // get the passphrase and token interactively let mut ssh_context = super::ssh_mod::SshContext::new(); // encrypt and save the encrypted token - cargo_auto_encrypt_secret_lib::encrypt_with_ssh_interactive_save_file(&mut ssh_context, identity_file_path, encrypted_string_file_path); + cargo_auto_encrypt_secret_lib::encrypt_with_ssh_interactive_save_file(&mut ssh_context, identity_private_file_path, encrypted_string_file_path); // read the token and decrypt, return CratesIoClient read_token_and_decrypt_return_crate_io_client(ssh_context, encrypted_string_file_path) } @@ -1370,7 +1382,255 @@ fn upper_greet_name(greet_name: &str) -> anyhow::Result<()> { // and it has some global stuff like the Error enum. // region: auto_md_to_doc_comments include README.md A //! - +//! # cargo-auto +//! +//! **Automation tasks coded in Rust language for the workflow of Rust projects** +//! ***version: 2024.422.132 date: 2024-04-22 author: [bestia.dev](https://bestia.dev) repository: [GitHub](https://github.com/automation-tasks-rs/cargo-auto)*** +//! +//! ![maintained](https://img.shields.io/badge/maintained-green) +//! ![ready-for-use](https://img.shields.io/badge/ready_for_use-green) +//! ![rustlang](https://img.shields.io/badge/rustlang-orange) +//! ![automation](https://img.shields.io/badge/automation-orange) +//! ![workflow](https://img.shields.io/badge/workflow-orange) +//! +//! ![logo](https://raw.githubusercontent.com/automation-tasks-rs/cargo-auto/main/images/logo/logo_cargo_auto.svg) +//! cargo-auto is part of the [automation_tasks_rs](https://github.com/automation-tasks-rs) project +//! +//! [![crates.io](https://img.shields.io/crates/v/cargo-auto.svg)](https://crates.io/crates/cargo-auto) +//! [![Documentation](https://docs.rs/cargo-auto/badge.svg)](https://docs.rs/cargo-auto/) +//! [![crev reviews](https://web.crev.dev/rust-reviews/badge/crev_count/cargo-auto.svg)](https://web.crev.dev/rust-reviews/crate/cargo-auto/) +//! [![Lib.rs](https://img.shields.io/badge/Lib.rs-rust-orange.svg)](https://lib.rs/crates/cargo-auto/) +//! [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/automation-tasks-rs/cargo-auto/blob/master/LICENSE) +//! [![Rust](https://github.com/automation-tasks-rs/cargo-auto/workflows/rust_fmt_auto_build_test/badge.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +//! [![Newest docs](https://img.shields.io/badge/newest_docs-blue.svg)](https://automation-tasks-rs.github.io/cargo-auto/cargo_auto/index.html) +//! ![cargo-auto](https://bestia.dev/webpage_hit_counter/get_svg_image/959103982.svg) +//! +//! [![Lines in Rust code](https://img.shields.io/badge/Lines_in_Rust-3141-green.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +//! [![Lines in Doc comments](https://img.shields.io/badge/Lines_in_Doc_comments-1950-blue.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +//! [![Lines in Comments](https://img.shields.io/badge/Lines_in_comments-704-purple.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +//! [![Lines in examples](https://img.shields.io/badge/Lines_in_examples-0-yellow.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +//! [![Lines in tests](https://img.shields.io/badge/Lines_in_tests-10898-orange.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +//! +//! Hashtags: #maintained #ready-for-use #rustlang #automation #workflow +//! My projects on GitHub are more like a tutorial than a finished product: [bestia-dev tutorials](https://github.com/bestia-dev/tutorials_rust_wasm). +//! I recommend using the [CRUSTDE - Containerized Rust Development Environment](https://github.com/CRUSTDE-ContainerizedRustDevEnvrustde_cnt_img_pod) to write Rust projects on Linux, isolated from your system. +//! +//! ## Try it +//! +//! First, we will use `cargo-auto` to create a new empty CLI Rust project similar to `cargo new`, but with a more complete project structure. +//! +//! ```bash +//! cargo install cargo-auto +//! cargo auto new_cli my_hello_project +//! cd my_hello_project +//! cargo auto +//! # it lists all the prepared automation tasks +//! # try a few +//! cargo auto build +//! cargo auto release +//! cargo auto doc +//! cargo auto test +//! ``` +//! +//! We can also add `automation tasks` to an existing Rust project. +//! Inside your Rust project directory (the one with Cargo.toml) run: +//! +//! ```bash +//! cargo auto new_auto +//! cargo auto +//! # it lists all the prepared automation tasks +//! # try to build +//! cargo auto build +//! ``` +//! +//! Congratulations! You are already using `cargo-auto`. Simple as that. +//! Now you can modify the tasks to your needs. It is all Rust language. +//! +//! ## Motivation +//! +//! Cargo is a great tool for building Rust projects. It has all the basics: `cargo build`, `cargo build --release`, `cargo fmt`, `cargo test`, `cargo doc`,... +//! But sometimes we need to do more things like copying some files, publishing to FTP, or entering long commands. These repetitive tasks must be automated. +//! Task automation makes work easier and faster, and simplifies the workflow while improving the consistency and accuracy of workflows. +//! This is also sometimes referred to as "workflow automation." +//! There are many different build systems and task runners there: `make`, `cmake`, `shell scripts`, `cargo-xtask`, `cargo-make`, `cargo-task`, `cargo-script`, `cargo-run-script`, `runner`, `python scripts`, `powershell scripts`, `cmd prompt scripts`, ... +//! Sadly there is no standard in the Rust community for now. +//! I want something similar to [build.rs](https://doc.rust-lang.org/cargo/reference/build-scripts.html), so I can write my "tasks" in pure Rust I don't want to learn another meta language with weird syntax and difficulty to debug. So I will make something really simple, easy, rusty, and extensible. +//! +//! ## cargo auto subcommand +//! +//! The command `cargo install cargo-auto` will add a new subcommand to cargo: +//! +//! ```bash +//! cargo auto +//! ``` +//! +//! This binary is super simple. It has only 1 trivial dependency: `lazy_static`. +//! The binary only reads the CLI arguments and runs the `automation_tasks_rs` binary with them. If needed it will compile `automation_tasks_rs` first. +//! The code-flow of the source code of `cargo-auto` is simple, fully commented, and straightforward to audit. +//! The source code is on [GitHub](https://github.com/automation-tasks-rs/cargo-auto) with MIT open-source licensing. +//! +//! ## bash auto-completion +//! +//! With the help of the crate [dev_bestia_cargo_completion](https://crates.io/crates/dev_bestia_cargo_completion), the commands `cargo` and `cargo auto` get bash auto-completion. Try it! +//! +//! ## cargo auto new_cli +//! +//! I like very much that Rust has the command `cargo new project_name`. It creates a super simple Rust Hello project that can be built and run immediately. But this example is too simple. It lacks the basic file structures of a serious CLI program. +//! I composed an opinionated template for a Rust CLI project. It is easy to run: +//! +//! ```bash +//! cargo auto new_cli project_name +//! # then +//! cd project_name +//! cargo auto build +//! # then follow detailed instructions +//! ``` +//! +//! ## cargo auto new_wasm +//! +//! I composed an opinionated template for a simple Rust WASM project for a browser. It is very similar to the new_cli template but for WASM. +//! It is easy to run: +//! +//! ```bash +//! cargo auto new_wasm project_name +//! # then +//! cd project_name +//! cargo auto build +//! # then follow detailed instructions +//! ``` +//! +//! ## cargo auto new_pwa_wasm +//! +//! I composed an opinionated template for a simple Rust PWA-WASM project for a browser. It is very similar to the new_cli template but for WASM. It adds the PWA standard functionality to work as an offline app. +//! The template needs the title, name, long name, and description inside a `pwa.json5` file and the `icon512x512.png` file for the icons. +//! It is easy to run: +//! +//! ```bash +//! cargo auto new_pwa_wasm +//! # on first run it will just create the `pwa.json5` and `icon512x512.png` files +//! # modify these files with data for your new app and then repeat +//! cargo auto new_pwa_wasm +//! # then +//! cd project_name +//! cargo auto build +//! # then follow detailed instructions +//! ``` +//! +//! ## scripting with rust +//! +//! Rust is a compiled language. It is not really a scripting or interpreted language. But the compilation of small projects is really fast and can be ignored. Subsequent calls will use the already-built binary so the speed will be even faster. +//! This tool `cargo-auto` is meant for Rust projects, so it means that all the Rust infrastructure is already in place. +//! +//! ## automation_tasks_rs Rust sub-project +//! +//! The command `cargo auto new_auto` will create a new Rust sub-project`automation_tasks_rs` inside your `Rust project`. It should not interfere with the main Rust project. This directory will be added to git commits and pushed to remote repositories as part of the main project. It has its own `.gitignore` to avoid committing to its target directory. +//! The `automation_tasks_rs` helper project contains user-defined tasks in Rust code. Your tasks. This helper project should be opened in a new editor starting from the `automation_tasks_rs` directory. It does not share dependencies with the main project. It is completely separate and independent. +//! You can edit it and add your dependencies and Rust code. No limits. Freedom of expression. +//! This is now your code, your tasks, and your helper Rust project! +//! Because only you know what you want to automate and how to do it. +//! Never write secrets, passwords, passphrases, or tokens inside your Rust code. Because then it is pushed to GitHub and the whole world can read it in the next second! +//! Basic example (most of the useful functions are already there): +//! +//! ```rust ignore +//! /// match arguments and call tasks functions +//! fn match_arguments_and_call_tasks(mut args: std::env::Args){ +//! // the first argument is the user defined task: (no argument for help), build, release,... +//! let arg_1 = args.next(); +//! match arg_1 { +//! None => print_help(), +//! Some(task) => { +//! println!("Running auto task: {}", &task); +//! if &task == "build"{ +//! task_build(); +//! } else if &task == "release" { +//! task_release(); +//! } else if &task == "doc" { +//! task_doc(); +//! } else { +//! println!("Task {} is unknown.", &task); +//! print_help(); +//! } +//! } +//! } +//! } +//! +//! /// write a comprehensible help for user defined tasks +//! fn print_help() { +//! println!(r#" +//! User defined tasks in automation_tasks_rs: +//! cargo auto build - builds the crate in debug mode +//! cargo auto release - builds the crate in release mode +//! cargo auto docs - builds the docs +//! "#); +//! } +//! +//! // region: tasks +//! +//! /// cargo build +//! fn task_build() { +//! run_shell_command("cargo fmt"); +//! run_shell_command("cargo build"); +//! } +//! +//! /// cargo build --release +//! fn task_release() { +//! run_shell_command("cargo fmt"); +//! run_shell_command("cargo build --release"); +//! } +//! +//! /// cargo doc, then copies to /docs/ folder, because this is a github standard folder +//! fn task_doc() { +//! run_shell_command("cargo doc --no-deps --document-private-items"); +//! // copy target/doc into docs/ because it is github standard +//! run_shell_command("rsync -a --info=progress2 --delete-after target/doc/ docs/"); +//! // Create simple index.html file in docs directory +//! run_shell_command(&format!( +//! "printf \"\\n\" > docs/index.html", +//! cargo_toml.package_name().replace("-","_") +//! )); +//! run_shell_command("cargo fmt"); +//! } +//! +//! // endregion: tasks +//! +//! ``` +//! +//! ## more complex tasks +//! +//! You can write more complex tasks in Rust language. +//! For example in this project I use automation to create GitHub Releases: +//! Here is a pretty complex workspace with more sub-projects: +//! +//! There is no end to your imagination. If you write something that looks like it can help other developers, please share it with me and I will add it here. +//! +//! ## Development details +//! +//! Read the development details in a separate md file: +//! [DEVELOPMENT.md](https://github.com/automation-tasks-rs/cargo-auto/blob/main/DEVELOPMENT.md) +//! +//! ## Releases changelog +//! +//! Read the changelog in a separate md file: +//! [RELEASES.md](https://github.com/automation-tasks-rs/cargo-auto/blob/main/RELEASES.md) +//! +//! ## TODO +//! +//! Nothing big in the near future. +//! +//! ## Open-source and free as a beer +//! +//! My open-source projects are free as a beer (MIT license). +//! I just love programming. +//! But I need also to drink. If you find my projects and tutorials helpful, please buy me a beer by donating to my [PayPal](https://paypal.me/LucianoBestia). +//! You know the price of a beer in your local bar ;-) +//! So I can drink a free beer for your health :-) +//! [Na zdravje!](https://translate.google.com/?hl=en&sl=sl&tl=en&text=Na%20zdravje&op=translate) [Alla salute!](https://dictionary.cambridge.org/dictionary/italian-english/alla-salute) [Prost!](https://dictionary.cambridge.org/dictionary/german-english/prost) [Nazdravlje!](https://matadornetwork.com/nights/how-to-say-cheers-in-50-languages/) 🍻 +//! +//! [//bestia.dev](https://bestia.dev) +//! [//github.com/automation-tasks-rs](https://github.com/automation-tasks-rs) +//! [//bestiadev.substack.com](https://bestiadev.substack.com) +//! [//youtube.com/@bestia-dev-tutorials](https://youtube.com/@bestia-dev-tutorials) +//! // endregion: auto_md_to_doc_comments include README.md A //! // access to modules diff --git a/src/template_new_pwa_wasm_mod.rs b/src/template_new_pwa_wasm_mod.rs index c2c951e..d575f4f 100644 --- a/src/template_new_pwa_wasm_mod.rs +++ b/src/template_new_pwa_wasm_mod.rs @@ -5,7 +5,7 @@ //! An automation task copy the content of the template_new_wasm folder into this strings. //! When installing a crate from crates.io, only the code is transferred. No additional files. -use crate::{GREEN, RED, RESET, YELLOW}; +use crate::{GREEN, RESET, YELLOW}; use serde::Deserialize; #[derive(Debug, Deserialize)] @@ -1005,18 +1005,7 @@ pub(crate) mod ssh_mod { ) } - let identity_private_file_path_expanded = cargo_auto_encrypt_secret_lib::file_path_home_expand(identity_private_file_path); - if !camino::Utf8Path::new(&identity_private_file_path_expanded).exists() { - eprintln!("{RED}Identity file {identity_private_file_path_expanded} that contains the SSH private key does not exist! {RESET}"); - eprintln!(" {YELLOW}Create the SSH key manually in bash with this command:{RESET}"); - if identity_private_file_path_expanded.as_str().contains("github_api") { - eprintln!(r#"{GREEN}ssh-keygen -t ed25519 -f \"{identity_private_file_path_expanded}\" -C \"github api token\"{RESET}"#); - } else if identity_private_file_path_expanded.as_str().contains("github_api") { - eprintln!(r#"{GREEN}ssh-keygen -t ed25519 -f \"{identity_private_file_path_expanded}\" -C \"crates io token\"{RESET}"#); - } - eprintln!(" "); - panic!("{RED}Error: File {identity_private_file_path_expanded} does not exist! {RESET}"); - } + let identity_private_file_path_expanded = expand_path_check_private_key_exists(identity_private_file_path); let fingerprint_from_file = cargo_auto_encrypt_secret_lib::get_fingerprint_from_file(&identity_private_file_path_expanded); @@ -1051,6 +1040,24 @@ pub(crate) mod ssh_mod { } } } + /// Expand path and check if identity file exists + /// + /// Inform the user how to generate identity file. + pub fn expand_path_check_private_key_exists(identity_private_file_path: &camino::Utf8Path) -> camino::Utf8PathBuf { + let identity_private_file_path_expanded = cargo_auto_encrypt_secret_lib::file_path_home_expand(identity_private_file_path); + if !camino::Utf8Path::new(&identity_private_file_path_expanded).exists() { + eprintln!("{RED}Identity file {identity_private_file_path_expanded} that contains the SSH private key does not exist! {RESET}"); + eprintln!(" {YELLOW}Create the SSH key manually in bash with this command:{RESET}"); + if identity_private_file_path_expanded.as_str().contains("github_api") { + eprintln!(r#"{GREEN}ssh-keygen -t ed25519 -f "{identity_private_file_path_expanded}" -C "github api token"{RESET}"#); + } else if identity_private_file_path_expanded.as_str().contains("crates_io") { + eprintln!(r#"{GREEN}ssh-keygen -t ed25519 -f "{identity_private_file_path_expanded}" -C "crates io token"{RESET}"#); + } + eprintln!(" "); + panic!("{RED}Error: File {identity_private_file_path_expanded} does not exist! {RESET}"); + } + identity_private_file_path_expanded + } } pub(crate) mod github_mod { @@ -1134,7 +1141,9 @@ pub(crate) mod github_mod { let encrypted_string_file_path = camino::Utf8Path::new("~/.ssh/github_api_token_encrypted.txt"); let encrypted_string_file_path_expanded = cargo_auto_encrypt_secret_lib::file_path_home_expand(encrypted_string_file_path); - let identity_file_path = camino::Utf8Path::new("~/.ssh/github_api_token_ssh_1"); + let identity_private_file_path = camino::Utf8Path::new("~/.ssh/github_api_token_ssh_1"); + let _identity_private_file_path_expanded = crate::secrets_always_local_mod::ssh_mod::expand_path_check_private_key_exists(identity_private_file_path); + if !encrypted_string_file_path_expanded.exists() { // ask interactive println!(" {BLUE}Do you want to store the GitHub API token encrypted with an SSH key? (y/n){RESET}"); @@ -1146,7 +1155,7 @@ pub(crate) mod github_mod { // get the passphrase and token interactively let mut ssh_context = super::ssh_mod::SshContext::new(); // encrypt and save the encrypted token - cargo_auto_encrypt_secret_lib::encrypt_with_ssh_interactive_save_file(&mut ssh_context, identity_file_path, encrypted_string_file_path); + cargo_auto_encrypt_secret_lib::encrypt_with_ssh_interactive_save_file(&mut ssh_context, identity_private_file_path, encrypted_string_file_path); // read the token and decrypt, return GitHubClient read_token_and_decrypt_return_github_client(ssh_context, encrypted_string_file_path) } @@ -1322,7 +1331,10 @@ pub(crate) mod crate_io_mod { let encrypted_string_file_path = camino::Utf8Path::new("~/.ssh/crates_io_token_encrypted.txt"); let encrypted_string_file_path_expanded = cargo_auto_encrypt_secret_lib::file_path_home_expand(encrypted_string_file_path); - let identity_file_path = camino::Utf8Path::new("~/.ssh/crates_io_token_ssh_1"); + let identity_private_file_path = camino::Utf8Path::new("~/.ssh/crates_io_token_ssh_1"); + + let _identity_private_file_path_expanded = crate::secrets_always_local_mod::ssh_mod::expand_path_check_private_key_exists(identity_private_file_path); + if !encrypted_string_file_path_expanded.exists() { // ask interactive println!(" {BLUE}Do you want to store the crates.io token encrypted with an SSH key? (y/n){RESET}"); @@ -1334,7 +1346,7 @@ pub(crate) mod crate_io_mod { // get the passphrase and token interactively let mut ssh_context = super::ssh_mod::SshContext::new(); // encrypt and save the encrypted token - cargo_auto_encrypt_secret_lib::encrypt_with_ssh_interactive_save_file(&mut ssh_context, identity_file_path, encrypted_string_file_path); + cargo_auto_encrypt_secret_lib::encrypt_with_ssh_interactive_save_file(&mut ssh_context, identity_private_file_path, encrypted_string_file_path); // read the token and decrypt, return CratesIoClient read_token_and_decrypt_return_crate_io_client(ssh_context, encrypted_string_file_path) } @@ -1347,7 +1359,6 @@ pub(crate) mod crate_io_mod { } /// decrypts the secret token in memory - #[allow(dead_code)] pub fn decrypt_token_in_memory(&self) -> secrecy::SecretString { self.encrypted_token.expose_decrypted_secret(&self.session_passcode) } @@ -1356,7 +1367,6 @@ pub(crate) mod crate_io_mod { /// /// This function encapsulates the secret crates.io token. /// The client can be passed to the library. It will not reveal the secret token. - #[allow(dead_code)] pub fn publish_to_crates_io(&self) { // print command without the token println!("{YELLOW}cargo publish --token [REDACTED]{RESET}"); @@ -2003,7 +2013,255 @@ pub const RESET: &str = "\x1b[0m"; // So the structure of the project modules can be similar to a binary CLI executable. // region: auto_md_to_doc_comments include README.md A //! - +//! # cargo-auto +//! +//! **Automation tasks coded in Rust language for the workflow of Rust projects** +//! ***version: 2024.422.132 date: 2024-04-22 author: [bestia.dev](https://bestia.dev) repository: [GitHub](https://github.com/automation-tasks-rs/cargo-auto)*** +//! +//! ![maintained](https://img.shields.io/badge/maintained-green) +//! ![ready-for-use](https://img.shields.io/badge/ready_for_use-green) +//! ![rustlang](https://img.shields.io/badge/rustlang-orange) +//! ![automation](https://img.shields.io/badge/automation-orange) +//! ![workflow](https://img.shields.io/badge/workflow-orange) +//! +//! ![logo](https://raw.githubusercontent.com/automation-tasks-rs/cargo-auto/main/images/logo/logo_cargo_auto.svg) +//! cargo-auto is part of the [automation_tasks_rs](https://github.com/automation-tasks-rs) project +//! +//! [![crates.io](https://img.shields.io/crates/v/cargo-auto.svg)](https://crates.io/crates/cargo-auto) +//! [![Documentation](https://docs.rs/cargo-auto/badge.svg)](https://docs.rs/cargo-auto/) +//! [![crev reviews](https://web.crev.dev/rust-reviews/badge/crev_count/cargo-auto.svg)](https://web.crev.dev/rust-reviews/crate/cargo-auto/) +//! [![Lib.rs](https://img.shields.io/badge/Lib.rs-rust-orange.svg)](https://lib.rs/crates/cargo-auto/) +//! [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/automation-tasks-rs/cargo-auto/blob/master/LICENSE) +//! [![Rust](https://github.com/automation-tasks-rs/cargo-auto/workflows/rust_fmt_auto_build_test/badge.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +//! [![Newest docs](https://img.shields.io/badge/newest_docs-blue.svg)](https://automation-tasks-rs.github.io/cargo-auto/cargo_auto/index.html) +//! ![cargo-auto](https://bestia.dev/webpage_hit_counter/get_svg_image/959103982.svg) +//! +//! [![Lines in Rust code](https://img.shields.io/badge/Lines_in_Rust-3141-green.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +//! [![Lines in Doc comments](https://img.shields.io/badge/Lines_in_Doc_comments-1950-blue.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +//! [![Lines in Comments](https://img.shields.io/badge/Lines_in_comments-704-purple.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +//! [![Lines in examples](https://img.shields.io/badge/Lines_in_examples-0-yellow.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +//! [![Lines in tests](https://img.shields.io/badge/Lines_in_tests-10898-orange.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +//! +//! Hashtags: #maintained #ready-for-use #rustlang #automation #workflow +//! My projects on GitHub are more like a tutorial than a finished product: [bestia-dev tutorials](https://github.com/bestia-dev/tutorials_rust_wasm). +//! I recommend using the [CRUSTDE - Containerized Rust Development Environment](https://github.com/CRUSTDE-ContainerizedRustDevEnvrustde_cnt_img_pod) to write Rust projects on Linux, isolated from your system. +//! +//! ## Try it +//! +//! First, we will use `cargo-auto` to create a new empty CLI Rust project similar to `cargo new`, but with a more complete project structure. +//! +//! ```bash +//! cargo install cargo-auto +//! cargo auto new_cli my_hello_project +//! cd my_hello_project +//! cargo auto +//! # it lists all the prepared automation tasks +//! # try a few +//! cargo auto build +//! cargo auto release +//! cargo auto doc +//! cargo auto test +//! ``` +//! +//! We can also add `automation tasks` to an existing Rust project. +//! Inside your Rust project directory (the one with Cargo.toml) run: +//! +//! ```bash +//! cargo auto new_auto +//! cargo auto +//! # it lists all the prepared automation tasks +//! # try to build +//! cargo auto build +//! ``` +//! +//! Congratulations! You are already using `cargo-auto`. Simple as that. +//! Now you can modify the tasks to your needs. It is all Rust language. +//! +//! ## Motivation +//! +//! Cargo is a great tool for building Rust projects. It has all the basics: `cargo build`, `cargo build --release`, `cargo fmt`, `cargo test`, `cargo doc`,... +//! But sometimes we need to do more things like copying some files, publishing to FTP, or entering long commands. These repetitive tasks must be automated. +//! Task automation makes work easier and faster, and simplifies the workflow while improving the consistency and accuracy of workflows. +//! This is also sometimes referred to as "workflow automation." +//! There are many different build systems and task runners there: `make`, `cmake`, `shell scripts`, `cargo-xtask`, `cargo-make`, `cargo-task`, `cargo-script`, `cargo-run-script`, `runner`, `python scripts`, `powershell scripts`, `cmd prompt scripts`, ... +//! Sadly there is no standard in the Rust community for now. +//! I want something similar to [build.rs](https://doc.rust-lang.org/cargo/reference/build-scripts.html), so I can write my "tasks" in pure Rust I don't want to learn another meta language with weird syntax and difficulty to debug. So I will make something really simple, easy, rusty, and extensible. +//! +//! ## cargo auto subcommand +//! +//! The command `cargo install cargo-auto` will add a new subcommand to cargo: +//! +//! ```bash +//! cargo auto +//! ``` +//! +//! This binary is super simple. It has only 1 trivial dependency: `lazy_static`. +//! The binary only reads the CLI arguments and runs the `automation_tasks_rs` binary with them. If needed it will compile `automation_tasks_rs` first. +//! The code-flow of the source code of `cargo-auto` is simple, fully commented, and straightforward to audit. +//! The source code is on [GitHub](https://github.com/automation-tasks-rs/cargo-auto) with MIT open-source licensing. +//! +//! ## bash auto-completion +//! +//! With the help of the crate [dev_bestia_cargo_completion](https://crates.io/crates/dev_bestia_cargo_completion), the commands `cargo` and `cargo auto` get bash auto-completion. Try it! +//! +//! ## cargo auto new_cli +//! +//! I like very much that Rust has the command `cargo new project_name`. It creates a super simple Rust Hello project that can be built and run immediately. But this example is too simple. It lacks the basic file structures of a serious CLI program. +//! I composed an opinionated template for a Rust CLI project. It is easy to run: +//! +//! ```bash +//! cargo auto new_cli project_name +//! # then +//! cd project_name +//! cargo auto build +//! # then follow detailed instructions +//! ``` +//! +//! ## cargo auto new_wasm +//! +//! I composed an opinionated template for a simple Rust WASM project for a browser. It is very similar to the new_cli template but for WASM. +//! It is easy to run: +//! +//! ```bash +//! cargo auto new_wasm project_name +//! # then +//! cd project_name +//! cargo auto build +//! # then follow detailed instructions +//! ``` +//! +//! ## cargo auto new_pwa_wasm +//! +//! I composed an opinionated template for a simple Rust PWA-WASM project for a browser. It is very similar to the new_cli template but for WASM. It adds the PWA standard functionality to work as an offline app. +//! The template needs the title, name, long name, and description inside a `pwa.json5` file and the `icon512x512.png` file for the icons. +//! It is easy to run: +//! +//! ```bash +//! cargo auto new_pwa_wasm +//! # on first run it will just create the `pwa.json5` and `icon512x512.png` files +//! # modify these files with data for your new app and then repeat +//! cargo auto new_pwa_wasm +//! # then +//! cd project_name +//! cargo auto build +//! # then follow detailed instructions +//! ``` +//! +//! ## scripting with rust +//! +//! Rust is a compiled language. It is not really a scripting or interpreted language. But the compilation of small projects is really fast and can be ignored. Subsequent calls will use the already-built binary so the speed will be even faster. +//! This tool `cargo-auto` is meant for Rust projects, so it means that all the Rust infrastructure is already in place. +//! +//! ## automation_tasks_rs Rust sub-project +//! +//! The command `cargo auto new_auto` will create a new Rust sub-project`automation_tasks_rs` inside your `Rust project`. It should not interfere with the main Rust project. This directory will be added to git commits and pushed to remote repositories as part of the main project. It has its own `.gitignore` to avoid committing to its target directory. +//! The `automation_tasks_rs` helper project contains user-defined tasks in Rust code. Your tasks. This helper project should be opened in a new editor starting from the `automation_tasks_rs` directory. It does not share dependencies with the main project. It is completely separate and independent. +//! You can edit it and add your dependencies and Rust code. No limits. Freedom of expression. +//! This is now your code, your tasks, and your helper Rust project! +//! Because only you know what you want to automate and how to do it. +//! Never write secrets, passwords, passphrases, or tokens inside your Rust code. Because then it is pushed to GitHub and the whole world can read it in the next second! +//! Basic example (most of the useful functions are already there): +//! +//! ```rust ignore +//! /// match arguments and call tasks functions +//! fn match_arguments_and_call_tasks(mut args: std::env::Args){ +//! // the first argument is the user defined task: (no argument for help), build, release,... +//! let arg_1 = args.next(); +//! match arg_1 { +//! None => print_help(), +//! Some(task) => { +//! println!("Running auto task: {}", &task); +//! if &task == "build"{ +//! task_build(); +//! } else if &task == "release" { +//! task_release(); +//! } else if &task == "doc" { +//! task_doc(); +//! } else { +//! println!("Task {} is unknown.", &task); +//! print_help(); +//! } +//! } +//! } +//! } +//! +//! /// write a comprehensible help for user defined tasks +//! fn print_help() { +//! println!(r#" +//! User defined tasks in automation_tasks_rs: +//! cargo auto build - builds the crate in debug mode +//! cargo auto release - builds the crate in release mode +//! cargo auto docs - builds the docs +//! "#); +//! } +//! +//! // region: tasks +//! +//! /// cargo build +//! fn task_build() { +//! run_shell_command("cargo fmt"); +//! run_shell_command("cargo build"); +//! } +//! +//! /// cargo build --release +//! fn task_release() { +//! run_shell_command("cargo fmt"); +//! run_shell_command("cargo build --release"); +//! } +//! +//! /// cargo doc, then copies to /docs/ folder, because this is a github standard folder +//! fn task_doc() { +//! run_shell_command("cargo doc --no-deps --document-private-items"); +//! // copy target/doc into docs/ because it is github standard +//! run_shell_command("rsync -a --info=progress2 --delete-after target/doc/ docs/"); +//! // Create simple index.html file in docs directory +//! run_shell_command(&format!( +//! "printf \"\\n\" > docs/index.html", +//! cargo_toml.package_name().replace("-","_") +//! )); +//! run_shell_command("cargo fmt"); +//! } +//! +//! // endregion: tasks +//! +//! ``` +//! +//! ## more complex tasks +//! +//! You can write more complex tasks in Rust language. +//! For example in this project I use automation to create GitHub Releases: +//! Here is a pretty complex workspace with more sub-projects: +//! +//! There is no end to your imagination. If you write something that looks like it can help other developers, please share it with me and I will add it here. +//! +//! ## Development details +//! +//! Read the development details in a separate md file: +//! [DEVELOPMENT.md](https://github.com/automation-tasks-rs/cargo-auto/blob/main/DEVELOPMENT.md) +//! +//! ## Releases changelog +//! +//! Read the changelog in a separate md file: +//! [RELEASES.md](https://github.com/automation-tasks-rs/cargo-auto/blob/main/RELEASES.md) +//! +//! ## TODO +//! +//! Nothing big in the near future. +//! +//! ## Open-source and free as a beer +//! +//! My open-source projects are free as a beer (MIT license). +//! I just love programming. +//! But I need also to drink. If you find my projects and tutorials helpful, please buy me a beer by donating to my [PayPal](https://paypal.me/LucianoBestia). +//! You know the price of a beer in your local bar ;-) +//! So I can drink a free beer for your health :-) +//! [Na zdravje!](https://translate.google.com/?hl=en&sl=sl&tl=en&text=Na%20zdravje&op=translate) [Alla salute!](https://dictionary.cambridge.org/dictionary/italian-english/alla-salute) [Prost!](https://dictionary.cambridge.org/dictionary/german-english/prost) [Nazdravlje!](https://matadornetwork.com/nights/how-to-say-cheers-in-50-languages/) 🍻 +//! +//! [//bestia.dev](https://bestia.dev) +//! [//github.com/automation-tasks-rs](https://github.com/automation-tasks-rs) +//! [//bestiadev.substack.com](https://bestiadev.substack.com) +//! [//youtube.com/@bestia-dev-tutorials](https://youtube.com/@bestia-dev-tutorials) +//! // endregion: auto_md_to_doc_comments include README.md A //! use wasm_bindgen::prelude::*; @@ -2195,7 +2453,7 @@ jobs: // but the new service worker will not be activated until all // tabs with this webapp are closed. -const CACHE_NAME = '2024.422.6'; +const CACHE_NAME = '2024.422.125'; self.addEventListener('install', event => { console.log('event install ', CACHE_NAME); diff --git a/src/template_new_wasm_mod.rs b/src/template_new_wasm_mod.rs index 8f802d5..2b16b88 100644 --- a/src/template_new_wasm_mod.rs +++ b/src/template_new_wasm_mod.rs @@ -871,18 +871,7 @@ pub(crate) mod ssh_mod { ) } - let identity_private_file_path_expanded = cargo_auto_encrypt_secret_lib::file_path_home_expand(identity_private_file_path); - if !camino::Utf8Path::new(&identity_private_file_path_expanded).exists() { - eprintln!("{RED}Identity file {identity_private_file_path_expanded} that contains the SSH private key does not exist! {RESET}"); - eprintln!(" {YELLOW}Create the SSH key manually in bash with this command:{RESET}"); - if identity_private_file_path_expanded.as_str().contains("github_api") { - eprintln!(r#"{GREEN}ssh-keygen -t ed25519 -f \"{identity_private_file_path_expanded}\" -C \"github api token\"{RESET}"#); - } else if identity_private_file_path_expanded.as_str().contains("github_api") { - eprintln!(r#"{GREEN}ssh-keygen -t ed25519 -f \"{identity_private_file_path_expanded}\" -C \"crates io token\"{RESET}"#); - } - eprintln!(" "); - panic!("{RED}Error: File {identity_private_file_path_expanded} does not exist! {RESET}"); - } + let identity_private_file_path_expanded = expand_path_check_private_key_exists(identity_private_file_path); let fingerprint_from_file = cargo_auto_encrypt_secret_lib::get_fingerprint_from_file(&identity_private_file_path_expanded); @@ -917,6 +906,24 @@ pub(crate) mod ssh_mod { } } } + /// Expand path and check if identity file exists + /// + /// Inform the user how to generate identity file. + pub fn expand_path_check_private_key_exists(identity_private_file_path: &camino::Utf8Path) -> camino::Utf8PathBuf { + let identity_private_file_path_expanded = cargo_auto_encrypt_secret_lib::file_path_home_expand(identity_private_file_path); + if !camino::Utf8Path::new(&identity_private_file_path_expanded).exists() { + eprintln!("{RED}Identity file {identity_private_file_path_expanded} that contains the SSH private key does not exist! {RESET}"); + eprintln!(" {YELLOW}Create the SSH key manually in bash with this command:{RESET}"); + if identity_private_file_path_expanded.as_str().contains("github_api") { + eprintln!(r#"{GREEN}ssh-keygen -t ed25519 -f "{identity_private_file_path_expanded}" -C "github api token"{RESET}"#); + } else if identity_private_file_path_expanded.as_str().contains("crates_io") { + eprintln!(r#"{GREEN}ssh-keygen -t ed25519 -f "{identity_private_file_path_expanded}" -C "crates io token"{RESET}"#); + } + eprintln!(" "); + panic!("{RED}Error: File {identity_private_file_path_expanded} does not exist! {RESET}"); + } + identity_private_file_path_expanded + } } pub(crate) mod github_mod { @@ -1000,7 +1007,9 @@ pub(crate) mod github_mod { let encrypted_string_file_path = camino::Utf8Path::new("~/.ssh/github_api_token_encrypted.txt"); let encrypted_string_file_path_expanded = cargo_auto_encrypt_secret_lib::file_path_home_expand(encrypted_string_file_path); - let identity_file_path = camino::Utf8Path::new("~/.ssh/github_api_token_ssh_1"); + let identity_private_file_path = camino::Utf8Path::new("~/.ssh/github_api_token_ssh_1"); + let _identity_private_file_path_expanded = crate::secrets_always_local_mod::ssh_mod::expand_path_check_private_key_exists(identity_private_file_path); + if !encrypted_string_file_path_expanded.exists() { // ask interactive println!(" {BLUE}Do you want to store the GitHub API token encrypted with an SSH key? (y/n){RESET}"); @@ -1012,7 +1021,7 @@ pub(crate) mod github_mod { // get the passphrase and token interactively let mut ssh_context = super::ssh_mod::SshContext::new(); // encrypt and save the encrypted token - cargo_auto_encrypt_secret_lib::encrypt_with_ssh_interactive_save_file(&mut ssh_context, identity_file_path, encrypted_string_file_path); + cargo_auto_encrypt_secret_lib::encrypt_with_ssh_interactive_save_file(&mut ssh_context, identity_private_file_path, encrypted_string_file_path); // read the token and decrypt, return GitHubClient read_token_and_decrypt_return_github_client(ssh_context, encrypted_string_file_path) } @@ -1188,7 +1197,10 @@ pub(crate) mod crate_io_mod { let encrypted_string_file_path = camino::Utf8Path::new("~/.ssh/crates_io_token_encrypted.txt"); let encrypted_string_file_path_expanded = cargo_auto_encrypt_secret_lib::file_path_home_expand(encrypted_string_file_path); - let identity_file_path = camino::Utf8Path::new("~/.ssh/crates_io_token_ssh_1"); + let identity_private_file_path = camino::Utf8Path::new("~/.ssh/crates_io_token_ssh_1"); + + let _identity_private_file_path_expanded = crate::secrets_always_local_mod::ssh_mod::expand_path_check_private_key_exists(identity_private_file_path); + if !encrypted_string_file_path_expanded.exists() { // ask interactive println!(" {BLUE}Do you want to store the crates.io token encrypted with an SSH key? (y/n){RESET}"); @@ -1200,7 +1212,7 @@ pub(crate) mod crate_io_mod { // get the passphrase and token interactively let mut ssh_context = super::ssh_mod::SshContext::new(); // encrypt and save the encrypted token - cargo_auto_encrypt_secret_lib::encrypt_with_ssh_interactive_save_file(&mut ssh_context, identity_file_path, encrypted_string_file_path); + cargo_auto_encrypt_secret_lib::encrypt_with_ssh_interactive_save_file(&mut ssh_context, identity_private_file_path, encrypted_string_file_path); // read the token and decrypt, return CratesIoClient read_token_and_decrypt_return_crate_io_client(ssh_context, encrypted_string_file_path) } @@ -1213,7 +1225,6 @@ pub(crate) mod crate_io_mod { } /// decrypts the secret token in memory - #[allow(dead_code)] pub fn decrypt_token_in_memory(&self) -> secrecy::SecretString { self.encrypted_token.expose_decrypted_secret(&self.session_passcode) } @@ -1222,7 +1233,6 @@ pub(crate) mod crate_io_mod { /// /// This function encapsulates the secret crates.io token. /// The client can be passed to the library. It will not reveal the secret token. - #[allow(dead_code)] pub fn publish_to_crates_io(&self) { // print command without the token println!("{YELLOW}cargo publish --token [REDACTED]{RESET}"); @@ -1726,7 +1736,255 @@ pub const RESET: &str = "\x1b[0m"; // So the structure of the project modules can be similar to a binary CLI executable. // region: auto_md_to_doc_comments include README.md A //! - +//! # cargo-auto +//! +//! **Automation tasks coded in Rust language for the workflow of Rust projects** +//! ***version: 2024.422.132 date: 2024-04-22 author: [bestia.dev](https://bestia.dev) repository: [GitHub](https://github.com/automation-tasks-rs/cargo-auto)*** +//! +//! ![maintained](https://img.shields.io/badge/maintained-green) +//! ![ready-for-use](https://img.shields.io/badge/ready_for_use-green) +//! ![rustlang](https://img.shields.io/badge/rustlang-orange) +//! ![automation](https://img.shields.io/badge/automation-orange) +//! ![workflow](https://img.shields.io/badge/workflow-orange) +//! +//! ![logo](https://raw.githubusercontent.com/automation-tasks-rs/cargo-auto/main/images/logo/logo_cargo_auto.svg) +//! cargo-auto is part of the [automation_tasks_rs](https://github.com/automation-tasks-rs) project +//! +//! [![crates.io](https://img.shields.io/crates/v/cargo-auto.svg)](https://crates.io/crates/cargo-auto) +//! [![Documentation](https://docs.rs/cargo-auto/badge.svg)](https://docs.rs/cargo-auto/) +//! [![crev reviews](https://web.crev.dev/rust-reviews/badge/crev_count/cargo-auto.svg)](https://web.crev.dev/rust-reviews/crate/cargo-auto/) +//! [![Lib.rs](https://img.shields.io/badge/Lib.rs-rust-orange.svg)](https://lib.rs/crates/cargo-auto/) +//! [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/automation-tasks-rs/cargo-auto/blob/master/LICENSE) +//! [![Rust](https://github.com/automation-tasks-rs/cargo-auto/workflows/rust_fmt_auto_build_test/badge.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +//! [![Newest docs](https://img.shields.io/badge/newest_docs-blue.svg)](https://automation-tasks-rs.github.io/cargo-auto/cargo_auto/index.html) +//! ![cargo-auto](https://bestia.dev/webpage_hit_counter/get_svg_image/959103982.svg) +//! +//! [![Lines in Rust code](https://img.shields.io/badge/Lines_in_Rust-3141-green.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +//! [![Lines in Doc comments](https://img.shields.io/badge/Lines_in_Doc_comments-1950-blue.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +//! [![Lines in Comments](https://img.shields.io/badge/Lines_in_comments-704-purple.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +//! [![Lines in examples](https://img.shields.io/badge/Lines_in_examples-0-yellow.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +//! [![Lines in tests](https://img.shields.io/badge/Lines_in_tests-10898-orange.svg)](https://github.com/automation-tasks-rs/cargo-auto/) +//! +//! Hashtags: #maintained #ready-for-use #rustlang #automation #workflow +//! My projects on GitHub are more like a tutorial than a finished product: [bestia-dev tutorials](https://github.com/bestia-dev/tutorials_rust_wasm). +//! I recommend using the [CRUSTDE - Containerized Rust Development Environment](https://github.com/CRUSTDE-ContainerizedRustDevEnvrustde_cnt_img_pod) to write Rust projects on Linux, isolated from your system. +//! +//! ## Try it +//! +//! First, we will use `cargo-auto` to create a new empty CLI Rust project similar to `cargo new`, but with a more complete project structure. +//! +//! ```bash +//! cargo install cargo-auto +//! cargo auto new_cli my_hello_project +//! cd my_hello_project +//! cargo auto +//! # it lists all the prepared automation tasks +//! # try a few +//! cargo auto build +//! cargo auto release +//! cargo auto doc +//! cargo auto test +//! ``` +//! +//! We can also add `automation tasks` to an existing Rust project. +//! Inside your Rust project directory (the one with Cargo.toml) run: +//! +//! ```bash +//! cargo auto new_auto +//! cargo auto +//! # it lists all the prepared automation tasks +//! # try to build +//! cargo auto build +//! ``` +//! +//! Congratulations! You are already using `cargo-auto`. Simple as that. +//! Now you can modify the tasks to your needs. It is all Rust language. +//! +//! ## Motivation +//! +//! Cargo is a great tool for building Rust projects. It has all the basics: `cargo build`, `cargo build --release`, `cargo fmt`, `cargo test`, `cargo doc`,... +//! But sometimes we need to do more things like copying some files, publishing to FTP, or entering long commands. These repetitive tasks must be automated. +//! Task automation makes work easier and faster, and simplifies the workflow while improving the consistency and accuracy of workflows. +//! This is also sometimes referred to as "workflow automation." +//! There are many different build systems and task runners there: `make`, `cmake`, `shell scripts`, `cargo-xtask`, `cargo-make`, `cargo-task`, `cargo-script`, `cargo-run-script`, `runner`, `python scripts`, `powershell scripts`, `cmd prompt scripts`, ... +//! Sadly there is no standard in the Rust community for now. +//! I want something similar to [build.rs](https://doc.rust-lang.org/cargo/reference/build-scripts.html), so I can write my "tasks" in pure Rust I don't want to learn another meta language with weird syntax and difficulty to debug. So I will make something really simple, easy, rusty, and extensible. +//! +//! ## cargo auto subcommand +//! +//! The command `cargo install cargo-auto` will add a new subcommand to cargo: +//! +//! ```bash +//! cargo auto +//! ``` +//! +//! This binary is super simple. It has only 1 trivial dependency: `lazy_static`. +//! The binary only reads the CLI arguments and runs the `automation_tasks_rs` binary with them. If needed it will compile `automation_tasks_rs` first. +//! The code-flow of the source code of `cargo-auto` is simple, fully commented, and straightforward to audit. +//! The source code is on [GitHub](https://github.com/automation-tasks-rs/cargo-auto) with MIT open-source licensing. +//! +//! ## bash auto-completion +//! +//! With the help of the crate [dev_bestia_cargo_completion](https://crates.io/crates/dev_bestia_cargo_completion), the commands `cargo` and `cargo auto` get bash auto-completion. Try it! +//! +//! ## cargo auto new_cli +//! +//! I like very much that Rust has the command `cargo new project_name`. It creates a super simple Rust Hello project that can be built and run immediately. But this example is too simple. It lacks the basic file structures of a serious CLI program. +//! I composed an opinionated template for a Rust CLI project. It is easy to run: +//! +//! ```bash +//! cargo auto new_cli project_name +//! # then +//! cd project_name +//! cargo auto build +//! # then follow detailed instructions +//! ``` +//! +//! ## cargo auto new_wasm +//! +//! I composed an opinionated template for a simple Rust WASM project for a browser. It is very similar to the new_cli template but for WASM. +//! It is easy to run: +//! +//! ```bash +//! cargo auto new_wasm project_name +//! # then +//! cd project_name +//! cargo auto build +//! # then follow detailed instructions +//! ``` +//! +//! ## cargo auto new_pwa_wasm +//! +//! I composed an opinionated template for a simple Rust PWA-WASM project for a browser. It is very similar to the new_cli template but for WASM. It adds the PWA standard functionality to work as an offline app. +//! The template needs the title, name, long name, and description inside a `pwa.json5` file and the `icon512x512.png` file for the icons. +//! It is easy to run: +//! +//! ```bash +//! cargo auto new_pwa_wasm +//! # on first run it will just create the `pwa.json5` and `icon512x512.png` files +//! # modify these files with data for your new app and then repeat +//! cargo auto new_pwa_wasm +//! # then +//! cd project_name +//! cargo auto build +//! # then follow detailed instructions +//! ``` +//! +//! ## scripting with rust +//! +//! Rust is a compiled language. It is not really a scripting or interpreted language. But the compilation of small projects is really fast and can be ignored. Subsequent calls will use the already-built binary so the speed will be even faster. +//! This tool `cargo-auto` is meant for Rust projects, so it means that all the Rust infrastructure is already in place. +//! +//! ## automation_tasks_rs Rust sub-project +//! +//! The command `cargo auto new_auto` will create a new Rust sub-project`automation_tasks_rs` inside your `Rust project`. It should not interfere with the main Rust project. This directory will be added to git commits and pushed to remote repositories as part of the main project. It has its own `.gitignore` to avoid committing to its target directory. +//! The `automation_tasks_rs` helper project contains user-defined tasks in Rust code. Your tasks. This helper project should be opened in a new editor starting from the `automation_tasks_rs` directory. It does not share dependencies with the main project. It is completely separate and independent. +//! You can edit it and add your dependencies and Rust code. No limits. Freedom of expression. +//! This is now your code, your tasks, and your helper Rust project! +//! Because only you know what you want to automate and how to do it. +//! Never write secrets, passwords, passphrases, or tokens inside your Rust code. Because then it is pushed to GitHub and the whole world can read it in the next second! +//! Basic example (most of the useful functions are already there): +//! +//! ```rust ignore +//! /// match arguments and call tasks functions +//! fn match_arguments_and_call_tasks(mut args: std::env::Args){ +//! // the first argument is the user defined task: (no argument for help), build, release,... +//! let arg_1 = args.next(); +//! match arg_1 { +//! None => print_help(), +//! Some(task) => { +//! println!("Running auto task: {}", &task); +//! if &task == "build"{ +//! task_build(); +//! } else if &task == "release" { +//! task_release(); +//! } else if &task == "doc" { +//! task_doc(); +//! } else { +//! println!("Task {} is unknown.", &task); +//! print_help(); +//! } +//! } +//! } +//! } +//! +//! /// write a comprehensible help for user defined tasks +//! fn print_help() { +//! println!(r#" +//! User defined tasks in automation_tasks_rs: +//! cargo auto build - builds the crate in debug mode +//! cargo auto release - builds the crate in release mode +//! cargo auto docs - builds the docs +//! "#); +//! } +//! +//! // region: tasks +//! +//! /// cargo build +//! fn task_build() { +//! run_shell_command("cargo fmt"); +//! run_shell_command("cargo build"); +//! } +//! +//! /// cargo build --release +//! fn task_release() { +//! run_shell_command("cargo fmt"); +//! run_shell_command("cargo build --release"); +//! } +//! +//! /// cargo doc, then copies to /docs/ folder, because this is a github standard folder +//! fn task_doc() { +//! run_shell_command("cargo doc --no-deps --document-private-items"); +//! // copy target/doc into docs/ because it is github standard +//! run_shell_command("rsync -a --info=progress2 --delete-after target/doc/ docs/"); +//! // Create simple index.html file in docs directory +//! run_shell_command(&format!( +//! "printf \"\\n\" > docs/index.html", +//! cargo_toml.package_name().replace("-","_") +//! )); +//! run_shell_command("cargo fmt"); +//! } +//! +//! // endregion: tasks +//! +//! ``` +//! +//! ## more complex tasks +//! +//! You can write more complex tasks in Rust language. +//! For example in this project I use automation to create GitHub Releases: +//! Here is a pretty complex workspace with more sub-projects: +//! +//! There is no end to your imagination. If you write something that looks like it can help other developers, please share it with me and I will add it here. +//! +//! ## Development details +//! +//! Read the development details in a separate md file: +//! [DEVELOPMENT.md](https://github.com/automation-tasks-rs/cargo-auto/blob/main/DEVELOPMENT.md) +//! +//! ## Releases changelog +//! +//! Read the changelog in a separate md file: +//! [RELEASES.md](https://github.com/automation-tasks-rs/cargo-auto/blob/main/RELEASES.md) +//! +//! ## TODO +//! +//! Nothing big in the near future. +//! +//! ## Open-source and free as a beer +//! +//! My open-source projects are free as a beer (MIT license). +//! I just love programming. +//! But I need also to drink. If you find my projects and tutorials helpful, please buy me a beer by donating to my [PayPal](https://paypal.me/LucianoBestia). +//! You know the price of a beer in your local bar ;-) +//! So I can drink a free beer for your health :-) +//! [Na zdravje!](https://translate.google.com/?hl=en&sl=sl&tl=en&text=Na%20zdravje&op=translate) [Alla salute!](https://dictionary.cambridge.org/dictionary/italian-english/alla-salute) [Prost!](https://dictionary.cambridge.org/dictionary/german-english/prost) [Nazdravlje!](https://matadornetwork.com/nights/how-to-say-cheers-in-50-languages/) 🍻 +//! +//! [//bestia.dev](https://bestia.dev) +//! [//github.com/automation-tasks-rs](https://github.com/automation-tasks-rs) +//! [//bestiadev.substack.com](https://bestiadev.substack.com) +//! [//youtube.com/@bestia-dev-tutorials](https://youtube.com/@bestia-dev-tutorials) +//! // endregion: auto_md_to_doc_comments include README.md A //! use wasm_bindgen::prelude::*; diff --git a/template_new_auto/.gitignore b/template_new_auto/.gitignore index f7b48ab..4aa0e28 100644 --- a/template_new_auto/.gitignore +++ b/template_new_auto/.gitignore @@ -6,3 +6,4 @@ Cargo.lock # not needed in commits, but also not a problem if they are committed /.file_hashes.json +/.old_metadata.json diff --git a/template_new_cli/.vscode/settings.json b/template_new_cli/.vscode/settings.json index c9459b5..e635ea7 100644 --- a/template_new_cli/.vscode/settings.json +++ b/template_new_cli/.vscode/settings.json @@ -19,17 +19,27 @@ "rust-analyzer.showUnlinkedFileNotification": false, "cSpell.words": [ "Alla", + "alloc", + "appender", "bestia", "bestiadev", + "camino", "CRUSTDE", + "Decryptor", + "Encryptor", "endregion", + "keygen", "Nazdravlje", + "passcode", "plantuml", "Prost", + "reqwest", "rustdevuser", "rustlang", "rustprojects", + "serde", "struct", + "subsecond", "substack", "thiserror", "zcvf", diff --git a/template_new_cli/automation_tasks_rs/.gitignore b/template_new_cli/automation_tasks_rs/.gitignore index f7b48ab..4aa0e28 100644 --- a/template_new_cli/automation_tasks_rs/.gitignore +++ b/template_new_cli/automation_tasks_rs/.gitignore @@ -6,3 +6,4 @@ Cargo.lock # not needed in commits, but also not a problem if they are committed /.file_hashes.json +/.old_metadata.json diff --git a/template_new_pwa_wasm/.vscode/settings.json b/template_new_pwa_wasm/.vscode/settings.json index 9b920cc..dbef6b4 100644 --- a/template_new_pwa_wasm/.vscode/settings.json +++ b/template_new_pwa_wasm/.vscode/settings.json @@ -19,22 +19,33 @@ "rust-analyzer.showUnlinkedFileNotification": false, "cSpell.words": [ "Alla", + "alloc", + "appender", "apos", "bestia", "bestiadev", "bindgen", + "camino", "cdylib", "CRUSTDE", + "Decryptor", + "Encryptor", "endregion", + "keygen", "Nazdravlje", + "passcode", "onchange", "onclick", "plantuml", "Prost", + "reqwest", + "rustdevuser", "rustc", "rustlang", "rustprojects", + "serde", "struct", + "subsecond", "substack", "thiserror", "webassembly", diff --git a/template_new_pwa_wasm/automation_tasks_rs/.gitignore b/template_new_pwa_wasm/automation_tasks_rs/.gitignore index f7b48ab..4aa0e28 100644 --- a/template_new_pwa_wasm/automation_tasks_rs/.gitignore +++ b/template_new_pwa_wasm/automation_tasks_rs/.gitignore @@ -6,3 +6,4 @@ Cargo.lock # not needed in commits, but also not a problem if they are committed /.file_hashes.json +/.old_metadata.json diff --git a/template_new_pwa_wasm/web_server_folder/pwa_short_name/service_worker.js b/template_new_pwa_wasm/web_server_folder/pwa_short_name/service_worker.js index 316f4fc..58d468d 100644 --- a/template_new_pwa_wasm/web_server_folder/pwa_short_name/service_worker.js +++ b/template_new_pwa_wasm/web_server_folder/pwa_short_name/service_worker.js @@ -7,7 +7,7 @@ // but the new service worker will not be activated until all // tabs with this webapp are closed. -const CACHE_NAME = '2024.422.15'; +const CACHE_NAME = '2024.422.132'; self.addEventListener('install', event => { console.log('event install ', CACHE_NAME); diff --git a/template_new_wasm/.vscode/settings.json b/template_new_wasm/.vscode/settings.json index 9b920cc..8d438ed 100644 --- a/template_new_wasm/.vscode/settings.json +++ b/template_new_wasm/.vscode/settings.json @@ -19,26 +19,41 @@ "rust-analyzer.showUnlinkedFileNotification": false, "cSpell.words": [ "Alla", + "alloc", + "appender", "apos", "bestia", "bestiadev", "bindgen", + "camino", "cdylib", "CRUSTDE", + "decryptor", + "encryptor", "endregion", + "keygen", "Nazdravlje", "onchange", "onclick", + "new_cli", + "octocrab", + "passcode", "plantuml", "Prost", + "reqwest", + "rustdevuser", "rustc", "rustlang", "rustprojects", + "serde", + "sshadd", "struct", + "subsecond", "substack", "thiserror", "webassembly", "zcvf", - "zdravje" + "zdravje", + "zeroize" ] } \ No newline at end of file diff --git a/template_new_wasm/automation_tasks_rs/.gitignore b/template_new_wasm/automation_tasks_rs/.gitignore index f7b48ab..4aa0e28 100644 --- a/template_new_wasm/automation_tasks_rs/.gitignore +++ b/template_new_wasm/automation_tasks_rs/.gitignore @@ -6,3 +6,4 @@ Cargo.lock # not needed in commits, but also not a problem if they are committed /.file_hashes.json +/.old_metadata.json