portal-javascript-sdk

## ⌨ Writing code

Unlike other libraries, most of the code here is not handwritten. We use [@ordercloud/oc-codegen](https://github.com/ordercloud-api/oc-codegen) to generate the code based on a set of templates located in `/codegen/`. This tool uses the Ordercloud Portal OpenAPI specification along with the templates to generate the full SDK. Most changes should be taking place on the OpenAPI spec. Any direct changes in `/src/` will simply be overwritten when you run `npm run build`.

## Generating the SDK

Be sure you have installed dependencies with run`npm install`. Then run `npm run build` to generate the SDK and docs.

```shell
npm run build
```

## ✨ Submitting a pull request

1. Install dependencies
2. Make your changes. Note: all of your changes should be to files in the openAPI spec or `/codegen` and not directly to any of the files in `src/` as those files get overwritten when the code is generated.
3. Run `npm run build` to regenerate the sdk, compile the code, run the tests, and generate the docs
4. Verify your changes work as expected. Run `npm install /path/to/this/folder` in a different project to install locally and test
5. Commit your changes. We adhere to the [gitmoji](https://github.com/carloscuesta/gitmoji/) standard
6. Update the sdk version in the [package.json](../package.json) and make a separate version commit in the format `:bookmark: {newVersionHere}`
7. Push to master.

## 🚀 Releasing

Assuming you or a contributor followed the instructions for [submitting a pull request](#✨-submitting-a-pull-request) and are a maintainer you can follow these instructions to release a new version of the sdk.

1. Verify the version has been bumped and adheres to [semantic versioning](https://semver.org/)
2. Create a publish a new release on github
3. Make sure you are logged into npm with `npm login`
4. Run `npm publish --dry-run` for a preview, or `npm publish`
