@@ -3,12 +3,13 @@ import path from 'node:path'
33import { createRequire } from 'node:module'
44import { printSchema , GraphQLSchema } from 'graphql'
55import { getGenerators , formatSchema } from '@prisma/internals'
6- import type { KeystoneConfig } from './types'
7- import { printGeneratedTypes } from './lib/typescript-schema-printer'
86import { ExitError } from './scripts/utils'
7+ import {
8+ type KeystoneConfig ,
9+ type __ResolvedKeystoneConfig
10+ } from './types'
911import { initialiseLists } from './lib/core/initialise-lists'
1012import { printPrismaSchema } from './lib/core/prisma-schema-printer'
11- import { initConfig } from './system'
1213
1314export function getFormattedGraphQLSchema ( schema : string ) {
1415 return (
@@ -19,7 +20,7 @@ export function getFormattedGraphQLSchema (schema: string) {
1920 )
2021}
2122
22- export async function getCommittedArtifacts ( config : KeystoneConfig , graphQLSchema : GraphQLSchema ) {
23+ export async function getCommittedArtifacts ( config : __ResolvedKeystoneConfig , graphQLSchema : GraphQLSchema ) {
2324 const lists = initialiseLists ( config )
2425 const prismaSchema = printPrismaSchema ( config , lists )
2526 return {
@@ -71,14 +72,14 @@ export function getBuiltKeystoneConfigurationPath (cwd: string) {
7172}
7273
7374export function getBuiltKeystoneConfiguration ( cwd : string ) {
74- return initConfig ( require ( getBuiltKeystoneConfigurationPath ( cwd ) ) . default )
75+ return require ( getBuiltKeystoneConfigurationPath ( cwd ) ) . default
7576}
7677
7778function posixify ( s : string ) {
7879 return s . split ( path . sep ) . join ( '/' )
7980}
8081
81- export function getSystemPaths ( cwd : string , config : KeystoneConfig ) {
82+ export function getSystemPaths ( cwd : string , config : KeystoneConfig | __ResolvedKeystoneConfig ) {
8283 const prismaClientPath = config . db . prismaClientPath === '@prisma/client'
8384 ? null
8485 : config . db . prismaClientPath
@@ -118,7 +119,7 @@ export function getSystemPaths (cwd: string, config: KeystoneConfig) {
118119
119120export async function validatePrismaAndGraphQLSchemas (
120121 cwd : string ,
121- config : KeystoneConfig ,
122+ config : __ResolvedKeystoneConfig ,
122123 graphQLSchema : GraphQLSchema
123124) {
124125 const paths = getSystemPaths ( cwd , config )
@@ -150,49 +151,7 @@ export async function validatePrismaAndGraphQLSchemas (
150151 throw new ExitError ( 1 )
151152}
152153
153- export async function generatePrismaAndGraphQLSchemas (
154- cwd : string ,
155- config : KeystoneConfig ,
156- graphQLSchema : GraphQLSchema
157- ) {
158- const paths = getSystemPaths ( cwd , config )
159- const artifacts = await getCommittedArtifacts ( config , graphQLSchema )
160-
161- await fs . writeFile ( paths . schema . graphql , artifacts . graphql )
162- await fs . writeFile ( paths . schema . prisma , artifacts . prisma )
163- return artifacts
164- }
165-
166- export async function generateTypescriptTypes (
167- cwd : string ,
168- config : KeystoneConfig ,
169- graphQLSchema : GraphQLSchema
170- ) {
171- const lists = initialiseLists ( config )
172- const paths = getSystemPaths ( cwd , config )
173- const schema = printGeneratedTypes ( paths . types . relativePrismaPath , graphQLSchema , lists )
174-
175- await fs . mkdir ( path . dirname ( paths . schema . types ) , { recursive : true } )
176- await fs . writeFile ( paths . schema . types , schema )
177- }
178-
179- export async function generateTypescriptTypesAndPrisma (
180- cwd : string ,
181- config : KeystoneConfig ,
182- graphQLSchema : GraphQLSchema
183- ) {
184- const paths = getSystemPaths ( cwd , config )
185- const dataProxy = config . db . url . startsWith ( 'prisma:' )
186- if ( dataProxy === true ) {
187- console . log ( '✨ Generating Prisma Client (data proxy)' )
188- }
189- await Promise . all ( [
190- generatePrismaClient ( paths . schema . prisma , dataProxy ) ,
191- generateTypescriptTypes ( cwd , config , graphQLSchema ) ,
192- ] )
193- }
194-
195- async function generatePrismaClient ( prismaSchemaPath : string , dataProxy : boolean ) {
154+ export async function generatePrismaClient ( prismaSchemaPath : string , dataProxy : boolean ) {
196155 const generators = await getGenerators ( {
197156 schemaPath : prismaSchemaPath ,
198157 dataProxy,
0 commit comments