diff options
author | zaverden <zaverden@yandex-team.com> | 2024-06-11 08:00:26 +0300 |
---|---|---|
committer | zaverden <zaverden@yandex-team.com> | 2024-06-11 08:15:47 +0300 |
commit | 799669481bc899de3c441756546785fca22d2423 (patch) | |
tree | 3ec9854cdb538283fe0de625d948c7611898386e /build/plugins/lib/nots/package_manager | |
parent | ca4183836a7f147ab01cf4c617b09f2f0ebd9155 (diff) | |
download | ydb-799669481bc899de3c441756546785fca22d2423.tar.gz |
feat(conf+builder): build without contrib/typescript
89c8f9767a1ef610f9ee050e1a5da5728bba02d7
Diffstat (limited to 'build/plugins/lib/nots/package_manager')
4 files changed, 36 insertions, 7 deletions
diff --git a/build/plugins/lib/nots/package_manager/base/lockfile.py b/build/plugins/lib/nots/package_manager/base/lockfile.py index fde0ee2b49..b1e0effdc8 100644 --- a/build/plugins/lib/nots/package_manager/base/lockfile.py +++ b/build/plugins/lib/nots/package_manager/base/lockfile.py @@ -29,6 +29,10 @@ class LockfilePackageMeta(object): def to_str(self): return " ".join([self.tarball_url, self.sky_id, self.integrity, self.integrity_algorithm]) + def to_uri(self): + pkg_uri = f"{self.tarball_url}#integrity={self.integrity_algorithm}-{self.integrity}" + return pkg_uri + class LockfilePackageMetaInvalidError(RuntimeError): pass diff --git a/build/plugins/lib/nots/package_manager/pnpm/lockfile.py b/build/plugins/lib/nots/package_manager/pnpm/lockfile.py index b7b07bcf6e..17b405df3b 100644 --- a/build/plugins/lib/nots/package_manager/pnpm/lockfile.py +++ b/build/plugins/lib/nots/package_manager/pnpm/lockfile.py @@ -1,5 +1,4 @@ import base64 -import binascii import yaml import os import io @@ -177,11 +176,16 @@ def _parse_package_integrity(integrity): """ 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: - hash_hex = binascii.hexlify(base64.b64decode(hash_b64)) + base64.b64decode(hash_b64) except TypeError as e: raise LockfilePackageMetaInvalidError( "Invalid package integrity encoding, integrity: {}, error: {}".format(integrity, e) ) - return (algo, hash_hex) + return (algo, hash_b64) diff --git a/build/plugins/lib/nots/package_manager/pnpm/package_manager.py b/build/plugins/lib/nots/package_manager/pnpm/package_manager.py index 3620ce8e6c..7022c2d9ed 100644 --- a/build/plugins/lib/nots/package_manager/pnpm/package_manager.py +++ b/build/plugins/lib/nots/package_manager/pnpm/package_manager.py @@ -87,6 +87,30 @@ class PnpmPackageManager(BasePackageManager): bundle_path=os.path.join(self.build_path, NODE_MODULES_WORKSPACE_BUNDLE_FILENAME), ) + 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_ws_config_path(self.module_path)), + b_rooted(build_pre_lockfile_path(self.module_path)), + ] + resources = [] + + if has_deps: + for dep_path in self.get_local_peers_from_package_json(): + ins.append(b_rooted(build_ws_config_path(dep_path))) + ins.append(b_rooted(build_pre_lockfile_path(dep_path))) + + 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 + # TODO: FBP-1254 # def calc_prepare_deps_inouts(self, store_path: str, has_deps: bool) -> (list[str], list[str]): def calc_prepare_deps_inouts(self, store_path, has_deps): 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 d696f4d53b..d10a7ca68f 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 @@ -99,10 +99,7 @@ def test_lockfile_get_packages_meta_ok(): assert len(packages) == 1 assert pkg.tarball_url == "@babel%2fcli/-/cli-7.6.2.tgz" assert pkg.sky_id == "rbtorrent:cb1849da3e4947e56a8f6bde6a1ec42703ddd187" - assert ( - pkg.integrity - == b"24367e4ff6ebf693df4f696600c272a490d34d31ccf5e3c3fc40f5d13463473255744572f89077891961cd8993b796243601efc561a55159cbb5dbfaaee883ad" - ) + assert pkg.integrity == "JDZ+T/br9pPfT2lmAMJypJDTTTHM9ePD/ED10TRjRzJVdEVy+JB3iRlhzYmTt5YkNgHvxWGlUVnLtdv6ruiDrQ==" assert pkg.integrity_algorithm == "sha512" |