Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use ten_rust::{
};

use crate::{
config::{internal::TmanInternalConfig, TmanConfig},
config::{metadata::TmanMetadata, TmanConfig},
output::TmanOutput,
};

Expand Down Expand Up @@ -48,8 +48,8 @@ pub fn parse_sub_cmd(
}

pub async fn execute_cmd(
_tman_config: Arc<TmanConfig>,
_tman_internal_config: Arc<TmanInternalConfig>,
_tman_config: Arc<tokio::sync::RwLock<TmanConfig>>,
_tman_metadata: Arc<tokio::sync::RwLock<TmanMetadata>>,
command_data: CheckManifestJsonCommand,
out: Arc<Box<dyn TmanOutput>>,
) -> Result<()> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use ten_rust::{
};

use crate::{
config::{internal::TmanInternalConfig, TmanConfig},
config::{metadata::TmanMetadata, TmanConfig},
output::TmanOutput,
};

Expand Down Expand Up @@ -48,8 +48,8 @@ pub fn parse_sub_cmd(
}

pub async fn execute_cmd(
_tman_config: Arc<TmanConfig>,
_tman_internal_config: Arc<TmanInternalConfig>,
_tman_config: Arc<tokio::sync::RwLock<TmanConfig>>,
_tman_metadata: Arc<tokio::sync::RwLock<TmanMetadata>>,
command_data: CheckPropertyJsonCommand,
out: Arc<Box<dyn TmanOutput>>,
) -> Result<()> {
Expand Down
10 changes: 5 additions & 5 deletions core/src/ten_manager/src/cmd/cmd_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use anyhow::Result;
use clap::{ArgMatches, Command};

use crate::{
config::{internal::TmanInternalConfig, TmanConfig},
config::{metadata::TmanMetadata, TmanConfig},
output::TmanOutput,
};

Expand Down Expand Up @@ -64,16 +64,16 @@ pub fn parse_sub_cmd(sub_cmd_args: &ArgMatches) -> Result<CheckCommandData> {
}

pub async fn execute_cmd(
tman_config: Arc<TmanConfig>,
tman_internal_config: Arc<TmanInternalConfig>,
tman_config: Arc<tokio::sync::RwLock<TmanConfig>>,
tman_metadata: Arc<tokio::sync::RwLock<TmanMetadata>>,
command_data: CheckCommandData,
out: Arc<Box<dyn TmanOutput>>,
) -> Result<()> {
match command_data {
CheckCommandData::CheckManifestJson(cmd) => {
crate::cmd::cmd_check::cmd_check_manifest_json::execute_cmd(
tman_config,
tman_internal_config,
tman_metadata,
cmd,
out,
)
Expand All @@ -82,7 +82,7 @@ pub async fn execute_cmd(
CheckCommandData::CheckPropertyJson(cmd) => {
crate::cmd::cmd_check::cmd_check_property_json::execute_cmd(
tman_config,
tman_internal_config,
tman_metadata,
cmd,
out,
)
Expand Down
8 changes: 4 additions & 4 deletions core/src/ten_manager/src/cmd/cmd_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use ten_rust::pkg_info::{
};

use crate::{
config::{internal::TmanInternalConfig, TmanConfig},
config::{metadata::TmanMetadata, TmanConfig},
create::create_pkg_in_path,
output::TmanOutput,
version_utils::parse_pkg_name_version_req,
Expand Down Expand Up @@ -154,8 +154,8 @@ pub fn parse_sub_cmd(sub_cmd_args: &ArgMatches) -> Result<CreateCommand> {
}

pub async fn execute_cmd(
tman_config: Arc<TmanConfig>,
_tman_internal_config: Arc<TmanInternalConfig>,
tman_config: Arc<tokio::sync::RwLock<TmanConfig>>,
_tman_metadata: Arc<tokio::sync::RwLock<TmanMetadata>>,
command_data: CreateCommand,
out: Arc<Box<dyn TmanOutput>>,
) -> Result<()> {
Expand All @@ -166,7 +166,7 @@ pub async fn execute_cmd(
.context("Failed to get current working directory")?;

create_pkg_in_path(
&tman_config,
tman_config,
&cwd,
&command_data.pkg_type,
&command_data.pkg_name,
Expand Down
9 changes: 5 additions & 4 deletions core/src/ten_manager/src/cmd/cmd_delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ use semver::Version;

use ten_rust::pkg_info::pkg_type::PkgType;

use crate::config::internal::TmanInternalConfig;
use crate::config::is_verbose;
use crate::config::metadata::TmanMetadata;
use crate::output::TmanOutput;
use crate::{config::TmanConfig, registry::delete_package};

Expand Down Expand Up @@ -77,12 +78,12 @@ pub fn parse_sub_cmd(
}

pub async fn execute_cmd(
tman_config: Arc<TmanConfig>,
_tman_internal_config: Arc<TmanInternalConfig>,
tman_config: Arc<tokio::sync::RwLock<TmanConfig>>,
_tman_metadata: Arc<tokio::sync::RwLock<TmanMetadata>>,
command_data: DeleteCommand,
out: Arc<Box<dyn TmanOutput>>,
) -> Result<()> {
if tman_config.verbose {
if is_verbose(tman_config.clone()).await {
out.normal_line("Executing delete command");
out.normal_line(&format!("{:?}", command_data));
}
Expand Down
27 changes: 10 additions & 17 deletions core/src/ten_manager/src/cmd/cmd_designer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
// Licensed under the Apache License, Version 2.0, with certain conditions.
// Refer to the "LICENSE" file in the root directory for more information.
//
use std::{
collections::HashMap,
path::Path,
sync::{Arc, RwLock},
};
use std::{collections::HashMap, path::Path, sync::Arc};

use actix_cors::Cors;
use actix_web::{http::header, web, App, HttpServer};
Expand All @@ -17,7 +13,7 @@ use clap::{value_parser, Arg, ArgMatches, Command};
use console::Emoji;

use crate::{
config::{internal::TmanInternalConfig, TmanConfig},
config::{is_verbose, metadata::TmanMetadata, TmanConfig},
constants::DESIGNER_BACKEND_DEFAULT_PORT,
designer::{configure_routes, frontend::get_frontend_asset, DesignerState},
fs::{check_is_app_folder, get_cwd},
Expand Down Expand Up @@ -85,12 +81,12 @@ pub fn parse_sub_cmd(
}

pub async fn execute_cmd(
tman_config: Arc<TmanConfig>,
tman_internal_config: Arc<TmanInternalConfig>,
tman_config: Arc<tokio::sync::RwLock<TmanConfig>>,
tman_metadata: Arc<tokio::sync::RwLock<TmanMetadata>>,
command_data: DesignerCommand,
out: Arc<Box<dyn TmanOutput>>,
) -> Result<()> {
if tman_config.verbose {
if is_verbose(tman_config.clone()).await {
out.normal_line("Executing designer command");
out.normal_line(&format!("{:?}", command_data));
out.normal_line(&format!("{:?}", tman_config));
Expand All @@ -115,13 +111,13 @@ pub async fn execute_cmd(
}
};

let state = Arc::new(RwLock::new(DesignerState {
let state = Arc::new(DesignerState {
tman_config,
tman_internal_config,
tman_metadata,
out: Arc::new(Box::new(TmanOutputCli)),
pkgs_cache: tokio::sync::RwLock::new(HashMap::new()),
graphs_cache: tokio::sync::RwLock::new(HashMap::new()),
}));
});

let mut actual_base_dir_opt: Option<String> = Some(base_dir);

Expand All @@ -138,11 +134,8 @@ pub async fn execute_cmd(
}

if let Some(actual_base_dir) = actual_base_dir_opt.as_ref() {
// =-=-=
let state_write = state.write().unwrap();

let mut pkgs_cache = state_write.pkgs_cache.write().await;
let mut graphs_cache = state_write.graphs_cache.write().await;
let mut pkgs_cache = state.pkgs_cache.write().await;
let mut graphs_cache = state.graphs_cache.write().await;

get_all_pkgs_in_app(
&mut pkgs_cache,
Expand Down
10 changes: 5 additions & 5 deletions core/src/ten_manager/src/cmd/cmd_fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use ten_rust::pkg_info::{
};

use crate::{
config::{internal::TmanInternalConfig, TmanConfig},
config::{metadata::TmanMetadata, TmanConfig},
output::TmanOutput,
package_file::unpackage::extract_and_process_tpkg_file,
registry::{get_package, get_package_list},
Expand Down Expand Up @@ -121,8 +121,8 @@ pub fn parse_sub_cmd(sub_cmd_args: &ArgMatches) -> Result<FetchCommand> {
}

pub async fn execute_cmd(
tman_config: Arc<TmanConfig>,
_tman_internal_config: Arc<TmanInternalConfig>,
tman_config: Arc<tokio::sync::RwLock<TmanConfig>>,
_tman_metadata: Arc<tokio::sync::RwLock<TmanMetadata>>,
command_data: FetchCommand,
out: Arc<Box<dyn TmanOutput>>,
) -> Result<()> {
Expand All @@ -135,7 +135,7 @@ pub async fn execute_cmd(

// Query the package from the registry.
let mut found_packages = get_package_list(
&tman_config,
tman_config.clone(),
Some(command_data.pkg_type),
Some(command_data.pkg_name.clone()),
Some(command_data.version_req.clone()),
Expand All @@ -157,7 +157,7 @@ pub async fn execute_cmd(

let mut temp_file = tempfile::NamedTempFile::new()?;
get_package(
tman_config.clone(),
tman_config,
&package.basic_info.type_and_name.pkg_type,
&package.basic_info.type_and_name.name,
&package.basic_info.version,
Expand Down
33 changes: 17 additions & 16 deletions core/src/ten_manager/src/cmd/cmd_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use ten_rust::pkg_info::{
};

use crate::{
config::{internal::TmanInternalConfig, TmanConfig},
config::{is_verbose, metadata::TmanMetadata, TmanConfig},
constants::{APP_DIR_IN_DOT_TEN_DIR, DOT_TEN_DIR},
dep_and_candidate::get_all_candidates_from_deps,
fs::{check_is_addon_folder, find_nearest_app_dir},
Expand Down Expand Up @@ -282,7 +282,7 @@ ten_package("app_for_standalone") {
}

fn prepare_basic_standalone_app_dir(
_tman_config: Arc<TmanConfig>,
_tman_config: Arc<tokio::sync::RwLock<TmanConfig>>,
extension_dir: &Path,
) -> Result<PathBuf> {
let dot_ten_app_dir =
Expand Down Expand Up @@ -314,7 +314,7 @@ fn prepare_basic_standalone_app_dir(

/// Prepare the `.ten/app/` folder in the extension standalone mode.
async fn prepare_standalone_app_dir(
tman_config: Arc<TmanConfig>,
tman_config: Arc<tokio::sync::RwLock<TmanConfig>>,
extension_dir: &Path,
) -> Result<PathBuf> {
let dot_ten_app_dir =
Expand All @@ -330,7 +330,7 @@ async fn prepare_standalone_app_dir(

/// Path logic for standalone mode and non-standalone mode.
async fn determine_app_dir_to_work_with(
tman_config: Arc<TmanConfig>,
tman_config: Arc<tokio::sync::RwLock<TmanConfig>>,
standalone: bool,
specified_cwd: &Path,
) -> Result<PathBuf> {
Expand All @@ -356,15 +356,13 @@ async fn determine_app_dir_to_work_with(
}

pub async fn execute_cmd(
tman_config: Arc<TmanConfig>,
_tman_internal_config: Arc<TmanInternalConfig>,
tman_config: Arc<tokio::sync::RwLock<TmanConfig>>,
_tman_metadata: Arc<tokio::sync::RwLock<TmanMetadata>>,
command_data: InstallCommand,
out: Arc<Box<dyn TmanOutput>>,
) -> Result<()> {
if tman_config.verbose {
if is_verbose(tman_config.clone()).await {
out.normal_line("Executing install command");
out.normal_line(&format!("command_data: {:?}", command_data));
out.normal_line(&format!("tman_config: {:?}", tman_config));
}

let started = Instant::now();
Expand Down Expand Up @@ -446,7 +444,8 @@ pub async fn execute_cmd(
tman_config.clone(),
&app_dir_to_work_with,
out.clone(),
)?;
)
.await?;

out.normal_line(&format!(
"{} Filter compatible packages...",
Expand All @@ -459,7 +458,8 @@ pub async fn execute_cmd(
&mut all_compatible_installed_pkgs,
&command_data.support,
out.clone(),
);
)
.await?;

if command_data.local_path.is_some() {
// tman install <local_path>
Expand Down Expand Up @@ -630,22 +630,23 @@ from manifest-lock.json...",
&all_candidates,
locked_pkgs.as_ref(),
out.clone(),
)?;
)
.await?;

// If there are answers are found, print out all the answers.
if tman_config.verbose {
if is_verbose(tman_config.clone()).await {
out.normal_line("\n");
out.normal_line("Result:");
}

if let Some(ref usable_model) = usable_model {
for result in usable_model {
if tman_config.verbose {
if is_verbose(tman_config.clone()).await {
out.normal_line(&format!(" {:?}", result));
}
}
}
if tman_config.verbose {
if is_verbose(tman_config.clone()).await {
out.normal_line("");
}

Expand Down Expand Up @@ -676,7 +677,7 @@ from manifest-lock.json...",
out.clone(),
);

if has_conflict && !tman_config.assume_yes {
if has_conflict && !tman_config.read().await.assume_yes {
if out.is_interactive() {
// "y" for continuing to install, "n" for stopping.
let ans = Confirm::new(
Expand Down
6 changes: 3 additions & 3 deletions core/src/ten_manager/src/cmd/cmd_modify/cmd_modify_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use ten_rust::{

use crate::{
cmd::cmd_modify::jq_util::jq_run,
config::{internal::TmanInternalConfig, TmanConfig},
config::{metadata::TmanMetadata, TmanConfig},
output::TmanOutput,
};

Expand Down Expand Up @@ -87,8 +87,8 @@ pub fn parse_sub_cmd(sub_cmd_args: &ArgMatches) -> Result<ModifyGraphCommand> {
}

pub async fn execute_cmd(
_tman_config: Arc<TmanConfig>,
_tman_internal_config: Arc<TmanInternalConfig>,
_tman_config: Arc<tokio::sync::RwLock<TmanConfig>>,
_tman_metadata: Arc<tokio::sync::RwLock<TmanMetadata>>,
command_data: ModifyGraphCommand,
out: Arc<Box<dyn TmanOutput>>,
) -> Result<()> {
Expand Down
Loading
Loading