Skip to content

Commit de3de7b

Browse files
authored
Merge pull request #27 from vitwit/addedShellScipt
Added shell script and fix some bugs
2 parents 27a66f2 + 789bba6 commit de3de7b

File tree

14 files changed

+6298
-141
lines changed

14 files changed

+6298
-141
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/__tests__

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ npm install -g @vitwit/js-sdkgen
1919
### Usage
2020

2121
```sh
22-
js-sdkgen --json-file=swagger.json --name=SampleSDK --version=1.0.0 --base-url=https://vitwit.com/api --required-headers accountId --optional-headers accessToken
22+
js-sdkgen --json-file swagger.json --name SampleSDK --version 1.0.0 --base-url https://vitwit.com/api --required-headers accountId --optional-headers accessToken --output src
2323
```
24+
Running above command will generate a folder with name sdk and will have a `js` file containing sdk code,`README.md` containing docs for using generated sdk.It also generates a `sdk.sh` file which contains the command you gave above, so that you don't have to type this again and again and you can simply run this file.
25+
You can even go ahead and edit this generated `sh` file and add a pre command like this `curl 'http://localhost.com/swagger.json' -O swagger.json &&` and save it forever.
26+
This is very helpful in active developement, now when any api is added or updated, just run the file `sh src/sdk/sdk.sh` it will fetch updated api-docs update file in local and run the rest of command.
2427

2528
Below are the list of parameters available for node cli config while generating SDK.
2629

__tests__/index.js

Whitespace-only changes.

__tests__/utils.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
import { toCamelCase, toTitleCase } from "../src/utils";
3+
4+
describe("utils", () => {
5+
test("it sould return valid js variable,given any kind of word", () => {
6+
expect(toCamelCase("YashRathore")).toBe("yashRathore");
7+
8+
expect(toCamelCase("yash-Rathore")).toBe("yashRathore");
9+
10+
expect(toCamelCase("Yash-rathore")).toBe("yashRathore");
11+
12+
expect(toCamelCase("Yash@Rathore")).toBe("yashRathore");
13+
14+
expect(toCamelCase("Yash Rathore")).toBe("yashRathore");
15+
})
16+
17+
test('it should return valid js variable,first letter capital for class name convention', () => {
18+
expect(toTitleCase("yash-Rathore")).toBe("YashRathore");
19+
20+
expect(toTitleCase("yash-rathore")).toBe("YashRathore");
21+
22+
expect(toTitleCase("yash rathore")).toBe("YashRathore");
23+
24+
expect(toTitleCase("yash@rathore")).toBe("YashRathore");
25+
26+
expect(toTitleCase("yash/rathore")).toBe("YashRathore");
27+
})
28+
});

babel.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
presets: [
3+
['@babel/preset-env', { targets: { node: 'current' } }]
4+
]
5+
}

0 commit comments

Comments
 (0)