mirror of https://github.com/abpframework/abp.git
3 changed files with 99 additions and 19 deletions
@ -1,17 +1,15 @@ |
|||||
import { addProjectConfiguration, formatFiles, generateFiles, Tree } from '@nx/devkit'; |
|
||||
import * as path from 'path'; |
|
||||
import { GenerateProxyGeneratorSchema } from './schema'; |
import { GenerateProxyGeneratorSchema } from './schema'; |
||||
|
import { Tree } from '@nrwl/devkit'; |
||||
|
import { wrapAngularDevkitSchematic } from '@nx/devkit/ngcli-adapter'; |
||||
|
|
||||
export async function generateProxyGenerator(tree: Tree, options: GenerateProxyGeneratorSchema) { |
export default async function (host: Tree, schema: GenerateProxyGeneratorSchema) { |
||||
const projectRoot = `libs/${options.name}`; |
const runAngularLibrarySchematic = wrapAngularDevkitSchematic('@abp/ng.schematics', 'proxy-add'); |
||||
addProjectConfiguration(tree, options.name, { |
|
||||
root: projectRoot, |
await runAngularLibrarySchematic(host, { |
||||
projectType: 'library', |
...schema, |
||||
sourceRoot: `${projectRoot}/src`, |
|
||||
targets: {}, |
|
||||
}); |
}); |
||||
generateFiles(tree, path.join(__dirname, 'files'), projectRoot, options); |
|
||||
await formatFiles(tree); |
|
||||
} |
|
||||
|
|
||||
export default generateProxyGenerator; |
return () => { |
||||
|
console.log(`proxy added '${schema.target}`); |
||||
|
}; |
||||
|
} |
||||
|
|||||
@ -1,3 +1,9 @@ |
|||||
export interface GenerateProxyGeneratorSchema { |
export interface GenerateProxyGeneratorSchema { |
||||
name: string; |
module: string; |
||||
|
apiName: string; |
||||
|
source: string; |
||||
|
target: string; |
||||
|
url: string; |
||||
|
serviceType: string; |
||||
|
entryPoint: string; |
||||
} |
} |
||||
|
|||||
@ -1,18 +1,94 @@ |
|||||
{ |
{ |
||||
"$schema": "http://json-schema.org/schema", |
"$schema": "https://json-schema.org/schema", |
||||
"$id": "GenerateProxy", |
"$id": "GenerateProxy", |
||||
"title": "", |
"title": "", |
||||
"type": "object", |
"type": "object", |
||||
"properties": { |
"properties": { |
||||
"name": { |
"module": { |
||||
|
"description": "Backend module name", |
||||
"type": "string", |
"type": "string", |
||||
"description": "", |
|
||||
"$default": { |
"$default": { |
||||
"$source": "argv", |
"$source": "argv", |
||||
"index": 0 |
"index": 0 |
||||
}, |
}, |
||||
"x-prompt": "What name would you like to use?" |
"x-prompt": "Please enter backend module name. (default: \"app\")" |
||||
|
}, |
||||
|
"apiName": { |
||||
|
"description": "Backend api name, a.k.a. remoteServiceName", |
||||
|
"type": "string", |
||||
|
"$default": { |
||||
|
"$source": "argv", |
||||
|
"index": 1 |
||||
|
}, |
||||
|
"x-prompt": "Please enter backend api name, a.k.a. remoteServiceName. (default: \"default\")" |
||||
|
}, |
||||
|
"source": { |
||||
|
"description": "Source Angular project for API definition URL & root namespace resolution", |
||||
|
"type": "string", |
||||
|
"$default": { |
||||
|
"$source": "argv", |
||||
|
"index": 2 |
||||
|
}, |
||||
|
"x-prompt": "Please enter source Angular project for API definition URL & root namespace resolution. (default: workspace \"defaultProject\")" |
||||
|
}, |
||||
|
"target": { |
||||
|
"description": "Target Angular project to place the generated code", |
||||
|
"type": "string", |
||||
|
"$default": { |
||||
|
"$source": "argv", |
||||
|
"index": 3 |
||||
|
}, |
||||
|
"x-prompt": "Please enter target Angular project to place the generated code. (default: workspace \"defaultProject\")" |
||||
|
}, |
||||
|
"url": { |
||||
|
"description": "Url for API definition", |
||||
|
"type": "string", |
||||
|
"$default": { |
||||
|
"$source": "argv", |
||||
|
"index": 4 |
||||
|
}, |
||||
|
"x-prompt": "Please enter URL for API definition (default: API Name's url in environment file)" |
||||
|
}, |
||||
|
"serviceType": { |
||||
|
"description": "Service type to the generated code", |
||||
|
"type": "string", |
||||
|
"$default": { |
||||
|
"$source": "argv", |
||||
|
"index": 5 |
||||
|
}, |
||||
|
"enum": [ |
||||
|
"application", |
||||
|
"integration", |
||||
|
"all" |
||||
|
], |
||||
|
"x-prompt": { |
||||
|
"message": "Specifies the service type to generate. `application`, `integration` and `all`, Default value: `application`", |
||||
|
"type": "list", |
||||
|
"items": [ |
||||
|
{ |
||||
|
"value": "all", |
||||
|
"label": "All" |
||||
|
}, |
||||
|
{ |
||||
|
"value": "application", |
||||
|
"label": "Application" |
||||
|
}, |
||||
|
{ |
||||
|
"value": "integration", |
||||
|
"label": "Integration" |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
}, |
||||
|
"entryPoint": { |
||||
|
"description": "Target Angular project to place the generated code", |
||||
|
"type": "string", |
||||
|
"$default": { |
||||
|
"$source": "argv", |
||||
|
"index": 6 |
||||
|
}, |
||||
|
"x-prompt": "Please enter target entry point to place the generated code. (default: null)" |
||||
} |
} |
||||
}, |
}, |
||||
"required": ["name"] |
"required": [] |
||||
} |
} |
||||
|
|||||
Loading…
Reference in new issue