@contentstack/cli-cm-export 0.1.1-beta.12 → 0.1.1-beta.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -2
- package/oclif.manifest.json +1 -1
- package/package.json +2 -1
- package/src/app.js +1 -1
- package/src/config/default.js +6 -0
- package/src/lib/export/assets.js +19 -2
- package/src/lib/util/contentstack-management-sdk.js +21 -1
package/README.md
CHANGED
|
@@ -10,6 +10,25 @@ It is Contentstack’s CLI plugin to export content from the stack. To learn how
|
|
|
10
10
|
* [Commands](#commands)
|
|
11
11
|
<!-- tocstop -->
|
|
12
12
|
|
|
13
|
+
For switching to EU region update the hosts at config/default.js
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
{
|
|
17
|
+
host:'https://eu-api.contentstack.com/v3',
|
|
18
|
+
cdn: 'https://eu-cdn.contentstack.com/v3',
|
|
19
|
+
...
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
For switching to AZURE-NA region update the hosts at config/default.js
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
{
|
|
27
|
+
host:'https://azure-na-api.contentstack.com/v3',
|
|
28
|
+
cdn: 'https://azure-na-cdn.contentstack.com/v3',
|
|
29
|
+
...
|
|
30
|
+
}
|
|
31
|
+
```
|
|
13
32
|
# Usage
|
|
14
33
|
|
|
15
34
|
<!-- usage -->
|
|
@@ -18,7 +37,7 @@ $ npm install -g @contentstack/cli-cm-export
|
|
|
18
37
|
$ csdx COMMAND
|
|
19
38
|
running command...
|
|
20
39
|
$ csdx (-v|--version|version)
|
|
21
|
-
@contentstack/cli-cm-export/0.1.1-beta.
|
|
40
|
+
@contentstack/cli-cm-export/0.1.1-beta.15 linux-x64 node-v16.14.2
|
|
22
41
|
$ csdx --help [COMMAND]
|
|
23
42
|
USAGE
|
|
24
43
|
$ csdx COMMAND
|
|
@@ -68,5 +87,5 @@ EXAMPLES
|
|
|
68
87
|
csdx cm:export -A -B [optional] branch name
|
|
69
88
|
```
|
|
70
89
|
|
|
71
|
-
_See code: [src/commands/cm/export.js](https://github.com/contentstack/cli/blob/v0.1.1-beta.
|
|
90
|
+
_See code: [src/commands/cm/export.js](https://github.com/contentstack/cli/blob/v0.1.1-beta.15/packages/contentstack-export/src/commands/cm/export.js)_
|
|
72
91
|
<!-- commandsstop -->
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.1.1-beta.
|
|
1
|
+
{"version":"0.1.1-beta.15","commands":{"cm:export":{"id":"cm:export","description":"Export content from a stack\n...\nExport content from one stack to another\n","pluginName":"@contentstack/cli-cm-export","pluginType":"core","aliases":[],"examples":["csdx cm:export -A","csdx cm:export -A -s <stack_ApiKey> -d <path/of/export/destination/dir>","csdx cm:export -A -c <path/to/config/dir>","csdx cm:export -A -m <single module name>","csdx cm:export -A --secured-assets","csdx cm:export -a <management_token_alias>","csdx cm:export -a <management_token_alias> -d <path/to/export/destination/dir>","csdx cm:export -a <management_token_alias> -c <path/to/config/file>","csdx cm:export -A -m <single module name>","csdx cm:export -A -m <single module name> -t <content type>","csdx cm:export -A -B [optional] branch name"],"flags":{"config":{"name":"config","type":"option","char":"c","description":"[optional] path of the config"},"stack-uid":{"name":"stack-uid","type":"option","char":"s","description":"API key of the source stack"},"data":{"name":"data","type":"option","char":"d","description":"path or location to store the data"},"management-token-alias":{"name":"management-token-alias","type":"option","char":"a","description":"alias of the management token"},"auth-token":{"name":"auth-token","type":"boolean","char":"A","description":"to use auth token","allowNo":false},"module":{"name":"module","type":"option","char":"m","description":"[optional] specific module name"},"content-type":{"name":"content-type","type":"option","char":"t","description":"[optional] content type"},"branch":{"name":"branch","type":"option","char":"B","description":"[optional] branch name"},"secured-assets":{"name":"secured-assets","type":"boolean","description":"[optional] use when assets are secured","allowNo":false}},"args":[]}}}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-cm-export",
|
|
3
3
|
"description": "Contentstack CLI plugin to export content from stack",
|
|
4
|
-
"version": "0.1.1-beta.
|
|
4
|
+
"version": "0.1.1-beta.15",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"is-valid-path": "^0.1.1",
|
|
19
19
|
"lodash": "^4.17.20",
|
|
20
20
|
"path": "^0.12.7",
|
|
21
|
+
"progress-stream": "^2.0.0",
|
|
21
22
|
"proxyquire": "^2.1.3",
|
|
22
23
|
"request": "^2.88.2",
|
|
23
24
|
"winston": "^2.2.0"
|
package/src/app.js
CHANGED
|
@@ -90,7 +90,7 @@ var singleExport = async (moduleName, types, config, branchName) => {
|
|
|
90
90
|
const result = await exportedModule.start(config, branchName);
|
|
91
91
|
if (result && iterateList[i] === "stack") {
|
|
92
92
|
let master_locale = {
|
|
93
|
-
master_locale: { code: result.
|
|
93
|
+
master_locale: { code: result.code },
|
|
94
94
|
};
|
|
95
95
|
config = _.merge(config, master_locale);
|
|
96
96
|
}
|
package/src/config/default.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
versioning: false,
|
|
3
|
+
host: 'https://api.contentstack.io/v3',
|
|
4
|
+
// use below hosts for eu region
|
|
5
|
+
// host:'https://eu-api.contentstack.com/v3',
|
|
6
|
+
// use below hosts for azure-na region
|
|
7
|
+
// host:'https://azure-na-api.contentstack.com/v3',
|
|
3
8
|
modules: {
|
|
4
9
|
types: [
|
|
5
10
|
'stack',
|
|
@@ -98,6 +103,7 @@ module.exports = {
|
|
|
98
103
|
],
|
|
99
104
|
// no of asset version files (of a single asset) that'll be downloaded parallelly
|
|
100
105
|
downloadLimit: 5,
|
|
106
|
+
enableDownloadStatus: false
|
|
101
107
|
},
|
|
102
108
|
content_types: {
|
|
103
109
|
dirName: 'content_types',
|
package/src/lib/export/assets.js
CHANGED
|
@@ -11,6 +11,7 @@ const fs = require('fs')
|
|
|
11
11
|
const Promise = require('bluebird')
|
|
12
12
|
const _ = require('lodash')
|
|
13
13
|
const chalk = require('chalk')
|
|
14
|
+
const progress = require('progress-stream')
|
|
14
15
|
|
|
15
16
|
const helper = require('../util/helper')
|
|
16
17
|
const {addlogs} = require('../util/log')
|
|
@@ -269,10 +270,26 @@ ExportAssets.prototype = {
|
|
|
269
270
|
|
|
270
271
|
self.assetStream.url = encodeURI(self.assetStream.url);
|
|
271
272
|
const assetStreamRequest = nativeRequest(self.assetStream)
|
|
272
|
-
assetStreamRequest.on('response', function () {
|
|
273
|
+
assetStreamRequest.on('response', function (response) {
|
|
274
|
+
|
|
273
275
|
helper.makeDirectory(assetFolderPath)
|
|
274
276
|
const assetFileStream = fs.createWriteStream(assetFilePath)
|
|
275
|
-
|
|
277
|
+
|
|
278
|
+
if(assetConfig.enableDownloadStatus) {
|
|
279
|
+
const str = progress({
|
|
280
|
+
length: response.headers['content-length'],
|
|
281
|
+
time: 5000,
|
|
282
|
+
})
|
|
283
|
+
|
|
284
|
+
str.on('progress', function (progressData) {
|
|
285
|
+
console.log(`${asset.filename}: ${Math.round(progressData.percentage)}%`)
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
assetStreamRequest.pipe(str).pipe(assetFileStream)
|
|
289
|
+
} else {
|
|
290
|
+
assetStreamRequest.pipe(assetFileStream)
|
|
291
|
+
}
|
|
292
|
+
|
|
276
293
|
assetFileStream.on('close', function () {
|
|
277
294
|
addlogs(config, 'Downloaded ' + asset.filename + ': ' + asset.uid + ' successfully!', 'success')
|
|
278
295
|
return resolve()
|
|
@@ -1,11 +1,31 @@
|
|
|
1
1
|
const contentstacksdk = require('@contentstack/management')
|
|
2
|
+
const https = require('https');
|
|
3
|
+
|
|
4
|
+
const { addlogs } = require('./log');
|
|
2
5
|
|
|
3
6
|
exports.Client = function (config) {
|
|
4
7
|
const option = {
|
|
5
8
|
host: config.host,
|
|
6
9
|
authtoken: config.auth_token,
|
|
7
10
|
api_key: config.source_stack,
|
|
8
|
-
|
|
11
|
+
maxRequests: 10,
|
|
12
|
+
retryLimit: 5,
|
|
13
|
+
timeout: 60000,
|
|
14
|
+
httpsAgent: new https.Agent({
|
|
15
|
+
maxSockets: 100,
|
|
16
|
+
maxFreeSockets: 10,
|
|
17
|
+
keepAlive: true,
|
|
18
|
+
timeout: 60000, // active socket keepalive for 60 seconds
|
|
19
|
+
freeSocketTimeout: 30000, // free socket keepalive for 30 seconds
|
|
20
|
+
}),
|
|
21
|
+
retryDelay: Math.floor(Math.random() * (8000 - 3000 + 1) + 3000),
|
|
22
|
+
logHandler: (level, data) => { },
|
|
23
|
+
retryCondition: (error) => {
|
|
24
|
+
if (error.response.status === 408) {
|
|
25
|
+
addlogs({ data: error.response }, 'Timeout error', 'error');
|
|
26
|
+
}
|
|
27
|
+
return false
|
|
28
|
+
}
|
|
9
29
|
}
|
|
10
30
|
|
|
11
31
|
if (typeof config.branchName === 'string') {
|