Repository navigation
feat(cli): add nx info command - #477
Conversation
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]>
Signed-off-by: Sumaiya Shaikh <[email protected]>
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]>
|
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
left a comment
There was a problem hiding this comment.
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]>
Signed-off-by: Sumaiya Shaikh <[email protected]>
|
Thanks for the update @devsumaiyask. Two points are fixed: the CLI starts again ( 1. 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. 3. Lint. 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
|
|
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 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. |
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
left a comment
There was a problem hiding this comment.
@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.
|
@devsumaiyask, I updated your branch with the latest |
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]>
|
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 @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.stdout2. The 11 other catalogs and the overview.
|
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]>
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]>
Signed-off-by: Sumaiya Shaikh <[email protected]>
Signed-off-by: Sumaiya Shaikh <[email protected]>
|
Hi @Espoir-Loem! All 11 other i18n catalogs ( |
|
Hi @devsumaiyask, good progress: on head From the logs (for example quality (3.12)): These are the error/fallback branches in
How to fix it (one small test per case, in
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( If you use an AI coding assistant, you can ask it to inspect and fix this PR directly with |
Signed-off-by: Sumaiya Shaikh <[email protected]>
Removed unused fixture from test_info.py. Signed-off-by: Sumaiya Shaikh <[email protected]>
|
Hi @Espoir-Loem! Added the 5 unit tests in |
|
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. |
|
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! 🙌 |
|
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. |
Closes #454 — Adds the nx info command, i18n keys, updated bug report template, and unit tests.