diff options
author | zaverden <[email protected]> | 2025-10-07 07:25:28 +0300 |
---|---|---|
committer | zaverden <[email protected]> | 2025-10-07 07:46:16 +0300 |
commit | 8fe7cfe254fde2772477a8933a163b5f303716b4 (patch) | |
tree | d517dcb7df5c8ca59bbd5c9e56cedab8dc89b7f1 | |
parent | f05194beea4af627041e74088f07a8e5f54dbcce (diff) |
chore(conf+builder): remove experimental support for npm
commit_hash:ff97bf7139227c9f62a7c1018bcf710ee907efc3
21 files changed, 19 insertions, 503 deletions
diff --git a/build/conf/ts/node_modules.conf b/build/conf/ts/node_modules.conf index 30face6c637..637793277d4 100644 --- a/build/conf/ts/node_modules.conf +++ b/build/conf/ts/node_modules.conf @@ -1,11 +1,8 @@ PNPM_ROOT= PNPM_SCRIPT=$PNPM_ROOT/node_modules/pnpm/dist/pnpm.cjs -NPM_ROOT= -NPM_SCRIPT=$NPM_ROOT/node_modules/npm/bin/npm-cli.js - -PM_SCRIPT= -PM_TYPE= +PM_SCRIPT=$PNPM_SCRIPT +PM_TYPE=pnpm # combined input/outputs records as list of directives ${hide;input:<path>} ${hide;output:<path>}, used in builders _NODE_MODULES_INOUTS= @@ -74,8 +71,8 @@ module _PREPARE_DEPS_BASE: _BARE_UNIT { DISABLE(START_TARGET) # we read pnpm-lock.yaml and package.json during configuration - SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${CURDIR}/pnpm-lock.yaml ${CURDIR}/package-lock.json ${CURDIR}/package.json) + SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${CURDIR}/pnpm-lock.yaml ${CURDIR}/package.json) - _SET_PACKAGE_MANAGER() + _PEERDIR_TS_RESOURCE(nodejs $PM_TYPE) _PREPARE_DEPS_CONFIGURE() } diff --git a/build/conf/ts/ts.conf b/build/conf/ts/ts.conf index 8eaf32039d6..4c2d95febd8 100644 --- a/build/conf/ts/ts.conf +++ b/build/conf/ts/ts.conf @@ -117,8 +117,7 @@ module _TS_BASE_UNIT: _BARE_UNIT { SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${ARCADIA_ROOT}/$ERM_PACKAGES_PATH) # PEERDIR that reads required version of tool from package.json - _PEERDIR_TS_RESOURCE(nodejs) - _SET_PACKAGE_MANAGER() + _PEERDIR_TS_RESOURCE(nodejs $PM_TYPE) } # tag:test diff --git a/build/conf/ts/ts_test.conf b/build/conf/ts/ts_test.conf index d1cfa532803..33a77888e39 100644 --- a/build/conf/ts/ts_test.conf +++ b/build/conf/ts/ts_test.conf @@ -166,8 +166,8 @@ module _TS_TEST_BASE: _BARE_UNIT { # parse module args _TS_TEST_FOR_ARGS($MODULE_ARGS_RAW) - # Set PM values from TS_TEST_FOR_DIR - _SET_PACKAGE_MANAGER() + # PEERDIR that reads required version of tool from package.json + _PEERDIR_TS_RESOURCE(nodejs $PM_TYPE) # we don't want to have TS outputs for tests DISABLE(TS_CONFIG_DEDUCE_OUT) diff --git a/build/conf/ts/ts_tsc.conf b/build/conf/ts/ts_tsc.conf index bff0e363717..d9e68588353 100644 --- a/build/conf/ts/ts_tsc.conf +++ b/build/conf/ts/ts_tsc.conf @@ -38,7 +38,7 @@ multimodule TS_TSC { _TS_CONFIGURE() - SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${CURDIR}/package.json ${CURDIR}/pnpm-lock.yaml ${CURDIR}/package-lock.json ${CURDIR}/${TS_CONFIG_PATH}) + SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${CURDIR}/package.json ${CURDIR}/pnpm-lock.yaml ${CURDIR}/${TS_CONFIG_PATH}) _TS_ADD_NODE_MODULES_FOR_BUILDER() } diff --git a/build/plugins/lib/nots/package_manager/__init__.py b/build/plugins/lib/nots/package_manager/__init__.py index 9827164bda7..e13db9ceec2 100644 --- a/build/plugins/lib/nots/package_manager/__init__.py +++ b/build/plugins/lib/nots/package_manager/__init__.py @@ -22,8 +22,6 @@ manager = PnpmPackageManager def get_package_manager_type(key: PackageManagerType) -> type[BasePackageManager]: if key == "pnpm": return PnpmPackageManager - # if key == "npm": - # return NpmPackageManager raise ValueError(f"Invalid package manager key: {key}") diff --git a/build/plugins/lib/nots/package_manager/npm/__init__.py b/build/plugins/lib/nots/package_manager/npm/__init__.py deleted file mode 100644 index 96e87ea8ce5..00000000000 --- a/build/plugins/lib/nots/package_manager/npm/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -from .npm_package_manager import NpmPackageManager - - -__all__ = [ - "NpmPackageManager", -] diff --git a/build/plugins/lib/nots/package_manager/npm/npm_constants.py b/build/plugins/lib/nots/package_manager/npm/npm_constants.py deleted file mode 100644 index a763f547352..00000000000 --- a/build/plugins/lib/nots/package_manager/npm/npm_constants.py +++ /dev/null @@ -1,9 +0,0 @@ -NPM_LOCKFILE_FILENAME = "package-lock.json" - -# This is a name of intermediate file that is used in TS_PREPARE_DEPS. -# This file has a structure same to package-lock.json, but all tarballs -# a set relative to the build root. -NPM_PRE_LOCKFILE_FILENAME = "pre.package-lock.json" - -# This is an intermediate file containing workspaces definitions for a package -NPM_WORKSPACE_FILENAME = "package-workspace.json" diff --git a/build/plugins/lib/nots/package_manager/npm/npm_lockfile.py b/build/plugins/lib/nots/package_manager/npm/npm_lockfile.py deleted file mode 100644 index ba11e77103a..00000000000 --- a/build/plugins/lib/nots/package_manager/npm/npm_lockfile.py +++ /dev/null @@ -1,135 +0,0 @@ -import base64 -import json -import os -import io - -import urllib.parse as urlparse - -from ..base import BaseLockfile, LockfilePackageMeta, LockfilePackageMetaInvalidError - -LOCKFILE_VERSION_FIELD = "lockfileVersion" - - -class NpmLockfile(BaseLockfile): - def read(self): - with io.open(self.path, "rb") as f: - self.data = json.load(f) or {LOCKFILE_VERSION_FIELD: 3} - - lockfile_version = self.data.get(LOCKFILE_VERSION_FIELD, "<no-version>") - if lockfile_version != 3: - raise Exception( - f'Error of project configuration: {self.path} has lockfileVersion: {lockfile_version}. ' - + f'This version is not supported. Please, delete {os.path.basename(self.path)} and regenerate it using "ya tool nots --clean install --lockfile-only --npm"' - ) - - def write(self, path=None): - """ - :param path: path to store lockfile, defaults to original path - :type path: str - """ - if path is None: - path = self.path - - with open(path, "w") as f: - json.dump(self.data, f, indent=2) - - def get_packages_meta(self): - """ - Extracts packages meta from lockfile. - :rtype: list of LockfilePackageMeta - """ - packages = self.data.get("packages", {}) - - for key, meta in packages.items(): - if self._should_skip_package(key, meta): - continue - yield _parse_package_meta(key, meta) - - def update_tarball_resolutions(self, fn): - """ - :param fn: maps `LockfilePackageMeta` instance to new `resolution.tarball` value - :type fn: lambda - """ - packages = self.data.get("packages", {}) - - for key, meta in packages.items(): - if self._should_skip_package(key, meta): - continue - meta["resolved"] = fn(_parse_package_meta(key, meta, allow_file_protocol=True)) - packages[key] = meta - - def get_requires_build_packages(self): - raise NotImplementedError() - - def validate_has_addons_flags(self): - raise NotImplementedError() - - def _should_skip_package(self, key, meta): - return not key or key.startswith(".") or meta.get("link", None) is True - - -def _parse_package_meta(key, meta, allow_file_protocol=False): - """ - :param key: uniq package key from lockfile - :type key: string - :param meta: package meta dict from lockfile - :type meta: dict - :rtype: LockfilePackageMetaInvalidError - """ - try: - tarball_url = _parse_tarball_url(meta["resolved"], allow_file_protocol) - sky_id = _parse_sky_id_from_tarball_url(meta["resolved"]) - integrity_algorithm, integrity = _parse_package_integrity(meta["integrity"]) - except KeyError as e: - raise TypeError("Invalid package meta for key '{}', missing '{}' key".format(key, e)) - except LockfilePackageMetaInvalidError as e: - raise TypeError("Invalid package meta for key '{}', parse error: '{}'".format(key, e)) - - return LockfilePackageMeta(key, tarball_url, sky_id, integrity, integrity_algorithm) - - -def _parse_tarball_url(tarball_url, allow_file_protocol): - if tarball_url.startswith("file:") and not allow_file_protocol: - raise LockfilePackageMetaInvalidError("tarball cannot point to a file, got {}".format(tarball_url)) - return tarball_url.split("?")[0] - - -def _parse_sky_id_from_tarball_url(tarball_url): - """ - :param tarball_url: tarball url - :type tarball_url: string - :rtype: string - """ - if tarball_url.startswith("file:"): - return "" - - rbtorrent_param = urlparse.parse_qs(urlparse.urlparse(tarball_url).query).get("rbtorrent") - - if rbtorrent_param is None: - return "" - - return "rbtorrent:{}".format(rbtorrent_param[0]) - - -def _parse_package_integrity(integrity): - """ - Returns tuple of algorithm and hash (hex). - :param integrity: package integrity in format "{algo}-{base64_of_hash}" - :type integrity: string - :rtype: (str, str) - """ - algo, hash_b64 = integrity.split("-", 1) - - if algo not in ("sha1", "sha512"): - raise LockfilePackageMetaInvalidError( - f"Invalid package integrity algorithm, expected one of ('sha1', 'sha512'), got '{algo}'" - ) - - try: - base64.b64decode(hash_b64) - except TypeError as e: - raise LockfilePackageMetaInvalidError( - "Invalid package integrity encoding, integrity: {}, error: {}".format(integrity, e) - ) - - return (algo, hash_b64) diff --git a/build/plugins/lib/nots/package_manager/npm/npm_package_manager.py b/build/plugins/lib/nots/package_manager/npm/npm_package_manager.py deleted file mode 100644 index 0249d7f6f8b..00000000000 --- a/build/plugins/lib/nots/package_manager/npm/npm_package_manager.py +++ /dev/null @@ -1,177 +0,0 @@ -import os - -from ..base import BasePackageManager, PackageManagerError -from ..base.constants import NODE_MODULES_WORKSPACE_BUNDLE_FILENAME -from ..base.node_modules_bundler import bundle_node_modules -from ..base.utils import b_rooted, build_nm_bundle_path, build_pj_path, build_tmp_pj_path, s_rooted - -from .npm_lockfile import NpmLockfile -from .npm_utils import build_lockfile_path, build_pre_lockfile_path, build_ws_config_path -from .npm_workspace import NpmWorkspace - - -class NpmPackageManager(BasePackageManager): - @classmethod - def load_lockfile(cls, path): - """ - :param path: path to lockfile - :type path: str - :rtype: NpmLockfile - """ - return NpmLockfile.load(path) - - @classmethod - def load_lockfile_from_dir(cls, dir_path): - """ - :param dir_path: path to directory with lockfile - :type dir_path: str - :rtype: NpmLockfile - """ - return cls.load_lockfile(build_lockfile_path(dir_path)) - - def extract_packages_meta_from_lockfiles(self, lf_paths): - """ - :type lf_paths: iterable of BaseLockfile - :rtype: iterable of LockfilePackageMeta - """ - tarballs = set() - errors = [] - - for lf_path in lf_paths: - try: - for pkg in self.load_lockfile(lf_path).get_packages_meta(): - if pkg.tarball_path not in tarballs: - tarballs.add(pkg.tarball_path) - yield pkg - except Exception as e: - errors.append("{}: {}".format(lf_path, e)) - - if errors: - raise PackageManagerError("Unable to process some lockfiles:\n{}".format("\n".join(errors))) - - def calc_prepare_deps_inouts_and_resources( - self, store_path: str, has_deps: bool - ) -> tuple[list[str], list[str], list[str]]: - ins = [ - s_rooted(build_pj_path(self.module_path)), - s_rooted(build_lockfile_path(self.module_path)), - ] - outs = [ - b_rooted(build_pre_lockfile_path(self.module_path)), - b_rooted(build_ws_config_path(self.module_path)), - ] - resources = [] - - if has_deps: - for pkg in self.extract_packages_meta_from_lockfiles([build_lockfile_path(self.sources_path)]): - resources.append(pkg.to_uri()) - outs.append(b_rooted(self._tarballs_store_path(pkg, store_path))) - - return ins, outs, resources - - def calc_node_modules_inouts(self, nm_bundle: bool) -> tuple[list[str], list[str]]: - """ - Returns input and optionally output paths for command that creates `node_modules` bundle. - It relies on .PEERDIRSELF=TS_PREPARE_DEPS - Inputs: - - source package.json - Outputs: - - node_modules bundle if `nm_bundle` is True else empty list - """ - ins = [ - s_rooted(build_pj_path(self.module_path)), - ] - outs = [] - - if nm_bundle: - outs.append(b_rooted(build_nm_bundle_path(self.module_path))) - - return ins, outs - - def build_workspace(self, tarballs_store: str): - ws = NpmWorkspace(build_ws_config_path(self.build_path)) - ws.set_from_package_json(self._build_package_json()) - - dep_paths = ws.get_paths(ignore_self=True) - self._build_merged_workspace_config(ws, dep_paths) - self._build_pre_lockfile(tarballs_store) - - return ws - - def _build_merged_workspace_config(self, ws: NpmWorkspace, dep_paths: list[str]): - """ - NOTE: This method mutates `ws`. - """ - for dep_path in dep_paths: - ws_config_path = build_ws_config_path(dep_path) - if os.path.isfile(ws_config_path): - ws.merge(NpmWorkspace.load(ws_config_path)) - - ws.write() - - def _build_pre_lockfile(self, tarballs_store: str): - lf = self.load_lockfile_from_dir(self.sources_path) - # Change to the output path for correct path calcs on merging. - lf.path = build_pre_lockfile_path(self.build_path) - lf.update_tarball_resolutions(lambda p: self._tarballs_store_path(p, tarballs_store)) - - lf.write() - - def create_node_modules(self, yatool_prebuilder_path=None, local_cli=False, nm_bundle=False): - """ - Creates node_modules directory according to the lockfile. - """ - - ws = self._prepare_workspace() - - for dep_path in ws.get_paths(): - module_path = dep_path[len(self.build_root) + 1 :] - dep_source_path = os.path.join(self.sources_root, module_path) - dep_pm = NpmPackageManager( - build_root=self.build_root, - build_path=dep_path, - sources_path=dep_source_path, - nodejs_bin_path=self.nodejs_bin_path, - script_path=self.script_path, - module_path=module_path, - sources_root=self.sources_root, - ) - dep_pm._prepare_workspace() - dep_pm._install_node_modules() - - self._install_node_modules() - - if not local_cli and nm_bundle: - bundle_node_modules( - build_root=self.build_root, - node_modules_path=self._nm_path(), - peers=[], - bundle_path=os.path.join(self.build_path, NODE_MODULES_WORKSPACE_BUNDLE_FILENAME), - ) - self._post_install_fix_pj() - - def _install_node_modules(self): - install_cmd = ["clean-install", "--ignore-scripts", "--audit=false"] - - env = os.environ.copy() - env.update({"NPM_CONFIG_CACHE": os.path.join(self.build_path, ".npm-cache")}) - - self._exec_command(install_cmd, cwd=self.build_path, env=env) - - def _prepare_workspace(self): - lf = self.load_lockfile(build_pre_lockfile_path(self.build_path)) - lf.update_tarball_resolutions(lambda p: "file:" + os.path.join(self.build_root, p.tarball_url)) - lf.write(build_lockfile_path(self.build_path)) - - ws = NpmWorkspace.load(build_ws_config_path(self.build_path)) - pj = self.load_package_json_from_dir(self.build_path) - pj.write(build_tmp_pj_path(self.build_path)) # save orig file to restore later - pj.data["workspaces"] = list(ws.packages) - os.unlink(pj.path) # for peers this file is hardlinked from RO cache - pj.write() - - return ws - - def _post_install_fix_pj(self): - os.remove(build_pj_path(self.build_path)) - os.rename(build_tmp_pj_path(self.build_path), build_pj_path(self.build_path)) diff --git a/build/plugins/lib/nots/package_manager/npm/npm_utils.py b/build/plugins/lib/nots/package_manager/npm/npm_utils.py deleted file mode 100644 index aa8224e2db3..00000000000 --- a/build/plugins/lib/nots/package_manager/npm/npm_utils.py +++ /dev/null @@ -1,15 +0,0 @@ -import os - -from .npm_constants import NPM_LOCKFILE_FILENAME, NPM_PRE_LOCKFILE_FILENAME, NPM_WORKSPACE_FILENAME - - -def build_ws_config_path(p): - return os.path.join(p, NPM_WORKSPACE_FILENAME) - - -def build_pre_lockfile_path(p): - return os.path.join(p, NPM_PRE_LOCKFILE_FILENAME) - - -def build_lockfile_path(p): - return os.path.join(p, NPM_LOCKFILE_FILENAME) diff --git a/build/plugins/lib/nots/package_manager/npm/npm_workspace.py b/build/plugins/lib/nots/package_manager/npm/npm_workspace.py deleted file mode 100644 index 7bdb67be8f2..00000000000 --- a/build/plugins/lib/nots/package_manager/npm/npm_workspace.py +++ /dev/null @@ -1,80 +0,0 @@ -import os -import json - - -class NpmWorkspace(object): - @classmethod - def load(cls, path): - ws = cls(path) - ws.read() - - return ws - - def __init__(self, path): - if not os.path.isabs(path): - raise TypeError("Absolute path required, given: {}".format(path)) - - self.path = path - # NOTE: pnpm requires relative workspace paths. - self.packages = set() - - def read(self): - with open(self.path) as f: - parsed = json.load(f) or {} - self.packages = set(parsed.get("workspaces", [])) - - def write(self, path=None): - if not path: - path = self.path - - with open(path, "w") as f: - data = { - "workspaces": list(self.packages), - } - json.dump(data, f, indent=2) - - def get_paths(self, base_path=None, ignore_self=False): - """ - Returns absolute paths of the workspace packages. - :param base_path: base path to resolve relative dep paths - :type base_path: str - :param ignore_self: whether path of the current module will be excluded (if present) - :type ignore_self: bool - :rtype: list of str - """ - if base_path is None: - base_path = os.path.dirname(self.path) - - return [ - os.path.normpath(os.path.join(base_path, pkg_path)) - for pkg_path in self.packages - if not ignore_self or pkg_path != "." - ] - - def set_from_package_json(self, package_json): - """ - Sets packages to "workspace" deps from given package.json. - :param package_json: package.json of workspace - :type package_json: PackageJson - """ - if os.path.dirname(package_json.path) != os.path.dirname(self.path): - raise TypeError( - "package.json should be in workspace directory {}, given: {}".format( - os.path.dirname(self.path), package_json.path - ) - ) - - self.packages = set(path for _, path in package_json.get_workspace_dep_spec_paths()) - - def merge(self, ws): - # type: (NpmWorkspace) -> None - """ - Adds `ws`'s packages to the workspace. - :param ws: workspace to merge - """ - dir_path = os.path.dirname(self.path) - ws_dir_path = os.path.dirname(ws.path) - - for p_rel_path in ws.packages: - p_path = os.path.normpath(os.path.join(ws_dir_path, p_rel_path)) - self.packages.add(os.path.relpath(p_path, dir_path)) diff --git a/build/plugins/lib/nots/package_manager/npm/ya.make b/build/plugins/lib/nots/package_manager/npm/ya.make deleted file mode 100644 index ad24cc64e3c..00000000000 --- a/build/plugins/lib/nots/package_manager/npm/ya.make +++ /dev/null @@ -1,20 +0,0 @@ -SUBSCRIBER(g:frontend_build_platform) - -PY3_LIBRARY() - -STYLE_PYTHON() - -PY_SRCS( - __init__.py - npm_constants.py - npm_lockfile.py - npm_package_manager.py - npm_utils.py - npm_workspace.py -) - -PEERDIR( - build/plugins/lib/nots/package_manager/base -) - -END() diff --git a/build/plugins/lib/nots/package_manager/pnpm/__init__.py b/build/plugins/lib/nots/package_manager/pnpm/__init__.py index 0f50359c47c..a29f7315e2f 100644 --- a/build/plugins/lib/nots/package_manager/pnpm/__init__.py +++ b/build/plugins/lib/nots/package_manager/pnpm/__init__.py @@ -1,8 +1,8 @@ from . import constants -from .lockfile import PnpmLockfile -from .package_manager import PnpmPackageManager +from .pnpm_lockfile import PnpmLockfile +from .pnpm_package_manager import PnpmPackageManager from .utils import build_ws_config_path, build_lockfile_path -from .workspace import PnpmWorkspace +from .pnpm_workspace import PnpmWorkspace __all__ = [ diff --git a/build/plugins/lib/nots/package_manager/pnpm/lockfile.py b/build/plugins/lib/nots/package_manager/pnpm/pnpm_lockfile.py index 10fc529c717..10fc529c717 100644 --- a/build/plugins/lib/nots/package_manager/pnpm/lockfile.py +++ b/build/plugins/lib/nots/package_manager/pnpm/pnpm_lockfile.py diff --git a/build/plugins/lib/nots/package_manager/pnpm/package_manager.py b/build/plugins/lib/nots/package_manager/pnpm/pnpm_package_manager.py index 7199e91a042..1cdf17d2deb 100644 --- a/build/plugins/lib/nots/package_manager/pnpm/package_manager.py +++ b/build/plugins/lib/nots/package_manager/pnpm/pnpm_package_manager.py @@ -9,7 +9,7 @@ from .constants import ( LOCAL_PNPM_INSTALL_MUTEX_FILENAME, VIRTUAL_STORE_DIRNAME, ) -from .lockfile import PnpmLockfile +from .pnpm_lockfile import PnpmLockfile from .utils import ( build_lockfile_path, build_build_backup_lockfile_path, @@ -17,7 +17,7 @@ from .utils import ( build_ws_config_path, build_pnpm_store_path, ) -from .workspace import PnpmWorkspace +from .pnpm_workspace import PnpmWorkspace from ..base import BasePackageManager, PackageManagerError from ..base.constants import ( NODE_MODULES_WORKSPACE_BUNDLE_FILENAME, diff --git a/build/plugins/lib/nots/package_manager/pnpm/workspace.py b/build/plugins/lib/nots/package_manager/pnpm/pnpm_workspace.py index 4e85a023b84..4e85a023b84 100644 --- a/build/plugins/lib/nots/package_manager/pnpm/workspace.py +++ b/build/plugins/lib/nots/package_manager/pnpm/pnpm_workspace.py diff --git a/build/plugins/lib/nots/package_manager/pnpm/tests/test_lockfile.py b/build/plugins/lib/nots/package_manager/pnpm/tests/test_lockfile.py index 953d35b727d..c45c7f9614f 100644 --- a/build/plugins/lib/nots/package_manager/pnpm/tests/test_lockfile.py +++ b/build/plugins/lib/nots/package_manager/pnpm/tests/test_lockfile.py @@ -1,7 +1,7 @@ import pytest import io -from build.plugins.lib.nots.package_manager.pnpm.lockfile import PnpmLockfile, PnpmLockfileHelper +from build.plugins.lib.nots.package_manager.pnpm.pnpm_lockfile import PnpmLockfile, PnpmLockfileHelper @pytest.fixture() diff --git a/build/plugins/lib/nots/package_manager/pnpm/tests/test_workspace.py b/build/plugins/lib/nots/package_manager/pnpm/tests/test_workspace.py index ffc010de882..6b97f2afb4e 100644 --- a/build/plugins/lib/nots/package_manager/pnpm/tests/test_workspace.py +++ b/build/plugins/lib/nots/package_manager/pnpm/tests/test_workspace.py @@ -1,5 +1,5 @@ from build.plugins.lib.nots.package_manager.base import PackageJson -from build.plugins.lib.nots.package_manager.pnpm.workspace import PnpmWorkspace +from build.plugins.lib.nots.package_manager.pnpm.pnpm_workspace import PnpmWorkspace def test_workspace_get_paths(): diff --git a/build/plugins/lib/nots/package_manager/pnpm/ya.make b/build/plugins/lib/nots/package_manager/pnpm/ya.make index 4b19a547b97..a68940d3ac2 100644 --- a/build/plugins/lib/nots/package_manager/pnpm/ya.make +++ b/build/plugins/lib/nots/package_manager/pnpm/ya.make @@ -7,9 +7,9 @@ STYLE_PYTHON() PY_SRCS( __init__.py constants.py - lockfile.py - package_manager.py - workspace.py + pnpm_lockfile.py + pnpm_package_manager.py + pnpm_workspace.py utils.py ) diff --git a/build/plugins/lib/nots/package_manager/ya.make b/build/plugins/lib/nots/package_manager/ya.make index 6853c7b50a8..b0995fff665 100644 --- a/build/plugins/lib/nots/package_manager/ya.make +++ b/build/plugins/lib/nots/package_manager/ya.make @@ -11,7 +11,6 @@ PY_SRCS( PEERDIR( build/plugins/lib/nots/package_manager/base build/plugins/lib/nots/package_manager/pnpm - build/plugins/lib/nots/package_manager/npm ) END() @@ -19,5 +18,4 @@ END() RECURSE( base pnpm - npm ) diff --git a/build/plugins/nots.py b/build/plugins/nots.py index 3c9ab09de26..60cf9b71685 100644 --- a/build/plugins/nots.py +++ b/build/plugins/nots.py @@ -11,7 +11,6 @@ import ytest from _common import ( rootrel_arc_src, sort_uniq, - strip_roots, to_yesno, ) from _dart_fields import create_dart_record @@ -131,11 +130,6 @@ class NotsUnitType(UnitType): Turn on code navigation indexing """ - def on_from_npm(self, args: UnitType.PluginArgs) -> None: - """ - TODO remove after removing on_from_pnpm_lockfiles - """ - def on_setup_install_node_modules_recipe(self) -> None: """ Setup test recipe to install node_modules before running tests @@ -368,7 +362,7 @@ def _create_erm_json(unit: NotsUnitType): def _get_pm_type(unit: NotsUnitType) -> 'PackageManagerType': resolved: PackageManagerType | None = unit.get("PM_TYPE") if not resolved: - raise Exception("PM_TYPE is not set yet. Macro _SET_PACKAGE_MANAGER() should be called before.") + raise Exception("PM_TYPE is not set yet.") return resolved @@ -398,34 +392,6 @@ def _create_pm(unit: NotsUnitType) -> 'BasePackageManager': @_with_report_configure_error -def on_set_package_manager(unit: NotsUnitType) -> None: - pm_type = "pnpm" # projects without any lockfile are processed by pnpm - - source_path = _get_source_path(unit) - - for pm_key, lockfile_name in [("pnpm", "pnpm-lock.yaml"), ("npm", "package-lock.json")]: - lf_path = os.path.join(source_path, lockfile_name) - lf_path_resolved = unit.resolve_arc_path(strip_roots(lf_path)) - - if lf_path_resolved: - pm_type = pm_key - break - - if pm_type == 'npm' and "devtools/dummy_arcadia/typescript/npm" not in source_path: - ymake.report_configure_error( - "\n" - "Project is configured to use npm as a package manager. \n" - "Only pnpm is supported at the moment.\n" - "Please follow the instruction to migrate your project:\n" - "https://docs.yandex-team.ru/frontend-in-arcadia/tutorials/migrate#migrate-to-pnpm" - ) - - unit.on_peerdir_ts_resource(pm_type) - unit.set(["PM_TYPE", pm_type]) - unit.set(["PM_SCRIPT", f"${pm_type.upper()}_SCRIPT"]) - - -@_with_report_configure_error def on_set_append_with_directive(unit: NotsUnitType, var_name: str, directive: str, *values: str) -> None: wrapped = [f'${{{directive}:"{v}"}}' for v in values] |