1use std::path::Path;
2use anyhow::anyhow;
3use cnctd_cargo::Cargo;
4use cnctd_npm::NPM;
5
6fn check_for_config_files() -> anyhow::Result<String> {
7 if Path::new("Cargo.toml").exists() {
8 return Ok(String::from("rust"));
9 } else if Path::new("package.json").exists() {
10 return Ok(String::from("npm"));
11 } else {
12 return Err(anyhow::anyhow!("No recognized config file found."));
13 }
14}
15
16pub async fn bump_project(version_part: &str) -> anyhow::Result<()> {
17 match &*check_for_config_files()? {
18 "rust" => {
19 Cargo::bump_version(version_part).await?;
20 Ok(())
21 }
22 "npm" => {
23 NPM::bump_version(version_part).await?;
24 Ok(())
25 }
26 &_ => Err(anyhow!("project type not detected"))
27 }
28}