Skip to content

Commit

Permalink
assets: implement install command for pnpm
Browse files Browse the repository at this point in the history
* also, use the module_pkg to execute the install command in the target
  path (rather than the instance's path, which made a difference in the
  case of pnpm)
  • Loading branch information
max-moser committed Feb 27, 2025
1 parent 323ab85 commit bd28804
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions invenio_cli/commands/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

"""Invenio module to ease the creation and management of applications."""

import subprocess
from pathlib import Path

import click
Expand Down Expand Up @@ -61,10 +60,12 @@ def _run_script(module_pkg):
status_code=status_code,
)

def _npm_install_command(self, path):
def _npm_install_command(self, path, module_pkg):
"""Run command and return a ProcessResponse."""
cmd = self.cli_config.javascript_package_manager.install_local_package(path)
status_code = subprocess.call(cmd)
install_args = self.cli_config.javascript_package_manager.install_local_package(
path
)
status_code = module_pkg.install(" ".join(install_args))
if status_code == 0:
return ProcessResponse(
output="Dependent packages installed correctly", status_code=0
Expand Down Expand Up @@ -134,7 +135,7 @@ def link_js_module(self, path):
steps = [
FunctionStep( # Install dependent packages
func=self._npm_install_command,
args={"path": path},
args={"path": path, "module_pkg": module_pkg},
message="Installing dependent packages...",
),
FunctionStep( # Run build script
Expand Down
4 changes: 2 additions & 2 deletions invenio_cli/helpers/package_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def create_pynpm_package(self, package_json_path):

def install_local_package(self, path):
"""Install the local JS package."""
return ["npm", "install", "--prefix", str(path)]
return ["--prefix", str(path)]

def env_overrides(self):
"""Provide environment overrides for building Invenio assets."""
Expand All @@ -225,7 +225,7 @@ def create_pynpm_package(self, package_json_path):

def install_local_package(self, path):
"""Install the local JS package."""
raise NotImplementedError()
return ["-C", str(path)]

def env_overrides(self):
"""Provide environment overrides for building Invenio assets."""
Expand Down

0 comments on commit bd28804

Please sign in to comment.