fix dependency autoconfig

This commit is contained in:
Aiden McClelland
2024-07-30 12:08:20 -06:00
parent 89e327383e
commit 7cd3f285ad
2 changed files with 28 additions and 8 deletions

View File

@@ -9,13 +9,13 @@ use rpc_toolkit::{from_fn_async, Context, Empty, HandlerExt, ParentHandler};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tracing::instrument; use tracing::instrument;
use ts_rs::TS; use ts_rs::TS;
use url::Url;
use crate::config::{Config, ConfigSpec, ConfigureContext}; use crate::config::{Config, ConfigSpec, ConfigureContext};
use crate::context::RpcContext; use crate::context::{CliContext, RpcContext};
use crate::db::model::package::CurrentDependencies; use crate::db::model::package::CurrentDependencies;
use crate::prelude::*; use crate::prelude::*;
use crate::rpc_continuations::Guid; use crate::rpc_continuations::Guid;
use crate::util::serde::HandlerExtSerde;
use crate::util::PathOrUrl; use crate::util::PathOrUrl;
use crate::Error; use crate::Error;
@@ -65,11 +65,20 @@ pub struct ConfigureParams {
dependency_id: PackageId, dependency_id: PackageId,
} }
pub fn configure<C: Context>() -> ParentHandler<C, ConfigureParams> { pub fn configure<C: Context>() -> ParentHandler<C, ConfigureParams> {
ParentHandler::new().root_handler( ParentHandler::new()
from_fn_async(configure_impl) .root_handler(
.with_inherited(|params, _| params) from_fn_async(configure_impl)
.no_cli(), .with_inherited(|params, _| params)
) .no_display()
.with_call_remote::<CliContext>(),
)
.subcommand(
"dry",
from_fn_async(configure_dry)
.with_inherited(|params, _| params)
.with_display_serializable()
.with_call_remote::<CliContext>(),
)
} }
pub async fn configure_impl( pub async fn configure_impl(
@@ -105,6 +114,17 @@ pub async fn configure_impl(
Ok(()) Ok(())
} }
pub async fn configure_dry(
ctx: RpcContext,
_: Empty,
ConfigureParams {
dependent_id,
dependency_id,
}: ConfigureParams,
) -> Result<ConfigDryRes, Error> {
configure_logic(ctx.clone(), (dependent_id, dependency_id.clone())).await
}
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct ConfigDryRes { pub struct ConfigDryRes {

View File

@@ -38,7 +38,7 @@ impl ServiceActorSeed {
) )
.await .await
.with_kind(ErrorKind::Dependency) .with_kind(ErrorKind::Dependency)
.map(|res| res.filter(|c| !c.is_empty())) .map(|res| res.filter(|c| !c.is_empty() && Some(c) != remote_config.as_ref()))
} }
} }