fix: preserve custom database scripts#867
Conversation
Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
There was a problem hiding this comment.
Code Review
This pull request updates the package.json generator to preserve custom database scripts instead of unconditionally overwriting them with generated wb commands. A test has been added to verify this behavior. The reviewer pointed out that the regular expression used to identify generated scripts is too loose and could accidentally overwrite custom wrapper scripts, and provided a more precise regex suggestion.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| function isGeneratedDatabaseScript(script: string): boolean { | ||
| return /\bwb\s+(?:db|prisma)\b/u.test(script); | ||
| } |
There was a problem hiding this comment.
The current regular expression /�wb\s+(?:db|prisma)�/u is too loose. If a repository has a custom database script that wraps or chains a wb command (for example, node setup.js && wb db migrate or wb db migrate && node cleanup.js), it will be incorrectly identified as a generated script and overwritten.
To prevent overwriting these custom wrappers, make the regex match only the exact generated script formats (allowing for an optional bun --bun prefix).
| function isGeneratedDatabaseScript(script: string): boolean { | |
| return /\bwb\s+(?:db|prisma)\b/u.test(script); | |
| } | |
| function isGeneratedDatabaseScript(script: string): boolean { | |
| return /^(?:bun\s+--bun\s+)?wb\s+(?:db|prisma)\s+(?:migrate-dev|migrate(?:\s+--check-idempotency)?|studio)$/u.test(script); | |
| } |
Customer Summary
wbfy.Technical Summary
wb dborwb prismacommands.wbdatabase scripts in place for projects without custom scripts.Why
wbfytomoti-aireplaced its custom migration wrapper with a genericwb db migratecommand.Testing
yarn vitest test/packageJson.test.tsyarn verify