Skip to content

Commit

Permalink
fix(cli): regenerate prisma schema during keystone prisma .. comman…
Browse files Browse the repository at this point in the history
…ds (#8698)

Co-authored-by: Daniel Cousens <[email protected]>
  • Loading branch information
pahaz and dcousens committed Sep 10, 2023
1 parent b0d6a2a commit 12183fa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/fix-frozen-prisma.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-6/core': major
---

Changes `keystone prisma` behaviour to not generate Typescript types and prisma schema when using `--frozen`
14 changes: 11 additions & 3 deletions packages/core/src/scripts/prisma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { createSystem } from '../lib/createSystem';
import {
getBuiltKeystoneConfiguration,
generateTypescriptTypesAndPrisma,
validatePrismaAndGraphQLSchemas,
generatePrismaAndGraphQLSchemas,
validatePrismaAndGraphQLSchemas
} from '../artifacts';
import { getEsbuildConfig } from '../lib/esbuild';
import { ExitError } from './utils';
Expand All @@ -19,8 +20,15 @@ export async function prisma(cwd: string, args: string[], frozen: boolean) {
// TODO: this cannot be changed for now, circular dependency with getSystemPaths, getEsbuildConfig
const config = getBuiltKeystoneConfiguration(cwd);
const { graphQLSchema } = createSystem(config);
await validatePrismaAndGraphQLSchemas(cwd, config, graphQLSchema);
await generateTypescriptTypesAndPrisma(cwd, config, graphQLSchema);

if (frozen) {
await validatePrismaAndGraphQLSchemas(cwd, config, graphQLSchema);
console.log('✨ GraphQL and Prisma schemas are up to date');
} else {
await generatePrismaAndGraphQLSchemas(cwd, config, graphQLSchema); // TODO: rename to generateSchemas (or similar)
console.log('✨ Generated GraphQL and Prisma schemas');
await generateTypescriptTypesAndPrisma(cwd, config, graphQLSchema); // TODO: rename to generatePrismaClientAndTypes (or similar)
}

return new Promise<void>((resolve, reject) => {
const p = execFile(
Expand Down

0 comments on commit 12183fa

Please sign in to comment.