@@ -7,6 +7,7 @@ import { message } from "@optique/core";
77import { kvStores , messageQueues } from "../lib.ts" ;
88import type { InitCommandData } from "../types.ts" ;
99import bareBonesDescription from "../webframeworks/bare-bones.ts" ;
10+ import nuxtDescription from "../webframeworks/nuxt.ts" ;
1011import { loadDenoConfig } from "./configs.ts" ;
1112import { patchFiles } from "./patch.ts" ;
1213
@@ -133,6 +134,28 @@ test("patchFiles creates a Biome config matching the npm package version", async
133134 }
134135} ) ;
135136
137+ test ( "patchFiles wires Nuxt logging through a Nitro plugin" , async ( ) => {
138+ const dir = await mkdtemp ( join ( tmpdir ( ) , "fedify-init-nuxt-" ) ) ;
139+
140+ try {
141+ const data = await createNuxtNpmInitData ( dir ) ;
142+ await patchFiles ( data ) ;
143+
144+ const logging = await readFile ( join ( dir , "server/logging.ts" ) , "utf8" ) ;
145+ const plugin = await readFile (
146+ join ( dir , "server/plugins/logging.ts" ) ,
147+ "utf8" ,
148+ ) ;
149+
150+ assert . match ( logging , / e x p o r t d e f a u l t c o n f i g u r e \( / ) ;
151+ assert . doesNotMatch ( logging , / a w a i t c o n f i g u r e \( / ) ;
152+ assert . match ( plugin , / i m p o r t l o g g i n g C o n f i g u r e d f r o m " \. \. \/ l o g g i n g " ; / ) ;
153+ assert . match ( plugin , / a w a i t l o g g i n g C o n f i g u r e d ; / ) ;
154+ } finally {
155+ await rm ( dir , { recursive : true , force : true } ) ;
156+ }
157+ } ) ;
158+
136159async function createNpmInitData ( dir : string ) : Promise < InitCommandData > {
137160 const initializer = await bareBonesDescription . init ( {
138161 command : "init" ,
@@ -166,6 +189,39 @@ async function createNpmInitData(dir: string): Promise<InitCommandData> {
166189 return data ;
167190}
168191
192+ async function createNuxtNpmInitData ( dir : string ) : Promise < InitCommandData > {
193+ const initializer = await nuxtDescription . init ( {
194+ command : "init" ,
195+ projectName : "example" ,
196+ packageManager : "npm" ,
197+ webFramework : "nuxt" ,
198+ kvStore : "in-memory" ,
199+ messageQueue : "in-process" ,
200+ dryRun : false ,
201+ allowNonEmpty : false ,
202+ testMode : false ,
203+ dir,
204+ } ) ;
205+
206+ const data = {
207+ command : "init" ,
208+ projectName : "example" ,
209+ packageManager : "npm" ,
210+ webFramework : "nuxt" ,
211+ kvStore : "in-memory" ,
212+ messageQueue : "in-process" ,
213+ dryRun : false ,
214+ allowNonEmpty : false ,
215+ testMode : false ,
216+ dir,
217+ initializer,
218+ kv : kvStores [ "in-memory" ] ,
219+ mq : messageQueues [ "in-process" ] ,
220+ env : { } ,
221+ } satisfies InitCommandData ;
222+ return data ;
223+ }
224+
169225function getSchemaVersion ( schema : string ) : string {
170226 const match = schema . match ( / \/ s c h e m a s \/ ( \d + \. \d + \. \d + ) \/ / ) ;
171227 assert . ok ( match , `Unexpected Biome schema URL: ${ schema } ` ) ;
0 commit comments