Add 'include' field to extension manifest, for copying files when packaging

This commit is contained in:
Max Brunsfeld 2024-11-08 17:13:21 -08:00
parent 1435900029
commit ec9dbd728a
3 changed files with 23 additions and 0 deletions

View file

@ -82,6 +82,9 @@ pub struct ExtensionManifest {
pub indexed_docs_providers: BTreeMap<Arc<str>, IndexedDocsProviderEntry>,
#[serde(default)]
pub snippets: Option<PathBuf>,
#[serde(default)]
pub include: Vec<String>,
}
#[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(),
}
}

View file

@ -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(())
}

View file

@ -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,
},