diff options
author | zaverden <zaverden@yandex-team.com> | 2023-09-22 09:10:23 +0300 |
---|---|---|
committer | zaverden <zaverden@yandex-team.com> | 2023-09-22 09:37:43 +0300 |
commit | 3fbf92623beec00dd8a0a82a7f95368027f7857d (patch) | |
tree | e8a1dab9bfc942014797d300ba843f1fd790e4d1 /build/plugins/lib/nots | |
parent | 52e89a78c67b7e466dbc6545a44e4a0a47b392c9 (diff) | |
download | ydb-3fbf92623beec00dd8a0a82a7f95368027f7857d.tar.gz |
feat(node_modules): call prebuilder apply-addons after install
Diffstat (limited to 'build/plugins/lib/nots')
-rw-r--r-- | build/plugins/lib/nots/package_manager/base/package_manager.py | 6 | ||||
-rw-r--r-- | build/plugins/lib/nots/package_manager/pnpm/package_manager.py | 21 |
2 files changed, 25 insertions, 2 deletions
diff --git a/build/plugins/lib/nots/package_manager/base/package_manager.py b/build/plugins/lib/nots/package_manager/base/package_manager.py index d594d4ea92..6b9faa56e8 100644 --- a/build/plugins/lib/nots/package_manager/base/package_manager.py +++ b/build/plugins/lib/nots/package_manager/base/package_manager.py @@ -104,12 +104,14 @@ class BasePackageManager(object): return [p[prefix_len:] for p in pj.get_workspace_map(ignore_self=True).keys()] - def _exec_command(self, args, include_defaults=True): + def _exec_command(self, args, include_defaults=True, script_path=None): if not self.nodejs_bin_path: raise PackageManagerError("Unable to execute command: nodejs_bin_path is not configured") cmd = ( - [self.nodejs_bin_path, self.script_path] + args + (self._get_default_options() if include_defaults else []) + [self.nodejs_bin_path, script_path or self.script_path] + + args + + (self._get_default_options() if include_defaults else []) ) p = subprocess.Popen( cmd, 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 69f27470e9..3f3e6a98b4 100644 --- a/build/plugins/lib/nots/package_manager/pnpm/package_manager.py +++ b/build/plugins/lib/nots/package_manager/pnpm/package_manager.py @@ -16,6 +16,7 @@ class PnpmPackageManager(BasePackageManager): _STORE_NM_PATH = os.path.join(".pnpm", "store") _VSTORE_NM_PATH = os.path.join(".pnpm", "virtual-store") _STORE_VER = "v3" + _PREBUILDER_PKG = "@yatool/prebuilder" @classmethod def load_lockfile(cls, path): @@ -57,6 +58,7 @@ class PnpmPackageManager(BasePackageManager): "--strict-peer-dependencies", ] ) + self._run_apply_addons() self._fix_stores_in_modules_yaml() bundle_node_modules( @@ -197,6 +199,22 @@ class PnpmPackageManager(BasePackageManager): ws.write() + def _run_apply_addons(self): + pj = self.load_package_json_from_dir(self.sources_path) + prebuilder_version = pj.get_dep_specifier(self._PREBUILDER_PKG) + if not prebuilder_version: + return # prebuilder should be in deps + + self._exec_command( + [ + "apply-addons", + "--virtual-store", + self._nm_path(self._VSTORE_NM_PATH), + ], + include_defaults=False, + script_path=self._get_prebuilder_bin(), + ) + def _fix_stores_in_modules_yaml(self): """ Ensures that store paths are the same as would be after installing deps in the source dir. @@ -221,3 +239,6 @@ class PnpmPackageManager(BasePackageManager): def _get_debug_log_path(self): return self._nm_path(".pnpm-debug.log") + + def _get_prebuilder_bin(self): + return self._nm_path(self._PREBUILDER_PKG, "build", "bin", "prebuilder.js") |