Skip to content

Commit f1bfadb

Browse files
committed
fix: skip template fetching for full stack mode and use scaffold copying directly
1 parent 08e6cd5 commit f1bfadb

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

src/ipc/handlers/createFromTemplate.ts

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -483,52 +483,53 @@ export async function createFromTemplate({
483483
fullAppPath,
484484
selectedTemplateId,
485485
selectedBackendFramework,
486+
isFullStack,
486487
}: {
487488
fullAppPath: string;
488489
selectedTemplateId?: string;
489490
selectedBackendFramework?: string | null;
491+
isFullStack?: boolean;
490492
}) {
491-
// EMERGENCY DEBUG: Create debug file at function start
492-
try {
493-
const debugStartContent = `DEBUG: createFromTemplate called at ${new Date().toISOString()}\nfullAppPath: ${fullAppPath}\nselectedTemplateId: ${selectedTemplateId}\nselectedBackendFramework: ${selectedBackendFramework}`;
494-
const debugPath = path.join(fullAppPath, 'DEBUG_FUNCTION_START.txt');
495-
await fs.writeFile(debugPath, debugStartContent);
496-
console.log('✅ EMERGENCY DEBUG: Function start debug file created');
497-
} catch (debugError) {
498-
console.error('❌ EMERGENCY DEBUG: Failed to create function start debug file:', debugError);
499-
}
500-
501493
const templateId = selectedTemplateId || readSettings().selectedTemplateId;
502-
logger.info(`Creating app with template: ${templateId}, backend: ${selectedBackendFramework}`);
494+
logger.info(`Creating app with template: ${templateId}, backend: ${selectedBackendFramework}, isFullStack: ${isFullStack}`);
503495

504496
// Create frontend directory
505497
const frontendPath = path.join(fullAppPath, "frontend");
506498
logger.info(`Creating frontend directory: ${frontendPath}`);
507499
await fs.ensureDir(frontendPath);
508500

509-
// Only create backend directory if a backend framework is selected
501+
// For full stack, always create both frontend and backend
502+
// For frontend-only, create frontend and optionally backend
503+
// For backend-only, create backend
510504
let backendPath: string | null = null;
511-
if (selectedBackendFramework) {
505+
506+
if (isFullStack || selectedBackendFramework) {
512507
backendPath = path.join(fullAppPath, "backend");
513508
logger.info(`Creating backend directory: ${backendPath}`);
514509
await fs.ensureDir(backendPath);
515510
}
516511

517512
// Set up selected backend framework if specified
518-
if (selectedBackendFramework && backendPath) {
513+
if ((isFullStack || selectedBackendFramework) && backendPath) {
519514
logger.info(`Setting up backend framework: ${selectedBackendFramework}`);
520-
await setupBackendFramework(backendPath, selectedBackendFramework);
515+
await setupBackendFramework(backendPath, selectedBackendFramework!);
521516
}
522517

523-
if (templateId === "react") {
518+
// For full stack, skip template processing and use scaffold copying directly
519+
if (isFullStack) {
520+
if (!selectedBackendFramework) {
521+
throw new Error("Backend framework must be selected for Full Stack app creation. Please select a backend framework in the Hub first.");
522+
}
523+
// Use scaffold copying for frontend (React) and backend framework setup
524+
logger.info(`Full stack mode: Using scaffold for frontend and ${selectedBackendFramework} for backend`);
524525
// For React template, put the frontend code in the frontend folder
525-
logger.info(`Setting up React template in frontend folder`);
526+
logger.info(`Setting up React scaffold in frontend folder`);
526527

527528
// EMERGENCY DEBUG: Create a debug file immediately
528529
try {
529-
const debugContent = `DEBUG: React template section reached at ${new Date().toISOString()}\nTemplate ID: ${templateId}`;
530-
await fs.writeFile(path.join(frontendPath, 'DEBUG_REACT_TEMPLATE.txt'), debugContent);
531-
logger.info('✅ DEBUG: Emergency debug file created');
530+
const debugContent = `DEBUG: Full stack scaffold section reached at ${new Date().toISOString()}\nBackend Framework: ${selectedBackendFramework}`;
531+
await fs.writeFile(path.join(frontendPath, 'DEBUG_FULL_STACK.txt'), debugContent);
532+
logger.info('✅ DEBUG: Full stack debug file created');
532533
} catch (debugError) {
533534
logger.error('❌ DEBUG: Failed to create debug file:', debugError);
534535
}

0 commit comments

Comments
 (0)