From 87638b4c7062e3faccd67a95bc14ed4f6c0a0940 Mon Sep 17 00:00:00 2001 From: Bruno Pimentel Date: Fri, 3 Jan 2025 17:11:35 -0300 Subject: [PATCH] yarn: remove unused code There's no need for Cachi2 to directly access the contents of the "npmRegistryServer" yarn_rc variable, since Yarn itself will read it when we execute "yarn install". The code refering to it is a leftover of the development phase. In a similar way, there's no use in setting "unsafeHttpWhitelist" as an empty list by default, since Cachi2 will purposefully set it to an empty list as a way to overwrite any unwanted user configuration. Signed-off-by: Bruno Pimentel --- cachi2/core/package_managers/yarn/project.py | 13 ------------- tests/unit/package_managers/yarn/test_main.py | 1 - tests/unit/package_managers/yarn/test_project.py | 2 -- 3 files changed, 16 deletions(-) diff --git a/cachi2/core/package_managers/yarn/project.py b/cachi2/core/package_managers/yarn/project.py index 403a7b797..450003eeb 100644 --- a/cachi2/core/package_managers/yarn/project.py +++ b/cachi2/core/package_managers/yarn/project.py @@ -43,9 +43,7 @@ class YarnRc(UserDict): _defaults = { "cacheFolder": "./.yarn/cache", "lockfileFilename": "yarn.lock", - "unsafeHttpWhitelist": [], "plugins": [], - "npmRegistryServer": "https://registry.yarnpkg.com", } def __init__(self, path: RootedPath, data: dict[str, Any]) -> None: @@ -57,17 +55,6 @@ def __init__(self, path: RootedPath, data: dict[str, Any]) -> None: self._path = path super().__init__(self._defaults | data) - def registry_server_for_scope(self, scope: str) -> str: - """Get the configured registry server for a scoped package. - - Fallback to the global defined registry server if there's no configuration for this specific - scope. - - See: https://v3.yarnpkg.com/configuration/yarnrc#npmScopes - """ - registry = self.data.get("npmScopes", {}).get(scope, {}).get("npmRegistryServer") - return registry or self["npmRegistryServer"] - def write(self) -> None: """Write the data to the yarnrc file.""" with self._path.path.open("w") as f: diff --git a/tests/unit/package_managers/yarn/test_main.py b/tests/unit/package_managers/yarn/test_main.py index 7ec76763e..5388d43b9 100644 --- a/tests/unit/package_managers/yarn/test_main.py +++ b/tests/unit/package_managers/yarn/test_main.py @@ -322,7 +322,6 @@ def test_set_yarnrc_configuration( "globalFolder": "/tmp/output/deps/yarn", "ignorePath": True, "lockfileFilename": "yarn.lock", - "npmRegistryServer": "https://registry.yarnpkg.com", "unsafeHttpWhitelist": [], "pnpMode": "strict", "plugins": expected_plugins, diff --git a/tests/unit/package_managers/yarn/test_project.py b/tests/unit/package_managers/yarn/test_project.py index 268be330e..240b19b45 100644 --- a/tests/unit/package_managers/yarn/test_project.py +++ b/tests/unit/package_managers/yarn/test_project.py @@ -112,11 +112,9 @@ def test_write_yarnrc(rooted_tmp_path: RootedPath) -> None: """ cacheFolder: .cache/folder lockfileFilename: yarn.lock - npmRegistryServer: https://registry.yarnpkg.com plugins: path: .path/to/plugin spec: '@yarnpkg/nice-plugin' - unsafeHttpWhitelist: [] """ ).lstrip()