feat: add print option to phpMyAdmin command to output URL to stdout#2760
feat: add print option to phpMyAdmin command to output URL to stdout#2760spenserhale wants to merge 1 commit intoAutomattic:trunkfrom
Conversation
|
There was a problem hiding this comment.
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 inPhpMyAdminCommandrefactored to accept an options object{ silent, print }, with--printmode printing the URL to stdout instead of callingopenUrl.vip-db-phpmyadmin.tsupdated to register the--printCLI option and pass it through tocmd.run().- A new test case added to verify the
--printbehavior and thenpm-shrinkwrap.jsonupdated 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
| if ( print ) { | ||
| // Output only the URL to stdout for scripting/automation use | ||
| console.log( url ); |
There was a problem hiding this comment.
When --print is used for scripting or piping (e.g., vip ... --print | pbcopy), the output will be contaminated by other messages written to stdout:
- The yellow "Note: PHPMyAdmin sessions are read-only..." message at line 183 is unconditionally written to
console.log(stdout). - The progress tracker (
singleLogLine, which targetsprocess.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.



Description
Adds a
--printoption tovip db phpmyadminthat 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--printoption 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
npm install && npm run build../dist/bin/vip-db-phpmyadmin.js @<app>.<env> --helpand verify--printappears in the options list../dist/bin/vip-db-phpmyadmin.js @<app>.<env>(without--print) and verify it opens phpMyAdmin in the default browser as before../dist/bin/vip-db-phpmyadmin.js @<app>.<env> --printand verify the URL is printed to stdout and no browser is opened.npx jest --forceExit __tests__/commands/phpmyadmin.tsand verify all tests pass.