From c7a7af769896ef358da9082edd202b9037f2bd4f Mon Sep 17 00:00:00 2001 From: "Sakamoto, Kazunori" Date: Mon, 2 Sep 2024 11:00:43 +0900 Subject: [PATCH] fix(wb): run 'playwright install --with-deps' on only setup command --- packages/wb/src/commands/setup.ts | 37 +++++-------------- .../wb/src/scripts/execution/baseScripts.ts | 4 +- 2 files changed, 12 insertions(+), 29 deletions(-) diff --git a/packages/wb/src/commands/setup.ts b/packages/wb/src/commands/setup.ts index 8dbdf1e1..2dbf1ba3 100644 --- a/packages/wb/src/commands/setup.ts +++ b/packages/wb/src/commands/setup.ts @@ -8,10 +8,9 @@ import type { ArgumentsCamelCase, CommandModule, InferredOptionTypes } from 'yar import { findDescendantProjects } from '../project.js'; import { runWithSpawn, runWithSpawnInParallel } from '../scripts/run.js'; import { promisePool } from '../utils/promisePool.js'; -import { isRunningOnBun, packageManagerWithRun, packageManager } from '../utils/runtime.js'; +import { packageManagerWithRun } from '../utils/runtime.js'; import { prepareForRunningCommand } from './commandUtils.js'; -import { httpServerPackages } from './constants.js'; const builder = {} as const; @@ -61,32 +60,16 @@ export async function setup( await runWithSpawn('poetry install --ansi', project, argv); } - const deps = project.packageJson.dependencies ?? {}; - const devDeps = project.packageJson.devDependencies || {}; - const scripts = project.packageJson.scripts ?? {}; - const newDeps: string[] = []; - let newDevDeps: string[] = []; - if (deps['blitz'] || deps['next']) { - newDeps.push('pm2'); - newDevDeps.push('concurrently', 'open-cli', 'vitest', 'wait-on'); - } else if (devDeps['@remix-run/dev']) { - newDeps.push('pm2'); - newDevDeps.push('concurrently', 'open-cli', 'vitest', 'wait-on'); - } else if (httpServerPackages.some((p) => deps[p])) { - newDeps.push('pm2'); - newDevDeps.push('concurrently', 'vitest', 'wait-on'); - } - if (isRunningOnBun) { - newDevDeps = newDevDeps.filter((dep) => dep !== 'vitest'); - } - if (newDeps.length > 0) { - await runWithSpawn(`${packageManager} add ${newDeps.join(' ')}`, project, argv); - } - if (newDevDeps.length > 0) { - await runWithSpawn(`${packageManager} add -D ${newDevDeps.join(' ')}`, project, argv); - } - if (scripts['gen-code']) { + if ( + (project === projects.root || !projects.root.packageJson.scripts?.['gen-code']) && + project.packageJson.scripts?.['gen-code'] + ) { await runWithSpawn(`${packageManagerWithRun} gen-code`, project, argv); } } + + const project = projects.descendants.find((p) => p.packageJson.devDependencies?.playwright); + if (project) { + await runWithSpawn(`${packageManagerWithRun} playwright install --with-deps`, project, argv); + } } diff --git a/packages/wb/src/scripts/execution/baseScripts.ts b/packages/wb/src/scripts/execution/baseScripts.ts index ae00dd79..43952c0e 100644 --- a/packages/wb/src/scripts/execution/baseScripts.ts +++ b/packages/wb/src/scripts/execution/baseScripts.ts @@ -49,7 +49,7 @@ export abstract class BaseScripts { const suffix = project.packageJson.scripts?.['test/e2e-additional'] ? ' && YARN test/e2e-additional' : ''; return `WB_ENV=${env} NEXT_PUBLIC_WB_ENV=${env} APP_ENV=${env} PORT=8080 YARN concurrently --kill-others --raw --success first "rm -Rf ${prismaDirectory}/mount && ${startCommand} && exit 1" - "concurrently --kill-others-on-fail --raw 'wait-on -t 600000 -i 2000 http-get://127.0.0.1:8080' 'BUN playwright install --with-deps' + "wait-on -t 600000 -i 2000 http-get://127.0.0.1:8080 && BUN playwright ${playwrightArgs === 'test tests/e2e' && argv.target ? playwrightArgs.replace('tests/e2e', argv.target) : playwrightArgs}${suffix}"`; } @@ -62,7 +62,7 @@ export abstract class BaseScripts { const suffix = project.packageJson.scripts?.['test/e2e-additional'] ? ' && YARN test/e2e-additional' : ''; return `WB_ENV=${env} NEXT_PUBLIC_WB_ENV=${env} APP_ENV=${env} PORT=8080 YARN concurrently --kill-others --raw --success first "${startCommand} && exit 1" - "concurrently --kill-others-on-fail --raw 'wait-on -t 600000 -i 2000 http-get://127.0.0.1:8080' 'BUN playwright install --with-deps' + "wait-on -t 600000 -i 2000 http-get://127.0.0.1:8080 && BUN playwright ${playwrightArgs === 'test tests/e2e' && argv.target ? playwrightArgs.replace('tests/e2e', argv.target) : playwrightArgs}${suffix}"`; }