Browse Source

Merge pull request #12362 from abpframework/feat/support-url-param-schematics

support url param in abp generate-proxy command
pull/12366/head
Mahmut Gundogdu 4 years ago
committed by GitHub
parent
commit
6546d5bd59
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      docs/en/CLI.md
  2. 7
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/Angular/AngularServiceProxyGenerator.cs
  3. 9
      npm/ng-packs/packages/schematics/src/commands/proxy-add/schema.json
  4. 9
      npm/ng-packs/packages/schematics/src/commands/proxy-refresh/schema.json
  5. 9
      npm/ng-packs/packages/schematics/src/commands/proxy-remove/schema.json
  6. 5
      npm/ng-packs/packages/schematics/src/models/generate-proxy-schema.ts
  7. 5
      npm/ng-packs/packages/schematics/src/utils/source.ts

8
docs/en/CLI.md

@ -298,7 +298,7 @@ abp generate-proxy -t <client-type> [options]
Examples:
````bash
abp generate-proxy -t ng
abp generate-proxy -t ng -url https://localhost:44302/
abp generate-proxy -t js -url https://localhost:44302/
abp generate-proxy -t csharp -url https://localhost:44302/
````
@ -312,12 +312,13 @@ abp generate-proxy -t csharp -url https://localhost:44302/
* `--api-name` or `-a`: The name of the API endpoint defined in the `/src/environments/environment.ts`. Default value: `default`.
* `--source` or `-s`: Specifies the Angular project name to resolve the root namespace & API definition URL from. Default value: `defaultProject`.
* `--target`: Specifies the Angular project name to place generated code in. Default value: `defaultProject`.
* `--url`: Specifies api definition url. Default value is API Name's url in environment file.
* `--prompt` or `-p`: Asks the options from the command line prompt (for the unspecified options).
* `js`: JavaScript. work in the `*.Web` project directory. There are some additional options for this client:
* `--output` or `-o`: JavaScript file path or folder to place generated code in.
* `--module` or `-m`: Specifies the name of the backend module you wish to generate proxies for. Default value: `app`.
* `--working-directory` or `-wd`: Execution directory. For `csharp` and `js` client types.
* `--url` or `-u`: API definition URL from. For `csharp` and `js` client types.
* `--url` or `-u`: API definition URL from.
> See the [Angular Service Proxies document](UI/Angular/Service-Proxies.md) for more.
@ -350,12 +351,13 @@ abp remove-proxy -t csharp --folder MyProxies/InnerFolder
* `--api-name` or `-a`: The name of the API endpoint defined in the `/src/environments/environment.ts`. Default value: `default`.
* `--source` or `-s`: Specifies the Angular project name to resolve the root namespace & API definition URL from. Default value: `defaultProject`.
* `--target`: Specifies the Angular project name to place generated code in. Default value: `defaultProject`.
* `--url`: Specifies api definition url. Default value is API Name's url in environment file.
* `--prompt` or `-p`: Asks the options from the command line prompt (for the unspecified options).
* `js`: JavaScript. work in the `*.Web` project directory. There are some additional options for this client:
* `--output` or `-o`: JavaScript file path or folder to place generated code in.
* `--module` or `-m`: Specifies the name of the backend module you wish to generate proxies for. Default value: `app`.
* `--working-directory` or `-wd`: Execution directory. For `csharp` and `js` client types.
* `--url` or `-u`: API definition URL from. For `csharp` and `js` client types.
* `--url` or `-u`: API definition URL from.
> See the [Angular Service Proxies document](UI/Angular/Service-Proxies.md) for more.

7
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/Angular/AngularServiceProxyGenerator.cs

@ -48,7 +48,7 @@ public class AngularServiceProxyGenerator : ServiceProxyGeneratorBase<AngularSer
var apiName = args.ApiName ?? defaultValue;
var source = args.Source ?? defaultValue;
var target = args.Target ?? defaultValue;
var url = args.Url ?? string.Empty;
var commandBuilder = new StringBuilder("npx ng g @abp/ng.schematics:" + schematicsCommandName);
if (module != null)
@ -71,6 +71,11 @@ public class AngularServiceProxyGenerator : ServiceProxyGeneratorBase<AngularSer
commandBuilder.Append($" --target {target}");
}
if (url != null)
{
commandBuilder.Append($" --url {url}");
}
_cmdhelper.RunCmd(commandBuilder.ToString());
}

9
npm/ng-packs/packages/schematics/src/commands/proxy-add/schema.json

@ -39,6 +39,15 @@
"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)"
}
},
"required": []

9
npm/ng-packs/packages/schematics/src/commands/proxy-refresh/schema.json

@ -39,6 +39,15 @@
"index": 3
},
"x-prompt": "Please enter target Angular project to place the generated code. (default: workspace \"defaultProject\")"
},
"url": {
"description": "API definition URL from",
"type": "string",
"$default": {
"$source": "argv",
"index": 4
},
"x-prompt": "Please enter URL for api definition (default: API Name's url in environment file)"
}
},
"required": []

9
npm/ng-packs/packages/schematics/src/commands/proxy-remove/schema.json

@ -39,6 +39,15 @@
"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)"
}
},
"required": []

5
npm/ng-packs/packages/schematics/src/models/generate-proxy-schema.ts

@ -18,4 +18,9 @@ export interface GenerateProxySchema {
* Target Angular project to place the generated code
*/
target?: string;
/**
* Url to API definition
*/
url?: string;
}

5
npm/ng-packs/packages/schematics/src/utils/source.ts

@ -16,10 +16,13 @@ import { readEnvironment, resolveProject } from './workspace';
export function createApiDefinitionGetter(params: GenerateProxySchema) {
const apiName = params.apiName || 'default';
let sourceUrl = params.url;
return async (host: Tree) => {
const source = await resolveProject(host, params.source!);
const sourceUrl = getSourceUrl(host, source, apiName);
if (!sourceUrl) {
sourceUrl = getSourceUrl(host, source, apiName);
}
return await getApiDefinition(sourceUrl);
};
}

Loading…
Cancel
Save