Skip to content

Commit

Permalink
Merge branch 'feat_backend_frontend_code_generate' into fix-ssr-and-c…
Browse files Browse the repository at this point in the history
…sr-issue
  • Loading branch information
NarwhalChen authored Jan 22, 2025
2 parents dd7bb9d + d2a57b7 commit 89c7d83
Show file tree
Hide file tree
Showing 34 changed files with 1,781 additions and 1,501 deletions.
205 changes: 88 additions & 117 deletions backend/src/build-system/__tests__/fullstack-gen.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@ import { isIntegrationTest } from 'src/common/utils';
import { BuildSequence } from '../types';
import { executeBuildSequence } from './utils';
import { Logger } from '@nestjs/common';
import { ProjectInitHandler } from '../handlers/project-init';
import { PRDHandler } from '../handlers/product-manager/product-requirements-document/prd';
import { UXSMDHandler } from '../handlers/ux/sitemap-document';
import { UXSMSHandler } from '../handlers/ux/sitemap-structure';
import { DBRequirementHandler } from '../handlers/database/requirements-document';
import { FileStructureHandler } from '../handlers/file-manager/file-structure';
import { UXSMSPageByPageHandler } from '../handlers/ux/sitemap-structure/sms-page';
import { DBSchemaHandler } from '../handlers/database/schemas/schemas';
import { FileFAHandler } from '../handlers/file-manager/file-arch';
import { BackendRequirementHandler } from '../handlers/backend/requirements-document';
import { BackendCodeHandler } from '../handlers/backend/code-generate';
import { BackendFileReviewHandler } from '../handlers/backend/file-review/file-review';

(isIntegrationTest ? describe : describe.skip)('Build Sequence Test', () => {
it('should execute build sequence successfully', async () => {
const sequence: BuildSequence = {
Expand All @@ -10,144 +23,102 @@ import { Logger } from '@nestjs/common';
name: 'Spotify-like Music Web',
description: 'Users can play music',
databaseType: 'SQLite',
steps: [
nodes: [
{
handler: ProjectInitHandler,
name: 'Project Folders Setup',
},
{
handler: PRDHandler,
name: 'Project Requirements Document Node',
},
{
handler: UXSMDHandler,
name: 'UX Sitemap Document Node',
},
{
handler: UXSMSHandler,
name: 'UX Sitemap Structure Node',
// requires: ['op:UX:SMD'],
},
{
handler: DBRequirementHandler,
name: 'Database Requirements Node',
// requires: ['op:UX:DATAMAP:DOC'],
},
{
handler: FileStructureHandler,
name: 'File Structure Generation',
// requires: ['op:UX:SMD', 'op:UX:DATAMAP:DOC'],
options: {
projectPart: 'frontend',
},
},
{
handler: UXSMSPageByPageHandler,
name: 'Level 2 UX Sitemap Structure Node details',
// requires: ['op:UX:SMS'],
},
{
id: 'step-0',
name: 'Project Initialization',
parallel: false,
nodes: [
{
id: 'op:PROJECT::STATE:SETUP',
name: 'Project Folders Setup',
},
],
handler: DBRequirementHandler,
name: 'Database Requirements Node',
// requires: ['op:UX:DATAMAP:DOC'],
},
{
id: 'step-1',
name: 'Initial Analysis',
parallel: false,
nodes: [
{
id: 'op:PRD',
name: 'Project Requirements Document Node',
},
],
handler: FileStructureHandler,
name: 'File Structure Generation',
// requires: ['op:UX:SMD', 'op:UX:DATAMAP:DOC'],
options: {
projectPart: 'frontend',
},
},
{
id: 'step-2',
name: 'UX Base Document Generation',
parallel: false,
nodes: [
{
id: 'op:UX:SMD',
name: 'UX Sitemap Document Node',
requires: ['op:PRD'],
},
],
handler: UXSMSPageByPageHandler,
name: 'Level 2 UX Sitemap Structure Node details',
// requires: ['op:UX:SMS'],
},
{
id: 'step-3',
name: 'Parallel UX Processing',
parallel: true,
nodes: [
{
id: 'op:UX:SMS',
name: 'UX Sitemap Structure Node',
requires: ['op:UX:SMD'],
},
{
id: 'op:UX:DATAMAP:DOC',
name: 'UX DataMap Document Node',
requires: ['op:UX:SMD'],
},
],
handler: DBSchemaHandler,
name: 'Database Schemas Node',
// requires: ['op:DATABASE_REQ'],
},
{
id: 'step-4',
name: 'Parallel Project Structure',
parallel: true,
nodes: [
{
id: 'op:DATABASE_REQ',
name: 'Database Requirements Node',
requires: ['op:UX:DATAMAP:DOC'],
},
{
id: 'op:FILE:STRUCT',
name: 'File Structure Generation',
requires: ['op:UX:SMD', 'op:UX:DATAMAP:DOC'],
options: {
projectPart: 'frontend',
},
},
{
id: 'op:UX:SMS:LEVEL2',
name: 'Level 2 UX Sitemap Structure Node details',
requires: ['op:UX:SMS'],
},
],
handler: FileFAHandler,
name: 'File Arch',
// requires: ['op:FILE:STRUCT', 'op:UX:DATAMAP:DOC'],
},
{
id: 'step-5',
name: 'Parallel Implementation',
parallel: true,
nodes: [
{
id: 'op:DATABASE:SCHEMAS',
name: 'Database Schemas Node',
requires: ['op:DATABASE_REQ'],
},
{
id: 'op:FILE:ARCH',
name: 'File Arch',
requires: ['op:FILE:STRUCT', 'op:UX:DATAMAP:DOC'],
},
{
id: 'op:BACKEND:REQ',
name: 'Backend Requirements Node',
requires: ['op:DATABASE_REQ', 'op:UX:DATAMAP:DOC', 'op:UX:SMD'],
},
],
handler: BackendRequirementHandler,
name: 'Backend Requirements Node',
// requires: ['op:DATABASE_REQ', 'op:UX:DATAMAP:DOC', 'op:UX:SMD'],
},
{
id: 'step-6',
name: 'Final Code Generation',
parallel: false,
nodes: [
{
id: 'op:BACKEND:CODE',
name: 'Backend Code Generator Node',
requires: [
'op:DATABASE:SCHEMAS',
'op:UX:DATAMAP:DOC',
'op:BACKEND:REQ',
],
},
{
id: 'op:FRONTEND:CODE',
name: 'Frontend Code Generator Node',
},
],
handler: BackendCodeHandler,
name: 'Backend Code Generator Node',
// requires: [
// 'op:DATABASE:SCHEMAS',
// 'op:UX:DATAMAP:DOC',
// 'op:BACKEND:REQ',
// ],
},
// TODO: code reviewer
// {
// handler:FrontendCodeHandler,
// id: 'op:FRONTEND:CODE',
// name: 'Frontend Code Generator Node',
// },
{
id: 'step-7',
name: 'Backend Code Review',
parallel: false,
nodes: [
{
id: 'op:BACKEND:FILE:REVIEW',
name: 'Backend File Review Node',
requires: ['op:BACKEND:CODE', 'op:BACKEND:REQ'],
},
],
handler: BackendFileReviewHandler,
name: 'Backend File Review Node',
// requires: ['op:BACKEND:CODE', 'op:BACKEND:REQ'],
},
],
};

const result = await executeBuildSequence('fullstack-code-gen', sequence);

// Assertion: ensure the build sequence runs successfully
expect(result.success).toBe(true);
expect(result.metrics).toBeDefined();
Logger.log(`Logs saved to: ${result.logFolderPath}`);
}, 300000);
}, 300000); // Set timeout to 5 minutes
});
Loading

0 comments on commit 89c7d83

Please sign in to comment.