Skip to content

Add support for uv and pnpm in check-requirements [--development]#429

Merged
fenekku merged 8 commits into
inveniosoftware:masterfrom
max-moser:mm.fixes
Jul 17, 2026
Merged

Add support for uv and pnpm in check-requirements [--development]#429
fenekku merged 8 commits into
inveniosoftware:masterfrom
max-moser:mm.fixes

Conversation

@max-moser

Copy link
Copy Markdown
Contributor

Since v14 has uv and pnpm as the blessed tools, I think it makes sense to consider them for check-requirements.
This also fixes some weird wording and handles the case better where the command is executed outside of a valid InvenioRDM project.

@max-moser
max-moser requested a review from fenekku July 17, 2026 18:00

@tmorrell tmorrell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, this needs to go in before v14. I'm not sure if we want to be stricter with the requirements, but at a minimum it shouldn't fail with uv and pnmp

)
)
]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to do node_version = 24 here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added node_version = 24 for v14+

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is 24 a hard minimum? 22 works too right but we "recommend" 24? If 22 works (or even something lower) would keep it to be as open. (we will only the build docker images for the recommended configuration though).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

relaxed it to v22

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will be testing some node variants in the docker image Monday so can comment on that further. It's not a blocker.

@fenekku fenekku left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General idea is good, most comments are minor/potential improvements. Am curious about the node version. If we can be accepting of wider range, it would be nice.

Comment thread invenio_cli/cli/cli.py Outdated
Comment thread invenio_cli/commands/requirements.py Outdated
Comment thread invenio_cli/commands/requirements.py Outdated
Comment on lines +84 to 118
response = cls.check_pnpm_version(**kwargs)
if response.status_code != 0:
response = cls.check_npm_version(**kwargs)

return response

@classmethod
def check_pnpm_version(
cls, pnpm_major, pnpm_minor=-1, pnpm_patch=-1, pnpm_exact=False, **kwargs
):
"""Check the pnpm version."""
# Output comes in the form of '11.3.0\n'
try:
result = run_cmd(["pnpm", "--version"])
version = cls._version_from_string(result.output.strip())
return cls._check_version(
"PNPM", version, pnpm_major, pnpm_minor, pnpm_patch, pnpm_exact
)
except Exception as err:
return ProcessResponse(error=f"PNPM not found. Got {err}.", status_code=1)

@classmethod
def check_npm_version(
cls, npm_major, npm_minor=-1, npm_patch=-1, npm_exact=False, **kwargs
):
"""Check the npm version."""
# Output comes in the form of '6.14.13\n'
try:
result = run_cmd(["npm", "--version"])
version = cls._version_from_string(result.output.strip())
return cls._check_version("NPM", version, major, minor, patch, exact)
return cls._check_version(
"NPM", version, npm_major, npm_minor, npm_patch, npm_exact
)
except Exception as err:
return ProcessResponse(error=f"NPM not found. Got {err}.", status_code=1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor (just me and seeing the repetition, obfuscation of clear matrix of parameters): could chunk it down (and similar for uv/pipenv)

Suggested change
response = cls.check_pnpm_version(**kwargs)
if response.status_code != 0:
response = cls.check_npm_version(**kwargs)
return response
@classmethod
def check_pnpm_version(
cls, pnpm_major, pnpm_minor=-1, pnpm_patch=-1, pnpm_exact=False, **kwargs
):
"""Check the pnpm version."""
# Output comes in the form of '11.3.0\n'
try:
result = run_cmd(["pnpm", "--version"])
version = cls._version_from_string(result.output.strip())
return cls._check_version(
"PNPM", version, pnpm_major, pnpm_minor, pnpm_patch, pnpm_exact
)
except Exception as err:
return ProcessResponse(error=f"PNPM not found. Got {err}.", status_code=1)
@classmethod
def check_npm_version(
cls, npm_major, npm_minor=-1, npm_patch=-1, npm_exact=False, **kwargs
):
"""Check the npm version."""
# Output comes in the form of '6.14.13\n'
try:
result = run_cmd(["npm", "--version"])
version = cls._version_from_string(result.output.strip())
return cls._check_version("NPM", version, major, minor, patch, exact)
return cls._check_version(
"NPM", version, npm_major, npm_minor, npm_patch, npm_exact
)
except Exception as err:
return ProcessResponse(error=f"NPM not found. Got {err}.", status_code=1)
# although this whole array could/should be passed as argument
js_pkg_managers = [
{"binary": "pnpm", "major": 10, "minor": -1, "patch": -1},
{"binary": "npm", "major": 10, "minor": -1, "patch": -1},
]
for pkg_manager in js_pkg_managers:
binary = pkg_manager["binary"]
try:
result = run_cmd([binary, "--version"])
version = cls._version_from_string(result.output.strip())
result = cls._check_version(
binary,
version,
pkg_manager["major"],
pkg_manager["minor"],
pkg_manager["patch"],
False
)
if result.status_code == 0:
break
except Exception as err:
return ProcessResponse(error=f"{binary} not found. Got {err}.", status_code=1)
return result

but with only 2 cases it's not that important.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created an issue motivating a general spring cleaning for this package (which may or may not be a bit dramatically worded): #430

Shall we consider this refactoring as part of that issue, as task for future us?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

)
)
]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is 24 a hard minimum? 22 works too right but we "recommend" 24? If 22 works (or even something lower) would keep it to be as open. (we will only the build docker images for the recommended configuration though).

Comment thread invenio_cli/commands/requirements.py

@fenekku fenekku left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's good for now and we can look into spring cleaning improvements as part of that other ticket.

@fenekku
fenekku merged commit 0db351d into inveniosoftware:master Jul 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants