@contentstack/cli-cm-import 0.1.1-beta.16 → 0.1.1-beta.17

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
@@ -34,7 +34,7 @@ $ npm install -g @contentstack/cli-cm-import
34
34
  $ csdx COMMAND
35
35
  running command...
36
36
  $ csdx (-v|--version|version)
37
- @contentstack/cli-cm-import/0.1.1-beta.16 linux-x64 node-v16.14.2
37
+ @contentstack/cli-cm-import/0.1.1-beta.17 linux-x64 node-v16.14.2
38
38
  $ csdx --help [COMMAND]
39
39
  USAGE
40
40
  $ csdx COMMAND
@@ -80,5 +80,5 @@ EXAMPLES
80
80
  csdx cm:import -A -B <branch name>
81
81
  ```
82
82
 
83
- _See code: [src/commands/cm/import.js](https://github.com/contentstack/cli/blob/v0.1.1-beta.16/packages/contentstack-import/src/commands/cm/import.js)_
83
+ _See code: [src/commands/cm/import.js](https://github.com/contentstack/cli/blob/v0.1.1-beta.17/packages/contentstack-import/src/commands/cm/import.js)_
84
84
  <!-- commandsstop -->
@@ -1 +1 @@
1
- {"version":"0.1.1-beta.16","commands":{"cm:import":{"id":"cm:import","description":"Import script for importing the content into new stack\n...\nOnce you export content from the source stack, import it to your destination stack by using the cm:import command.\n","pluginName":"@contentstack/cli-cm-import","pluginType":"core","aliases":[],"examples":["csdx cm:import -A","csdx cm:import -A -s <stack_ApiKey> -d <path/of/export/destination/dir>","csdx cm:import -A -c <path/of/config/dir>","csdx cm:import -A -m <single module name>","csdx cm:import -A -m <single module name> -b <backup dir>","csdx cm:import -a <management_token_alias>","csdx cm:import -a <management_token_alias> -d <path/of/export/destination/dir>","csdx cm:import -a <management_token_alias> -c <path/of/config/file>","csdx cm:import -A -m <single module name>","csdx cm:import -A -B <branch name>"],"flags":{"config":{"name":"config","type":"option","char":"c","description":"[optional] path of config file"},"stack-uid":{"name":"stack-uid","type":"option","char":"s","description":"API key of the target stack"},"data":{"name":"data","type":"option","char":"d","description":"path and location where data is stored"},"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"},"backup-dir":{"name":"backup-dir","type":"option","char":"b","description":"[optional] backup directory name when using specific module"},"branch":{"name":"branch","type":"option","char":"B","description":"[optional] branch name"}},"args":[]}}}
1
+ {"version":"0.1.1-beta.17","commands":{"cm:import":{"id":"cm:import","description":"Import script for importing the content into new stack\n...\nOnce you export content from the source stack, import it to your destination stack by using the cm:import command.\n","pluginName":"@contentstack/cli-cm-import","pluginType":"core","aliases":[],"examples":["csdx cm:import -A","csdx cm:import -A -s <stack_ApiKey> -d <path/of/export/destination/dir>","csdx cm:import -A -c <path/of/config/dir>","csdx cm:import -A -m <single module name>","csdx cm:import -A -m <single module name> -b <backup dir>","csdx cm:import -a <management_token_alias>","csdx cm:import -a <management_token_alias> -d <path/of/export/destination/dir>","csdx cm:import -a <management_token_alias> -c <path/of/config/file>","csdx cm:import -A -m <single module name>","csdx cm:import -A -B <branch name>"],"flags":{"config":{"name":"config","type":"option","char":"c","description":"[optional] path of config file"},"stack-uid":{"name":"stack-uid","type":"option","char":"s","description":"API key of the target stack"},"data":{"name":"data","type":"option","char":"d","description":"path and location where data is stored"},"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"},"backup-dir":{"name":"backup-dir","type":"option","char":"b","description":"[optional] backup directory name when using specific module"},"branch":{"name":"branch","type":"option","char":"B","description":"[optional] branch name"}},"args":[]}}}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@contentstack/cli-cm-import",
3
3
  "description": "Contentstack CLI plugin to import content into stack",
4
- "version": "0.1.1-beta.16",
4
+ "version": "0.1.1-beta.17",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {
@@ -191,6 +191,7 @@ importContentTypes.prototype = {
191
191
  // eslint-disable-next-line no-undef
192
192
  return Promise.map(globalFieldPendingPath, function (globalfield) {
193
193
  let Obj = _.find(self.globalfields, {uid: globalfield})
194
+ supress(Obj.schema)
194
195
  let globalFieldObj = stack.globalField(globalfield)
195
196
  Object.assign(globalFieldObj, _.cloneDeep(Obj))
196
197
  return globalFieldObj.update()
@@ -906,7 +906,7 @@ importEntries.prototype = {
906
906
  for (let i = 0; i < ctSchema.length; i++) {
907
907
  switch(ctSchema[i].data_type) {
908
908
  case 'blocks': {
909
- if (entry[ctSchema[i].uid] !== undefined) {
909
+ if (entry[ctSchema[i].uid]) {
910
910
  if (ctSchema[i].multiple) {
911
911
  entry[ctSchema[i].uid] = entry[ctSchema[i].uid].map(e => {
912
912
  let key = Object.keys(e).pop()
@@ -920,7 +920,7 @@ importEntries.prototype = {
920
920
  }
921
921
  case 'global_field':
922
922
  case 'group': {
923
- if (entry[ctSchema[i].uid] !== undefined) {
923
+ if (entry[ctSchema[i].uid]) {
924
924
  if (ctSchema[i].multiple) {
925
925
  entry[ctSchema[i].uid] = entry[ctSchema[i].uid].map(e => {
926
926
  e = this.removeEntryRefsFromJSONRTE(e, ctSchema[i].schema)
@@ -933,7 +933,7 @@ importEntries.prototype = {
933
933
  break;
934
934
  }
935
935
  case 'json': {
936
- if (entry[ctSchema[i].uid] !== undefined) {
936
+ if (entry[ctSchema[i].uid] && ctSchema[i].field_metadata.rich_text_type) {
937
937
  if (ctSchema[i].multiple) {
938
938
  entry[ctSchema[i].uid] = entry[ctSchema[i].uid].map(jsonRteData => {
939
939
  // repeated code from else block, will abstract later
@@ -987,7 +987,7 @@ importEntries.prototype = {
987
987
  for (let i = 0; i < ctSchema.length; i++) {
988
988
  switch (ctSchema[i].data_type) {
989
989
  case 'blocks': {
990
- if (entry[ctSchema[i].uid] !== undefined) {
990
+ if (entry[ctSchema[i].uid]) {
991
991
  if (ctSchema[i].multiple) {
992
992
  entry[ctSchema[i].uid] = entry[ctSchema[i].uid].map((e, eIndex) => {
993
993
  let key = Object.keys(e).pop()
@@ -1002,7 +1002,7 @@ importEntries.prototype = {
1002
1002
  }
1003
1003
  case 'global_field':
1004
1004
  case 'group': {
1005
- if (entry[ctSchema[i].uid] !== undefined) {
1005
+ if (entry[ctSchema[i].uid]) {
1006
1006
  if (ctSchema[i].multiple) {
1007
1007
  entry[ctSchema[i].uid] = entry[ctSchema[i].uid].map((e, eIndex) => {
1008
1008
  let sourceStackElement = sourceStackEntry[ctSchema[i].uid][eIndex]
@@ -1017,7 +1017,7 @@ importEntries.prototype = {
1017
1017
  break;
1018
1018
  }
1019
1019
  case 'json': {
1020
- if (entry[ctSchema[i].uid] !== undefined) {
1020
+ if (entry[ctSchema[i].uid] && ctSchema[i].field_metadata.rich_text_type) {
1021
1021
  if (ctSchema[i].multiple) {
1022
1022
  entry[ctSchema[i].uid] = entry[ctSchema[i].uid].map((field, index) => {
1023
1023
  field.children = [
@@ -1060,7 +1060,7 @@ importEntries.prototype = {
1060
1060
  for (let i = 0; i < ctSchema.length; i++) {
1061
1061
  switch (ctSchema[i].data_type) {
1062
1062
  case 'blocks': {
1063
- if (entry[ctSchema[i].uid] !== undefined) {
1063
+ if (entry[ctSchema[i].uid]) {
1064
1064
  if (ctSchema[i].multiple) {
1065
1065
  entry[ctSchema[i].uid] = entry[ctSchema[i].uid].map(e => {
1066
1066
  let key = Object.keys(e).pop()
@@ -1074,7 +1074,7 @@ importEntries.prototype = {
1074
1074
  }
1075
1075
  case 'global_field':
1076
1076
  case 'group': {
1077
- if (entry[ctSchema[i].uid] !== undefined) {
1077
+ if (entry[ctSchema[i].uid]) {
1078
1078
  if (ctSchema[i].multiple) {
1079
1079
  entry[ctSchema[i].uid] = entry[ctSchema[i].uid].map(e => {
1080
1080
  e = this.generateUidsForJsonRteFields(e, ctSchema[i].schema)
@@ -1087,7 +1087,7 @@ importEntries.prototype = {
1087
1087
  break;
1088
1088
  }
1089
1089
  case 'json': {
1090
- if (entry[ctSchema[i].uid] !== undefined) {
1090
+ if (entry[ctSchema[i].uid] && ctSchema[i].field_metadata.rich_text_type) {
1091
1091
  if (ctSchema[i].multiple) {
1092
1092
  entry[ctSchema[i].uid] = entry[ctSchema[i].uid].map(jsonRteData => {
1093
1093
  jsonRteData.uid = this.generateUid()
@@ -76,7 +76,7 @@ importExtensions.prototype = {
76
76
  })
77
77
  }
78
78
  // the extensions has already been created
79
- addlogs(config, chalk.white('The extension: \'' + ext.name +
79
+ addlogs(config, chalk.white('The extension: \'' + ext.title +
80
80
  '\' already exists. Skipping it to avoid duplicates!'), 'success')
81
81
  // import 2 extensions at a time
82
82
  }, {
@@ -1,4 +1,7 @@
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 = {
@@ -8,6 +11,17 @@ exports.Client = function (config) {
8
11
  api_key: config.target_stack,
9
12
  maxContentLength: 100000000,
10
13
  maxBodyLength: 1000000000,
14
+ maxRequests: 10,
15
+ retryLimit: 5,
16
+ timeout: 60000,
17
+ httpsAgent: new https.Agent({
18
+ maxSockets: 100,
19
+ maxFreeSockets: 10,
20
+ keepAlive: true,
21
+ timeout: 60000, // active socket keepalive for 60 seconds
22
+ freeSocketTimeout: 30000, // free socket keepalive for 30 seconds
23
+ }),
24
+ retryDelay: Math.floor(Math.random() * (8000 - 3000 + 1) + 3000),
11
25
  logHandler: (level, data) => {},
12
26
  retryCondition: (error) => {
13
27
  // no async function should be used here
@@ -22,12 +36,12 @@ exports.Client = function (config) {
22
36
  retryDelayOptions: {
23
37
  base: 1000,
24
38
  },
25
- }
26
- if (typeof config.branchName === 'string') {
39
+ };
40
+ if (typeof config.branchName === "string") {
27
41
  option.headers = {
28
42
  branch: config.branchName,
29
- }
43
+ };
30
44
  }
31
- const client = contentstacksdk.client(option)
32
- return client
33
- }
45
+ const client = contentstacksdk.client(option);
46
+ return client;
47
+ };
@@ -67,7 +67,7 @@ module.exports = function (data, mappedAssetUids, mappedAssetUrls, assetUidMappe
67
67
  for (let i = 0; i < ctSchema.length; i++) {
68
68
  switch (ctSchema[i].data_type) {
69
69
  case 'blocks': {
70
- if (entry[ctSchema[i].uid] !== undefined) {
70
+ if (entry[ctSchema[i].uid]) {
71
71
  if (ctSchema[i].multiple) {
72
72
  entry[ctSchema[i].uid].forEach(e => {
73
73
  let key = Object.keys(e).pop()
@@ -80,7 +80,7 @@ module.exports = function (data, mappedAssetUids, mappedAssetUrls, assetUidMappe
80
80
  }
81
81
  case 'global_field':
82
82
  case 'group': {
83
- if (entry[ctSchema[i].uid] !== undefined) {
83
+ if (entry[ctSchema[i].uid]) {
84
84
  if (ctSchema[i].multiple) {
85
85
  entry[ctSchema[i].uid].forEach(e => {
86
86
  findAssetIdsFromJsonRte(e, ctSchema[i].schema)
@@ -92,7 +92,7 @@ module.exports = function (data, mappedAssetUids, mappedAssetUrls, assetUidMappe
92
92
  break;
93
93
  }
94
94
  case 'json': {
95
- if (entry[ctSchema[i].uid] !== undefined) {
95
+ if (entry[ctSchema[i].uid] && ctSchema[i].field_metadata.rich_text_type) {
96
96
  if (ctSchema[i].multiple) {
97
97
  entry[ctSchema[i].uid].forEach(jsonRteData => {
98
98
  gatherJsonRteAssetIds(jsonRteData)
@@ -235,7 +235,7 @@ function findFileUrls (schema, _entry, assetUrls) {
235
235
  var text;
236
236
  // Regex to detect v3 asset uri patterns
237
237
  if (schema && schema.field_metadata && schema.field_metadata.markdown) {
238
- text = marked(_entry);
238
+ text = marked(JSON.stringify(_entry));
239
239
  } else {
240
240
  text = JSON.stringify(_entry);
241
241
  }
@@ -133,7 +133,7 @@ module.exports = function (data, mappedUids, uidMapperPath) {
133
133
  for (let i = 0; i < ctSchema.length; i++) {
134
134
  switch (ctSchema[i].data_type) {
135
135
  case 'blocks': {
136
- if (entry[ctSchema[i].uid] !== undefined) {
136
+ if (entry[ctSchema[i].uid]) {
137
137
  if (ctSchema[i].multiple) {
138
138
  entry[ctSchema[i].uid].forEach(e => {
139
139
  let key = Object.keys(e).pop()
@@ -146,7 +146,7 @@ module.exports = function (data, mappedUids, uidMapperPath) {
146
146
  }
147
147
  case 'global_field':
148
148
  case 'group': {
149
- if (entry[ctSchema[i].uid] !== undefined) {
149
+ if (entry[ctSchema[i].uid]) {
150
150
  if (ctSchema[i].multiple) {
151
151
  entry[ctSchema[i].uid].forEach(e => {
152
152
  findEntryIdsFromJsonRte(e, ctSchema[i].schema)
@@ -158,7 +158,7 @@ module.exports = function (data, mappedUids, uidMapperPath) {
158
158
  break;
159
159
  }
160
160
  case 'json': {
161
- if (entry[ctSchema[i].uid] !== undefined) {
161
+ if (entry[ctSchema[i].uid] && ctSchema[i].field_metadata.rich_text_type) {
162
162
  if (ctSchema[i].multiple) {
163
163
  entry[ctSchema[i].uid].forEach(jsonRteData => {
164
164
  gatherJsonRteEntryIds(jsonRteData)