Skip to content

Commit

Permalink
Merge pull request #27 from vitwit/addedShellScipt
Browse files Browse the repository at this point in the history
Added shell script and fix some bugs
  • Loading branch information
anilcse authored Oct 15, 2019
2 parents 27a66f2 + 789bba6 commit de3de7b
Show file tree
Hide file tree
Showing 14 changed files with 6,298 additions and 141 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/__tests__
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ npm install -g @vitwit/js-sdkgen
### Usage

```sh
js-sdkgen --json-file=swagger.json --name=SampleSDK --version=1.0.0 --base-url=https://vitwit.com/api --required-headers accountId --optional-headers accessToken
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
```
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.
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.
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.

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

Expand Down
Empty file added __tests__/index.js
Empty file.
28 changes: 28 additions & 0 deletions __tests__/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

import { toCamelCase, toTitleCase } from "../src/utils";

describe("utils", () => {
test("it sould return valid js variable,given any kind of word", () => {
expect(toCamelCase("YashRathore")).toBe("yashRathore");

expect(toCamelCase("yash-Rathore")).toBe("yashRathore");

expect(toCamelCase("Yash-rathore")).toBe("yashRathore");

expect(toCamelCase("Yash@Rathore")).toBe("yashRathore");

expect(toCamelCase("Yash Rathore")).toBe("yashRathore");
})

test('it should return valid js variable,first letter capital for class name convention', () => {
expect(toTitleCase("yash-Rathore")).toBe("YashRathore");

expect(toTitleCase("yash-rathore")).toBe("YashRathore");

expect(toTitleCase("yash rathore")).toBe("YashRathore");

expect(toTitleCase("yash@rathore")).toBe("YashRathore");

expect(toTitleCase("yash/rathore")).toBe("YashRathore");
})
});
5 changes: 5 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
presets: [
['@babel/preset-env', { targets: { node: 'current' } }]
]
}
Loading

0 comments on commit de3de7b

Please sign in to comment.