Skip to content

Commit

Permalink
fix(wb): error "/bin/sh: prisma: command not found" in a Next.js proj…
Browse files Browse the repository at this point in the history
…ect without Prisma (#205)
  • Loading branch information
reminjp authored Nov 28, 2023
1 parent f10e548 commit c5ba832
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
5 changes: 5 additions & 0 deletions packages/wb/src/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 14 additions & 15 deletions packages/wb/src/scripts/execution/nextScripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(' && '),
});
}

Expand Down

0 comments on commit c5ba832

Please sign in to comment.