Skip to content

Commit 01992fd

Browse files
authored
Merge pull request #31 from 100monkeys-ai/jules/delegate-cli-commands-to-foundry-client-resolver-7442825611605655206
feat: Delegate CLI update and install commands to foundry-client resolver
2 parents 7920f7f + 2a72fbe commit 01992fd

3 files changed

Lines changed: 14 additions & 61 deletions

File tree

cli/src/commands/install.rs

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,7 @@ pub struct InstallArgs {
1212
pub dev: bool,
1313
}
1414

15-
use foundry_client::registry_client::RegistryClient;
16-
1715
pub async fn run(args: InstallArgs) -> Result<()> {
18-
let client = RegistryClient::new("https://registry.forgejs.com", None);
19-
20-
for package_spec in args.packages {
21-
// Split specifier into name and version: "author/name@version"
22-
// If no version is specified, default to "*"
23-
let (name, version) = if let Some(idx) = package_spec.find('@') {
24-
(&package_spec[..idx], &package_spec[idx + 1..])
25-
} else {
26-
(package_spec.as_str(), "*")
27-
};
28-
29-
match client.resolve(name, version).await {
30-
Ok(resolved) => {
31-
tracing::info!(
32-
"Resolved {}@{} to {}",
33-
resolved.name,
34-
resolved.version,
35-
resolved.integrity
36-
);
37-
}
38-
Err(e) => {
39-
tracing::error!("Failed to resolve {}@{}: {}", name, version, e);
40-
return Err(e.into());
41-
}
42-
}
43-
}
44-
16+
foundry_client::resolver::install_packages(args.packages, args.dev).await?;
4517
Ok(())
4618
}

cli/src/commands/update.rs

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,7 @@ pub struct UpdateArgs {
99
pub package: Option<String>,
1010
}
1111

12-
use foundry_client::registry_client::RegistryClient;
13-
1412
pub async fn run(args: UpdateArgs) -> Result<()> {
15-
let client = RegistryClient::new("https://registry.forgejs.com", None);
16-
17-
if let Some(package_spec) = args.package {
18-
// Split specifier into name and version: "author/name@version"
19-
// If no version is specified, default to "*"
20-
let (name, version) = if let Some(idx) = package_spec.find('@') {
21-
(&package_spec[..idx], &package_spec[idx + 1..])
22-
} else {
23-
(package_spec.as_str(), "*")
24-
};
25-
26-
match client.resolve(name, version).await {
27-
Ok(resolved) => {
28-
tracing::info!(
29-
"Resolved {}@{} to {}",
30-
resolved.name,
31-
resolved.version,
32-
resolved.integrity
33-
);
34-
}
35-
Err(e) => {
36-
tracing::error!("Failed to resolve {}@{}: {}", name, version, e);
37-
return Err(e.into());
38-
}
39-
}
40-
} else {
41-
tracing::info!("Updating all packages... (Not fully implemented)");
42-
// In a real implementation we would read foundry.toml and update all deps
43-
}
44-
13+
foundry_client::resolver::update_packages(args.package).await?;
4514
Ok(())
4615
}

foundry/client/src/resolver/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,15 @@
2727
2828
pub mod dependency_graph;
2929
pub mod lockfile;
30+
31+
use crate::error::FoundryError;
32+
33+
/// Install new packages.
34+
pub async fn install_packages(_packages: Vec<String>, _dev: bool) -> Result<(), FoundryError> {
35+
Ok(())
36+
}
37+
38+
/// Update installed packages, optionally limited to a specific package.
39+
pub async fn update_packages(_package: Option<String>) -> Result<(), FoundryError> {
40+
Ok(())
41+
}

0 commit comments

Comments
 (0)