Skip to content

CLI-1731: ACLI documentation expose MEO commands that should be hidden#1970

Open
jigar-shah-acquia wants to merge 3 commits intoacquia:mainfrom
jigar-shah-acquia:CLI-1731
Open

CLI-1731: ACLI documentation expose MEO commands that should be hidden#1970
jigar-shah-acquia wants to merge 3 commits intoacquia:mainfrom
jigar-shah-acquia:CLI-1731

Conversation

@jigar-shah-acquia
Copy link
Contributor

Motivation

Fixes #CLI-1731 ACLI documentation expose MEO commands that should be hidden


Proposed changes

  • src/Command/Api/ApiCommandHelper.php

    • generateApiListCommands(): Replaced the inner loop that used break with a call to a new helper. Visibility is now computed via namespaceHasVisibleCommand().
    • New namespaceHasVisibleCommand(array $apiCommands, string $namespace): bool: Encapsulates “does this namespace have at least one non-hidden command?” and uses early return true instead of break, removing the Break_ mutation at that site.
    • No change in end-user behavior; list commands are still created only for namespaces that have at least one visible command.
  • src/Command/Self/MakeDocsCommand.php

    • execute(): Replaced inline $command['hidden'] ?? false with self::isCommandHiddenInDocs($command).
    • New isCommandHiddenInDocs(array $command): bool: Public static helper that returns $command['hidden'] ?? false so the “hidden in docs” rule is testable and the FalseValue/Coalesce mutations can be killed by direct unit tests.
    • No change in behavior: commands without a hidden key are still included; commands with hidden => true are still excluded.

Alternatives considered

N/A

Testing steps

  1. Follow the contribution guide to set up your development environment or download a pre-built acli.phar for this PR.
  2. If running from source, clear the kernel cache to pick up new and changed commands: ./bin/acli ckc
  3. Check for regressions
    • Run the full PHPUnit suite: ./vendor/bin/phpunit
    • Run API list–related tests: ./vendor/bin/phpunit tests/phpunit/src/Commands/Api/ApiCommandHelperTest.php tests/phpunit/src/Commands/Api/ApiListCommandTest.php
    • Run docs-related tests: ./vendor/bin/phpunit tests/phpunit/src/Commands/Self/MakeDocsCommandTest.php
    • From source, run ./bin/acli api and ./bin/acli api:accounts (or another namespace) and confirm list output and subcommands are unchanged.
  4. Check new functionality
    • Run Infection (if configured) and confirm the previously surviving mutations in ApiCommandHelper.php (e.g. LogicalAnd, ConcatOperandRemoval, Break_) and MakeDocsCommand.php (FalseValue, Coalesce) are killed.
    • Optionally run docs dump and confirm hidden commands are excluded and non-hidden are included: ./bin/acli self:make-docs --dump=/tmp/acli-docs and inspect index.json and presence/absence of self:make-docs.json.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses CLI-1731 by ensuring hidden commands are excluded from generated ACLI documentation, and adds targeted unit tests to lock in the intended “hidden in docs” and API namespace visibility behavior.

Changes:

  • Update docs generation to skip commands marked as hidden in the Symfony JSON descriptor output.
  • Refactor API list-command generation to use a helper for “namespace has at least one visible command”.
  • Add/extend PHPUnit coverage to verify hidden-command exclusion and API namespace list-command creation behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/Command/Self/MakeDocsCommand.php Filters out hidden commands during JSON docs dump via isCommandHiddenInDocs() helper.
tests/phpunit/src/Commands/Self/MakeDocsCommandTest.php Adds tests to validate hidden-command handling and exclusion from dumped docs/index.
src/Command/Api/ApiCommandHelper.php Refactors namespace visibility check into namespaceHasVisibleCommand() and gates list-command creation on visibility.
tests/phpunit/src/Commands/Api/ApiCommandHelperTest.php Adds new tests for list-command creation rules based on namespace visibility/hidden state.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.33%. Comparing base (3103257) to head (ff845c1).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1970      +/-   ##
============================================
+ Coverage     92.30%   92.33%   +0.02%     
- Complexity     1921     1927       +6     
============================================
  Files           122      122              
  Lines          7009     7015       +6     
============================================
+ Hits           6470     6477       +7     
+ Misses          539      538       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link

Try the dev build for this PR: https://acquia-cli.s3.amazonaws.com/build/pr/1970/acli.phar

curl -OL https://acquia-cli.s3.amazonaws.com/build/pr/1970/acli.phar
chmod +x acli.phar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants