diff --git a/Cargo.lock b/Cargo.lock index 9aea983..200cda5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -52,6 +52,8 @@ dependencies = [ "env_logger", "guidon", "itertools", + "ron", + "serde", "which", ] @@ -87,6 +89,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + [[package]] name = "base64ct" version = "1.6.0" @@ -764,7 +772,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.28", ] [[package]] @@ -816,9 +824,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] @@ -831,9 +839,9 @@ checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" [[package]] name = "quote" -version = "1.0.26" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" dependencies = [ "proc-macro2", ] @@ -894,6 +902,17 @@ version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" +[[package]] +name = "ron" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300a51053b1cb55c80b7a9fde4120726ddf25ca241a1cbb926626f62fb136bff" +dependencies = [ + "base64", + "bitflags", + "serde", +] + [[package]] name = "rustix" version = "0.37.11" @@ -916,19 +935,22 @@ checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "serde" -version = "1.0.160" +version = "1.0.183" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c" +checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c" +dependencies = [ + "serde_derive", +] [[package]] name = "serde_derive" -version = "1.0.160" +version = "1.0.183" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" +checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.28", ] [[package]] @@ -1003,9 +1025,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.15" +version = "2.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" dependencies = [ "proc-macro2", "quote", @@ -1057,7 +1079,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.28", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 41695b6..e706619 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,3 +20,5 @@ env_logger = "0.10.0" dialoguer = "0.10.4" which = "4.4.0" itertools = "0.11.0" +ron = "0.8.0" +serde = { version = "1.0.183", features = ["derive"] } diff --git a/src/commands/create.rs b/src/commands/create.rs index f7569d9..e5f2098 100644 --- a/src/commands/create.rs +++ b/src/commands/create.rs @@ -83,7 +83,10 @@ fn get_vars(args: &Create) -> BTreeMap { } fn post_create(args: Create) { - android_cli::create_local_properties_file(args.dest.unwrap().as_path(), &args.sdk_path.unwrap()) + let dest = args.dest.clone().unwrap(); + + android_cli::create_local_properties_file(&dest, &args.sdk_path.unwrap()); + android_cli::create_dot_file(&dest, args.package_id.unwrap()); } fn ensure_valid_args(args: Create) -> Create { diff --git a/src/lib.rs b/src/lib.rs index fcd1162..40499d6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,8 @@ mod utils; -use itertools::Itertools; use guidon::{GitOptions, Guidon, TryNew}; +use itertools::Itertools; +use serde::{Deserialize, Serialize}; use std::{ collections::BTreeMap, @@ -9,13 +10,21 @@ use std::{ process::{Command, ExitStatus}, }; -use utils::find_gradle; +use utils::{find_adb, find_gradle}; -use crate::utils::find_adb; +const VERSION: &str = env!("CARGO_PKG_VERSION"); const DEFAULT_TEMPLATE_REPO: &str = "https://github.com/SyedAhkam/android-cli-template"; const TEMPLATE_REV: &str = "master"; +const DOTFILE_COMMENT: &str = "// DO NOT MODIFY; Generated by Android CLI for internal usage.\n"; + +#[derive(Debug, Serialize, Deserialize)] +struct DotAndroid { + pub package_id: String, + pub gen_at_version: String, +} + pub fn copy_template(dest: &Path, vars: BTreeMap) { let git_options = GitOptions::builder() .repo(DEFAULT_TEMPLATE_REPO) @@ -45,9 +54,7 @@ pub fn invoke_gradle_command(cmd: &str) -> Result Result