fix #4: make sure plugins are not removed from all_plugins.json, unless unused
This commit is contained in:
parent
76c0cbc037
commit
465f62cc94
612 changed files with 6031 additions and 5477 deletions
|
|
@ -2,7 +2,7 @@ mod ides;
|
|||
mod logging;
|
||||
mod plugins;
|
||||
|
||||
use clap::Parser;
|
||||
use clap::{Parser, Subcommand};
|
||||
use log::info;
|
||||
use std::path::PathBuf;
|
||||
use tokio::try_join;
|
||||
|
|
@ -11,7 +11,18 @@ use tokio::try_join;
|
|||
struct Cli {
|
||||
#[arg(short, long)]
|
||||
output_path: PathBuf,
|
||||
#[clap(subcommand)]
|
||||
command: Command,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum Command {
|
||||
/// Generate the IDE JSON files and create/update all_plugins.json
|
||||
Generate,
|
||||
/// Remove all plugins from all_plugins.json that are no longer used in any IDE json file.
|
||||
Cleanup,
|
||||
}
|
||||
|
||||
const PLUGIN_INDICES: &[&str] = &[
|
||||
"https://downloads.marketplace.jetbrains.com/files/pluginsXMLIds.json",
|
||||
"https://downloads.marketplace.jetbrains.com/files/jbPluginsXMLIds.json",
|
||||
|
|
@ -23,6 +34,14 @@ async fn main() -> anyhow::Result<()> {
|
|||
_ = logging::setup_logging();
|
||||
info!("Starting...");
|
||||
|
||||
match cli.command {
|
||||
Command::Generate => generate(cli).await,
|
||||
Command::Cleanup => cleanup(cli).await,
|
||||
}
|
||||
}
|
||||
|
||||
async fn generate(cli: Cli) -> anyhow::Result<()> {
|
||||
info!("running generate.");
|
||||
let (ides, mut plugins, jb_plugins) = try_join!(
|
||||
ides::collect_ids(),
|
||||
plugins::index(PLUGIN_INDICES[0]),
|
||||
|
|
@ -38,9 +57,22 @@ async fn main() -> anyhow::Result<()> {
|
|||
plugins.extend_from_slice(&jb_plugins);
|
||||
|
||||
info!("Loading old database.");
|
||||
let cache_db = plugins::db_cache_load(&cli.output_path).await?;
|
||||
let mut db = plugins::db_load(&cli.output_path).await?;
|
||||
info!("Beginning plugin download...");
|
||||
let db = plugins::build_db(&cache_db, &ides, &plugins).await?;
|
||||
plugins::db_update(&mut db, &ides, &plugins).await?;
|
||||
info!("Saving DB...");
|
||||
plugins::db_save(&cli.output_path, db).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn cleanup(cli: Cli) -> anyhow::Result<()> {
|
||||
info!("Loading database and IDE mappings.");
|
||||
let mut db = plugins::db_load_full(&cli.output_path).await?;
|
||||
|
||||
info!("Running cleanup...");
|
||||
plugins::db_cleanup(&mut db).await?;
|
||||
|
||||
info!("Saving DB...");
|
||||
plugins::db_save(&cli.output_path, db).await?;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue