diff --git a/packages/wb/src/project.ts b/packages/wb/src/project.ts index 3765234d..cb514783 100644 --- a/packages/wb/src/project.ts +++ b/packages/wb/src/project.ts @@ -74,6 +74,11 @@ export class Project { return JSON.parse(fs.readFileSync(path.join(this.dirPath, 'package.json'), 'utf8')); } + @memoize + get hasPrisma(): boolean { + return !!this.packageJson.dependencies?.['prisma']; + } + @memoize get dockerPackageJson(): PackageJson { return path.dirname(this.findFile('Dockerfile')) === this.dirPath diff --git a/packages/wb/src/scripts/execution/nextScripts.ts b/packages/wb/src/scripts/execution/nextScripts.ts index a4288b03..f81d33b4 100644 --- a/packages/wb/src/scripts/execution/nextScripts.ts +++ b/packages/wb/src/scripts/execution/nextScripts.ts @@ -22,26 +22,25 @@ class NextScripts extends BaseExecutionScripts { override startProduction(project: Project, argv: ScriptArgv, port: number): string { return `NODE_ENV=production YARN concurrently --raw --kill-others-on-fail - "${prismaScripts.reset(project)} && ${project.buildCommand} && PORT=${port} pm2-runtime start ${project.findFile( - 'ecosystem.config.cjs' - )} ${argv.normalizedArgsText ?? ''}" + "${[ + ...(project.hasPrisma ? [prismaScripts.reset(project)] : []), + project.buildCommand, + `PORT=${port} pm2-runtime start ${project.findFile('ecosystem.config.cjs')} ${argv.normalizedArgsText ?? ''}`, + ].join(' && ')}" "${this.waitAndOpenApp(project, argv, port)}"`; } - override testE2E( - project: Project, - argv: ScriptArgv, - { - playwrightArgs = 'test tests/e2e', - startCommand = `${prismaScripts.reset(project)} && ${ - project.buildCommand - } && pm2-runtime start ${project.findFile('ecosystem.config.cjs')}`, - }: TestE2EOptions - ): string { + override testE2E(project: Project, argv: ScriptArgv, options: TestE2EOptions): string { return super.testE2E(project, argv, { - playwrightArgs, + playwrightArgs: options.playwrightArgs ?? 'test tests/e2e', prismaDirectory: 'db', - startCommand, + startCommand: + options.startCommand ?? + [ + ...(project.hasPrisma ? [prismaScripts.reset(project)] : []), + project.buildCommand, + `pm2-runtime start ${project.findFile('ecosystem.config.cjs')}`, + ].join(' && '), }); }