Skip to content

Commit 20847c7

Browse files
committed
Added prettier formatting and Readme
1 parent ae8e361 commit 20847c7

26 files changed

Lines changed: 5483 additions & 5355 deletions

.gitconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[core]
2+
hooksPath = .githooks

.githooks/pre-commit

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#! /bin/bash
2+
3+
npx prettier --write .

.github/workflows/ci.yml

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
11
name: CI
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
pull_request:
8-
branches:
9-
- main
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
1010

1111
jobs:
12-
build:
13-
runs-on: ubuntu-latest
12+
build:
13+
runs-on: ubuntu-latest
1414

15-
strategy:
16-
matrix:
17-
node-version: [18.x]
15+
strategy:
16+
matrix:
17+
node-version: [18.x]
1818

19-
steps:
20-
- name: Checkout repository
21-
uses: actions/checkout@v2
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v2
2222

23-
- name: Setup Node.js ${{ matrix.node-version }}
24-
uses: actions/setup-node@v2
25-
with:
26-
node-version: ${{ matrix.node-version }}
23+
- name: Setup Node.js ${{ matrix.node-version }}
24+
uses: actions/setup-node@v2
25+
with:
26+
node-version: ${{ matrix.node-version }}
2727

28-
- name: Cache Node.js modules
29-
uses: actions/cache@v2
30-
with:
31-
path: ~/.npm
32-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
33-
restore-keys: |
34-
${{ runner.os }}-node-
28+
- name: Cache Node.js modules
29+
uses: actions/cache@v2
30+
with:
31+
path: ~/.npm
32+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
33+
restore-keys: |
34+
${{ runner.os }}-node-
3535
36-
- name: Install dependencies
37-
run: npm ci
36+
- name: Install dependencies
37+
run: npm ci
3838

39-
- name: Run tests
40-
run: npm test
39+
- name: Run tests
40+
run: npm test
4141

42-
- name: Check code style
43-
run: npm run lint
42+
- name: Check code style
43+
run: npm run lint
4444

45-
- name: Build assets
46-
run: npm run build
45+
- name: Build assets
46+
run: npm run build

.prettierignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Ignore artifacts:
2+
dist
3+
coverage
4+
5+
# Ignore all HTML files:
6+
*.html

.prettierrc.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"singleQuote": true,
3+
"endOfLine": "lf",
4+
"printWidth": 120,
5+
"tabWidth": 4,
6+
"arrowParens": "always",
7+
"semi": false
8+
}

README.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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+
```

index.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
// Nothing to see here, move along please. This is just a cli wrapper.
1+
// Nothing to see here, move along please. This is just a cli wrapper.

0 commit comments

Comments
 (0)