Skip to content

Commit

Permalink
fix(wb): run 'playwright install --with-deps' on only setup command
Browse files Browse the repository at this point in the history
  • Loading branch information
exKAZUu committed Sep 2, 2024
1 parent 210f72c commit c7a7af7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 29 deletions.
37 changes: 10 additions & 27 deletions packages/wb/src/commands/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
}
4 changes: 2 additions & 2 deletions packages/wb/src/scripts/execution/baseScripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}"`;
}

Expand All @@ -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}"`;
}

Expand Down

0 comments on commit c7a7af7

Please sign in to comment.