File tree Expand file tree Collapse file tree 10 files changed +42
-20
lines changed
tests/test-projects/live-reloading Expand file tree Collapse file tree 10 files changed +42
-20
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @keystone-6/core " : major
3+ ---
4+
5+ Changes the type for ` ui.getAdditionalFiles ` to be flattened, prefer function composition when wrapping
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ export default config({
66 provider : 'sqlite' ,
77 url : process . env . DATABASE_URL || 'file:./keystone-example.db' ,
88
9- // WARNING: this is only needed for our monorepo examples, dont do this
9+ // WARNING: this is needed for our monorepo, you may not want this
1010 prismaClientPath : 'node_modules/myprisma' ,
1111 } ,
1212 lists,
Original file line number Diff line number Diff line change 1- // you don't need this if you're building something outside of the Keystone repo
2-
1+ // WARNING: this is needed for our monorepo, you may not want this
32const withPreconstruct = require ( '@preconstruct/next' )
43
54module . exports = withPreconstruct ( )
Original file line number Diff line number Diff line change @@ -68,5 +68,23 @@ export default config<TypeInfo>({
6868 ] ,
6969 } ,
7070 } ,
71+ ui : {
72+ getAdditionalFiles : async ( ) => [
73+ {
74+ mode : 'write' ,
75+ src : `export default ${ JSON . stringify ( {
76+ // stop the default Next logging
77+ logging : false , // we use pino
78+
79+ // defaults from packages/core/src/templates/next-config.ts
80+ bundlePagesRouterDependencies : true ,
81+ eslint : { ignoreDuringBuilds : true } ,
82+ typescript : { ignoreBuildErrors : true } ,
83+ transpilePackages : [ '../../admin' ] ,
84+ } ) } `,
85+ outputPath : 'next.config.js' ,
86+ } ,
87+ ] ,
88+ } ,
7189 lists,
7290} )
Original file line number Diff line number Diff line change @@ -215,7 +215,7 @@ export function createAuth<ListTypeInfo extends BaseListTypeInfo>({
215215 let { ui } = config
216216 if ( ! ui ?. isDisabled ) {
217217 const {
218- getAdditionalFiles = [ ] ,
218+ getAdditionalFiles = ( ) => [ ] ,
219219 isAccessAllowed = defaultIsAccessAllowed ,
220220 pageMiddleware,
221221 publicPages = [ ] ,
@@ -224,7 +224,10 @@ export function createAuth<ListTypeInfo extends BaseListTypeInfo>({
224224 ui = {
225225 ...ui ,
226226 publicPages : [ ...publicPages , ...authPublicPages ] ,
227- getAdditionalFiles : [ ...getAdditionalFiles , ( ) => authGetAdditionalFiles ( config ) ] ,
227+ getAdditionalFiles : async ( ) => [
228+ ...( await getAdditionalFiles ( ) ) ,
229+ ...authGetAdditionalFiles ( config ) ,
230+ ] ,
228231
229232 isAccessAllowed : async ( context : KeystoneContext ) => {
230233 if ( await hasInitFirstItemConditions ( context ) ) return true
Original file line number Diff line number Diff line change @@ -68,8 +68,7 @@ export async function generateAdminUI(
6868 }
6969
7070 // Write out the files configured by the user
71- const userFiles = config . ui ?. getAdditionalFiles ?. map ( x => x ( ) ) ?? [ ]
72- const userFilesToWrite = ( await Promise . all ( userFiles ) ) . flat ( )
71+ const userFilesToWrite = await config . ui . getAdditionalFiles ( )
7372 const savedFiles = await Promise . all (
7473 userFilesToWrite . map ( file => writeAdminFile ( file , projectAdminPath ) )
7574 )
Original file line number Diff line number Diff line change @@ -139,7 +139,7 @@ export function config<TypeInfo extends BaseKeystoneTypeInfo>(
139139 basePath : config . ui ?. basePath ?? '' ,
140140 isAccessAllowed : config . ui ?. isAccessAllowed ?? defaultIsAccessAllowed ,
141141 isDisabled : config . ui ?. isDisabled ?? false ,
142- getAdditionalFiles : config . ui ?. getAdditionalFiles ?? [ ] ,
142+ getAdditionalFiles : config . ui ?. getAdditionalFiles ?? ( ( ) => [ ] ) ,
143143 pageMiddleware : config . ui ?. pageMiddleware ?? noop ,
144144 publicPages : config . ui ?. publicPages ?? [ ] ,
145145 } ,
Original file line number Diff line number Diff line change 11import next from 'next'
22
3- import { createSystem } from '../lib/createSystem'
4- import { createExpressServer } from '../lib/createExpressServer'
53import { createAdminUIMiddlewareWithNextApp } from '../lib/createAdminUIMiddleware'
4+ import { createExpressServer } from '../lib/createExpressServer'
5+ import { createSystem } from '../lib/createSystem'
66import { withMigrate } from '../lib/migrations'
7+ import type { Flags } from './cli'
78import { importBuiltKeystoneConfiguration } from './utils'
8- import { type Flags } from './cli'
99
1010export async function start (
1111 cwd : string ,
Original file line number Diff line number Diff line change @@ -162,7 +162,7 @@ export type KeystoneConfigPre<TypeInfo extends BaseKeystoneTypeInfo = BaseKeysto
162162 /** The Base Path for Keystones Admin UI */
163163 basePath ?: string
164164
165- getAdditionalFiles ?: readonly ( ( ) => MaybePromise < readonly AdminFileToWrite [ ] > ) [ ]
165+ getAdditionalFiles ?: ( ) => MaybePromise < readonly AdminFileToWrite [ ] >
166166
167167 /** An async middleware function that can optionally return a redirect */
168168 pageMiddleware ?: ( args : {
Original file line number Diff line number Diff line change @@ -15,14 +15,12 @@ export default config({
1515 extendGraphqlSchema,
1616 } ,
1717 ui : {
18- getAdditionalFiles : [
19- ( ) => [
20- {
21- mode : 'write' ,
22- src : "export default function(req,res) {res.send('something')}" ,
23- outputPath : 'pages/api/blah/[...rest].js' ,
24- } ,
25- ] ,
18+ getAdditionalFiles : ( ) => [
19+ {
20+ mode : 'write' ,
21+ src : "export default function(req,res) {res.send('something')}" ,
22+ outputPath : 'pages/api/blah/[...rest].js' ,
23+ } ,
2624 ] ,
2725 } ,
2826} )
You can’t perform that action at this time.
0 commit comments