From e93f268450b310637a2683fb0edf40fce48075bc Mon Sep 17 00:00:00 2001 From: nokazn <41154684+nokazn@users.noreply.github.com> Date: Sat, 10 Feb 2024 15:04:34 +0900 Subject: [PATCH] refactor: PackageManagerKind variant names --- src/core.rs | 16 ++++++++-------- src/package_json.rs | 4 ++-- src/workspaces.rs | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/core.rs b/src/core.rs index 75d6e51..4621f60 100644 --- a/src/core.rs +++ b/src/core.rs @@ -3,19 +3,19 @@ use strum_macros::EnumIter; #[derive(EnumIter, Serialize, Deserialize, Hash, Clone, Copy, Debug)] pub enum PackageManagerKind { - PackageLock, - YarnLock, - PnpmLock, - BunLockb, + Npm, + Yarn, + Pnpm, + Bun, } impl PackageManagerKind { pub fn file_names(&self) -> Vec<&str> { match self { - PackageManagerKind::PackageLock => vec!["package-lock.json"], - PackageManagerKind::YarnLock => vec!["yarn.lock"], - PackageManagerKind::PnpmLock => vec!["pnpm-lock.yaml", "pnpm-lock.yml"], - PackageManagerKind::BunLockb => vec!["bun.lockb"], + PackageManagerKind::Npm => vec!["package-lock.json"], + PackageManagerKind::Yarn => vec!["yarn.lock"], + PackageManagerKind::Pnpm => vec!["pnpm-lock.yaml", "pnpm-lock.yml"], + PackageManagerKind::Bun => vec!["bun.lockb"], } } } diff --git a/src/package_json.rs b/src/package_json.rs index 94e86b2..455a20b 100644 --- a/src/package_json.rs +++ b/src/package_json.rs @@ -113,14 +113,14 @@ impl WorkspacePackage { fn validate_package_json_fields>(self, base_dir: T) -> Result { let package_json_path = to_package_json_path(&base_dir); match self.kind { - PackageManagerKind::YarnLock + PackageManagerKind::Yarn if self.original.name.is_none() || self.original.version.is_none() => { Err(Error::InvalidPackageJsonFieldsForYarnError( package_json_path, )) } - PackageManagerKind::BunLockb if self.original.name.is_none() => Err( + PackageManagerKind::Bun if self.original.name.is_none() => Err( Error::InvalidPackageJsonFieldsForBunError(package_json_path), ), _ => Ok(self), diff --git a/src/workspaces.rs b/src/workspaces.rs index 996084f..98a349e 100644 --- a/src/workspaces.rs +++ b/src/workspaces.rs @@ -22,10 +22,10 @@ impl Workspaces { Self { kind: kind, packages: match &kind { - PackageManagerKind::PackageLock => Workspaces::resolve_npm_workspaces(base_dir, patterns), - PackageManagerKind::BunLockb => Workspaces::resolve_bun_workspaces(base_dir, patterns), - PackageManagerKind::YarnLock => Workspaces::resolve_yarn_workspaces(base_dir, patterns), - PackageManagerKind::PnpmLock => Workspaces::resolve_pnpm_workspaces(base_dir), + PackageManagerKind::Npm => Workspaces::resolve_npm_workspaces(base_dir, patterns), + PackageManagerKind::Bun => Workspaces::resolve_bun_workspaces(base_dir, patterns), + PackageManagerKind::Yarn => Workspaces::resolve_yarn_workspaces(base_dir, patterns), + PackageManagerKind::Pnpm => Workspaces::resolve_pnpm_workspaces(base_dir), }, } }