extension_cli: Include the list of what an extension provides in the generated manifest (#24295)
This PR updates the Zed extension CLI with support for populating the `provides` field in the generated extension manifest. This field will contain the set of features that the extension provides. For example: ``` "provides": ["themes", "icon-themes"] ``` Release Notes: - N/A
This commit is contained in:
parent
aaf432fcd2
commit
5a25751521
4 changed files with 81 additions and 12 deletions
|
@ -1,20 +1,18 @@
|
|||
use std::{
|
||||
collections::HashMap,
|
||||
env, fs,
|
||||
path::{Path, PathBuf},
|
||||
process::Command,
|
||||
sync::Arc,
|
||||
};
|
||||
use std::collections::{BTreeSet, HashMap};
|
||||
use std::env;
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
use std::sync::Arc;
|
||||
|
||||
use ::fs::{copy_recursive, CopyOptions, Fs, RealFs};
|
||||
use anyhow::{anyhow, bail, Context, Result};
|
||||
use clap::Parser;
|
||||
use extension::{
|
||||
extension_builder::{CompileExtensionOptions, ExtensionBuilder},
|
||||
ExtensionManifest,
|
||||
};
|
||||
use extension::extension_builder::{CompileExtensionOptions, ExtensionBuilder};
|
||||
use extension::ExtensionManifest;
|
||||
use language::LanguageConfig;
|
||||
use reqwest_client::ReqwestClient;
|
||||
use rpc::ExtensionProvides;
|
||||
use tree_sitter::{Language, Query, WasmStore};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
|
@ -99,6 +97,8 @@ async fn main() -> Result<()> {
|
|||
);
|
||||
}
|
||||
|
||||
let extension_provides = extension_provides(&manifest);
|
||||
|
||||
let manifest_json = serde_json::to_string(&rpc::ExtensionApiManifest {
|
||||
name: manifest.name,
|
||||
version: manifest.version,
|
||||
|
@ -109,6 +109,7 @@ async fn main() -> Result<()> {
|
|||
.repository
|
||||
.ok_or_else(|| anyhow!("missing repository in extension manifest"))?,
|
||||
wasm_api_version: manifest.lib.version.map(|version| version.to_string()),
|
||||
provides: extension_provides,
|
||||
})?;
|
||||
fs::remove_dir_all(&archive_dir)?;
|
||||
fs::write(output_dir.join("manifest.json"), manifest_json.as_bytes())?;
|
||||
|
@ -116,6 +117,44 @@ async fn main() -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Returns the set of features provided by the extension.
|
||||
fn extension_provides(manifest: &ExtensionManifest) -> BTreeSet<ExtensionProvides> {
|
||||
let mut provides = BTreeSet::default();
|
||||
if !manifest.themes.is_empty() {
|
||||
provides.insert(ExtensionProvides::Themes);
|
||||
}
|
||||
|
||||
if !manifest.icon_themes.is_empty() {
|
||||
provides.insert(ExtensionProvides::IconThemes);
|
||||
}
|
||||
|
||||
if !manifest.languages.is_empty() {
|
||||
provides.insert(ExtensionProvides::Languages);
|
||||
}
|
||||
|
||||
if !manifest.grammars.is_empty() {
|
||||
provides.insert(ExtensionProvides::Grammars);
|
||||
}
|
||||
|
||||
if !manifest.language_servers.is_empty() {
|
||||
provides.insert(ExtensionProvides::LanguageServers);
|
||||
}
|
||||
|
||||
if !manifest.context_servers.is_empty() {
|
||||
provides.insert(ExtensionProvides::ContextServers);
|
||||
}
|
||||
|
||||
if !manifest.indexed_docs_providers.is_empty() {
|
||||
provides.insert(ExtensionProvides::IndexedDocsProviders);
|
||||
}
|
||||
|
||||
if manifest.snippets.is_some() {
|
||||
provides.insert(ExtensionProvides::Snippets);
|
||||
}
|
||||
|
||||
provides
|
||||
}
|
||||
|
||||
async fn copy_extension_resources(
|
||||
manifest: &ExtensionManifest,
|
||||
extension_path: &Path,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue