Skip to content

Commit

Permalink
feat: generateTemplate fun support context
Browse files Browse the repository at this point in the history
  • Loading branch information
MrLiangLong authored and LeoYuan committed Jul 25, 2023
1 parent 02a3361 commit e875e33
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions modules/code-generator/src/generator/ProjectBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ export class ProjectBuilder implements IProjectBuilder {
// Init
const { schemaParser } = this;

const projectRoot = await this.template.generateTemplate();

let schema: IPublicTypeProjectSchema =
typeof originalSchema === 'string' ? JSON.parse(originalSchema) : originalSchema;

Expand All @@ -131,6 +129,9 @@ export class ProjectBuilder implements IProjectBuilder {
// Collect Deps
// Parse JSExpression
const parseResult: IParseResult = schemaParser.parse(schema);

const projectRoot = await this.template.generateTemplate(parseResult);

let buildResult: IModuleInfo[] = [];

const builders = this.createModuleBuilders({
Expand Down
2 changes: 1 addition & 1 deletion modules/code-generator/src/types/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export interface ISchemaParser {

export interface IProjectTemplate {
slots: Record<string, IProjectSlot>;
generateTemplate: () => ResultDir | Promise<ResultDir>;
generateTemplate: (data: IParseResult) => ResultDir | Promise<ResultDir>;
}

export interface IProjectSlot {
Expand Down

0 comments on commit e875e33

Please sign in to comment.