Skip to content

Commit 412bdc8

Browse files
author
Michal Paukert
authored
Merge pull request #8 from Kentico/michalpaukert-patch-1
Retry logic for timeouts and known status codes
2 parents a630f10 + cb614e7 commit 412bdc8

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ kontent environment add --name DEV --api-key <Api key> --project-id <Project ID>
5757
npm run migrate 01_sample_init_createBlogType
5858
```
5959

60+
Kontent CLI supports only running JavaScript migration files so in case you want to write in TypesSript, CoffeScript or in any other language you have to transpile your code before running.
61+
In the case of TypeScript, you may use this example from [Kontent CLI boilerplate](https://github.com/Kentico/kontent-migrations-boilerplate/blob/master/package.json#L7)
62+
6063
That's it! You've run your first Kontent migration. This migration created a content type called *Blog* that contains three text elements named *Title*, *Author* and *Text*. The sample migration is written in TypeScript.
6164

6265
The boilerplate is configured to transpile TypeScript migrations into plain JavaScript so that the Kontent CLI can execute the migrations. Note that if you don't want to use TypeScript for your migrations, it's fine to write the migrations directly in JavaScript.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kentico/kontent-cli",
3-
"version": "0.0.5",
3+
"version": "0.0.6",
44
"description": "Command line interface tool that can be used for generating and running Kontent migration scripts",
55
"main": "./lib/index.js",
66
"types": "./lib/types/index.d.ts",
@@ -29,20 +29,20 @@
2929
},
3030
"repository": {
3131
"type": "git",
32-
"url": "git+https://github.com/Kentico/kontent-migrations-boilerplate.git"
32+
"url": "git+https://github.com/Kentico/kontent-cli.git"
3333
},
3434
"author": "Kentico",
3535
"license": "MIT",
3636
"bugs": {
37-
"url": "https://github.com/Kentico/kontent-migrations-boilerplate/issues"
37+
"url": "https://github.com/Kentico/kontent-cli/issues"
3838
},
3939
"prettier": {
4040
"semi": true,
4141
"singleQuote": true,
4242
"tabWidth": 4,
4343
"printWidth": 250
4444
},
45-
"homepage": "https://github.com/Kentico/kontent-migrations-boilerplate#readme",
45+
"homepage": "https://github.com/Kentico/kontent-cli#readme",
4646
"dependencies": {
4747
"chalk": "^2.4.2",
4848
"yargs": "^14.2.0",

src/managementClientFactory.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ export const createManagementClient = (params: ICreateManagementClientParams): M
5151
maxCumulativeWaitTimeMs: 60000,
5252
maxAttempts: 10,
5353
canRetryError: (error: any) => {
54-
return retryAbleCodes.includes(error.response.status);
54+
const timeout = error.errno === 'ETIMEDOUT';
55+
return timeout || (error.response && retryAbleCodes.includes(error.response.status));
5556
}
5657
}
5758
});

0 commit comments

Comments
 (0)