GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(codegen): add demo slots & add new cli option solutionOptions · huihao/lowcode-engine@2bd40d7

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • modules/code-generator
    • bin
      • lowcode-code-generator.js
    • src
      • cli
        • run.ts
      • generator
        • ProjectBuilder.ts
      • types
        • core.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎modules/code-generator/bin/lowcode-code-generator.js‎

Copy file name to clipboardExpand all lines: modules/code-generator/bin/lowcode-code-generator.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ program
1414
.option('-c, --cwd <cwd>', 'specify the working directory', '.')
1515
.option('-q, --quiet', 'be quiet, do not output anything unless get error', false)
1616
.option('-v, --verbose', 'be verbose, output more information', false)
17+
.option('--solution-options <options>', 'specify the solution options', '{}')
1718
.arguments('[input-schema] ali lowcode schema JSON file')
1819
.action(function doGenerate(inputSchema, command) {
1920
var options = command.opts();
Collapse file

‎modules/code-generator/src/cli/run.ts‎

Copy file name to clipboardExpand all lines: modules/code-generator/src/cli/run.ts
+16-2Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export async function run(
2525
output?: string;
2626
quiet?: boolean;
2727
verbose?: boolean;
28+
solutionOptions?: string;
2829
},
2930
): Promise<number> {
3031
try {
@@ -41,14 +42,27 @@ export async function run(
4142
);
4243
}
4344

45+
let solutionOptions = {};
46+
47+
if (options.solutionOptions) {
48+
try {
49+
solutionOptions = JSON.parse(options.solutionOptions);
50+
} catch (err: any) {
51+
throw new Error(
52+
`solution options parse error, error message is "${err.message}"`,
53+
);
54+
}
55+
}
56+
57+
4458
// 读取 Schema
4559
const schema = await loadSchemaFile(schemaFile);
4660

4761
// 创建一个项目构建器
4862
const createProjectBuilder = await getProjectBuilderFactory(options.solution, {
4963
quiet: options.quiet,
5064
});
51-
const builder = createProjectBuilder();
65+
const builder = createProjectBuilder(solutionOptions);
5266

5367
// 生成代码
5468
const generatedSourceCodes = await builder.generateProject(schema);
@@ -75,7 +89,7 @@ export async function run(
7589
async function getProjectBuilderFactory(
7690
solution: string,
7791
{ quiet }: { quiet?: boolean },
78-
): Promise<() => IProjectBuilder> {
92+
): Promise<(options: {[prop: string]: any}) => IProjectBuilder> {
7993
if (solution in CodeGenerator.solutions) {
8094
return CodeGenerator.solutions[solution as 'icejs' | 'rax'];
8195
}
Collapse file

‎modules/code-generator/src/generator/ProjectBuilder.ts‎

Copy file name to clipboardExpand all lines: modules/code-generator/src/generator/ProjectBuilder.ts
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,15 @@ export class ProjectBuilder implements IProjectBuilder {
241241
});
242242
}
243243

244+
// demo
245+
if (parseResult.project && builders.demo) {
246+
const { files } = await builders.demo.generateModule(parseResult.project);
247+
buildResult.push({
248+
path: this.template.slots.demo.path,
249+
files,
250+
});
251+
}
252+
244253
// TODO: 更多 slots 的处理??是不是可以考虑把 template 中所有的 slots 都处理下?
245254

246255
// Post Process
Collapse file

‎modules/code-generator/src/types/core.ts‎

Copy file name to clipboardExpand all lines: modules/code-generator/src/types/core.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export enum FileType {
2525
TS = 'ts',
2626
TSX = 'tsx',
2727
JSON = 'json',
28+
MD = 'md',
2829
}
2930

3031
export enum ChunkType {

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.