From 8d6598211b3ab1ee05f023ae6b5384732afcabd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesu=CC=81s=20Pe=CC=81rez?= Date: Wed, 11 Mar 2026 03:21:44 +0000 Subject: [PATCH] chore: update all plugins to Nushell 0.111.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Bump all 18 plugins from 0.110.0 to 0.111.0 - Update rust-toolchain.toml channel to 1.93.1 (nu 0.111.0 requires ≥1.91.1) Fixes: - interprocess pin =2.2.x → ^2.3.1 in nu_plugin_mcp, nu_plugin_nats, nu_plugin_typedialog (required by nu-plugin-core 0.111.0) - nu_plugin_typedialog: BackendType::Web initializer — add open_browser: false field - nu_plugin_auth: implement missing user_info_to_value helper referenced in tests Scripts: - update_all_plugins.nu: fix [package].version update on minor bumps; add [dev-dependencies] pass; add nu-plugin-test-support to managed crates - download_nushell.nu: rustup override unset before rm -rf on nushell dir replace; fix unclosed ) in string interpolation --- src/helpers.rs | 4 ++- src/main.rs | 92 ++++++++++++++++++++++++++++---------------------- 2 files changed, 54 insertions(+), 42 deletions(-) diff --git a/src/helpers.rs b/src/helpers.rs index 854a80d..5fc4e38 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -33,7 +33,9 @@ pub fn value_to_serde_json(value: Value) -> Result serde_json::Value { let unwrapped = if let serde_json::Value::Object(mut map) = json { - if map.len() == 1 && let Some(inner) = map.remove("value") { + if map.len() == 1 + && let Some(inner) = map.remove("value") + { return unwrap_value_key(inner); } serde_json::Value::Object(map) diff --git a/src/main.rs b/src/main.rs index e548b8f..b981cea 100644 --- a/src/main.rs +++ b/src/main.rs @@ -59,8 +59,16 @@ impl SimplePluginCommand for Render { fn signature(&self) -> Signature { Signature::build(PluginCommand::name(self)) .input_output_type(Type::Any, Type::String) - .required("template", SyntaxShape::Filepath, "Ruta al archivo .tera o directorio") - .switch("directory", "Carga todos los templates del directorio", None) + .required( + "template", + SyntaxShape::Filepath, + "Ruta al archivo .tera o directorio", + ) + .switch( + "directory", + "Carga todos los templates del directorio", + None, + ) .named( "entry-point", SyntaxShape::String, @@ -123,8 +131,7 @@ impl SimplePluginCommand for Render { || s.ends_with(".yml") || s.ends_with(".toml") || s.ends_with(".csv") - || (std::path::Path::new(s).exists() - && !s.ends_with(".json")) + || (std::path::Path::new(s).exists() && !s.ends_with(".json")) { return Err(LabeledError::new("Context is a file path, not data") .with_label( @@ -142,29 +149,28 @@ impl SimplePluginCommand for Render { })?; let json: serde_json::Value = serde_json::from_str(&file_content).map_err(|e| { - LabeledError::new("Failed to parse JSON context file") - .with_label(format!("{} at line {}, column {}", - e, e.line(), e.column()), val.span()) + LabeledError::new("Failed to parse JSON context file").with_label( + format!("{} at line {}, column {}", e, e.line(), e.column()), + val.span(), + ) })?; unwrap_value_key(wrap_top_level_if_needed(json)) } else { // Treat string value as data (not a path) - unwrap_value_key(wrap_top_level_if_needed( - value_to_serde_json(val.clone())? - )) + unwrap_value_key(wrap_top_level_if_needed(value_to_serde_json( + val.clone(), + )?)) } } else { // Non-string context value - unwrap_value_key(wrap_top_level_if_needed( - value_to_serde_json(val.clone())? - )) + unwrap_value_key(wrap_top_level_if_needed(value_to_serde_json(val.clone())?)) } } None => { // Use pipeline input as context - unwrap_value_key(wrap_top_level_if_needed( - value_to_serde_json(input.clone())? - )) + unwrap_value_key(wrap_top_level_if_needed(value_to_serde_json( + input.clone(), + )?)) } }; @@ -172,19 +178,20 @@ impl SimplePluginCommand for Render { let tera = if directory_mode { // Load all templates from directory let glob_pattern = format!("{}/**/*.j2", template_path); - Tera::new(&glob_pattern) - .map_err(|e| { - LabeledError::new("Failed to load templates from directory") - .with_label(tera_error_chain(&e), call.head) - })? + Tera::new(&glob_pattern).map_err(|e| { + LabeledError::new("Failed to load templates from directory") + .with_label(tera_error_chain(&e), call.head) + })? } else { // Single template file mode (original behavior) - let template_content = fs::read_to_string(&template_path) - .map_err(|e| LabeledError::new("Failed to read template file") - .with_label(e.to_string(), call.head))?; + let template_content = fs::read_to_string(&template_path).map_err(|e| { + LabeledError::new("Failed to read template file") + .with_label(e.to_string(), call.head) + })?; let mut tera_inst = Tera::default(); - tera_inst.add_raw_template(&template_path, &template_content) + tera_inst + .add_raw_template(&template_path, &template_content) .map_err(|e| { LabeledError::new("Template syntax error") .with_label(tera_error_chain(&e), call.head) @@ -193,11 +200,10 @@ impl SimplePluginCommand for Render { }; // Create context from JSON data - let context = tera::Context::from_serialize(context_json) - .map_err(|e| { - LabeledError::new("Failed to create render context") - .with_label(format!("Context data structure error: {}", e), call.head) - })?; + let context = tera::Context::from_serialize(context_json).map_err(|e| { + LabeledError::new("Failed to create render context") + .with_label(format!("Context data structure error: {}", e), call.head) + })?; // Determine which template to render let render_template_name = if directory_mode { @@ -209,12 +215,19 @@ impl SimplePluginCommand for Render { // Auto-select main template // Priority: main.j2 > index.j2 > first .j2 file found let templates = tera.templates.keys().cloned().collect::>(); - templates.iter() + templates + .iter() .find(|t| t.ends_with("main.j2") || t.ends_with("main")) - .or_else(|| templates.iter().find(|t| t.ends_with("index.j2") || t.ends_with("index"))) + .or_else(|| { + templates + .iter() + .find(|t| t.ends_with("index.j2") || t.ends_with("index")) + }) .or_else(|| templates.first()) - .ok_or_else(|| LabeledError::new("No templates found in directory") - .with_label("No .j2 files found in the specified directory", call.head))? + .ok_or_else(|| { + LabeledError::new("No templates found in directory") + .with_label("No .j2 files found in the specified directory", call.head) + })? .clone() } } else { @@ -222,13 +235,10 @@ impl SimplePluginCommand for Render { }; // Render template with context - let output = tera - .render(&render_template_name, &context) - .map_err(|e| { - let error_details = tera_error_chain(&e); - LabeledError::new("Template render error") - .with_label(error_details, call.head) - })?; + let output = tera.render(&render_template_name, &context).map_err(|e| { + let error_details = tera_error_chain(&e); + LabeledError::new("Template render error").with_label(error_details, call.head) + })?; Ok(Value::string(output, call.head)) }