From 73fbd4d2ffd6ecac71b59990ff2c37980cdec970 Mon Sep 17 00:00:00 2001 From: "Sakamoto, Kazunori" Date: Wed, 29 Apr 2026 21:02:21 +0900 Subject: [PATCH 1/7] fix: improve wb test command Co-authored-by: WillBooster (Codex CLI) --- packages/wb/src/commands/test.ts | 2 +- .../wb/src/scripts/execution/baseScripts.ts | 10 ++++++-- .../scripts/execution/httpServerScripts.ts | 24 +++++++++++-------- .../execution/httpServerScripts.test.ts | 5 ++-- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/packages/wb/src/commands/test.ts b/packages/wb/src/commands/test.ts index 0f379d1df..9a9f9e6af 100644 --- a/packages/wb/src/commands/test.ts +++ b/packages/wb/src/commands/test.ts @@ -243,7 +243,7 @@ function getDefaultUnitTargets(project: Project): string[] | false { return []; } if (project.hasVitest && fs.existsSync(path.join(project.dirPath, 'test'))) { - return ['test']; + return fs.existsSync(path.join(project.dirPath, 'test', 'e2e')) ? ['test', '--exclude', 'test/e2e/**'] : ['test']; } return false; } diff --git a/packages/wb/src/scripts/execution/baseScripts.ts b/packages/wb/src/scripts/execution/baseScripts.ts index 4e5e6a594..662fcf403 100644 --- a/packages/wb/src/scripts/execution/baseScripts.ts +++ b/packages/wb/src/scripts/execution/baseScripts.ts @@ -6,6 +6,7 @@ import { buildShellCommand, buildShellEnvironmentAssignment } from '../../utils/ import type { ScriptArgv } from '../builder.js'; import { toDevNull } from '../builder.js'; import { dockerScripts } from '../dockerScripts.js'; +import { drizzleScripts } from '../drizzleScripts.js'; import { prismaScripts } from '../prismaScripts.js'; export interface TestE2EOptions { @@ -88,11 +89,16 @@ export abstract class BaseScripts { ecosystemConfigPath === undefined ? [ `YARN wb buildIfNeeded ${argv.verbose ? '--verbose' : ''}`.trim(), - `node dist/index.js ${argv.normalizedArgsText ?? ''}`.trim(), + `${project.isBunAvailable ? 'BUN' : 'node'} dist/index.js ${argv.normalizedArgsText ?? ''}`.trim(), ] : [project.buildCommand, `pm2-runtime start --no-autorestart ${ecosystemConfigPath}`]; - return [...(project.hasPrisma ? prismaScripts.migrate(project).split('&&') : []), ...commands] + const migrationCommand = project.hasPrisma + ? prismaScripts.migrate(project) + : project.hasDrizzle + ? drizzleScripts.migrate(project) + : ''; + return [...migrationCommand.split('&&'), ...commands] .filter(Boolean) .map((cmd) => `${cmd} ${toDevNull(argv)}`.trim()) .join(' && '); diff --git a/packages/wb/src/scripts/execution/httpServerScripts.ts b/packages/wb/src/scripts/execution/httpServerScripts.ts index 4131980f9..64b382db1 100644 --- a/packages/wb/src/scripts/execution/httpServerScripts.ts +++ b/packages/wb/src/scripts/execution/httpServerScripts.ts @@ -33,6 +33,19 @@ class HttpServerScripts extends BaseScripts { const port = await checkAndKillPortProcess(project.env.PORT, project); const suffix = project.packageJson.scripts?.['test/e2e-additional'] ? ' && YARN test/e2e-additional' : ''; const targets = argv.targets?.map(String); + const testCommand = project.hasVitest + ? buildShellCommand([ + 'vitest', + 'run', + ...(targets && targets.length > 0 ? targets : ['test/e2e/']), + '--color', + '--passWithNoTests', + '--allowOnly', + ...(argv.bail ? ['--bail=1'] : []), + ]) + : project.isBunAvailable + ? buildShellCommand(['bun', 'test', ...(targets && targets.length > 0 ? targets : ['test/e2e/'])]) + : 'echo "No tests."'; return buildShellCommand([ 'YARN', 'wb', @@ -42,16 +55,7 @@ class HttpServerScripts extends BaseScripts { '--success', 'first', `${startCommand} && exit 1`, - `wait-on -t 600000 -i 2000 http-get://127.0.0.1:${port} - && ${buildShellCommand([ - 'vitest', - 'run', - ...(targets && targets.length > 0 ? targets : ['test/e2e/']), - '--color', - '--passWithNoTests', - '--allowOnly', - ...(argv.bail ? ['--bail=1'] : []), - ])}${suffix}`, + `wait-on -t 600000 -i 2000 http-get://127.0.0.1:${port} && ${testCommand}${suffix}`, ]); } } diff --git a/packages/wb/test/scripts/execution/httpServerScripts.test.ts b/packages/wb/test/scripts/execution/httpServerScripts.test.ts index 3c1f4bee9..eca470546 100644 --- a/packages/wb/test/scripts/execution/httpServerScripts.test.ts +++ b/packages/wb/test/scripts/execution/httpServerScripts.test.ts @@ -18,6 +18,7 @@ describe('HttpServerScripts.testE2E', () => { env: { WB_ENV: 'test', PORT: '3000' }, packageJson: { scripts: {} }, hasPlaywrightConfig: false, + hasVitest: true, hasPrisma: false, buildCommand: 'echo "no build"', findFile: vi.fn().mockImplementation(() => { @@ -51,6 +52,7 @@ describe('HttpServerScripts.testE2E', () => { env: { WB_ENV: 'test', PORT: '3000' }, packageJson: { scripts: {} }, hasPlaywrightConfig: false, + hasVitest: true, hasPrisma: false, buildCommand: 'echo "no build"', findFile: vi.fn().mockImplementation(() => { @@ -73,8 +75,7 @@ describe('HttpServerScripts.testE2E', () => { '--success', 'first', 'YARN wb buildIfNeeded && node dist/index.js && exit 1', - `wait-on -t 600000 -i 2000 http-get://127.0.0.1:3000 - && ${buildShellCommand([ + `wait-on -t 600000 -i 2000 http-get://127.0.0.1:3000 && ${buildShellCommand([ 'vitest', 'run', `test/e2e/quo'te.spec.ts`, From 0e9441b40615af64bed9f3953d632c11056dcc96 Mon Sep 17 00:00:00 2001 From: "Sakamoto, Kazunori" Date: Wed, 29 Apr 2026 22:08:38 +0900 Subject: [PATCH 2/7] fix: address wb test review feedback Co-authored-by: WillBooster (Codex CLI) --- packages/wb/src/scripts/execution/baseScripts.ts | 2 +- packages/wb/src/scripts/execution/httpServerScripts.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/wb/src/scripts/execution/baseScripts.ts b/packages/wb/src/scripts/execution/baseScripts.ts index 662fcf403..790e87221 100644 --- a/packages/wb/src/scripts/execution/baseScripts.ts +++ b/packages/wb/src/scripts/execution/baseScripts.ts @@ -98,7 +98,7 @@ export abstract class BaseScripts { : project.hasDrizzle ? drizzleScripts.migrate(project) : ''; - return [...migrationCommand.split('&&'), ...commands] + return [...(migrationCommand ? migrationCommand.split('&&') : []), ...commands] .filter(Boolean) .map((cmd) => `${cmd} ${toDevNull(argv)}`.trim()) .join(' && '); diff --git a/packages/wb/src/scripts/execution/httpServerScripts.ts b/packages/wb/src/scripts/execution/httpServerScripts.ts index 64b382db1..a4192605f 100644 --- a/packages/wb/src/scripts/execution/httpServerScripts.ts +++ b/packages/wb/src/scripts/execution/httpServerScripts.ts @@ -33,18 +33,20 @@ class HttpServerScripts extends BaseScripts { const port = await checkAndKillPortProcess(project.env.PORT, project); const suffix = project.packageJson.scripts?.['test/e2e-additional'] ? ' && YARN test/e2e-additional' : ''; const targets = argv.targets?.map(String); + const normalizedTargets = targets && targets.length > 0 ? targets : ['test/e2e/']; const testCommand = project.hasVitest ? buildShellCommand([ 'vitest', 'run', - ...(targets && targets.length > 0 ? targets : ['test/e2e/']), + ...normalizedTargets, '--color', '--passWithNoTests', '--allowOnly', ...(argv.bail ? ['--bail=1'] : []), ]) : project.isBunAvailable - ? buildShellCommand(['bun', 'test', ...(targets && targets.length > 0 ? targets : ['test/e2e/'])]) + ? // Use literal `bun test`; the `BUN` placeholder normalizes to `bun --bun run` and may recurse into a `test` package script. + buildShellCommand(['bun', 'test', ...normalizedTargets]) : 'echo "No tests."'; return buildShellCommand([ 'YARN', From 86d15b51fa982121cba840cdb96e1c74c76d6f1e Mon Sep 17 00:00:00 2001 From: "Sakamoto, Kazunori" Date: Wed, 29 Apr 2026 22:16:05 +0900 Subject: [PATCH 3/7] fix: pass bail to bun e2e tests Co-authored-by: WillBooster (Codex CLI) --- packages/wb/src/scripts/execution/httpServerScripts.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/wb/src/scripts/execution/httpServerScripts.ts b/packages/wb/src/scripts/execution/httpServerScripts.ts index a4192605f..265ec3573 100644 --- a/packages/wb/src/scripts/execution/httpServerScripts.ts +++ b/packages/wb/src/scripts/execution/httpServerScripts.ts @@ -46,7 +46,7 @@ class HttpServerScripts extends BaseScripts { ]) : project.isBunAvailable ? // Use literal `bun test`; the `BUN` placeholder normalizes to `bun --bun run` and may recurse into a `test` package script. - buildShellCommand(['bun', 'test', ...normalizedTargets]) + buildShellCommand(['bun', 'test', ...normalizedTargets, ...(argv.bail ? ['--bail'] : [])]) : 'echo "No tests."'; return buildShellCommand([ 'YARN', From d7dcc13daeda6716f5551c9f6e94ded74ab1ccfb Mon Sep 17 00:00:00 2001 From: "Sakamoto, Kazunori" Date: Wed, 29 Apr 2026 22:24:49 +0900 Subject: [PATCH 4/7] fix: refine wb test command helpers Co-authored-by: WillBooster (Codex CLI) --- .../wb/src/scripts/execution/baseScripts.ts | 2 +- .../scripts/execution/httpServerScripts.ts | 34 +++++++++++-------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/packages/wb/src/scripts/execution/baseScripts.ts b/packages/wb/src/scripts/execution/baseScripts.ts index 790e87221..5af3961c6 100644 --- a/packages/wb/src/scripts/execution/baseScripts.ts +++ b/packages/wb/src/scripts/execution/baseScripts.ts @@ -89,7 +89,7 @@ export abstract class BaseScripts { ecosystemConfigPath === undefined ? [ `YARN wb buildIfNeeded ${argv.verbose ? '--verbose' : ''}`.trim(), - `${project.isBunAvailable ? 'BUN' : 'node'} dist/index.js ${argv.normalizedArgsText ?? ''}`.trim(), + `${project.isBunAvailable ? 'bun' : 'node'} dist/index.js ${argv.normalizedArgsText ?? ''}`.trim(), ] : [project.buildCommand, `pm2-runtime start --no-autorestart ${ecosystemConfigPath}`]; diff --git a/packages/wb/src/scripts/execution/httpServerScripts.ts b/packages/wb/src/scripts/execution/httpServerScripts.ts index 265ec3573..d7c0e1b3c 100644 --- a/packages/wb/src/scripts/execution/httpServerScripts.ts +++ b/packages/wb/src/scripts/execution/httpServerScripts.ts @@ -34,20 +34,7 @@ class HttpServerScripts extends BaseScripts { const suffix = project.packageJson.scripts?.['test/e2e-additional'] ? ' && YARN test/e2e-additional' : ''; const targets = argv.targets?.map(String); const normalizedTargets = targets && targets.length > 0 ? targets : ['test/e2e/']; - const testCommand = project.hasVitest - ? buildShellCommand([ - 'vitest', - 'run', - ...normalizedTargets, - '--color', - '--passWithNoTests', - '--allowOnly', - ...(argv.bail ? ['--bail=1'] : []), - ]) - : project.isBunAvailable - ? // Use literal `bun test`; the `BUN` placeholder normalizes to `bun --bun run` and may recurse into a `test` package script. - buildShellCommand(['bun', 'test', ...normalizedTargets, ...(argv.bail ? ['--bail'] : [])]) - : 'echo "No tests."'; + const testCommand = this.buildFallbackTestCommand(project, argv, normalizedTargets); return buildShellCommand([ 'YARN', 'wb', @@ -60,6 +47,25 @@ class HttpServerScripts extends BaseScripts { `wait-on -t 600000 -i 2000 http-get://127.0.0.1:${port} && ${testCommand}${suffix}`, ]); } + + private buildFallbackTestCommand(project: Project, argv: TestArgv, targets: string[]): string { + if (project.hasVitest) { + return buildShellCommand([ + 'vitest', + 'run', + ...targets, + '--color', + '--passWithNoTests', + '--allowOnly', + ...(argv.bail ? ['--bail=1'] : []), + ]); + } + if (project.isBunAvailable) { + // Use literal `bun test`; the `BUN` placeholder normalizes to `bun --bun run` and may recurse into a `test` package script. + return buildShellCommand(['bun', 'test', ...targets, ...(argv.bail ? ['--bail'] : [])]); + } + return 'echo "No tests."'; + } } export const httpServerScripts = new HttpServerScripts(); From 286889cb274afc5ec006c857fe5b88e37c48a91c Mon Sep 17 00:00:00 2001 From: "Sakamoto, Kazunori" Date: Wed, 29 Apr 2026 22:34:33 +0900 Subject: [PATCH 5/7] fix: simplify fallback e2e target selection Co-authored-by: WillBooster (Codex CLI) --- packages/wb/src/scripts/execution/httpServerScripts.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/wb/src/scripts/execution/httpServerScripts.ts b/packages/wb/src/scripts/execution/httpServerScripts.ts index d7c0e1b3c..7973d7a15 100644 --- a/packages/wb/src/scripts/execution/httpServerScripts.ts +++ b/packages/wb/src/scripts/execution/httpServerScripts.ts @@ -33,7 +33,7 @@ class HttpServerScripts extends BaseScripts { const port = await checkAndKillPortProcess(project.env.PORT, project); const suffix = project.packageJson.scripts?.['test/e2e-additional'] ? ' && YARN test/e2e-additional' : ''; const targets = argv.targets?.map(String); - const normalizedTargets = targets && targets.length > 0 ? targets : ['test/e2e/']; + const normalizedTargets = targets?.length ? targets : ['test/e2e/']; const testCommand = this.buildFallbackTestCommand(project, argv, normalizedTargets); return buildShellCommand([ 'YARN', From 62a3783c7c8ebabc3620646d5c2cf5420f2bd61f Mon Sep 17 00:00:00 2001 From: "Sakamoto, Kazunori" Date: Wed, 29 Apr 2026 22:44:47 +0900 Subject: [PATCH 6/7] fix: reuse unit test command for e2e fallback Co-authored-by: WillBooster (Codex CLI) --- .../scripts/execution/httpServerScripts.ts | 21 +------------------ .../execution/httpServerScripts.test.ts | 2 ++ 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/packages/wb/src/scripts/execution/httpServerScripts.ts b/packages/wb/src/scripts/execution/httpServerScripts.ts index 7973d7a15..5e44fb52d 100644 --- a/packages/wb/src/scripts/execution/httpServerScripts.ts +++ b/packages/wb/src/scripts/execution/httpServerScripts.ts @@ -34,7 +34,7 @@ class HttpServerScripts extends BaseScripts { const suffix = project.packageJson.scripts?.['test/e2e-additional'] ? ' && YARN test/e2e-additional' : ''; const targets = argv.targets?.map(String); const normalizedTargets = targets?.length ? targets : ['test/e2e/']; - const testCommand = this.buildFallbackTestCommand(project, argv, normalizedTargets); + const testCommand = this.testUnit(project, { ...argv, targets: normalizedTargets }); return buildShellCommand([ 'YARN', 'wb', @@ -47,25 +47,6 @@ class HttpServerScripts extends BaseScripts { `wait-on -t 600000 -i 2000 http-get://127.0.0.1:${port} && ${testCommand}${suffix}`, ]); } - - private buildFallbackTestCommand(project: Project, argv: TestArgv, targets: string[]): string { - if (project.hasVitest) { - return buildShellCommand([ - 'vitest', - 'run', - ...targets, - '--color', - '--passWithNoTests', - '--allowOnly', - ...(argv.bail ? ['--bail=1'] : []), - ]); - } - if (project.isBunAvailable) { - // Use literal `bun test`; the `BUN` placeholder normalizes to `bun --bun run` and may recurse into a `test` package script. - return buildShellCommand(['bun', 'test', ...targets, ...(argv.bail ? ['--bail'] : [])]); - } - return 'echo "No tests."'; - } } export const httpServerScripts = new HttpServerScripts(); diff --git a/packages/wb/test/scripts/execution/httpServerScripts.test.ts b/packages/wb/test/scripts/execution/httpServerScripts.test.ts index eca470546..78fd0b7af 100644 --- a/packages/wb/test/scripts/execution/httpServerScripts.test.ts +++ b/packages/wb/test/scripts/execution/httpServerScripts.test.ts @@ -76,6 +76,7 @@ describe('HttpServerScripts.testE2E', () => { 'first', 'YARN wb buildIfNeeded && node dist/index.js && exit 1', `wait-on -t 600000 -i 2000 http-get://127.0.0.1:3000 && ${buildShellCommand([ + 'YARN', 'vitest', 'run', `test/e2e/quo'te.spec.ts`, @@ -83,6 +84,7 @@ describe('HttpServerScripts.testE2E', () => { '--color', '--passWithNoTests', '--allowOnly', + '--watch=false', ])}`, ]) ); From db58eb6f26892862a11f080f3f94ae0d85173ce0 Mon Sep 17 00:00:00 2001 From: "Sakamoto, Kazunori" Date: Wed, 29 Apr 2026 22:53:27 +0900 Subject: [PATCH 7/7] fix: run all configured db migrations Co-authored-by: WillBooster (Codex CLI) --- packages/wb/src/scripts/execution/baseScripts.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/wb/src/scripts/execution/baseScripts.ts b/packages/wb/src/scripts/execution/baseScripts.ts index 5af3961c6..00b62ede1 100644 --- a/packages/wb/src/scripts/execution/baseScripts.ts +++ b/packages/wb/src/scripts/execution/baseScripts.ts @@ -93,12 +93,11 @@ export abstract class BaseScripts { ] : [project.buildCommand, `pm2-runtime start --no-autorestart ${ecosystemConfigPath}`]; - const migrationCommand = project.hasPrisma - ? prismaScripts.migrate(project) - : project.hasDrizzle - ? drizzleScripts.migrate(project) - : ''; - return [...(migrationCommand ? migrationCommand.split('&&') : []), ...commands] + const migrationCommands = [ + ...(project.hasPrisma ? [prismaScripts.migrate(project)] : []), + ...(project.hasDrizzle ? [drizzleScripts.migrate(project)] : []), + ]; + return [...migrationCommands.flatMap((cmd) => cmd.split('&&')), ...commands] .filter(Boolean) .map((cmd) => `${cmd} ${toDevNull(argv)}`.trim()) .join(' && ');