Skip to content

Commit

Permalink
Fixes 4
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-alkov committed Oct 28, 2024
1 parent 903bd5b commit ea7eeb4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
15 changes: 6 additions & 9 deletions cachi2/core/package_managers/yarn_classic/main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import logging

import semver

from cachi2.core.errors import PackageManagerError, PackageRejected
from cachi2.core.models.input import Request
from cachi2.core.models.output import Component, EnvironmentVariable, RequestOutput
from cachi2.core.package_managers.yarn.utils import extract_yarn_version_from_env, run_yarn_cmd
from cachi2.core.package_managers.yarn.utils import (
VersionsRange,
extract_yarn_version_from_env,
run_yarn_cmd,
)
from cachi2.core.package_managers.yarn_classic.project import Project
from cachi2.core.package_managers.yarn_classic.workspaces import extract_workspace_metadata
from cachi2.core.rooted_path import RootedPath
Expand Down Expand Up @@ -134,12 +136,7 @@ def _verify_corepack_yarn_version(source_dir: RootedPath, env: dict[str, str]) -
"""Verify that corepack installed the correct version of yarn by checking `yarn --version`."""
installed_yarn_version = extract_yarn_version_from_env(source_dir, env)

min_version_inclusive = semver.version.Version(1, 22, 0)
max_version_exclusive = semver.version.Version(2, 0, 0)
if (
installed_yarn_version < min_version_inclusive
or installed_yarn_version >= max_version_exclusive
):
if installed_yarn_version not in VersionsRange("1.22.0", "2.0.0"):
raise PackageManagerError(
"Cachi2 expected corepack to install yarn >=1.22.0,<2.0.0, but instead "
f"found yarn@{installed_yarn_version}."
Expand Down
5 changes: 1 addition & 4 deletions cachi2/core/package_managers/yarn_classic/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,7 @@ def is_pnp_install(self) -> bool:
PurePath(file).match("*.pnp.cjs") for file in self.source_dir.path.iterdir()
)
node_modules_exists = self.source_dir.join_within_root("node_modules").path.exists()
is_pnp = False
if install_config_pnp_on or pnp_cjs_exists or node_modules_exists:
is_pnp = True
return is_pnp
return install_config_pnp_on or pnp_cjs_exists or node_modules_exists

@classmethod
def from_source_dir(cls, source_dir: RootedPath) -> "Project":
Expand Down

0 comments on commit ea7eeb4

Please sign in to comment.