Skip to content

Commit

Permalink
check if virtual dir correct at file arch
Browse files Browse the repository at this point in the history
  • Loading branch information
ZHallen122 committed Jan 5, 2025
1 parent 98ea9c8 commit 125576c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions backend/src/build-system/handlers/file-manager/file-arch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@ import { BuilderContext } from 'src/build-system/context';
import { generateFileArchPrompt } from './prompt';
import { Logger } from '@nestjs/common';
import { extractJsonFromMarkdown } from 'src/build-system/utils/strings';
import { VirtualDirectory } from '../../../virtual-dir';
import {
buildDependencyGraph,
validateAgainstVirtualDirectory,
} from '../../../utils/file_generator_util';

export class FileArchGenerateHandler implements BuildHandler<string> {
readonly id = 'op:FILE:ARCH';
private readonly logger: Logger = new Logger('FileArchGenerateHandler');
private virtualDir: VirtualDirectory;

// TODO: adding page by page analysis
async run(context: BuilderContext): Promise<BuildResult<string>> {
this.logger.log('Generating File Architecture Document...');

this.virtualDir = context.virtualDirectory;

const fileStructure = context.getNodeData('op:FILE:STRUCT');
// TODO: here should use datamap struct
const datamapDoc = context.getNodeData('op:UX:DATAMAP:DOC');
Expand Down Expand Up @@ -72,6 +80,14 @@ export class FileArchGenerateHandler implements BuildHandler<string> {
this.logger.error('File architecture JSON validation failed');
continue;
}
console.log(jsonData);
// validate with virutual dir
const { graph, nodes, fileInfos } = buildDependencyGraph(jsonData);
if (!validateAgainstVirtualDirectory(nodes, this.virtualDir)) {
retry += 1;
this.logger.error('Validate Against Virtual Directory Fail !!!');
continue;
}

successBuild = true;
} catch (error) {
Expand Down

0 comments on commit 125576c

Please sign in to comment.