@@ -170,27 +170,27 @@ async function loadProjectQuestions(
170170 try {
171171 const content = fs . readFileSync ( jsonPath , "utf8" ) ;
172172 const questions = JSON . parse ( content ) ;
173- return validateQuestions ( questions ) ? questions : null ;
173+ return validateQuestions ( questions ) ? normalizeQuestions ( questions ) : null ;
174174 } catch ( error ) {
175175 const errorMessage =
176176 error instanceof Error ? error . message : String ( error ) ;
177177 console . warn ( `Failed to parse .questions.json: ${ errorMessage } ` ) ;
178178 }
179179 }
180-
180+
181181 const jsPath = path . join ( templateDir , ".questions.js" ) ;
182182 if ( fs . existsSync ( jsPath ) ) {
183183 try {
184184 const module = require ( jsPath ) ;
185185 const questions = module . default || module ;
186- return validateQuestions ( questions ) ? questions : null ;
186+ return validateQuestions ( questions ) ? normalizeQuestions ( questions ) : null ;
187187 } catch ( error ) {
188188 const errorMessage =
189189 error instanceof Error ? error . message : String ( error ) ;
190190 console . warn ( `Failed to load .questions.js: ${ errorMessage } ` ) ;
191191 }
192192 }
193-
193+
194194 return null ;
195195}
196196
@@ -286,6 +286,21 @@ function normalizePlaceholder(entry: string): string | null {
286286 return entry || null ;
287287}
288288
289+ /**
290+ * Normalize questions by ensuring all required fields have default values
291+ * @param questions - Questions object to normalize
292+ * @returns Normalized questions object
293+ */
294+ function normalizeQuestions ( questions : Questions ) : Questions {
295+ return {
296+ ...questions ,
297+ questions : questions . questions . map ( ( q : any ) => ( {
298+ ...q ,
299+ type : q . type || 'text'
300+ } ) )
301+ } ;
302+ }
303+
289304/**
290305 * Validate that the questions object has the correct structure
291306 * @param obj - Object to validate
0 commit comments