diff --git a/Cargo.lock b/Cargo.lock index b74174a4..df60f48c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1123,12 +1123,12 @@ dependencies = [ "futures", "futures-util", "harmont-cloud", + "harmont-cloud-raw", "hex", "hm-common", "hm-core", "hm-dsl-engine", "hm-pipeline-ir", - "hm-plugin-cloud", "hm-plugin-protocol", "hm-render", "hm-vm", @@ -1342,29 +1342,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "hm-plugin-cloud" -version = "0.0.0-dev" -dependencies = [ - "anyhow", - "base64", - "chrono", - "clap", - "dialoguer", - "harmont-cloud", - "harmont-cloud-raw", - "hm-core", - "hm-plugin-protocol", - "hm-render", - "rstest", - "secrecy", - "serde_json", - "tokio", - "tracing", - "uuid", - "webbrowser", -] - [[package]] name = "hm-plugin-protocol" version = "0.0.0-dev" diff --git a/Cargo.toml b/Cargo.toml index 1b450bb8..89451b21 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,6 @@ members = [ "crates/hm-core", "crates/hm-plugin-protocol", "crates/hm-pipeline-ir", - "crates/hm-plugin-cloud", "crates/hm-dsl-engine", "crates/hm-render", "crates/hm-vm", @@ -17,7 +16,6 @@ default-members = [ "crates/hm-core", "crates/hm-plugin-protocol", "crates/hm-pipeline-ir", - "crates/hm-plugin-cloud", "crates/hm-dsl-engine", "crates/hm-render", "crates/hm-vm", @@ -31,7 +29,6 @@ repository = "https://github.com/harmont-dev/harmont-cli" [workspace.dependencies] hm-core = { path = "crates/hm-core", version = "0.0.0-dev" } hm-plugin-protocol = { path = "crates/hm-plugin-protocol", version = "0.0.0-dev" } -hm-plugin-cloud = { path = "crates/hm-plugin-cloud", version = "0.0.0-dev" } hm-pipeline-ir = { path = "crates/hm-pipeline-ir", version = "0.0.0-dev" } hm-dsl-engine = { path = "crates/hm-dsl-engine", version = "0.0.0-dev" } hm-render = { path = "crates/hm-render", version = "0.0.0-dev" } diff --git a/crates/hm-core/src/exec/cloud/mod.rs b/crates/hm-core/src/exec/cloud/mod.rs index b4b0c491..22fcb0ac 100644 --- a/crates/hm-core/src/exec/cloud/mod.rs +++ b/crates/hm-core/src/exec/cloud/mod.rs @@ -1,5 +1,5 @@ //! Cloud execution backend (submit + watch over the SDK). -pub mod watch; // pub: hm-plugin-cloud's `build watch`/`job log` verbs reuse it +pub mod watch; // pub: the CLI's `cloud build watch`/`cloud job log` verbs reuse it mod backend; pub use backend::CloudBackend; diff --git a/crates/hm-plugin-cloud/Cargo.toml b/crates/hm-plugin-cloud/Cargo.toml deleted file mode 100644 index 1d700f94..00000000 --- a/crates/hm-plugin-cloud/Cargo.toml +++ /dev/null @@ -1,36 +0,0 @@ -[package] -name = "hm-plugin-cloud" -version = "0.0.0-dev" -edition.workspace = true -license.workspace = true -repository.workspace = true -description = "Cloud client library for the hm CLI." -keywords = ["ci", "harmont", "cloud"] -categories = ["command-line-utilities"] - -[lib] -path = "src/lib.rs" - -[dependencies] -secrecy = "0.10" -harmont-cloud = { workspace = true } -harmont-cloud-raw = { workspace = true } -hm-core = { workspace = true } -hm-render = { workspace = true } -hm-plugin-protocol = { workspace = true } -serde_json = { workspace = true } -chrono = { workspace = true } -uuid = { workspace = true } -clap = { version = "4", features = ["derive"] } -anyhow = "1" -base64 = "0.22" -tokio = { version = "1", features = ["net", "rt", "time", "sync", "macros"] } -webbrowser = "1" -dialoguer = "0.11" -tracing = { workspace = true } - -[dev-dependencies] -rstest = { workspace = true } - -[lints] -workspace = true diff --git a/crates/hm-render/src/lib.rs b/crates/hm-render/src/lib.rs index da22dada..42d4599d 100644 --- a/crates/hm-render/src/lib.rs +++ b/crates/hm-render/src/lib.rs @@ -1,4 +1,4 @@ -//! Build-event renderers shared by the `hm` CLI and `hm-plugin-cloud`. +//! Build-event renderers shared across the `hm` CLI's local and cloud paths. //! //! This crate owns the output layer: the [`OutputRenderer`] trait, the //! [`OutputMode`] selection enum, and the concrete renderers @@ -15,7 +15,7 @@ use hm_plugin_protocol::BuildEvent; /// the `NO_COLOR` env convention, and whether stderr is a TTY. /// /// Single source of truth for the color rule, shared by the `hm` run -/// context and `hm-plugin-cloud`'s render preferences. +/// context and the cloud commands' render preferences. #[must_use] pub fn color_enabled(no_color_flag: bool) -> bool { !no_color_flag && std::env::var_os("NO_COLOR").is_none() && std::io::stderr().is_terminal() diff --git a/crates/hm/Cargo.toml b/crates/hm/Cargo.toml index 77510047..2301d04c 100644 --- a/crates/hm/Cargo.toml +++ b/crates/hm/Cargo.toml @@ -62,8 +62,8 @@ hm-pipeline-ir = { workspace = true } hm-plugin-protocol = { workspace = true } hm-common = { workspace = true } hm-core = { workspace = true } -hm-plugin-cloud = { workspace = true } -harmont-cloud = { workspace = true } +harmont-cloud = { workspace = true } +harmont-cloud-raw = { workspace = true } hm-vm = { workspace = true, features = ["docker-backend"] } hm-dsl-engine = { workspace = true } hm-render = { workspace = true } diff --git a/crates/hm/README.md b/crates/hm/README.md index 50c84c27..27efe862 100644 --- a/crates/hm/README.md +++ b/crates/hm/README.md @@ -133,8 +133,7 @@ hm run --help # full flag reference ## Cloud `hm cloud ` talks to the hosted Harmont API at `api.harmont.dev`. -Every cloud verb is delivered by the embedded `hm-plugin-cloud` crate -(no separate install step): +Every cloud verb is built into the `hm` binary (no separate install step): ```sh hm cloud login # browser-loopback OAuth (or --paste to diff --git a/crates/hm/src/cli/mod.rs b/crates/hm/src/cli/mod.rs index 5932bd59..60fe3b8a 100644 --- a/crates/hm/src/cli/mod.rs +++ b/crates/hm/src/cli/mod.rs @@ -70,7 +70,7 @@ pub enum Command { /// Interact with the Harmont cloud API. #[command(subcommand)] - Cloud(hm_plugin_cloud::cli::CloudCommand), + Cloud(crate::commands::cloud::cli::CloudCommand), } #[derive(Debug, Clone, Subcommand)] @@ -116,7 +116,7 @@ pub async fn dispatch(command: Command, ctx: RunContext<'_>) -> Result { Command::Plugin(cmd) => plugin::run(cmd).await.map(|()| 0), Command::Cloud(cmd) => { let env = std::env::vars().collect(); - hm_plugin_cloud::cli::dispatch_command(cmd, env, app).await + crate::commands::cloud::cli::dispatch_command(cmd, env, app).await } } } diff --git a/crates/hm-plugin-cloud/src/auth/login.rs b/crates/hm/src/commands/cloud/auth/login.rs similarity index 99% rename from crates/hm-plugin-cloud/src/auth/login.rs rename to crates/hm/src/commands/cloud/auth/login.rs index 22a66d99..f1200ddd 100644 --- a/crates/hm-plugin-cloud/src/auth/login.rs +++ b/crates/hm/src/commands/cloud/auth/login.rs @@ -17,7 +17,7 @@ use anyhow::{Result, bail}; use harmont_cloud::{HarmontClient, HarmontError}; use hm_core::app_ctx::AppCtx; -use crate::settings; +use crate::commands::cloud::settings; pub(crate) async fn run( env: &BTreeMap, diff --git a/crates/hm-plugin-cloud/src/auth/logout.rs b/crates/hm/src/commands/cloud/auth/logout.rs similarity index 100% rename from crates/hm-plugin-cloud/src/auth/logout.rs rename to crates/hm/src/commands/cloud/auth/logout.rs diff --git a/crates/hm-plugin-cloud/src/auth/mod.rs b/crates/hm/src/commands/cloud/auth/mod.rs similarity index 100% rename from crates/hm-plugin-cloud/src/auth/mod.rs rename to crates/hm/src/commands/cloud/auth/mod.rs diff --git a/crates/hm-plugin-cloud/src/auth/whoami.rs b/crates/hm/src/commands/cloud/auth/whoami.rs similarity index 94% rename from crates/hm-plugin-cloud/src/auth/whoami.rs rename to crates/hm/src/commands/cloud/auth/whoami.rs index 1548e419..1a5911e4 100644 --- a/crates/hm-plugin-cloud/src/auth/whoami.rs +++ b/crates/hm/src/commands/cloud/auth/whoami.rs @@ -5,7 +5,7 @@ use std::collections::BTreeMap; use anyhow::Result; use hm_core::app_ctx::AppCtx; -use crate::settings; +use crate::commands::cloud::settings; pub(crate) async fn run(_env: &BTreeMap, app: &AppCtx) -> Result<()> { let (client, _ctx) = settings::client(app).await?; diff --git a/crates/hm-plugin-cloud/src/cli.rs b/crates/hm/src/commands/cloud/cli.rs similarity index 99% rename from crates/hm-plugin-cloud/src/cli.rs rename to crates/hm/src/commands/cloud/cli.rs index b7e11cb0..915fa3aa 100644 --- a/crates/hm-plugin-cloud/src/cli.rs +++ b/crates/hm/src/commands/cloud/cli.rs @@ -6,7 +6,7 @@ use anyhow::Result; use clap::Subcommand; use hm_core::app_ctx::AppCtx; -use crate::{auth, verbs}; +use crate::commands::cloud::{auth, verbs}; /// Process exit status for the cloud subcommands. enum ExitCode { diff --git a/crates/hm-plugin-cloud/src/lib.rs b/crates/hm/src/commands/cloud/mod.rs similarity index 81% rename from crates/hm-plugin-cloud/src/lib.rs rename to crates/hm/src/commands/cloud/mod.rs index 979e7f7e..cb5a8a40 100644 --- a/crates/hm-plugin-cloud/src/lib.rs +++ b/crates/hm/src/commands/cloud/mod.rs @@ -1,6 +1,4 @@ -//! Cloud client library for the hm CLI. -//! -//! Implements `hm cloud {login,logout,whoami,org,pipeline,build,job,billing,run}`. +//! `hm cloud {login,logout,whoami,org,pipeline,build,job,billing,run}`. pub mod cli; pub mod settings; diff --git a/crates/hm-plugin-cloud/src/settings.rs b/crates/hm/src/commands/cloud/settings.rs similarity index 100% rename from crates/hm-plugin-cloud/src/settings.rs rename to crates/hm/src/commands/cloud/settings.rs diff --git a/crates/hm-plugin-cloud/src/verbs/billing.rs b/crates/hm/src/commands/cloud/verbs/billing.rs similarity index 97% rename from crates/hm-plugin-cloud/src/verbs/billing.rs rename to crates/hm/src/commands/cloud/verbs/billing.rs index badea99b..dff8bd4a 100644 --- a/crates/hm-plugin-cloud/src/verbs/billing.rs +++ b/crates/hm/src/commands/cloud/verbs/billing.rs @@ -5,8 +5,8 @@ use std::collections::BTreeMap; use anyhow::Result; use harmont_cloud::HarmontClient; -use crate::cli::BillingCommand; -use crate::settings; +use crate::commands::cloud::cli::BillingCommand; +use crate::commands::cloud::settings; use hm_core::app_ctx::AppCtx; /// Convert an integer cent amount to dollars for display. diff --git a/crates/hm-plugin-cloud/src/verbs/build.rs b/crates/hm/src/commands/cloud/verbs/build.rs similarity index 94% rename from crates/hm-plugin-cloud/src/verbs/build.rs rename to crates/hm/src/commands/cloud/verbs/build.rs index 856006e1..fe0d3577 100644 --- a/crates/hm-plugin-cloud/src/verbs/build.rs +++ b/crates/hm/src/commands/cloud/verbs/build.rs @@ -5,8 +5,8 @@ use std::collections::BTreeMap; use anyhow::Result; use harmont_cloud::HarmontClient; -use crate::cli::BuildCommand; -use crate::settings; +use crate::commands::cloud::cli::BuildCommand; +use crate::commands::cloud::settings; use hm_core::app_ctx::AppCtx; use hm_core::exec::cloud::watch::watch_build; @@ -61,7 +61,7 @@ async fn watch(client: &HarmontClient, org: &str, pipe: &str, number: i64) -> Re // Render the live build through the shared `hm-render` renderers (the same // ones a local `hm run` uses), driven by the `BuildEvent`s `watch_build` // emits over an mpsc channel. - let prefs = crate::settings::RenderPrefs::detect(); + let prefs = crate::commands::cloud::settings::RenderPrefs::detect(); let renderer = hm_render::renderer_for("human", prefs.color, prefs.logs)?; let (tx, rx) = tokio::sync::mpsc::channel(1024); let driver = tokio::spawn(hm_render::drive(renderer, rx)); diff --git a/crates/hm-plugin-cloud/src/verbs/job.rs b/crates/hm/src/commands/cloud/verbs/job.rs similarity index 98% rename from crates/hm-plugin-cloud/src/verbs/job.rs rename to crates/hm/src/commands/cloud/verbs/job.rs index 379d1777..86649ae6 100644 --- a/crates/hm-plugin-cloud/src/verbs/job.rs +++ b/crates/hm/src/commands/cloud/verbs/job.rs @@ -9,8 +9,8 @@ use hm_plugin_protocol::events::{BuildEvent, PlanSummary}; use hm_plugin_protocol::ir::DurationMs; use uuid::Uuid; -use crate::cli::JobCommand; -use crate::settings; +use crate::commands::cloud::cli::JobCommand; +use crate::commands::cloud::settings; use hm_core::app_ctx::AppCtx; use hm_core::exec::cloud::watch::stream_job_logs_as_events; diff --git a/crates/hm-plugin-cloud/src/verbs/mod.rs b/crates/hm/src/commands/cloud/verbs/mod.rs similarity index 100% rename from crates/hm-plugin-cloud/src/verbs/mod.rs rename to crates/hm/src/commands/cloud/verbs/mod.rs diff --git a/crates/hm-plugin-cloud/src/verbs/org.rs b/crates/hm/src/commands/cloud/verbs/org.rs similarity index 94% rename from crates/hm-plugin-cloud/src/verbs/org.rs rename to crates/hm/src/commands/cloud/verbs/org.rs index 67b090f2..7ff04df4 100644 --- a/crates/hm-plugin-cloud/src/verbs/org.rs +++ b/crates/hm/src/commands/cloud/verbs/org.rs @@ -7,8 +7,8 @@ use hm_core::app_ctx::AppCtx; use hm_core::config::domain::BackendConfig; use hm_core::config::user::UserCloudConfig; -use crate::cli::OrgCommand; -use crate::settings; +use crate::commands::cloud::cli::OrgCommand; +use crate::commands::cloud::settings; pub(crate) async fn run( _env: &BTreeMap, diff --git a/crates/hm-plugin-cloud/src/verbs/pipeline.rs b/crates/hm/src/commands/cloud/verbs/pipeline.rs similarity index 94% rename from crates/hm-plugin-cloud/src/verbs/pipeline.rs rename to crates/hm/src/commands/cloud/verbs/pipeline.rs index 7ce476a0..ebd95556 100644 --- a/crates/hm-plugin-cloud/src/verbs/pipeline.rs +++ b/crates/hm/src/commands/cloud/verbs/pipeline.rs @@ -5,8 +5,8 @@ use std::collections::BTreeMap; use anyhow::Result; use harmont_cloud::HarmontClient; -use crate::cli::PipelineCommand; -use crate::settings; +use crate::commands::cloud::cli::PipelineCommand; +use crate::commands::cloud::settings; use hm_core::app_ctx::AppCtx; pub(crate) async fn run( diff --git a/crates/hm-plugin-cloud/src/verbs/run.rs b/crates/hm/src/commands/cloud/verbs/run.rs similarity index 95% rename from crates/hm-plugin-cloud/src/verbs/run.rs rename to crates/hm/src/commands/cloud/verbs/run.rs index 82b92c3a..700a0496 100644 --- a/crates/hm-plugin-cloud/src/verbs/run.rs +++ b/crates/hm/src/commands/cloud/verbs/run.rs @@ -14,7 +14,7 @@ use clap::Parser; use harmont_cloud::builds::NewBuild; use hm_core::app_ctx::AppCtx; -use crate::settings; +use crate::commands::cloud::settings; #[derive(Debug, Clone, Parser)] pub struct RunArgs { @@ -74,9 +74,9 @@ pub(crate) async fn run(env: &BTreeMap, args: RunArgs, app: &App if args.no_watch { return Ok(()); } - crate::verbs::build::run( + crate::commands::cloud::verbs::build::run( env, - crate::cli::BuildCommand::Watch { + crate::commands::cloud::cli::BuildCommand::Watch { pipeline: args.pipeline.clone(), number: build.number, }, diff --git a/crates/hm/src/commands/init.rs b/crates/hm/src/commands/init.rs index 0bead8d5..b7462e01 100644 --- a/crates/hm/src/commands/init.rs +++ b/crates/hm/src/commands/init.rs @@ -114,10 +114,10 @@ async fn prompt_cloud_registration( return Ok(()); } - hm_plugin_cloud::login_interactive(app).await?; + crate::commands::cloud::login_interactive(app).await?; } - let (client, _ctx) = hm_plugin_cloud::settings::client(app) + let (client, _ctx) = crate::commands::cloud::settings::client(app) .await .context("could not build authenticated cloud client")?; @@ -125,7 +125,7 @@ async fn prompt_cloud_registration( .raw() .list_organizations(None, None) .await - .map_err(hm_plugin_cloud::settings::map_raw) + .map_err(crate::commands::cloud::settings::map_raw) .context("fetching organizations")? .into_inner(); diff --git a/crates/hm/src/commands/mod.rs b/crates/hm/src/commands/mod.rs index 52773b1e..cb82e75c 100644 --- a/crates/hm/src/commands/mod.rs +++ b/crates/hm/src/commands/mod.rs @@ -1,3 +1,4 @@ pub mod cache; +pub mod cloud; pub mod init; pub mod run; diff --git a/crates/hm/src/commands/run/mod.rs b/crates/hm/src/commands/run/mod.rs index 3445a731..5aa6fb0d 100644 --- a/crates/hm/src/commands/run/mod.rs +++ b/crates/hm/src/commands/run/mod.rs @@ -485,12 +485,12 @@ async fn register_remoteless_pipeline( .raw() .create_pipeline(org, &body) .await - .map_err(hm_plugin_cloud::settings::map_raw) + .map_err(crate::commands::cloud::settings::map_raw) .with_context(|| format!("registering pipeline '{pipeline_name}' in org {org}"))?; created.into_inner().slug } Err(e) => { - return Err(hm_plugin_cloud::settings::map_raw(e)) + return Err(crate::commands::cloud::settings::map_raw(e)) .with_context(|| format!("looking up pipeline '{pipeline_name}' in org {org}")); } }; @@ -554,7 +554,7 @@ async fn resolve_or_create_cloud_pipeline( Ok(p) => return Ok(Some(p.into_inner().slug)), Err(e) if e.status().is_some_and(|s| s.as_u16() == 404) => {} // truly absent → create Err(e) => { - return Err(hm_plugin_cloud::settings::map_raw(e)) + return Err(crate::commands::cloud::settings::map_raw(e)) .with_context(|| format!("looking up pipeline '{}' in org {}", ac.name, ac.org)); } } @@ -586,7 +586,7 @@ async fn resolve_or_create_cloud_pipeline( .raw() .create_pipeline(&ac.org, &body) .await - .map_err(hm_plugin_cloud::settings::map_raw) + .map_err(crate::commands::cloud::settings::map_raw) .with_context(|| format!("creating pipeline '{}' in org {}", ac.name, ac.org))?; let slug = created.into_inner().slug; tracing::info!("created pipeline '{slug}' — submitting build");