From ec9dbd728a899a6287736618934c09c00974b0a0 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 8 Nov 2024 17:13:21 -0800 Subject: [PATCH] Add 'include' field to extension manifest, for copying files when packaging --- crates/extension/src/extension_manifest.rs | 4 ++++ crates/extension_cli/src/main.rs | 16 ++++++++++++++++ crates/extensions_ui/src/extension_store_test.rs | 3 +++ 3 files changed, 23 insertions(+) diff --git a/crates/extension/src/extension_manifest.rs b/crates/extension/src/extension_manifest.rs index 77be30c6c0..faa6dcb3cc 100644 --- a/crates/extension/src/extension_manifest.rs +++ b/crates/extension/src/extension_manifest.rs @@ -82,6 +82,9 @@ pub struct ExtensionManifest { pub indexed_docs_providers: BTreeMap, IndexedDocsProviderEntry>, #[serde(default)] pub snippets: Option, + + #[serde(default)] + pub include: Vec, } #[derive(Clone, Default, PartialEq, Eq, Debug, Deserialize, Serialize)] @@ -214,5 +217,6 @@ fn manifest_from_old_manifest( slash_commands: BTreeMap::default(), indexed_docs_providers: BTreeMap::default(), snippets: None, + include: Vec::new(), } } diff --git a/crates/extension_cli/src/main.rs b/crates/extension_cli/src/main.rs index ffa9555c21..7944f29fbb 100644 --- a/crates/extension_cli/src/main.rs +++ b/crates/extension_cli/src/main.rs @@ -191,6 +191,22 @@ async fn copy_extension_resources( } } + if !manifest.include.is_empty() { + for include_path in &manifest.include { + copy_recursive( + fs.as_ref(), + &extension_path.join(&include_path), + &output_dir.join(&include_path), + CopyOptions { + overwrite: true, + ignore_if_exists: false, + }, + ) + .await + .with_context(|| format!("failed to copy included path '{}'", include_path))?; + } + } + Ok(()) } diff --git a/crates/extensions_ui/src/extension_store_test.rs b/crates/extensions_ui/src/extension_store_test.rs index 88730e8eee..1630a1d94f 100644 --- a/crates/extensions_ui/src/extension_store_test.rs +++ b/crates/extensions_ui/src/extension_store_test.rs @@ -166,6 +166,7 @@ async fn test_extension_store(cx: &mut TestAppContext) { slash_commands: BTreeMap::default(), indexed_docs_providers: BTreeMap::default(), snippets: None, + include: Vec::new(), }), dev: false, }, @@ -193,6 +194,7 @@ async fn test_extension_store(cx: &mut TestAppContext) { slash_commands: BTreeMap::default(), indexed_docs_providers: BTreeMap::default(), snippets: None, + include: Vec::new(), }), dev: false, }, @@ -365,6 +367,7 @@ async fn test_extension_store(cx: &mut TestAppContext) { slash_commands: BTreeMap::default(), indexed_docs_providers: BTreeMap::default(), snippets: None, + include: Vec::new(), }), dev: false, },