|
1 | 1 | # Custom Generator
|
2 | 2 |
|
3 |
| -Client Generator provides support for many of the popular JS frameworks, but you may be using another framework or language and may need a solution adapted to your specific needs. For this cenario, you can write your own generator and pass it to the CLI using a path as the `-g` argument. |
| 3 | +Create Client provides support for many of the popular JS frameworks, but you may be using another framework or language and may need a solution adapted to your specific needs. For this cenario, you can write your own generator and pass it to the CLI using a path as the `-g` argument. |
4 | 4 |
|
5 |
| -You will probably want to extend or, at least, take a look at [BaseGenerator.js](https://github.com/api-platform/client-generator/blob/main/src/generators/BaseGenerator.js), since the library expects some methods to be available, as well as one of the [included generators](https://github.com/api-platform/client-generator/blob/main/src/generators/BaseGenerator.j) to make your own. |
| 5 | +You will probably want to extend or, at least, take a look at [BaseGenerator.js](https://github.com/api-platform/create-client/blob/main/src/generators/BaseGenerator.js), since the library expects some methods to be available, as well as one of the [included generators](https://github.com/api-platform/create-client/blob/main/src/generators/BaseGenerator.j) to make your own. |
6 | 6 |
|
7 | 7 | ## Usage
|
8 | 8 |
|
9 | 9 | ```shell
|
10 |
| -generate-api-platform-client -g "$(pwd)/path/to/custom/generator.js" -t "$(pwd)/path/to/templates" |
| 10 | +npm init @api-platform/client -g "$(pwd)/path/to/custom/generator.js" -t "$(pwd)/path/to/templates" |
11 | 11 | ```
|
12 | 12 |
|
13 | 13 | The `-g` argument can point to any resolvable node module which means it can be a package dependency of the current project as well as any js file.
|
14 | 14 |
|
15 | 15 | ## Example
|
16 | 16 |
|
17 |
| -Client Generator makes use of the [Handlebars](https://handlebarsjs.com/) template engine. You can use any programming language or file type. Your generator can also pass data to your templates in any shape you want. |
| 17 | +Create Client makes use of the [Handlebars](https://handlebarsjs.com/) template engine. You can use any programming language or file type. Your generator can also pass data to your templates in any shape you want. |
18 | 18 |
|
19 | 19 | In this example, we'll create a simple [Rust](https://www.rust-lang.org) file defining a new `struct` and creating some instances of this `struct`.
|
20 | 20 |
|
21 | 21 | ### Generator
|
22 | 22 |
|
23 | 23 | ```js
|
24 | 24 | // ./Generator.js
|
25 |
| -import BaseGenerator from "@api-platform/client-generator/lib/generators/BaseGenerator"; |
| 25 | +import BaseGenerator from "@api-platform/create-client/lib/generators/BaseGenerator"; |
26 | 26 |
|
27 | 27 | export default class extends BaseGenerator {
|
28 | 28 | constructor(params) {
|
@@ -94,7 +94,7 @@ fn main() {
|
94 | 94 | Then we can use our generator:
|
95 | 95 |
|
96 | 96 | ```shell
|
97 |
| -generate-api-platform-client https://demo.api-platform.com out/ -g "$(pwd)/Generator.js" -t "$(pwd)/template" |
| 97 | +npm init @api-platform/client https://demo.api-platform.com out/ -g "$(pwd)/Generator.js" -t "$(pwd)/template" |
98 | 98 | ```
|
99 | 99 |
|
100 | 100 | which will produces:
|
|
0 commit comments