Skip to content

feat(cli): add nx info command - #477

Merged
Espoir-Loem merged 38 commits into
NexyPy:developfrom
devsumaiyask:develop
Nov 20, 2026
Merged

Espoir-Loem merged 38 commits into
NexyPy:developfrom
devsumaiyask:develop

Conversation

@devsumaiyask

Copy link
Copy Markdown
Contributor

Closes #454 — Adds the nx info command, i18n keys, updated bug report template, and unit tests.

This script provides information about the environment and project versions, including Nexy, Python, OS, Node, package manager, router, and frameworks.

Signed-off-by: Sumaiya Shaikh <[email protected]>
This file contains tests for the `nx info` command, verifying the output when inside and outside a project directory, including scenarios with and without Node.js and package manager detection.

Signed-off-by: Sumaiya Shaikh <[email protected]>
This module provides the `info` command to print environment and project versions, including Nexy, Python, OS, Node, package manager, router, and frameworks.

Signed-off-by: Sumaiya Shaikh <[email protected]>
Signed-off-by: Sumaiya Shaikh <[email protected]>
Signed-off-by: Sumaiya Shaikh <[email protected]>
Signed-off-by: Sumaiya Shaikh <[email protected]>
Signed-off-by: Sumaiya Shaikh <[email protected]>
Signed-off-by: Sumaiya Shaikh <[email protected]>
Added additional spacing for better readability in the bug report template.

Signed-off-by: Sumaiya Shaikh <[email protected]>
@devsumaiyask

Copy link
Copy Markdown
Contributor Author

Hi @Espoir-Loem! I've opened this PR implementing nx info along with the i18n keys, updated bug report template, and unit tests covering both inside/outside a project and missing Node/package manager cases. Happy to adjust anything after CI runs and your review!

@Espoir-Loem Espoir-Loem left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you @devsumaiyask, this is a solid first pull request: info.py is clean, every value has a "not found" path, and running it locally prints exactly the block the issue asked for. A few things stop the merge, all small.

1. The CLI does not start (blocking). nexy/modules/cli/commands/__init__.py now imports nexy.modules.cli.commands.format_, but the file is format.py, so import nexy fails and the whole suite errors at collection. Keep the original line:

from nexy.modules.cli.commands.format import format_

2. The test patches a path that does not exist. commands/__init__.py exports the info function, so "nexy.modules.cli.commands.info.subprocess.run" resolves to an attribute of that function and pytest raises ModuleNotFoundError. Patch the module object instead:

import importlib

info_module = importlib.import_module("nexy.modules.cli.commands.info")
monkeypatch.setattr(info_module.subprocess, "run", fake_run)

3. The other 11 languages need the new keys. tests/unit/nexy/i18n/test_cli_catalogs.py checks that every catalog in nexy/modules/i18n/ has exactly the English keys. Add the info block to each of them (English text is fine for now). Also, cli.cmd.info is never read: add ("info", t("cli.cmd.info", "...")) to the list in nexy/modules/cli/overview.py, next to check, so nx shows the command.

4. Lint. ruff check tests/unit/nexy/cli/test_info.py reports unused lambda arguments; name them with a leading underscore (lambda _name: None).

5. One assertion per test (CONTRIBUTING.md). Split the two tests into one per row, for example test_info_prints_the_node_version, test_info_says_not_found_without_node, and so on; a small fixture can hold the setup they share.

6. Bug template. A few lines with only spaces are left after the info field in 01_bug_report.yml; please remove them.

Before pushing, python scripts/verify.py runs the same gates as CI. Ask here if anything is unclear, I am happy to help.

Signed-off-by: Sumaiya Shaikh <[email protected]>
@github-actions github-actions Bot added area:cli The nx command area:ci Workflows and scripts labels Nov 19, 2026
Signed-off-by: Sumaiya Shaikh <[email protected]>
@Espoir-Loem

Copy link
Copy Markdown
Member

Thanks for the update @devsumaiyask. Two points are fixed: the CLI starts again (format import) and the bug template has no trailing spaces left. Four remain before the merge; I ran them locally on your latest commit (53186de):

1. test_info.py fails. monkeypatch.setattr("nexy.modules.cli.commands.info.subprocess.run", ...) still raises ModuleNotFoundError: 'nexy.modules.cli.commands.info' is not a package, because commands/__init__.py exports the info function under that name. Patch the module object:

import importlib

info_module = importlib.import_module("nexy.modules.cli.commands.info")
monkeypatch.setattr(info_module.subprocess, "run", fake_run)

2. The 11 other catalogs. pytest tests/unit/nexy/i18n gives 13 failures: each file in nexy/modules/i18n/ other than en.json needs the same info keys (English text is fine), and cli.cmd.info must be read by nexy/modules/cli/overview.py, next to check, so nx lists the command.

3. Lint. ruff check tests/unit/nexy/cli/test_info.py reports ARG005 on the lambdas: lambda _name: None, lambda _root=None: "pnpm", lambda *_args, **_kwargs: ....

4. One assertion per test. The two tests hold 8 and 5 assertions; one test per line of output, sharing a fixture for the setup, for example test_info_prints_the_node_version and test_info_says_node_is_not_found.

python scripts/verify.py runs all of this in one command before you push. You are close!

@Espoir-Loem

Copy link
Copy Markdown
Member

Thank you @devsumaiyask, and well done on the speed: #454 was opened at 06:20 and your pull request was up two hours later, with the command, the i18n keys, the bug template and tests. That is a great first contribution to Nexy.

I ran nx info from your branch, inside a project and outside one, and it prints exactly the block the issue asked for:

Nexy        2.6.4
Python      3.13.15 (CPython)
OS          Linux 7.0.0-43-generic x86_64
Node        26.13.0
Package     bun 1.4.4
Router      file-based
Frameworks  react 19.2.5

What is left is about the tests and the other languages, not the command itself: the four points are in my comment above. Once they are pushed, I approve the CI run and merge. Ask me anything along the way.

@Espoir-Loem

Copy link
Copy Markdown
Member

Happy to adjust anything after CI runs and your review!

Thanks for this message @devsumaiyask, and sorry it waited: the review is in, and you already pushed two fixes the same day. Four small adjustments are left, listed in this comment with the exact code for the test. The CI runs as soon as you push them; I will approve it right away.

@Espoir-Loem Espoir-Loem left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@devsumaiyask, here are the four points left, each on its line (Files changed tab). Resolve each conversation once it is fixed; python scripts/verify.py checks them all before you push.

Comment thread tests/unit/nexy/cli/test_info.py Resolved
Comment thread tests/unit/nexy/cli/test_info.py Resolved
Comment thread tests/unit/nexy/cli/test_info.py Resolved
Comment thread nexy/modules/i18n/en.json Resolved
@Espoir-Loem

Copy link
Copy Markdown
Member

@devsumaiyask, I updated your branch with the latest develop (commit 8ec324e) and started the CI. Before your next push, run git pull on your develop branch, or the push will be refused. The CI will show the four points of the review as failing checks until they are fixed: that is expected.

Signed-off-by: Sumaiya Shaikh <[email protected]>
Added tests for the `nx info` command to validate output in various environments, including project and empty states.

Signed-off-by: Sumaiya Shaikh <[email protected]>
@Espoir-Loem

Copy link
Copy Markdown
Member

Great progress @devsumaiyask, and quickly done: the patch now targets the module, the tests are split one assertion each (12 tests, all passing), and the bug template is clean. Thank you!

Two points are left before the merge:

1. Lint (ARG001). The tests take the fixtures empty_env and the other one as arguments without using them, so ruff check tests/unit/nexy/cli/test_info.py reports 12 findings. Ask for them with a marker instead of an argument:

@pytest.mark.usefixtures("empty_env")
def test_info_says_package_is_not_found() -> None:
    result = runner.invoke(CLI, ["info"])
    assert "Package     not found" in result.stdout

2. The 11 other catalogs and the overview. pytest tests/unit/nexy/i18n still gives 12 failures:

  • add the info block of nexy/modules/i18n/en.json to each of the 11 other files of that folder (the English text is fine);
  • add ("info", t("cli.cmd.info", "...")) to the list in nexy/modules/cli/overview.py, next to check, so nx lists the command and the key is used.

python scripts/verify.py runs every gate of the CI before you push. You are almost there!

Signed-off-by: Sumaiya Shaikh <[email protected]>
@devsumaiyask

Copy link
Copy Markdown
Contributor Author

Hi @Espoir-Loem! All 11 other i18n catalogs (ar, de, es, fr, hi, id, ja, ko, pt, ru, zh), the en.json indentation fix, and the info entry in nexy/modules/cli/overview.py are now pushed directly onto develop (Files changed: 18). Ready for CI approval and merge!

@Espoir-Loem

Copy link
Copy Markdown
Member

Hi @devsumaiyask, good progress: on head 9c98697 the previous i18n failures are gone, and Windows (3.13), E2E, CodeQL, build and attribution are green. The 4 required jobs still red are quality (3.12/3.13/3.14/3.15), and they all fail at the same step: Diff coverage (every added line runs in a test).

From the logs (for example quality (3.12)):

error: nexy/modules/cli/commands/info.py:37 never runs in a test
error: nexy/modules/cli/commands/info.py:38 never runs in a test
error: nexy/modules/cli/commands/info.py:40 never runs in a test
error: nexy/modules/cli/commands/info.py:52 never runs in a test
error: nexy/modules/cli/commands/info.py:63 never runs in a test
error: nexy/modules/cli/commands/info.py:73 never runs in a test
error: nexy/modules/cli/commands/info.py:74 never runs in a test
error: nexy/modules/cli/commands/info.py:39 has a branch no test takes (to line 40)
error: nexy/modules/cli/commands/info.py:51 has a branch no test takes (to line 52)
error: nexy/modules/cli/commands/info.py:61 has a branch no test takes (to line 63)
10 added line(s) or branch(es) run in no test

These are the error/fallback branches in nexy/modules/cli/commands/info.py that are not exercised yet:

Case Lines / branch What to cover
Node command raises 37-38 subprocess.run raises OSError (or subprocess.SubprocessError) -> Node prints not found
Node returns non-zero 39 -> 40, 40 subprocess.run returns SimpleNamespace(returncode=1, stdout="v22.0.0\n") -> Node prints not found
Package manager without version 51 -> 52, 52 package_manager.detect returns a manager but package_manager.version returns None -> Package prints the manager name only
Router is not file-based 61 -> 63, 63 detect_profile returns a profile whose router is not "fbr" (for example "modular") -> Router prints that value
package.json unreadable/invalid 73-74 json.loads(...) fails (ValueError) or reading fails (OSError) -> Frameworks prints not found

How to fix it (one small test per case, in tests/unit/nexy/cli/test_info.py, same style as the existing ones):

  • Keep using the existing fixtures/monkeypatching pattern (package_manager.resolve/detect/version, info_module.subprocess.run, info_module.detect_profile, tmp_path + monkeypatch.chdir).
  • Example ideas:
    • Node exception: monkeypatch.setattr(info_module.subprocess, "run", lambda *_a, **_k: (_ for _ in ()).throw(OSError("boom")))
    • Node non-zero: lambda *_a, **_k: SimpleNamespace(returncode=1, stdout="")
    • Package without version: monkeypatch.setattr(package_manager, "detect", lambda _r=None: "pnpm") and monkeypatch.setattr(package_manager, "version", lambda _m: None)
    • Non-FBR router: create nexyconfig.py in tmp_path, then monkeypatch.setattr(info_module, "detect_profile", lambda _r: SimpleNamespace(router="modular"))
    • Invalid package.json: Path("package.json").write_text("{", encoding="utf-8") then call info()

Before pushing, please run:

python -m pytest tests/unit/nexy/cli/test_info.py -q
python -m pytest tests/unit/nexy/i18n/test_cli_catalogs.py -q
ruff check tests/unit/nexy/cli/test_info.py nexy/modules/cli/commands/info.py
python scripts/verify.py

(scripts/verify.py runs the same gates as CI, including diff coverage.) Then git pull on your branch if needed and push to devsumaiyask/nexy:develop.

If you use an AI coding assistant, you can ask it to inspect and fix this PR directly with gh, for example: gh pr checks 477, gh run view 44801559521 --job 136518220268 --log-failed, then add the missing tests in tests/unit/nexy/cli/test_info.py, run the commands above, and commit/push the fix. If you prefer to do it by hand, the table above lists exactly which branches still need a test. Once these 10 lines/branches are covered, the 4 quality jobs should turn green.

Signed-off-by: Sumaiya Shaikh <[email protected]>
Removed unused fixture from test_info.py.

Signed-off-by: Sumaiya Shaikh <[email protected]>
@devsumaiyask

Copy link
Copy Markdown
Contributor Author

Hi @Espoir-Loem! Added the 5 unit tests in tests/unit/nexy/cli/test_info.py covering all remaining error and fallback branches (OSError, non-zero exit code, missing package manager version, non-fbr router, and invalid package.json). Hope all set to go now

@Espoir-Loem

Copy link
Copy Markdown
Member

Congratulations @devsumaiyask, and thank you for this first contribution. is a solid addition: the command is clear, the fallbacks are covered, the tests now exercise every branch, and the CI is fully green.

Approving and merging this now. This closes #454.

@devsumaiyask

Copy link
Copy Markdown
Contributor Author

Thank you so much @Espoir-Loem for the thorough review and guidance throughout! Learned a lot about Ruff, single-assertion pytest patterns, and diff coverage. Glad to contribute! 🙌

@Espoir-Loem

Copy link
Copy Markdown
Member

Thank you @devsumaiyask, that means a lot. This is exactly what the Nexy community is about: learning together and building together. Every contribution, every question, and every review is part of that.

If you feel like it, share your experience and invite others to join in, whether they are junior, senior, or just curious. Nexy is for everyone: whether you want to build projects quickly with AI or by hand, the goal is to give you a tool that fits your needs.

You can follow Nexy and help grow the community here:

And of course, you are always welcome to pick another issue, share feedback, or help someone else get started. Looking forward to seeing you around.

@Espoir-Loem
Espoir-Loem merged commit 27fa219 into NexyPy:develop Nov 20, 2026
1 check passed
@Espoir-Loem Espoir-Loem mentioned this pull request Nov 21, 2026
1 of 6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci Workflows and scripts area:cli The nx command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants