From 5ec127655a1e1f2db3ee17bf8081e197d030acd7 Mon Sep 17 00:00:00 2001 From: Miguel Ramos Date: Tue, 9 Jul 2024 07:55:58 +0100 Subject: [PATCH 1/6] feat: method to format repo url --- packages/package-a/package.json | 4 ++++ packages/package-b/package.json | 4 ++++ src/monorepo/packages.rs | 37 ++++++++++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/packages/package-a/package.json b/packages/package-a/package.json index 1c0595a8..1141d9e6 100644 --- a/packages/package-a/package.json +++ b/packages/package-a/package.json @@ -3,6 +3,10 @@ "version": "1.0.0", "description": "", "main": "index.mjs", + "repository": { + "url": "git+ssh://git@github.com/websublime/workspace-node-binding-tools.git", + "type": "git" + }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "dev": "node index.mjs" diff --git a/packages/package-b/package.json b/packages/package-b/package.json index ed1385da..79bb5230 100644 --- a/packages/package-b/package.json +++ b/packages/package-b/package.json @@ -3,6 +3,10 @@ "version": "1.0.0", "description": "", "main": "index.mjs", + "repository": { + "url": "git+ssh://git@github.com/websublime/workspace-node-binding-tools.git", + "type": "git" + }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "dev": "node index.mjs" diff --git a/src/monorepo/packages.rs b/src/monorepo/packages.rs index fe96092c..e0e8dcbd 100644 --- a/src/monorepo/packages.rs +++ b/src/monorepo/packages.rs @@ -9,10 +9,11 @@ use crate::agent::manager::Agent; use crate::filesystem::paths::get_project_root_path; use crate::git::commands::Git; use execute::Execute; -use package_json_schema::PackageJson; +use package_json_schema::{PackageJson, Repository}; use std::path::Path; use std::process::{Command, Stdio}; use wax::{CandidatePath, Glob, Pattern}; +use regex::Regex; #[derive(Debug, Deserialize, Serialize)] struct PnpmInfo { @@ -53,6 +54,38 @@ impl Monorepo { Agent::detect(&path) } + pub fn format_repo_url(repo: Option) -> String { + let regex = Regex::new(r"(?m)^((?git[/+]))?((?https?|ssh|git|ftps?)://)?((?[^/@]+)@)?(?[^/:]+)[/:](?[^/:]+)/(?.+/)?(?.+?)(?\.git[/]?)?$").unwrap(); + + match repo { + Some(Repository::Path(repo)) => { + let captures = regex.captures(&repo).unwrap(); + + let protocol = captures.name("protocol").unwrap().as_str().to_string(); + let host = captures.name("host").unwrap().as_str().to_string(); + let port = captures.name("port").unwrap().as_str().to_string(); + let path = captures.name("path").unwrap().as_str().to_string(); + let repo = captures.name("repo").unwrap().as_str(); + + format!("{}{}{}{}{}", protocol, host, port, path, repo) + + }, + Some(Repository::Object{url, .. }) => { + let url = url.unwrap(); + let captures = regex.captures(&url).unwrap(); + + let protocol = captures.name("protocol").unwrap().as_str().to_string(); + let host = captures.name("host").unwrap().as_str().to_string(); + let port = captures.name("port").unwrap().as_str().to_string(); + let path = captures.name("path").unwrap().as_str().to_string(); + let repo = captures.name("repo").unwrap().as_str(); + + format!("{}{}{}{}{}", protocol, host, port, path, repo) + }, + None => String::from("") + } + } + pub fn get_packages() -> Vec { return match Monorepo::get_agent() { Some(Agent::Pnpm) => { @@ -91,6 +124,8 @@ impl Monorepo { } }; + Monorepo::format_repo_url(pkg_json.repository.clone()); + PackageInfo { name: info.name.clone(), private: info.private, From f04f14be8516e7d73d69e754b38e2d986fe63a7c Mon Sep 17 00:00:00 2001 From: Miguel Ramos Date: Tue, 9 Jul 2024 07:56:24 +0100 Subject: [PATCH 2/6] chore: maintenance format --- src/monorepo/packages.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/monorepo/packages.rs b/src/monorepo/packages.rs index e0e8dcbd..445fb5d4 100644 --- a/src/monorepo/packages.rs +++ b/src/monorepo/packages.rs @@ -10,10 +10,10 @@ use crate::filesystem::paths::get_project_root_path; use crate::git::commands::Git; use execute::Execute; use package_json_schema::{PackageJson, Repository}; +use regex::Regex; use std::path::Path; use std::process::{Command, Stdio}; use wax::{CandidatePath, Glob, Pattern}; -use regex::Regex; #[derive(Debug, Deserialize, Serialize)] struct PnpmInfo { @@ -68,9 +68,8 @@ impl Monorepo { let repo = captures.name("repo").unwrap().as_str(); format!("{}{}{}{}{}", protocol, host, port, path, repo) - - }, - Some(Repository::Object{url, .. }) => { + } + Some(Repository::Object { url, .. }) => { let url = url.unwrap(); let captures = regex.captures(&url).unwrap(); @@ -81,8 +80,8 @@ impl Monorepo { let repo = captures.name("repo").unwrap().as_str(); format!("{}{}{}{}{}", protocol, host, port, path, repo) - }, - None => String::from("") + } + None => String::from(""), } } From 9c23a0c215ce1aba04cc9fbb6a3fb61319309ae3 Mon Sep 17 00:00:00 2001 From: Miguel Ramos Date: Tue, 9 Jul 2024 08:12:34 +0100 Subject: [PATCH 3/6] chore: add repo url to package info --- src/monorepo/packages.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/monorepo/packages.rs b/src/monorepo/packages.rs index 445fb5d4..aa9496d0 100644 --- a/src/monorepo/packages.rs +++ b/src/monorepo/packages.rs @@ -38,6 +38,7 @@ pub struct PackageInfo { pub pkg_json: Value, pub root: bool, pub version: String, + pub url: String, } pub struct Monorepo; @@ -61,27 +62,27 @@ impl Monorepo { Some(Repository::Path(repo)) => { let captures = regex.captures(&repo).unwrap(); - let protocol = captures.name("protocol").unwrap().as_str().to_string(); + //let protocol = captures.name("protocol").unwrap().as_str().to_string(); let host = captures.name("host").unwrap().as_str().to_string(); let port = captures.name("port").unwrap().as_str().to_string(); - let path = captures.name("path").unwrap().as_str().to_string(); + //let path = captures.name("path").unwrap().as_str().to_string(); let repo = captures.name("repo").unwrap().as_str(); - format!("{}{}{}{}{}", protocol, host, port, path, repo) + format!("https://{}/{}/{}", host, port, repo) } Some(Repository::Object { url, .. }) => { let url = url.unwrap(); let captures = regex.captures(&url).unwrap(); - let protocol = captures.name("protocol").unwrap().as_str().to_string(); + //let protocol = captures.name("protocol").unwrap().as_str().to_string(); let host = captures.name("host").unwrap().as_str().to_string(); let port = captures.name("port").unwrap().as_str().to_string(); - let path = captures.name("path").unwrap().as_str().to_string(); + //let path = captures.name("path").unwrap_or("").as_str().to_string(); let repo = captures.name("repo").unwrap().as_str(); - format!("{}{}{}{}{}", protocol, host, port, path, repo) + format!("https://{}/{}/{}", host, port, repo) } - None => String::from(""), + None => String::from("https://github.com/my-orga/my-repo"), } } @@ -123,7 +124,7 @@ impl Monorepo { } }; - Monorepo::format_repo_url(pkg_json.repository.clone()); + let repo_url = Monorepo::format_repo_url(pkg_json.repository.clone()); PackageInfo { name: info.name.clone(), @@ -134,6 +135,7 @@ impl Monorepo { pkg_json: serde_json::to_value(&pkg_json).unwrap(), root: is_root, version, + url: repo_url, } }) .collect::>() @@ -198,6 +200,8 @@ impl Monorepo { let name = pkg_json.name.clone().unwrap(); let version = pkg_json.version.clone().unwrap_or(String::from("0.0.0")); + let repo_url = Monorepo::format_repo_url(pkg_json.repository.clone()); + let pkg_info = PackageInfo { name, private, @@ -213,6 +217,7 @@ impl Monorepo { pkg_json: serde_json::to_value(&pkg_json).unwrap(), root: false, version, + url: repo_url, }; packages.push(pkg_info); @@ -248,6 +253,7 @@ impl Monorepo { pkg_json: pkg.pkg_json.clone(), root: pkg.root, version: pkg.version.clone(), + url: pkg.url.clone(), }) .collect::>(); From 6a8ff308c4c88d660b6ef0d0bc0d1f222a723d43 Mon Sep 17 00:00:00 2001 From: Miguel Ramos Date: Wed, 10 Jul 2024 08:02:25 +0100 Subject: [PATCH 4/6] chore: append to url for creation and init package json validation --- src/monorepo/errors.rs | 24 +++++++++++++ src/monorepo/mod.rs | 1 + src/monorepo/packages.rs | 77 +++++++++++++++++++++++++++++++++------- 3 files changed, 90 insertions(+), 12 deletions(-) create mode 100644 src/monorepo/errors.rs diff --git a/src/monorepo/errors.rs b/src/monorepo/errors.rs new file mode 100644 index 00000000..3114b115 --- /dev/null +++ b/src/monorepo/errors.rs @@ -0,0 +1,24 @@ +use std::fmt::{ Display, Formatter, Error }; + +#[derive(Debug)] +pub enum PackageJsonErrorEnum { + InvalidName(String), + InvalidDescription(String), + InvalidVersion(String), + UnknownErr, +} + +impl std::error::Error for PackageJsonErrorEnum {} + +impl Display for PackageJsonErrorEnum { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { + match self { + PackageJsonErrorEnum::InvalidName(message) => { + write!(f, "{}", message) + } + _ => todo!(), + } + } +} + +// Err(PackageJsonErrorEnum::InvalidName("No valid name")) diff --git a/src/monorepo/mod.rs b/src/monorepo/mod.rs index 0fab8a16..a06a764f 100644 --- a/src/monorepo/mod.rs +++ b/src/monorepo/mod.rs @@ -1,2 +1,3 @@ pub mod packages; pub mod utils; +pub mod errors; diff --git a/src/monorepo/packages.rs b/src/monorepo/packages.rs index aa9496d0..fa865f29 100644 --- a/src/monorepo/packages.rs +++ b/src/monorepo/packages.rs @@ -14,6 +14,8 @@ use regex::Regex; use std::path::Path; use std::process::{Command, Stdio}; use wax::{CandidatePath, Glob, Pattern}; +use super::errors::PackageJsonErrorEnum; + #[derive(Debug, Deserialize, Serialize)] struct PnpmInfo { @@ -61,31 +63,82 @@ impl Monorepo { match repo { Some(Repository::Path(repo)) => { let captures = regex.captures(&repo).unwrap(); + let mut url = "https://".to_string(); + + if captures.name("host").is_some() { + url.push_str(captures.name("host").unwrap().as_str()); + } - //let protocol = captures.name("protocol").unwrap().as_str().to_string(); - let host = captures.name("host").unwrap().as_str().to_string(); - let port = captures.name("port").unwrap().as_str().to_string(); - //let path = captures.name("path").unwrap().as_str().to_string(); - let repo = captures.name("repo").unwrap().as_str(); + if captures.name("port").is_some() { + url.push_str("/"); + url.push_str(captures.name("port").unwrap().as_str()); + } - format!("https://{}/{}/{}", host, port, repo) + if captures.name("path").is_some() { + url.push_str("/"); + url.push_str(captures.name("repo").unwrap().as_str()); + } + + if captures.name("repo").is_some() { + url.push_str("/"); + url.push_str(captures.name("repo").unwrap().as_str()); + } + + url } Some(Repository::Object { url, .. }) => { let url = url.unwrap(); let captures = regex.captures(&url).unwrap(); + let mut url = "https://".to_string(); + + if captures.name("host").is_some() { + url.push_str(captures.name("host").unwrap().as_str()); + } + + if captures.name("port").is_some() { + url.push_str("/"); + url.push_str(captures.name("port").unwrap().as_str()); + } + + if captures.name("path").is_some() { + url.push_str("/"); + url.push_str(captures.name("repo").unwrap().as_str()); + } - //let protocol = captures.name("protocol").unwrap().as_str().to_string(); - let host = captures.name("host").unwrap().as_str().to_string(); - let port = captures.name("port").unwrap().as_str().to_string(); - //let path = captures.name("path").unwrap_or("").as_str().to_string(); - let repo = captures.name("repo").unwrap().as_str(); + if captures.name("repo").is_some() { + url.push_str("/"); + url.push_str(captures.name("repo").unwrap().as_str()); + } - format!("https://{}/{}/{}", host, port, repo) + url } None => String::from("https://github.com/my-orga/my-repo"), } } + pub fn validate_packages_json() -> Result<(), PackageJsonErrorEnum> { + let packages = Monorepo::get_packages(); + + for pkg in packages { + let pkg_json = serde_json::from_value::(pkg.pkg_json).unwrap(); + + let name = pkg_json.name.unwrap_or(String::from("unknown")); + let version = pkg_json.version.unwrap_or(String::from("0")); + + if name == "unknown" { + Err(PackageJsonErrorEnum::InvalidName("No valid name".to_string()))?; + panic!("Package name in package.json does not match the directory name"); + } + + if version == "0" { + Err(PackageJsonErrorEnum::InvalidVersion("No valid version".to_string()))?; + panic!("Package version in package.json does not match the directory version"); + } + } + + Ok(()) + } + pub fn get_packages() -> Vec { return match Monorepo::get_agent() { Some(Agent::Pnpm) => { From 93ded92523aba50c1adb3a34cc75f15e1a6502de Mon Sep 17 00:00:00 2001 From: Miguel Ramos Date: Thu, 11 Jul 2024 07:27:42 +0100 Subject: [PATCH 5/6] chore: more options in package info --- src/git/commands.rs | 32 ++++++------- src/git/conventional.rs | 3 -- src/monorepo/errors.rs | 20 ++++++++- src/monorepo/mod.rs | 2 +- src/monorepo/packages.rs | 97 ++++++++++++++++++++++++++++++++++++---- 5 files changed, 125 insertions(+), 29 deletions(-) diff --git a/src/git/commands.rs b/src/git/commands.rs index 1425027b..961728da 100644 --- a/src/git/commands.rs +++ b/src/git/commands.rs @@ -14,7 +14,9 @@ use version_compare::{Cmp, Version}; use crate::{ filesystem::paths::get_project_root_path, - monorepo::{packages::PackageInfo, utils::package_scope_name_version}, + monorepo::{ + packages::PackageInfo, packages::PackageRepositoryInfo, utils::package_scope_name_version, + }, }; use super::conventional::{ConventionalPackage, ConventionalPackageOptions}; @@ -509,21 +511,25 @@ impl Git { let convention_options = match conventional_options { Some(options) => ConventionalPackageOptions { - owner: options.owner.or(Some(String::from("orga"))), - repo: options.repo.or(Some(String::from("tenant"))), version: options.version.or(Some(String::from("0.0.0"))), - domain: options.domain.or(Some(String::from("https://github.com"))), title: options.title, }, None => ConventionalPackageOptions { - owner: Some(String::from("orga")), - repo: Some(String::from("tenant")), version: Some(String::from("0.0.0")), - domain: Some(String::from("https://github.com")), title: None, }, }; + let repo_info = package_info.repository_info.clone(); + let repository_info = match repo_info { + Some(info) => info, + None => PackageRepositoryInfo { + orga: String::from("my-orga"), + project: String::from("my-repo"), + domain: String::from("https://github.com"), + }, + }; + let commits_since = Self::get_commits_since( Some(current_working_dir), hash, @@ -531,15 +537,9 @@ impl Git { ); let mut conventional_package = ConventionalPackage::new(package_info); let conventional_config = conventional_package.define_config( - convention_options - .owner - .expect("Owner repo needs to be defined"), - convention_options - .repo - .expect("Repo scope needs to be defined"), - convention_options - .domain - .expect("Github main domain url need to be defined"), + repository_info.orga, + repository_info.project, + repository_info.domain, convention_options.title, None, ); diff --git a/src/git/conventional.rs b/src/git/conventional.rs index 8c6c3fcf..0282d8b5 100644 --- a/src/git/conventional.rs +++ b/src/git/conventional.rs @@ -26,10 +26,7 @@ pub struct ConventionalPackage { #[napi(object)] #[derive(Debug, Clone)] pub struct ConventionalPackageOptions { - pub owner: Option, - pub repo: Option, pub version: Option, - pub domain: Option, pub title: Option, } diff --git a/src/monorepo/errors.rs b/src/monorepo/errors.rs index 3114b115..e25af92d 100644 --- a/src/monorepo/errors.rs +++ b/src/monorepo/errors.rs @@ -1,10 +1,13 @@ -use std::fmt::{ Display, Formatter, Error }; +use std::fmt::{Display, Error, Formatter}; #[derive(Debug)] pub enum PackageJsonErrorEnum { InvalidName(String), InvalidDescription(String), InvalidVersion(String), + InvalidRepository(String), + InvalidFiles(String), + InvalidLicense(String), UnknownErr, } @@ -16,6 +19,21 @@ impl Display for PackageJsonErrorEnum { PackageJsonErrorEnum::InvalidName(message) => { write!(f, "{}", message) } + PackageJsonErrorEnum::InvalidDescription(message) => { + write!(f, "{}", message) + } + PackageJsonErrorEnum::InvalidVersion(message) => { + write!(f, "{}", message) + } + PackageJsonErrorEnum::InvalidRepository(message) => { + write!(f, "{}", message) + } + PackageJsonErrorEnum::InvalidFiles(message) => { + write!(f, "{}", message) + } + PackageJsonErrorEnum::InvalidLicense(message) => { + write!(f, "{}", message) + } _ => todo!(), } } diff --git a/src/monorepo/mod.rs b/src/monorepo/mod.rs index a06a764f..ddc97138 100644 --- a/src/monorepo/mod.rs +++ b/src/monorepo/mod.rs @@ -1,3 +1,3 @@ +pub mod errors; pub mod packages; pub mod utils; -pub mod errors; diff --git a/src/monorepo/packages.rs b/src/monorepo/packages.rs index fa865f29..ee55334f 100644 --- a/src/monorepo/packages.rs +++ b/src/monorepo/packages.rs @@ -5,6 +5,7 @@ use serde::{Deserialize, Serialize}; use serde_json::Value; +use super::errors::PackageJsonErrorEnum; use crate::agent::manager::Agent; use crate::filesystem::paths::get_project_root_path; use crate::git::commands::Git; @@ -14,8 +15,6 @@ use regex::Regex; use std::path::Path; use std::process::{Command, Stdio}; use wax::{CandidatePath, Glob, Pattern}; -use super::errors::PackageJsonErrorEnum; - #[derive(Debug, Deserialize, Serialize)] struct PnpmInfo { @@ -41,6 +40,15 @@ pub struct PackageInfo { pub root: bool, pub version: String, pub url: String, + pub repository_info: Option, +} + +#[napi(object)] +#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, Hash)] +pub struct PackageRepositoryInfo { + pub domain: String, + pub orga: String, + pub project: String, } pub struct Monorepo; @@ -57,6 +65,21 @@ impl Monorepo { Agent::detect(&path) } + pub fn get_package_repository_info(url: String) -> PackageRepositoryInfo { + let regex = Regex::new(r"(?m)((?[a-z]+)://)((?[^/]*)/)(?([^/]*)/)(?(.*))(\.git)?").unwrap(); + + let captures = regex.captures(&url).unwrap(); + let domain = captures.name("domain").unwrap().as_str(); + let orga = captures.name("org").unwrap().as_str(); + let project = captures.name("project").unwrap().as_str(); + + PackageRepositoryInfo { + domain: domain.to_string(), + orga: orga.to_string(), + project: project.to_string(), + } + } + pub fn format_repo_url(repo: Option) -> String { let regex = Regex::new(r"(?m)^((?git[/+]))?((?https?|ssh|git|ftps?)://)?((?[^/@]+)@)?(?[^/:]+)[/:](?[^/:]+)/(?.+/)?(?.+?)(?\.git[/]?)?$").unwrap(); @@ -116,7 +139,7 @@ impl Monorepo { } } - pub fn validate_packages_json() -> Result<(), PackageJsonErrorEnum> { + pub fn validate_packages_json() -> Result { let packages = Monorepo::get_packages(); for pkg in packages { @@ -124,19 +147,70 @@ impl Monorepo { let name = pkg_json.name.unwrap_or(String::from("unknown")); let version = pkg_json.version.unwrap_or(String::from("0")); + let description = pkg_json.description.unwrap_or(String::from("unknown")); + let repository = pkg_json.repository.is_some(); + let files = pkg_json.files.unwrap_or(vec![]); + let license = pkg_json.license.unwrap_or(String::from("unknown")); if name == "unknown" { - Err(PackageJsonErrorEnum::InvalidName("No valid name".to_string()))?; - panic!("Package name in package.json does not match the directory name"); + Err(PackageJsonErrorEnum::InvalidName( + "No valid name".to_string(), + ))?; + return Ok(false); } if version == "0" { - Err(PackageJsonErrorEnum::InvalidVersion("No valid version".to_string()))?; - panic!("Package version in package.json does not match the directory version"); + Err(PackageJsonErrorEnum::InvalidVersion( + "No valid version".to_string(), + ))?; + return Ok(false); + } + + if description == "unknown" { + Err(PackageJsonErrorEnum::InvalidDescription( + "No valid description".to_string(), + ))?; + return Ok(false); + } + + if !repository { + Err(PackageJsonErrorEnum::InvalidRepository( + "No valid repository object".to_string(), + ))?; + return Ok(false); + } + + if repository { + let repo = pkg_json.repository.unwrap(); + let repo = match repo { + Repository::Path(repo) => repo, + Repository::Object { url, .. } => url.unwrap_or(String::from("")), + }; + + if repo.is_empty() { + Err(PackageJsonErrorEnum::InvalidRepository( + "No valid repository url".to_string(), + ))?; + return Ok(false); + } + } + + if files.is_empty() { + Err(PackageJsonErrorEnum::InvalidFiles( + "No valid files".to_string(), + ))?; + return Ok(false); + } + + if license == "unknown" { + Err(PackageJsonErrorEnum::InvalidLicense( + "No valid license".to_string(), + ))?; + return Ok(false); } } - Ok(()) + Ok(true) } pub fn get_packages() -> Vec { @@ -178,6 +252,8 @@ impl Monorepo { }; let repo_url = Monorepo::format_repo_url(pkg_json.repository.clone()); + let repository_info = + Monorepo::get_package_repository_info(repo_url.clone()); PackageInfo { name: info.name.clone(), @@ -189,6 +265,7 @@ impl Monorepo { root: is_root, version, url: repo_url, + repository_info: Some(repository_info), } }) .collect::>() @@ -254,6 +331,8 @@ impl Monorepo { let version = pkg_json.version.clone().unwrap_or(String::from("0.0.0")); let repo_url = Monorepo::format_repo_url(pkg_json.repository.clone()); + let repository_info = + Monorepo::get_package_repository_info(repo_url.clone()); let pkg_info = PackageInfo { name, @@ -271,6 +350,7 @@ impl Monorepo { root: false, version, url: repo_url, + repository_info: Some(repository_info), }; packages.push(pkg_info); @@ -307,6 +387,7 @@ impl Monorepo { root: pkg.root, version: pkg.version.clone(), url: pkg.url.clone(), + repository_info: pkg.repository_info.clone(), }) .collect::>(); From c5d825c13e154295354f3fbd2a125de3fdecc45a Mon Sep 17 00:00:00 2001 From: Miguel Ramos Date: Thu, 11 Jul 2024 07:38:27 +0100 Subject: [PATCH 6/6] fix: clippy suggestions and upgrade serde --- Cargo.lock | 8 ++++---- Cargo.toml | 4 ++-- src/monorepo/packages.rs | 14 +++++++------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 51d714f8..3b897f5b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1816,18 +1816,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 20248273..e37717ee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,8 +13,8 @@ path = "src/lib.rs" [dependencies] execute = "0.2.13" -serde = { version = "1.0.195", features = ["derive"] } -serde_json = "1.0.111" +serde = { version = "1.0.204", features = ["derive"] } +serde_json = "1.0.120" regex = "1.10.3" wax = { version = "0.6.0", features = ["walk"] } napi-derive = "2.16.8" diff --git a/src/monorepo/packages.rs b/src/monorepo/packages.rs index ee55334f..08e8024b 100644 --- a/src/monorepo/packages.rs +++ b/src/monorepo/packages.rs @@ -93,17 +93,17 @@ impl Monorepo { } if captures.name("port").is_some() { - url.push_str("/"); + url.push('/'); url.push_str(captures.name("port").unwrap().as_str()); } if captures.name("path").is_some() { - url.push_str("/"); + url.push('/'); url.push_str(captures.name("repo").unwrap().as_str()); } if captures.name("repo").is_some() { - url.push_str("/"); + url.push('/'); url.push_str(captures.name("repo").unwrap().as_str()); } @@ -119,17 +119,17 @@ impl Monorepo { } if captures.name("port").is_some() { - url.push_str("/"); + url.push('/'); url.push_str(captures.name("port").unwrap().as_str()); } if captures.name("path").is_some() { - url.push_str("/"); + url.push('/'); url.push_str(captures.name("repo").unwrap().as_str()); } if captures.name("repo").is_some() { - url.push_str("/"); + url.push('/'); url.push_str(captures.name("repo").unwrap().as_str()); } @@ -149,7 +149,7 @@ impl Monorepo { let version = pkg_json.version.unwrap_or(String::from("0")); let description = pkg_json.description.unwrap_or(String::from("unknown")); let repository = pkg_json.repository.is_some(); - let files = pkg_json.files.unwrap_or(vec![]); + let files = pkg_json.files.unwrap_or_default(); let license = pkg_json.license.unwrap_or(String::from("unknown")); if name == "unknown" {