feat: db push prefix-safety + URL remap, sync mirror/webroot, exec shell & MOTD fix#4
Merged
Merged
Conversation
…ec shell & MOTD fix Addresses validated feedback from a LocalWP -> cloud mirror-overwrite workflow: - db push: detect table-prefix mismatch (warn + offer rewrite); --rewrite-prefix remaps dump table identifiers + role/capability keys so admin login survives - db push: --search-replace <from> <to> (serialization-safe, runs post-import) - wp/exec: strip server login banner/MOTD from stdout and the --json payload - exec: --shell '<cmdline>' for pipes/;/>/globs; fix misleading help example - sync push/pull: --delete (mirror, confirm-guarded) + --remote-path/--webroot - versions create: echo the identifier the user typed in restore/list hints Pure helpers extracted to lib/sql-dump.ts, lib/remote-command.ts, lib/paths.ts with 27 new unit tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
Re-test feedback (#11, #12): - db push success summary prints readable "from -> to" for rewrote_prefix and search_replaced instead of "[object Object]" - --search-replace now passes --skip-columns=guid (post GUIDs are permanent identifiers, not links — WP best practice); same applied to local push --with-db Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
Contributor
Re-test update (2026-06-23)The tester rebuilt from this branch and re-ran against a real LocalWP → cloud mirror-overwrite. 7 of 10 validated fixed, including the High-severity #1 (real push: detected mismatch, rewrote prefix, remapped cap keys, 0 orphan tables) and #6 (235 replacements, 0 residual localhost). Two new minor findings from the re-test are now fixed in
Remaining from the original 10:
|
Closes the last open item from the CLI feedback. `exec --stdin` forwards the local process's stdin to the remote command (uploads, restore pipes, `tar czf - dir | exec --stdin 'tar xzf -'`). Implemented as an explicit opt-in flag so the default wp/exec path is unchanged (no regression risk to the command-via-stdin delivery the servers expect). The --stdin path passes the command as an ssh argument — freeing stdin to stream — and as a side effect runs a non-login remote shell, so it emits no MOTD. Text mode inherits stdio for binary-safe real-time passthrough; JSON mode captures. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
Finalize CHANGELOG header and bump version for the CLI-feedback fixes (db push prefix-safety/--search-replace, MOTD strip, exec --shell/--stdin, sync --delete/--webroot/--remote-path, versions identifier echo). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses validated feedback from a real LocalWP → cloud mirror-overwrite workflow (each item was checked against the source and adversarially re-reviewed before implementing).
Changes
$table_prefix; warns loudly and offers to rewrite.--rewrite-prefixremaps the dump's table identifiers (streamed; leaves data values untouched) and, post-import, remaps the prefix-bound role/capability keys ({prefix}capabilities,{prefix}user_level,{prefix}user_roles) so admin login survives. Under--force/--jsonit warns and proceeds (back-compat).--search-replace <from> <to>runs serialization-safewp search-replace --all-tablesafter import.wp/execstdout--jsonmodes. Exit code unaffected.exec --shell '<cmdline>'wraps args inbash -lc(pipes/;/>/globs). Replaced the deceptive-- ps aux | grep phpexample (which piped locally) and added a metacharacter note.--deleteon push/pull (true mirror), confirmation-guarded (--yesto skip,--dry-runto preview); additive stays default; errors clearly on Windows/SFTP.--remote-path <path>/--webrooton sync push/pull.versions createechoes the restore/list hint with the identifier you typed.Implementation notes
lib/sql-dump.ts(prefix detect/rewrite),lib/remote-command.ts(command build + MOTD slice), andbuildRemotePath→lib/paths.ts— matching the existingpaths.ts/local-instance.tspattern.--rewrite-prefixflow reuses the same role/capability-key remap thatlocal push --with-dbalready does.Tests
sql-dump,remote-command,sync-remote-path),tscclean, help output verified.sqlite-to-mysql) are environmental —better-sqlite3built against a different Node version (npm rebuild better-sqlite3), unrelated to this PR.Deliberately deferred
spawnSync'sinputalready owns ssh's stdin to deliver the command); separate, riskier change.--jsonargv-strip bug inindex.ts(a bare--jsonmeant for WP-CLI is stripped globally) — left untouched to keep scope tight.🤖 Generated with Claude Code