Skip to content

Commit

Permalink
Re use install_plugin_bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
andreievg committed Feb 9, 2025
1 parent 08bcc3e commit 532f988
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions server/cli/src/plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::{ffi::OsStr, fs, path::PathBuf};

use base64::{prelude::BASE64_STANDARD, Engine};
use cli::{queries_mutations::INSTALL_PLUGINS, Api, ApiError};
use log::info;
use repository::{BackendPluginRow, PluginTypes, PluginVariantType};
use reqwest::Url;
use serde::Deserialize;
Expand Down Expand Up @@ -185,7 +186,7 @@ pub(super) async fn install_plugin_bundle(
)
.await?;

println!(
info!(
"Result:{}",
serde_json::to_string_pretty(&upload_result).unwrap()
);
Expand All @@ -209,24 +210,14 @@ pub(super) async fn generate_and_install_plugin_bundle(
out_file: out_file.clone(),
})?;

let api = Api::new_with_token(url.clone(), username, password).await?;

let uploaded_file = api.upload_file(out_file.clone()).await?;

install_plugin_bundle(InstallPluginBundle {
path: out_file.clone(),
url,
username,
password,
})
.await?;
fs::remove_file(out_file.clone()).map_err(|e| Error::FiledToRemoveTempFile(e, out_file))?;

let upload_result = api
.gql(
INSTALL_PLUGINS,
json!( { "fileId": uploaded_file.file_id} ),
Some("CentralServerMutationNode"),
)
.await?;

println!(
"Result:{}",
serde_json::to_string_pretty(&upload_result).unwrap()
);

Ok(())
}

0 comments on commit 532f988

Please sign in to comment.