fix: correct wpcli invocation (--profile cli + safe arg passing in kiqr wp) - #24
Merged
Merged
Conversation
…qr wp) (a) buildWpCliArgs now inserts `--profile cli` before the `run` subcommand. The wpcli compose service declares `profiles: ['cli']` (BitnamiRuntimeProvider), and on Docker Compose v2 a profiled service targeted by `run` may not start unless its profile is enabled. The flag is positioned before `run` so it takes effect, and is safe regardless of the Compose version. This also covers `kiqr db dump`/`db restore`, which go through buildWpCliArgs via spawnWpCli. (b) `kiqr wp` previously built a shell string and passed it to execSync, which mangled arguments containing spaces/quotes/special characters (e.g. `--post_title="Hello World"`). It now uses a new array-based, shell-free helper (runWpCliInherit) that spawns docker with an args array and inherits stdio so output still streams to the terminal. The raw process args are forwarded verbatim, and the no-args `--help` path is preserved. The readProjectConfig() call is wrapped in try/catch so an invalid config surfaces a clear message instead of crashing. Tests for buildWpCliArgs are updated to expect `--profile cli`, assert the flag precedes `run`, and confirm args are passed verbatim. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Two related fixes to how WP-CLI is invoked.
(a) Enable the
cliprofile for the wpcli servicebuildWpCliArgs(src/lib/wpcli.ts) returned:but the
wpclicompose service declaresprofiles: ['cli'](seesrc/providers/BitnamiRuntimeProvider.ts). On Docker Compose v2, a profiled service targeted byrunmay not start unless its profile is enabled. We now insert--profile clibefore therunsubcommand (where it takes effect):This also fixes
kiqr db dump/db restore, which route throughbuildWpCliArgsviaspawnWpCli. The flag is safe to add regardless of Compose version.(b) Safe argument passing in
kiqr wpsrc/commands/wp.tsxbuilt a shell command string and ran it withexecSync:Joining args into a shell string mangles values containing spaces, quotes, or special characters (e.g.
kiqr wp post create --post_title="Hello World"). It now uses a new array-based, shell-free helperrunWpCliInherit(added towpcli.ts), which spawnsdockerwith an args array and inherits stdio so output still streams to the terminal. The raw process args are forwarded verbatim, and the no-args--helppath is preserved. ThereadProjectConfig()call is wrapped in try/catch so an invalid config surfaces a clear message instead of crashing.Tests
tests/lib/wpcli.test.tsupdated to expect--profile cli, assert the flag precedesrun, and confirm args are passed verbatim as separate array elements.Smoke test note
The
--profile clibehavior is Docker-Compose-version-dependent. No Docker daemon was available in this environment, so this should get a quick realkiqr db dumpsmoke test on a Docker machine to confirm. The flag is safe to add regardless.Gates
npm run typecheck✅npm test✅ (194 passed)npm run build✅npm run lint✅🤖 Generated with Claude Code