Skip to content

[CLI] make --no-auto-mount actually disable auto-detection on start#3503

Merged
ashfame merged 4 commits intotrunkfrom
fix/cli-no-auto-mount
Apr 21, 2026
Merged

[CLI] make --no-auto-mount actually disable auto-detection on start#3503
ashfame merged 4 commits intotrunkfrom
fix/cli-no-auto-mount

Conversation

@pento
Copy link
Copy Markdown
Member

@pento pento commented Apr 17, 2026

Motivation for the change, related issues

The documented invocation wp-playground start --no-auto-mount fails with Unknown arguments: auto-mount, autoMount, so there is no way to disable auto-detection on the start command.

Root cause: the start command declared a literal no-auto-mount boolean option. yargs-parser's built-in boolean-negation (combined with camel-case-expansion) rewrites --no-auto-mount into { "auto-mount": false, autoMount: false } against an undefined auto-mount option. With strictOptions() enforced, those phantom keys get rejected as unknown.

Implementation details

  • Rename the option from no-auto-mount (boolean, default false) to auto-mount (boolean, default true) on the start command. yargs-parser's negation now matches a defined option, so --no-auto-mount parses cleanly as { autoMount: false } — no phantom keys, no strictOptions rejection. --auto-mount=false and --noAutoMount also continue to work.
  • Update expandStartCommandArgs to gate on args.autoMount !== false. Because yargs stores the boolean in the same autoMount property the server command uses for a string path, the boolean form is scrubbed before any downstream consumer sees it.
  • Widen RunCLIArgs.autoMount to string | boolean (start = boolean toggle; server & friends = string path). Drop the now-unused RunCLIArgs.noAutoMount. No public consumers of noAutoMount were found inside the monorepo.
  • Guard the shared .check() path-validation block so the "not a directory" check only runs for subcommands where --auto-mount is a string. Otherwise the start command's boolean true would be fed to fs.statSync() and blow up.

Alternative I considered but rejected: disabling boolean-negation on the yargs instance. That would silently change the semantics of every other --no-X flag in the CLI — broader blast radius than a targeted rename.

Testing Instructions (or ideally a Blueprint)

Automated:

  • npx nx typecheck playground-cli
  • npx nx lint playground-cli
  • npx nx test-playground-cli playground-cli --testFile=mounts.spec.ts — confirms mount logic is untouched (20/20 pass).
  • npx nx test-playground-cli playground-cli --testNamePattern="--no-auto-mount" — new integration test boots start --no-auto-mount via parseOptionsAndRunCLI, asserts the server URL comes up, and asserts the sample-plugin directory is not mounted under /wordpress/wp-content/plugins/. Requires network (WordPress download), so it runs in CI rather than offline.

Manual:

  1. npx nx build playground-cli
  2. In a scratch dir with a plugin file (my-plugin.php with a Plugin Name: header):
    • wp-playground start --no-auto-mount --path=./ — server boots; the plugin is not visible under /wordpress/wp-content/plugins/.
    • wp-playground start --path=./ — server boots; the plugin is auto-mounted and activated (default behavior, unchanged).
    • wp-playground start --auto-mount=false --path=./ — equivalent to --no-auto-mount.
    • wp-playground start --noAutoMount --path=./ — the legacy camelCase workaround still works.
  3. wp-playground start --help shows --auto-mount (with its describe text noting --no-auto-mount disables it) instead of the old --no-auto-mount entry.

The `start` command declared a literal `no-auto-mount` boolean option, which
collided with yargs-parser's built-in boolean-negation: `--no-auto-mount` was
parsed as `{ autoMount: false }` against an undefined `auto-mount` option,
so strictOptions rejected it with `Unknown arguments: auto-mount, autoMount`.

Rename the option to a naturally-negatable `auto-mount` boolean that defaults
to true, update `expandStartCommandArgs` to gate on `args.autoMount \!== false`,
and guard the shared `--auto-mount` path validation so it only runs for
subcommands where the option is a string path.
@pento pento requested review from a team, ashfame and Copilot April 17, 2026 00:12
Copy link
Copy Markdown
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

Note

Copilot was unable to run its full agentic suite in this review.

Fixes wp-playground start --no-auto-mount failing under strictOptions() by aligning the start command’s option definition with yargs-parser’s built-in boolean negation behavior.

Changes:

  • Renames start’s no-auto-mount option to auto-mount (default true) so --no-auto-mount parses without “unknown arguments”.
  • Updates start-arg expansion to enable auto-mount unless args.autoMount === false, and widens RunCLIArgs.autoMount to string | boolean.
  • Adds an integration regression test covering start --no-auto-mount.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
packages/playground/cli/tests/run-cli.spec.ts Adds regression/integration test asserting --no-auto-mount is accepted and skips automount detection.
packages/playground/cli/src/run-cli.ts Updates yargs option definitions, shared validation, and start arg expansion to support boolean-negation semantics.
packages/playground/cli/src/mounts.ts Adapts auto-mount expansion to the updated autoMount type.

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

Comment thread packages/playground/cli/src/run-cli.ts
Comment thread packages/playground/cli/src/run-cli.ts
Comment thread packages/playground/cli/src/mounts.ts Outdated
@pento pento requested a review from Copilot April 17, 2026 01:56
Copy link
Copy Markdown
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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.


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

Comment thread packages/playground/cli/src/run-cli.ts
Comment thread packages/playground/cli/tests/run-cli.spec.ts
Comment thread packages/playground/cli/tests/run-cli.spec.ts Outdated
@pento pento changed the title fix(cli): make --no-auto-mount actually disable auto-detection on start [CLI] make --no-auto-mount actually disable auto-detection on start Apr 17, 2026
Copy link
Copy Markdown
Member

@ashfame ashfame left a comment

Choose a reason for hiding this comment

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

@pento Thanks for the contribution! 😄

@ashfame ashfame merged commit a86fac8 into trunk Apr 21, 2026
47 checks passed
@ashfame ashfame deleted the fix/cli-no-auto-mount branch April 21, 2026 14:02
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