inveniosoftware / invenio-cli

CLI module for Invenio
https://invenio-cli.readthedocs.io
MIT License
10 stars 43 forks source link

invenio-cli check-requirements --development fails on non-RDM site #343

Open mesemus opened 1 year ago

mesemus commented 1 year ago

Package version (if known): 1.0.17

Describe the bug

invenio-cli in version 1.0.17 started checking for RDM version - see https://github.com/inveniosoftware/invenio-cli/blob/master/invenio_cli/commands/requirements.py#L195

The problem is that if Invenio-cli is used on site without invenio-app-rdm installed, this check fails with a key error:

Traceback (most recent call last):
  File "/private/tmp/blah/.venv/invenio-cli/bin/invenio-cli", line 8, in <module>
    sys.exit(invenio_cli())
  File "/private/tmp/blah/.venv/invenio-cli/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/private/tmp/blah/.venv/invenio-cli/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/private/tmp/blah/.venv/invenio-cli/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/private/tmp/blah/.venv/invenio-cli/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/private/tmp/blah/.venv/invenio-cli/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/private/tmp/blah/.venv/invenio-cli/lib/python3.9/site-packages/invenio_cli/cli/cli.py", line 62, in check_requirements
    steps = RequirementsCommands.check(development)
  File "/private/tmp/blah/.venv/invenio-cli/lib/python3.9/site-packages/invenio_cli/commands/requirements.py", line 254, in check
    steps.extend(cls.check_dev())
  File "/private/tmp/blah/.venv/invenio-cli/lib/python3.9/site-packages/invenio_cli/commands/requirements.py", line 195, in check_dev
    if rdm_version()[0] >= 11:
  File "/private/tmp/blah/.venv/invenio-cli/lib/python3.9/site-packages/invenio_cli/helpers/rdm.py", line 21, in rdm_version
    r"[0-9]*\.[0-9]*\.[0-9]*", parsed.data["default"]["invenio-app-rdm"]["version"]
KeyError: 'invenio-app-rdm'

There is currently no workaround for this.

Steps to Reproduce

  1. Install invenio with invenio-cli
  2. Remove invenio-app-rdm from the pipfile
  3. Run check-requirements

Expected behavior

The check is supposed to pass, ideally allowing to use node 16