@@ -31,7 +31,10 @@ import {
3131} from "./config.js" ;
3232import { recursivelyDelete } from "./fsUtils.js" ;
3333import { componentServerTS } from "../codegen_templates/component_server.js" ;
34- import { ComponentDirectory } from "./components/definition/directoryStructure.js" ;
34+ import {
35+ ComponentDirectory ,
36+ isComponentDirectory ,
37+ } from "./components/definition/directoryStructure.js" ;
3538import { StartPushResponse } from "./deployApi/startPush.js" ;
3639import {
3740 componentApiDTS ,
@@ -65,8 +68,24 @@ export async function doCodegenForNewProject(ctx: Context) {
6568 const configPath = await configFilepath ( ctx ) ;
6669 const functionsPath = functionsDir ( configPath , existingProjectConfig ) ;
6770 await doInitCodegen ( ctx , functionsPath , true ) ;
68- // Disable typechecking since there isn't any code yet.
69- await doCodegen ( ctx , functionsPath , "disable" ) ;
71+
72+ const componentDir = isComponentDirectory ( ctx , functionsPath , true ) ;
73+ if ( componentDir . kind === "err" ) {
74+ return await ctx . crash ( {
75+ exitCode : 1 ,
76+ errorType : "invalid filesystem data" ,
77+ printedMessage : `Invalid component directory: ${ componentDir . why } ` ,
78+ } ) ;
79+ }
80+
81+ if ( componentDir . component . isRootWithoutConfig ) {
82+ // Disable typechecking since there isn't any code yet.
83+ await doCodegen ( ctx , functionsPath , "disable" ) ;
84+ } else {
85+ await withTmpDir ( async ( tmpDir ) => {
86+ await doInitialComponentCodegen ( ctx , tmpDir , componentDir . component ) ;
87+ } ) ;
88+ }
7089}
7190
7291export async function doInitCodegen (
0 commit comments