Skip to content

Commit

Permalink
Update readme to show the changes
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanKiral committed Apr 14, 2023
1 parent 54691fb commit a99b07b
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,30 @@ The supported commands are divided into groups according to their target, at thi
* `backup --action [backup|restore|clean]` - This command enables you to use [Kontent.ai backup manager](https://github.com/kontent-ai/backup-manager-js)
* The purpose of this tool is to backup & restore [Kontent.ai projects](https://kontent.ai/). This project uses CM API to both get & restore data.

* `status --implementation` - This command creates in your working directory a new directory with a file `statusImpl.ts`. Having this file created, CLI will take your custom implementation of saving/reading the migrations status.
> 1. Don't forget to transpile the `statusImpl.ts` into `statusImpl.js` into the Javascript as it won't work otherwise!
### Custom implementation of reading/saving status of migrations

You might want to implement your way to store information about migrations status. For instance, you would like to save it into DB such as MongoDB, Firebase, etc,... and not use the default JSON file. Therefore, we provide you with an option to implement functions `readStatus` and `saveStatus`. To do so, create a new file called `plugins.js` at the root of your migrations project, and implement mentioned functions there. To fit into the required declarations, you can use the template below:

```js
//plugins.js
exports.saveStatus = async (data) => {}
exports.readStatus = async () => {}
```
> Note: Both functions must be implemented.

It is also possible to use Typescript. We have prepared types `SaveStatusType` and `ReadStatusType` to typesafe your functions. To create plugins in Typescript, create a file `plugins.ts` and implement your functions there. We suggest using and implementing the template below:

```ts
//plugins.ts
import type { ReadStatusType, SaveStatusType } from "@kontent-ai/cli";
export const saveStatus: SaveStatusType = async (data: string) => {}
export const readStatus: ReadStatusType = async () => {}
```

> Note: Don't forget to transpile `plugins.ts` into `plugins.js` otherwise your plugins will not work.

### Debugging

Expand Down

0 comments on commit a99b07b

Please sign in to comment.