|
| 1 | +# @ng2react/cli |
| 2 | + |
| 3 | +> A command line interface for wrapper for [@ng2react/core](https://github.com/ng2react/core) that converts AngularJS components to React using OpenAI. |
| 4 | +
|
| 5 | +## Installation |
| 6 | + |
| 7 | +```bash |
| 8 | +npm install -g @ng2react/cli |
| 9 | +``` |
| 10 | + |
| 11 | +## Usage |
| 12 | + |
| 13 | +### Search for components |
| 14 | + |
| 15 | +```log |
| 16 | +ng2react search <file> |
| 17 | +
|
| 18 | +Finds angular components in a file |
| 19 | +
|
| 20 | +Positionals: |
| 21 | + file The file to search [string] [required] |
| 22 | +
|
| 23 | +Options: |
| 24 | + --version Show version number [boolean] |
| 25 | + --cwd The current working directory |
| 26 | + [string] [default: "/Users/maxbilbow/repos/dissertation/ng2react/cli"] |
| 27 | + --quiet Suppresses all logging [boolean] |
| 28 | + --json Outputs the result as json. When provided, all responses will be in |
| 29 | + the format {data: any, error?: string} [boolean] |
| 30 | + --verbose Outputs more information [boolean] |
| 31 | + --help Show help [boolean] |
| 32 | +``` |
| 33 | + |
| 34 | +### Convert your AngularJS component or directive to React |
| 35 | + |
| 36 | +```log |
| 37 | +ng2react convert <file> <componentName> |
| 38 | +
|
| 39 | +Converts angular components to react |
| 40 | +
|
| 41 | +Positionals: |
| 42 | + file The file containing the component [string] [required] |
| 43 | + componentName The file to convert [string] [required] |
| 44 | +
|
| 45 | +Options: |
| 46 | + --version Show version number [boolean] |
| 47 | + --cwd The current working directory |
| 48 | + [string] [default: "/Users/maxbilbow/repos/dissertation/ng2react/cli"] |
| 49 | + --quiet Suppresses all logging [boolean] |
| 50 | + --json Outputs the result as json. When provided, all responses will |
| 51 | + be in the format {data: any, error?: string} [boolean] |
| 52 | + --verbose Outputs more information [boolean] |
| 53 | + --help Show help [boolean] |
| 54 | + --apiKey The openai api key [string] |
| 55 | + --model The openai model to use [string] [default: "gpt-4"] |
| 56 | + --organization The openai model to use [string] |
| 57 | + --sourceRoot The source root where all AngularJS JS and HTML are located |
| 58 | + [string] |
| 59 | + --temperature The temperature to use when generating text, between 0 and 2 |
| 60 | + [number] [default: 0.2] |
| 61 | +``` |
| 62 | + |
| 63 | +## JSON API |
| 64 | + |
| 65 | +If you wish to integrate this into your own application, you can use the JSON API by adding the `--json` flag. |
| 66 | + |
| 67 | +The response types are found in See [src/lib/model](./src/lib/model/): |
| 68 | + |
| 69 | +### Search Response: |
| 70 | + |
| 71 | +```typescript |
| 72 | +type SearchResult = { |
| 73 | + result: { |
| 74 | + name: string |
| 75 | + file: string |
| 76 | + location: { |
| 77 | + start: number |
| 78 | + end: number |
| 79 | + } |
| 80 | + }[] |
| 81 | +} |
| 82 | +``` |
| 83 | +
|
| 84 | +### Convert Response: |
| 85 | +
|
| 86 | +```typescript |
| 87 | +type ConvertResult = { |
| 88 | + result: readonly { |
| 89 | + jsx: string |
| 90 | + markdown: string |
| 91 | + }[] |
| 92 | +} |
| 93 | +``` |
0 commit comments