diff --git a/.gitignore b/.gitignore index 5fa23887..9a2038ec 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,8 @@ **/node_modules/ /src/x.rs -.DS_Store \ No newline at end of file +.DS_Store + +# IDEs +.idea +.vscode \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 304c85a2..5343b72a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -412,6 +412,16 @@ dependencies = [ "nom", ] +[[package]] +name = "assert-json-diff" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e4f2b81832e72834d7518d8487a0396a28cc408186a2e8854c0f98011faf12" +dependencies = [ + "serde", + "serde_json", +] + [[package]] name = "assert_cmd" version = "2.0.14" @@ -2415,6 +2425,29 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "env_filter" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "env_logger" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c012a26a7f605efc424dd53697843a72be7dc86ad2d01f7814337794a12231d" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "humantime", + "log", +] + [[package]] name = "environmental" version = "1.1.4" @@ -3154,6 +3187,12 @@ dependencies = [ "libm", ] +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + [[package]] name = "hyper" version = "0.14.28" @@ -4422,6 +4461,25 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "mockito" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2f6e023aa5bdf392aa06c78e4a4e6d498baab5138d0c993503350ebbc37bf1e" +dependencies = [ + "assert-json-diff", + "colored", + "futures-core", + "hyper 0.14.28", + "log", + "rand", + "regex", + "serde_json", + "serde_urlencoded", + "similar", + "tokio", +] + [[package]] name = "multiaddr" version = "0.18.1" @@ -5320,12 +5378,16 @@ dependencies = [ "console", "dirs", "duct", + "env_logger", "git2", "os_info", "pop-contracts", "pop-parachains", + "pop-telemetry", "predicates", "reqwest", + "serde", + "serde_json", "sp-core 30.0.0", "sp-weights 29.0.0", "strum 0.26.2", @@ -5381,6 +5443,23 @@ dependencies = [ "zombienet-support", ] +[[package]] +name = "pop-telemetry" +version = "0.1.0" +dependencies = [ + "dirs", + "env_logger", + "log", + "mockito", + "reqwest", + "serde", + "serde_json", + "tempfile", + "thiserror", + "tokio", + "url", +] + [[package]] name = "portable-atomic" version = "1.6.0" @@ -6830,6 +6909,12 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" +[[package]] +name = "similar" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa42c91313f1d05da9b26f267f931cf178d4aba455b4c4622dd7355eb80c6640" + [[package]] name = "simple-mermaid" version = "0.1.1" diff --git a/Cargo.toml b/Cargo.toml index 5ff96284..f9e4d4b2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,12 +12,22 @@ codegen-units = 1 resolver = "2" members = ["crates/*"] +[workspace.package] +edition = "2021" + [workspace.dependencies] anyhow = "1.0" -thiserror = "1.0.58" +dirs = "5.0" +env_logger = "0.11.1" duct = "0.13" git2 = "0.18" +log = "0.4.20" +mockito = "1.4.0" tempfile = "3.8" +thiserror = "1.0.58" + +# networking +reqwest = { version = "0.11", features = ["json"] } tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] } url = { version = "2.5" } @@ -37,7 +47,6 @@ walkdir = "2.4" indexmap = { version = "2.2" } toml_edit = { version = "0.22", features = ["serde"] } symlink = { version = "0.1" } -reqwest = { version = "0.11" } serde_json = { version = "1.0" } serde = { version = "1.0", features = ["derive"] } zombienet-sdk = { git = "https://github.com/r0gue-io/zombienet-sdk", branch = "pop" } diff --git a/crates/pop-cli/Cargo.toml b/crates/pop-cli/Cargo.toml index 362db78d..ba21f832 100644 --- a/crates/pop-cli/Cargo.toml +++ b/crates/pop-cli/Cargo.toml @@ -2,7 +2,7 @@ name = "pop-cli" description = "An all-in-one tool for Polkadot development." version = "0.1.0" -edition = "2021" +edition.workspace = true [[bin]] name = "pop" @@ -11,11 +11,14 @@ path = "src/main.rs" [dependencies] anyhow.workspace = true duct.workspace = true +env_logger.workspace = true +os_info.workspace = true +reqwest.workspace = true +serde.workspace = true +serde_json.workspace = true tempfile.workspace = true -url.workspace = true tokio.workspace = true -reqwest.workspace = true -os_info.workspace = true +url.workspace = true # pop-cli clap.workspace = true @@ -34,12 +37,15 @@ pop-parachains = { path = "../pop-parachains", optional = true } dirs = { version = "5.0", optional = true } git2 = { workspace = true, features = ["vendored-openssl"] } +# telemetry +pop-telemetry = { path = "../pop-telemetry", optional = true } + [dev-dependencies] assert_cmd = "2.0.14" predicates = "3.1.0" [features] -default = ["contract", "parachain"] +default = ["contract", "parachain", "telemetry"] contract = [ "dep:pop-contracts", "dep:sp-core", @@ -49,3 +55,4 @@ parachain = [ "dep:pop-parachains", "dep:dirs", ] +telemetry = ["dep:pop-telemetry"] diff --git a/crates/pop-cli/src/commands/new/contract.rs b/crates/pop-cli/src/commands/new/contract.rs index 54510d2e..5d2f679b 100644 --- a/crates/pop-cli/src/commands/new/contract.rs +++ b/crates/pop-cli/src/commands/new/contract.rs @@ -50,6 +50,7 @@ impl NewContractCommand { let spinner = cliclack::spinner(); spinner.start("Generating contract..."); create_smart_contract(&self.name, contract_path.as_path())?; + spinner.stop("Smart contract created!"); outro(format!("cd into \"{}\" and enjoy hacking! 🚀", contract_path.display()))?; Ok(()) diff --git a/crates/pop-cli/src/commands/new/pallet.rs b/crates/pop-cli/src/commands/new/pallet.rs index 30e739ea..9f569823 100644 --- a/crates/pop-cli/src/commands/new/pallet.rs +++ b/crates/pop-cli/src/commands/new/pallet.rs @@ -55,6 +55,7 @@ impl NewPalletCommand { description: self.description.clone().expect("default values"), }, )?; + spinner.stop("Generation complete"); outro(format!("cd into \"{}\" and enjoy hacking! 🚀", &self.name))?; Ok(()) diff --git a/crates/pop-cli/src/commands/new/parachain.rs b/crates/pop-cli/src/commands/new/parachain.rs index 09733198..113bf742 100644 --- a/crates/pop-cli/src/commands/new/parachain.rs +++ b/crates/pop-cli/src/commands/new/parachain.rs @@ -5,11 +5,7 @@ use clap::{ builder::{PossibleValue, PossibleValuesParser, TypedValueParser}, Args, }; -use std::{ - fs, - path::{Path, PathBuf}, - str::FromStr, -}; +use std::{fs, path::Path, str::FromStr}; use cliclack::{clear_screen, confirm, input, intro, log, outro, outro_cancel, set_theme}; use pop_parachains::{ @@ -20,7 +16,7 @@ use strum::VariantArray; const DEFAULT_INITIAL_ENDOWMENT: &str = "1u64 << 60"; -#[derive(Args)] +#[derive(Args, Clone)] pub struct NewParachainCommand { #[arg(help = "Name of the project. If empty assistance in the process will be provided.")] pub(crate) name: Option, @@ -37,6 +33,12 @@ pub struct NewParachainCommand { value_parser = crate::enum_variants!(Template) )] pub(crate) template: Option