@contentstack/cli-cm-export 0.1.1-beta.10 → 0.1.1-beta.11

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 CHANGED
@@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-cm-export
18
18
  $ csdx COMMAND
19
19
  running command...
20
20
  $ csdx (-v|--version|version)
21
- @contentstack/cli-cm-export/0.1.1-beta.10 linux-x64 node-v12.22.7
21
+ @contentstack/cli-cm-export/0.1.1-beta.11 linux-x64 node-v12.22.7
22
22
  $ csdx --help [COMMAND]
23
23
  USAGE
24
24
  $ csdx COMMAND
@@ -68,5 +68,5 @@ EXAMPLES
68
68
  csdx cm:export -A -B [optional] branch name
69
69
  ```
70
70
 
71
- _See code: [src/commands/cm/export.js](https://github.com/contentstack/cli/blob/v0.1.1-beta.10/packages/contentstack-export/src/commands/cm/export.js)_
71
+ _See code: [src/commands/cm/export.js](https://github.com/contentstack/cli/blob/v0.1.1-beta.11/packages/contentstack-export/src/commands/cm/export.js)_
72
72
  <!-- commandsstop -->
@@ -1 +1 @@
1
- {"version":"0.1.1-beta.10","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":[]}}}
1
+ {"version":"0.1.1-beta.11","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.10",
4
+ "version": "0.1.1-beta.11",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {
@@ -39,6 +39,8 @@ ExportAssets.prototype = {
39
39
  start: function (credentialConfig) {
40
40
  this.assetContents = {}
41
41
  this.folderData = []
42
+ this.assetDownloadRetry = {};
43
+ this.assetDownloadRetryLimit = 3;
42
44
  let self = this
43
45
  config = credentialConfig
44
46
  assetsFolderPath = path.resolve(config.data, (config.branchName || ""), assetConfig.dirName)
@@ -69,9 +71,9 @@ ExportAssets.prototype = {
69
71
  // log.success(chalk.white('The following asset has been downloaded successfully: ' +
70
72
  // assetJSON.uid))
71
73
  }).catch(function (error) {
72
- addlogs(self.configchalk.red('The following asset failed to download\n' + JSON.stringify(
74
+ addlogs(config, chalk.red('The following asset failed to download\n' + JSON.stringify(
73
75
  assetJSON)))
74
- addlogs(config, error, 'error')
76
+ addlogs(config, error, 'error')
75
77
  })
76
78
  }, {
77
79
  concurrency: vLimit,
@@ -210,6 +212,10 @@ ExportAssets.prototype = {
210
212
  let self = this
211
213
  let assetVersionInfo = bucket || []
212
214
  return new Promise(function (resolve, reject) {
215
+ if (self.assetDownloadRetry[uid + version] > self.assetDownloadRetryLimit) {
216
+ return reject(new Error('Asset Max download retry limit exceeded! ' + uid));
217
+ }
218
+
213
219
  if (version <= 0) {
214
220
  const assetVersionInfoFile = path.resolve(assetsFolderPath, uid, '_contentstack_' + uid + '.json')
215
221
  helper.writeFile(assetVersionInfoFile, assetVersionInfo)
@@ -231,8 +237,17 @@ ExportAssets.prototype = {
231
237
  assetVersionInfo = _.uniqWith(assetVersionInfo, _.isEqual)
232
238
  self.getVersionedAssetJSON(uid, --version, assetVersionInfo)
233
239
  .then(resolve)
234
- .catch(reject)
240
+ .catch(reject)
235
241
  }).catch(reject)
242
+ }).catch((error) => {
243
+ if (error.status === 408) {
244
+ // retrying when timeout
245
+ (self.assetDownloadRetry[uid+version] ? ++self.assetDownloadRetry[uid+version] : self.assetDownloadRetry[uid+version] = 1 )
246
+ return self.getVersionedAssetJSON(uid, version, assetVersionInfo)
247
+ .then(resolve)
248
+ .catch(reject)
249
+ }
250
+ reject(error);
236
251
  })
237
252
  })
238
253
  },
@@ -252,6 +267,7 @@ ExportAssets.prototype = {
252
267
  : asset.url,
253
268
  };
254
269
 
270
+ self.assetStream.url = encodeURI(self.assetStream.url);
255
271
  const assetStreamRequest = nativeRequest(self.assetStream)
256
272
  assetStreamRequest.on('response', function () {
257
273
  helper.makeDirectory(assetFolderPath)