pesde/src/cli/commands/update.rs
daimond113 a2ce747879
feat: update instead of recreating packages folders
Instead of recreating the packages folders, we now
update the existing ones. Additionally switches
a few APIs from accepting `&TargetKind` to `TargetKind`.
2025-01-18 14:18:46 +01:00

48 lines
1.1 KiB
Rust

use crate::cli::{
install::{install, InstallOptions},
run_on_workspace_members,
};
use clap::Args;
use pesde::Project;
use std::num::NonZeroUsize;
#[derive(Debug, Args, Copy, Clone)]
pub struct UpdateCommand {
/// Update the dependencies but don't install them
#[arg(long)]
no_install: bool,
/// The maximum number of concurrent network requests
#[arg(long, default_value = "16")]
network_concurrency: NonZeroUsize,
/// Whether to re-install all dependencies even if they are already installed
#[arg(long)]
force: bool,
}
impl UpdateCommand {
pub async fn run(self, project: Project, reqwest: reqwest::Client) -> anyhow::Result<()> {
let options = InstallOptions {
locked: false,
prod: false,
write: !self.no_install,
network_concurrency: self.network_concurrency,
use_lockfile: false,
force: self.force,
};
install(&options, &project, reqwest.clone(), true).await?;
run_on_workspace_members(&project, |project| {
let reqwest = reqwest.clone();
async move {
install(&options, &project, reqwest, false).await?;
Ok(())
}
})
.await?;
Ok(())
}
}