Skip to content

[CLI-util] Replace Xdebug console logs with CLI output#3460

Merged
mho22 merged 2 commits intotrunkfrom
replace-xdebug-console-logs-with-cli-output
Apr 28, 2026
Merged

[CLI-util] Replace Xdebug console logs with CLI output#3460
mho22 merged 2 commits intotrunkfrom
replace-xdebug-console-logs-with-cli-output

Conversation

@mho22
Copy link
Copy Markdown
Collaborator

@mho22 mho22 commented Apr 2, 2026

Motivation for the change, related issues

Both @php-wasm/cli and @wp-playground/cli duplicate the same inline ANSI formatting helpers and use raw console.log calls for Xdebug output. This makes the output inconsistent across CLIs and harder to maintain.

This pull request extracts a shared CLIOutput base class into @php-wasm/cli-util and replaces all Xdebug-related console.log calls with it in both CLIs.

Implementation details

  • New CLIOutput class in @php-wasm/cli-util : provides TTY-aware ANSI formatting and generic output methods. Uses a configurable writeStream and respects a verbosity setting.
  • @php-wasm/cli: removed standalone formatting functions and /* eslint-disable no-console */. Imports CLIOutput from @php-wasm/cli-util directly. All Xdebug console.log calls replaced with cliOutput.print().
  • @wp-playground/cli : the existing CLIOutput class now extends the base from @php-wasm/cli-util, removing its duplicated private formatting methods. Playground-specific methods remain. Standalone formatting functions in run-cli.ts removed. All Xdebug console.log calls replaced with cliOutput method calls.
  • Tests added for the base CLIOutput class covering formatting, output methods, quiet mode suppression, and getter behavior.

Testing Instructions (or ideally a Blueprint)

CLI

🧪 packages/php-wasm/cli-util/src/test/cli-output.spec.ts

@mho22 mho22 requested a review from a team April 2, 2026 23:23
Copilot AI review requested due to automatic review settings April 2, 2026 23:23
@mho22 mho22 requested review from bgrgicak and removed request for Copilot April 2, 2026 23:23
@mho22
Copy link
Copy Markdown
Collaborator Author

mho22 commented Apr 2, 2026

8 console.log remain in the packages/playground/cli/src/run-cli.ts. I am not sure I should replace them with cliOutput here.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done.

Comment thread packages/playground/cli/src/run-cli.ts Outdated
@bgrgicak
Copy link
Copy Markdown
Collaborator

8 console.log remain in the packages/playground/cli/src/run-cli.ts. I am not sure I should replace them with cliOutput here.

Let's replace the rest while we are working on it, otherwise in the future we will wonder if we should use console.log or CLIOutput.

Copy link
Copy Markdown
Collaborator

@bgrgicak bgrgicak left a comment

Choose a reason for hiding this comment

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

I left a couple of comments that we should address before merging, but overall it works as expected.

@mho22 mho22 force-pushed the replace-xdebug-console-logs-with-cli-output branch from b4bc306 to 799884e Compare April 27, 2026 08:41
Copilot AI review requested due to automatic review settings April 27, 2026 08:41
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.

This PR standardizes CLI terminal output by introducing a shared CLIOutput base in @php-wasm/cli-util and migrating Xdebug-related messages away from raw console.log, improving consistency and maintainability across CLIs.

Changes:

  • Added shared CLIOutput (TTY-aware formatting + print helpers) to @php-wasm/cli-util with accompanying tests.
  • Updated @php-wasm/cli and @wp-playground/cli to use CLIOutput for Xdebug messaging and removed duplicated inline ANSI helpers.
  • Refactored Playground CLI’s output class to extend the shared base class.

Reviewed changes

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

Show a summary per file
File Description
packages/playground/cli/src/run-cli.ts Removes inline ANSI helpers, routes Xdebug + start-command output through CLIOutput.
packages/playground/cli/src/cli-output.ts Refactors Playground output to extend shared base; trims duplicated formatter logic.
packages/php-wasm/cli/src/main.ts Replaces Xdebug-related console.log with shared CLIOutput calls.
packages/php-wasm/cli-util/src/test/cli-output.spec.ts Adds unit tests for shared CLIOutput formatting and output behavior.
packages/php-wasm/cli-util/src/lib/index.ts Exports new shared CLIOutput from package entrypoint.
packages/php-wasm/cli-util/src/lib/cli-output.ts Introduces shared CLIOutput implementation (formatters + print helpers).

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

Comment thread packages/php-wasm/cli-util/src/lib/cli-output.ts
Comment thread packages/playground/cli/src/run-cli.ts
Comment thread packages/php-wasm/cli/src/main.ts Outdated
Comment thread packages/playground/cli/src/run-cli.ts Outdated
Comment thread packages/php-wasm/cli/src/main.ts Outdated
@mho22 mho22 force-pushed the replace-xdebug-console-logs-with-cli-output branch 2 times, most recently from 35eb157 to b90cd42 Compare April 27, 2026 11:00
@mho22
Copy link
Copy Markdown
Collaborator Author

mho22 commented Apr 27, 2026

@bero Thanks for the review! 3 new failing tests but they are not related to this pull request. I think I can merge.

@mho22 mho22 force-pushed the replace-xdebug-console-logs-with-cli-output branch from b90cd42 to deb08c3 Compare April 28, 2026 06:26
@mho22 mho22 merged commit 327f7e8 into trunk Apr 28, 2026
46 of 47 checks passed
@mho22 mho22 deleted the replace-xdebug-console-logs-with-cli-output branch April 28, 2026 06:51
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.

3 participants