Skip to content

feat: add print option to phpMyAdmin command to output URL to stdout#2760

Open
spenserhale wants to merge 1 commit intoAutomattic:trunkfrom
spenserhale:add/print-option-phpmyadmin
Open

feat: add print option to phpMyAdmin command to output URL to stdout#2760
spenserhale wants to merge 1 commit intoAutomattic:trunkfrom
spenserhale:add/print-option-phpmyadmin

Conversation

@spenserhale
Copy link

Description

Adds a --print option to vip db phpmyadmin that outputs the phpMyAdmin URL to stdout instead of automatically opening it in the default browser. This is useful for opening in a non-default, i.e. ie specific browser. In my use case, there were networking issues, and I could not easily debug Chrome network logs in the browser when the auto-opened link was used. Additional use cases are scripting, automation, and piping to clipboard utilities.

Changelog Description

Added

  • vip db phpmyadmin: Added --print option to output the phpMyAdmin URL to stdout instead of opening it in a browser.

Pull request checklist

Pull request checklist (skipped, no changes)

New release checklist

Steps to Test

  1. Check out PR.
  2. Run npm install && npm run build.
  3. Run ./dist/bin/vip-db-phpmyadmin.js @<app>.<env> --help and verify --print appears in the options list.
  4. Run ./dist/bin/vip-db-phpmyadmin.js @<app>.<env> (without --print) and verify it opens phpMyAdmin in the default browser as before.
  5. Run ./dist/bin/vip-db-phpmyadmin.js @<app>.<env> --print and verify the URL is printed to stdout and no browser is opened.
  6. Verify the printed URL is valid by pasting it into a browser manually.
  7. Run npx jest --forceExit __tests__/commands/phpmyadmin.ts and verify all tests pass.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 6, 2026

@sjinks sjinks requested a review from Copilot March 9, 2026 04:41
sjinks
sjinks previously approved these changes Mar 9, 2026
@sjinks sjinks added the [Status] Needs Docs The feature or update requires an update to our public VIP Documentation label Mar 9, 2026
@sjinks sjinks requested a review from yolih March 9, 2026 04:42
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 adds a --print option to the vip db phpmyadmin command that outputs the generated phpMyAdmin URL to stdout instead of automatically opening it in the default browser, enabling scripting, automation, and piping workflows.

Changes:

  • run() method in PhpMyAdminCommand refactored to accept an options object { silent, print }, with --print mode printing the URL to stdout instead of calling openUrl.
  • vip-db-phpmyadmin.ts updated to register the --print CLI option and pass it through to cmd.run().
  • A new test case added to verify the --print behavior and the npm-shrinkwrap.json updated with a routine production/dev dependency reclassification.

Reviewed changes

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

File Description
src/commands/phpmyadmin.ts Adds print option to run(), conditionally printing URL to stdout or opening browser
src/bin/vip-db-phpmyadmin.ts Registers --print CLI flag and passes it to the command
__tests__/commands/phpmyadmin.ts Adds test for --print behavior
npm-shrinkwrap.json Routine dependency reclassification (minimatch moved from dev to production)
Files not reviewed (1)
  • npm-shrinkwrap.json: Language not supported

Comment on lines +234 to +236
if ( print ) {
// Output only the URL to stdout for scripting/automation use
console.log( url );
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

When --print is used for scripting or piping (e.g., vip ... --print | pbcopy), the output will be contaminated by other messages written to stdout:

  1. The yellow "Note: PHPMyAdmin sessions are read-only..." message at line 183 is unconditionally written to console.log (stdout).
  2. The progress tracker (singleLogLine, which targets process.stdout) outputs step status during execution.

This means the piped content will include this extra text alongside the URL, breaking the scripting/automation use case that is the primary motivation for --print. The URL won't be cleanly isolated in stdout.

To fix this, when print is true, the informational messages and progress tracker output should be suppressed or redirected to stderr. For example, you could use process.stderr.write(...) for the read-only note and progress tracker when in --print mode, or leverage the existing silent mechanism for those messages.

Copilot uses AI. Check for mistakes.
@sjinks sjinks self-requested a review March 9, 2026 04:58
@sjinks sjinks dismissed their stale review March 9, 2026 04:59

Copilot's comments

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

Labels

[Status] Needs Docs The feature or update requires an update to our public VIP Documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants