From 720899e19e764aadc5a3504ba094120035c0f21d Mon Sep 17 00:00:00 2001 From: Andrew Voynov <37143421+Andrew15-5@users.noreply.github.com> Date: Tue, 14 May 2024 17:39:56 +0300 Subject: [PATCH] feat(cli): now user interaction can be skipped (#1872) when creating a new project --- Cargo.lock | 143 +++++++++++++++++---------------- packages/cli/Cargo.toml | 2 +- packages/cli/src/cli/create.rs | 34 +++++++- 3 files changed, 104 insertions(+), 75 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5ecf3cb32..950cb252a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1023,15 +1023,6 @@ dependencies = [ "serde", ] -[[package]] -name = "btoi" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dd6407f73a9b8b6162d8a2ef999fe6afd7cc15902ebf42c5cd296addf17e0ad" -dependencies = [ - "num-traits", -] - [[package]] name = "built" version = "0.7.2" @@ -1147,20 +1138,20 @@ dependencies = [ [[package]] name = "cargo-generate" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92c1b6f44358912a9538fa3b6ac8d3aa3f585444f9dc32f12ed85d1545a9df9f" +checksum = "aa7015584550945f11fdfb7af113d30e2727468ec281c1d7f28cc1019196c25d" dependencies = [ "anyhow", "auth-git2", - "clap 4.4.18", + "clap 4.5.4", "console", "dialoguer", - "env_logger 0.10.2", + "env_logger 0.11.3", "fs-err", "git2", "gix-config", - "heck 0.4.1", + "heck 0.5.0", "home", "ignore", "indexmap 2.2.6", @@ -1376,9 +1367,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.18" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" +checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" dependencies = [ "clap_builder", "clap_derive", @@ -1386,23 +1377,23 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.18" +version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim", + "strsim 0.11.1", ] [[package]] name = "clap_derive" -version = "4.4.7" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" dependencies = [ - "heck 0.4.1", + "heck 0.5.0", "proc-macro2", "quote", "syn 2.0.60", @@ -1410,9 +1401,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "cocoa" @@ -1741,7 +1732,7 @@ dependencies = [ "anes", "cast", "ciborium", - "clap 4.4.18", + "clap 4.5.4", "criterion-plot 0.5.0", "futures", "is-terminal", @@ -1968,7 +1959,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim", + "strsim 0.10.0", "syn 2.0.60", ] @@ -2154,7 +2145,7 @@ dependencies = [ "cargo_metadata 0.18.1", "cargo_toml 0.18.0", "chrono", - "clap 4.4.18", + "clap 4.5.4", "colored 2.1.0", "ctrlc", "dioxus-autofmt", @@ -2215,7 +2206,7 @@ name = "dioxus-cli-config" version = "0.5.2" dependencies = [ "cargo_toml 0.18.0", - "clap 4.4.18", + "clap 4.5.4", "once_cell", "serde", "serde_json", @@ -3109,9 +3100,6 @@ name = "faster-hex" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2a2b11eda1d40935b26cf18f6833c526845ae8c41e58d09af6adeb6f0269183" -dependencies = [ - "serde", -] [[package]] name = "fastrand" @@ -3682,23 +3670,23 @@ dependencies = [ [[package]] name = "gix-actor" -version = "0.28.1" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eadca029ef716b4378f7afb19f7ee101fde9e58ba1f1445971315ac866db417" +checksum = "45c3a3bde455ad2ee8ba8a195745241ce0b770a8a26faae59fcf409d01b28c46" dependencies = [ "bstr 1.9.1", - "btoi", "gix-date", + "gix-utils", "itoa 1.0.11", "thiserror", - "winnow 0.5.40", + "winnow 0.6.7", ] [[package]] name = "gix-config" -version = "0.32.1" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0341471d55d8676e98b88e121d7065dfa4c9c5acea4b6d6ecdd2846e85cce0c3" +checksum = "7580e05996e893347ad04e1eaceb92e1c0e6a3ffe517171af99bf6b6df0ca6e5" dependencies = [ "bstr 1.9.1", "gix-config-value", @@ -3712,7 +3700,7 @@ dependencies = [ "smallvec", "thiserror", "unicode-bom", - "winnow 0.5.40", + "winnow 0.6.7", ] [[package]] @@ -3742,12 +3730,13 @@ dependencies = [ [[package]] name = "gix-features" -version = "0.36.1" +version = "0.38.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d46a4a5c6bb5bebec9c0d18b65ada20e6517dbd7cf855b87dd4bbdce3a771b2" +checksum = "db4254037d20a247a0367aa79333750146a369719f0c6617fec4f5752cc62b37" dependencies = [ "gix-hash", "gix-trace", + "gix-utils", "libc", "prodash", "sha1_smol", @@ -3756,18 +3745,19 @@ dependencies = [ [[package]] name = "gix-fs" -version = "0.8.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20e86eb040f5776a5ade092282e51cdcad398adb77d948b88d17583c2ae4e107" +checksum = "e2184c40e7910529677831c8b481acf788ffd92427ed21fad65b6aa637e631b8" dependencies = [ "gix-features", + "gix-utils", ] [[package]] name = "gix-glob" -version = "0.14.1" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5db19298c5eeea2961e5b3bf190767a2d1f09b8802aeb5f258e42276350aff19" +checksum = "682bdc43cb3c00dbedfcc366de2a849b582efd8d886215dbad2ea662ec156bb5" dependencies = [ "bitflags 2.5.0", "bstr 1.9.1", @@ -3777,9 +3767,9 @@ dependencies = [ [[package]] name = "gix-hash" -version = "0.13.3" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f8cf8c2266f63e582b7eb206799b63aa5fa68ee510ad349f637dfe2d0653de0" +checksum = "f93d7df7366121b5018f947a04d37f034717e113dcf9ccd85c34b58e57a74d5e" dependencies = [ "faster-hex", "thiserror", @@ -3787,9 +3777,9 @@ dependencies = [ [[package]] name = "gix-lock" -version = "11.0.1" +version = "13.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e5c65e6a29830a435664891ced3f3c1af010f14900226019590ee0971a22f37" +checksum = "e7c359f81f01b8352063319bcb39789b7ea0887b406406381106e38c4a34d049" dependencies = [ "gix-tempfile", "gix-utils", @@ -3798,21 +3788,21 @@ dependencies = [ [[package]] name = "gix-object" -version = "0.39.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "febf79c5825720c1c63fe974c7bbe695d0cb54aabad73f45671c60ce0e501e33" +checksum = "3d4f8efae72030df1c4a81d02dbe2348e748d9b9a11e108ed6efbd846326e051" dependencies = [ "bstr 1.9.1", - "btoi", "gix-actor", "gix-date", "gix-features", "gix-hash", + "gix-utils", "gix-validate", "itoa 1.0.11", "smallvec", "thiserror", - "winnow 0.5.40", + "winnow 0.6.7", ] [[package]] @@ -3830,9 +3820,9 @@ dependencies = [ [[package]] name = "gix-ref" -version = "0.39.1" +version = "0.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2069adc212cf7f3317ef55f6444abd06c50f28479dbbac5a86acf3b05cbbfe" +checksum = "fd4aba68b925101cb45d6df328979af0681364579db889098a0de75b36c77b65" dependencies = [ "gix-actor", "gix-date", @@ -3843,10 +3833,11 @@ dependencies = [ "gix-object", "gix-path", "gix-tempfile", + "gix-utils", "gix-validate", "memmap2", "thiserror", - "winnow 0.5.40", + "winnow 0.6.7", ] [[package]] @@ -3863,9 +3854,9 @@ dependencies = [ [[package]] name = "gix-tempfile" -version = "11.0.1" +version = "13.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388dd29114a86ec69b28d1e26d6d63a662300ecf61ab3f4cc578f7d7dc9e7e23" +checksum = "a761d76594f4443b675e85928e4902dec333273836bd386906f01e7e346a0d11" dependencies = [ "gix-fs", "libc", @@ -7048,9 +7039,9 @@ dependencies = [ [[package]] name = "prodash" -version = "26.2.2" +version = "28.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "794b5bf8e2d19b53dcdcec3e4bba628e20f5b6062503ba89281fa7037dd7bbcf" +checksum = "744a264d26b88a6a7e37cbad97953fa233b94d585236310bcbc88474b4092d79" [[package]] name = "profiling" @@ -7505,9 +7496,9 @@ dependencies = [ [[package]] name = "rhai" -version = "1.16.3" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3625f343d89990133d013e39c46e350915178cf94f1bec9f49b0cbef98a3e3c" +checksum = "f6273372244d04a8a4b0bec080ea1e710403e88c5d9d83f9808b2bfa64f0982a" dependencies = [ "ahash 0.8.11", "bitflags 2.5.0", @@ -7517,13 +7508,14 @@ dependencies = [ "rhai_codegen", "smallvec", "smartstring", + "thin-vec", ] [[package]] name = "rhai_codegen" -version = "1.6.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "853977598f084a492323fe2f7896b4100a86284ee8473612de60021ea341310f" +checksum = "59aecf17969c04b9c0c5d21f6bc9da9fec9dd4980e64d1871443a476589d8c86" dependencies = [ "proc-macro2", "quote", @@ -8675,6 +8667,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "subprocess" version = "0.2.9" @@ -8880,7 +8878,7 @@ dependencies = [ "serde_json", "sha1", "sha2", - "strsim", + "strsim 0.10.0", "tar", "tauri-icns", "tauri-utils", @@ -8934,15 +8932,14 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.8.1" +version = "3.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if", "fastrand", - "redox_syscall 0.4.1", "rustix", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -8990,6 +8987,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8eaa81235c7058867fa8c0e7314f33dcce9c215f535d1913822a2b3f5e289f3c" +[[package]] +name = "thin-vec" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a38c90d48152c236a3ab59271da4f4ae63d678c5d7ad6b7714d7cb9760be5e4b" + [[package]] name = "thiserror" version = "1.0.59" @@ -9696,9 +9699,9 @@ checksum = "65dd7eed29412da847b0f78bcec0ac98588165988a8cfe41d4ea1d429f8ccfff" [[package]] name = "walkdir" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ "same-file", "winapi-util", diff --git a/packages/cli/Cargo.toml b/packages/cli/Cargo.toml index 272f37568..7cbbf4acb 100644 --- a/packages/cli/Cargo.toml +++ b/packages/cli/Cargo.toml @@ -73,7 +73,7 @@ mlua = { version = "0.8.1", features = [ ], optional = true } ctrlc = "3.2.3" open = "5.0.1" -cargo-generate = "0.19.0" +cargo-generate = "0.20.0" toml_edit = "0.21.0" # bundling diff --git a/packages/cli/src/cli/create.rs b/packages/cli/src/cli/create.rs index 96fe11133..60ba1d504 100644 --- a/packages/cli/src/cli/create.rs +++ b/packages/cli/src/cli/create.rs @@ -1,26 +1,52 @@ use super::*; use cargo_generate::{GenerateArgs, TemplatePath}; +static DEFAULT_TEMPLATE: &str = "gh:dioxuslabs/dioxus-template"; + #[derive(Clone, Debug, Default, Deserialize, Parser)] #[clap(name = "new")] pub struct Create { + /// Project name (required when `--yes` is used) + name: Option, /// Template path - #[clap(default_value = "gh:dioxuslabs/dioxus-template", long)] + #[clap(default_value = DEFAULT_TEMPLATE, short, long)] template: String, + /// Pass