@contentstack/cli-cm-import 0.1.1-beta.9 → 1.0.0

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.
@@ -1,152 +1,191 @@
1
1
  /*!
2
- * Contentstack Export
3
- * Copyright (c) 2019 Contentstack LLC
4
- * MIT Licensed
5
- */
6
- let defaultConfig = require('../../config/default')
7
- let { initial } = require('../../app')
8
- let _ = require('lodash')
9
- const { cli } = require('cli-ux')
10
- let message = require('../../../messages/index.json')
11
-
12
- exports.configWithMToken = function (config, managementTokens, moduleName, host, _authToken, backupdir) {
2
+ * Contentstack Export
3
+ * Copyright (c) 2019 Contentstack LLC
4
+ * MIT Licensed
5
+ */
6
+ let defaultConfig = require('../../config/default');
7
+ let { initial } = require('../../app');
8
+ let _ = require('lodash');
9
+ const { cliux } = require('@contentstack/cli-utilities');
10
+ let message = require('../../../messages/index.json');
11
+
12
+ exports.configWithMToken = function (
13
+ config,
14
+ managementTokens,
15
+ moduleName,
16
+ host,
17
+ _authToken,
18
+ backupdir,
19
+ importCommandFlags,
20
+ ) {
13
21
  return new Promise(async function (resolve, reject) {
14
- let externalConfig = require(config)
15
- defaultConfig.management_token = managementTokens.token
22
+ let externalConfig = config ? require(config) : {};
23
+ const modules = externalConfig.modules;
24
+
25
+ if (_.isArray(externalConfig['modules'])) {
26
+ externalConfig = _.omit(externalConfig, ['modules']);
27
+ }
28
+
29
+ defaultConfig.host = host;
30
+ defaultConfig.branchName = importCommandFlags.branchName;
31
+ defaultConfig.target_stack = managementTokens.apiKey;
32
+ defaultConfig.management_token = managementTokens.token;
33
+ defaultConfig.importWebhookStatus = importCommandFlags.importWebhookStatus;
34
+
16
35
  if (moduleName && moduleName !== undefined) {
17
- defaultConfig.moduleName = moduleName
36
+ defaultConfig.moduleName = moduleName;
18
37
  }
19
- defaultConfig.host = host
38
+
20
39
  if (backupdir) {
21
40
  defaultConfig.useBackedupDir = backupdir;
22
41
  }
23
- defaultConfig.auth_token = _authToken
24
- defaultConfig = _.merge(defaultConfig, externalConfig)
25
- initial(defaultConfig)
26
- .then(() => {
27
- return resolve()
28
- }).catch((error) => {
29
- return reject()
30
- })
31
- })
32
- }
33
-
34
- exports.parameterWithMToken = function (managementTokens, data, moduleName, host, _authToken, backupdir) {
42
+
43
+ defaultConfig.auth_token = _authToken;
44
+ defaultConfig = _.merge(defaultConfig, externalConfig);
45
+
46
+ if(!defaultConfig.data) {
47
+ const exporteddata = await cliux.prompt(message.promptMessageList.promptPathStoredData);
48
+ defaultConfig.data = exporteddata
49
+ }
50
+
51
+ if (_.isArray(modules)) {
52
+ defaultConfig.modules.types = _.filter(defaultConfig.modules.types, (module) => _.includes(modules, module));
53
+ }
54
+
55
+ initial(defaultConfig).then(resolve).catch(reject);
56
+ });
57
+ };
58
+
59
+ exports.parameterWithMToken = function (
60
+ managementTokens,
61
+ data,
62
+ moduleName,
63
+ host,
64
+ _authToken,
65
+ backupdir,
66
+ importCommandFlags,
67
+ ) {
35
68
  return new Promise(async function (resolve, reject) {
36
- defaultConfig.management_token = managementTokens.token
37
- defaultConfig.target_stack = managementTokens.apiKey
38
- defaultConfig.auth_token = _authToken
69
+ defaultConfig.management_token = managementTokens.token;
70
+ defaultConfig.target_stack = managementTokens.apiKey;
71
+ defaultConfig.auth_token = _authToken;
72
+ defaultConfig.branchName = importCommandFlags.branchName;
73
+ defaultConfig.importWebhookStatus = importCommandFlags.importWebhookStatus;
39
74
  if (moduleName && moduleName !== undefined) {
40
- defaultConfig.moduleName = moduleName
75
+ defaultConfig.moduleName = moduleName;
41
76
  }
42
- defaultConfig.data = data
43
- defaultConfig.host = host
77
+ defaultConfig.data = data;
78
+ defaultConfig.host = host;
44
79
  if (backupdir) {
45
80
  defaultConfig.useBackedupDir = backupdir;
46
81
  }
47
- initial(defaultConfig)
48
- .then(() => {
49
- return resolve()
50
- }).catch((error) => {
51
- return reject()
52
- })
53
- })
54
- }
82
+ initial(defaultConfig).then(resolve).catch(reject);
83
+ });
84
+ };
55
85
 
56
86
  // using ManagemetToken
57
- exports.withoutParameterMToken = async (managementTokens, moduleName, host, _authToken, backupdir) => {
87
+ exports.withoutParameterMToken = async (
88
+ managementTokens,
89
+ moduleName,
90
+ host,
91
+ _authToken,
92
+ backupdir,
93
+ importCommandFlags,
94
+ ) => {
58
95
  return new Promise(async function (resolve, reject) {
59
- const exporteddata = await cli.prompt(message.promptMessageList.promptPathStoredData)
60
- defaultConfig.management_token = managementTokens.token
61
- defaultConfig.target_stack = managementTokens.apiKey
62
- defaultConfig.auth_token = _authToken
96
+ const exporteddata = await cliux.prompt(message.promptMessageList.promptPathStoredData);
97
+ defaultConfig.management_token = managementTokens.token;
98
+ defaultConfig.target_stack = managementTokens.apiKey;
99
+ defaultConfig.auth_token = _authToken;
100
+ defaultConfig.branchName = importCommandFlags.branchName;
101
+ defaultConfig.importWebhookStatus = importCommandFlags.importWebhookStatus;
63
102
  if (moduleName && moduleName !== undefined) {
64
- defaultConfig.moduleName = moduleName
103
+ defaultConfig.moduleName = moduleName;
65
104
  }
66
- defaultConfig.data = exporteddata
67
- defaultConfig.host = host
105
+ defaultConfig.data = exporteddata;
106
+ defaultConfig.host = host;
68
107
  if (backupdir) {
69
108
  defaultConfig.useBackedupDir = backupdir;
70
109
  }
71
- initial(defaultConfig)
72
- .then(() => {
73
- return resolve()
74
- }).catch((error) => {
75
- return reject()
76
- })
77
- })
78
- }
79
-
80
- exports.configWithAuthToken = function (config, _authToken, moduleName, host, backupdir) {
110
+ initial(defaultConfig).then(resolve).catch(reject);
111
+ });
112
+ };
113
+
114
+ exports.configWithAuthToken = function (config, _authToken, moduleName, host, backupdir, importCommandFlags) {
81
115
  return new Promise(async function (resolve, reject) {
82
- let externalConfig = require(config)
83
- defaultConfig.auth_token = _authToken
116
+ let externalConfig = require(config);
117
+ defaultConfig.auth_token = _authToken;
118
+ defaultConfig.branchName = importCommandFlags.branchName;
119
+ defaultConfig.importWebhookStatus = importCommandFlags.importWebhookStatus;
84
120
  if (moduleName && moduleName !== undefined) {
85
- defaultConfig.moduleName = moduleName
121
+ defaultConfig.moduleName = moduleName;
86
122
  }
87
- defaultConfig.host = host
123
+ defaultConfig.host = host;
88
124
 
89
125
  if (externalConfig.modules) {
90
- defaultConfig.modules.types = externalConfig.modules
91
- delete externalConfig.modules
126
+ defaultConfig.modules.types = externalConfig.modules;
127
+ delete externalConfig.modules;
92
128
  }
93
129
 
94
130
  if (backupdir) {
95
131
  defaultConfig.useBackedupDir = backupdir;
96
132
  }
97
- defaultConfig = _.merge(defaultConfig, externalConfig)
98
- initial(defaultConfig)
99
- .then(() => {
100
- return resolve()
101
- }).catch((error) => {
102
- return reject()
103
- })
104
- })
105
- }
106
-
107
- exports.parametersWithAuthToken = function (_authToken, targetStack, data, moduleName, host, backupdir) {
133
+ defaultConfig = _.merge(defaultConfig, externalConfig);
134
+ if (!defaultConfig.data) {
135
+ const exporteddata = await cliux.prompt(message.promptMessageList.promptPathStoredData);
136
+ defaultConfig.data = exporteddata
137
+ }
138
+ initial(defaultConfig).then(resolve).catch(reject);
139
+ });
140
+ };
141
+
142
+ exports.parametersWithAuthToken = function (
143
+ _authToken,
144
+ targetStack,
145
+ data,
146
+ moduleName,
147
+ host,
148
+ backupdir,
149
+ importCommandFlags,
150
+ ) {
108
151
  return new Promise(async function (resolve, reject) {
109
- defaultConfig.auth_token = _authToken
110
- defaultConfig.target_stack = targetStack
152
+ defaultConfig.auth_token = _authToken;
153
+ defaultConfig.target_stack = targetStack;
154
+ defaultConfig.branchName = importCommandFlags.branchName;
155
+ defaultConfig.importWebhookStatus = importCommandFlags.importWebhookStatus;
111
156
  if (moduleName && moduleName !== undefined && backupdir === undefined) {
112
- defaultConfig.moduleName = moduleName
157
+ defaultConfig.moduleName = moduleName;
113
158
  } else if (moduleName && moduleName !== undefined && backupdir !== undefined) {
114
- defaultConfig.moduleName = moduleName
115
- defaultConfig.useBackedupDir = backupdir
159
+ defaultConfig.moduleName = moduleName;
160
+ defaultConfig.useBackedupDir = backupdir;
161
+ } else if (backupdir) {
162
+ defaultConfig.useBackedupDir = backupdir;
116
163
  }
117
- defaultConfig.data = data
118
- defaultConfig.host = host
119
-
120
- initial(defaultConfig)
121
- .then(() => {
122
- return resolve()
123
- }).catch((error) => {
124
- return reject()
125
- })
126
- })
127
- }
128
-
129
- exports.withoutParametersWithAuthToken = async (_authToken, moduleName, host, backupdir) => {
164
+ defaultConfig.data = data;
165
+ defaultConfig.host = host;
166
+
167
+ initial(defaultConfig).then(resolve).catch(reject);
168
+ });
169
+ };
170
+
171
+ exports.withoutParametersWithAuthToken = async (_authToken, moduleName, host, backupdir, importCommandFlags) => {
130
172
  return new Promise(async function (resolve, reject) {
131
- const stackUid = await cli.prompt(message.promptMessageList.promptTargetStack)
132
- const exporteddata = await cli.prompt(message.promptMessageList.promptPathStoredData)
133
- defaultConfig.auth_token = _authToken
134
- defaultConfig.target_stack = stackUid
135
- defaultConfig.data = exporteddata
173
+ const stackUid = await cliux.prompt(message.promptMessageList.promptTargetStack);
174
+ const exporteddata = await cliux.prompt(message.promptMessageList.promptPathStoredData);
175
+ defaultConfig.auth_token = _authToken;
176
+ defaultConfig.target_stack = stackUid;
177
+ defaultConfig.data = exporteddata;
178
+ defaultConfig.branchName = importCommandFlags.branchName;
179
+ defaultConfig.importWebhookStatus = importCommandFlags.importWebhookStatus;
136
180
  if (moduleName && moduleName !== undefined && backupdir === undefined) {
137
- defaultConfig.moduleName = moduleName
181
+ defaultConfig.moduleName = moduleName;
138
182
  } else if (moduleName && moduleName !== undefined && backupdir !== undefined) {
139
- defaultConfig.moduleName = moduleName
140
- defaultConfig.useBackedupDir = backupdir
183
+ defaultConfig.moduleName = moduleName;
184
+ defaultConfig.useBackedupDir = backupdir;
141
185
  }
142
186
 
143
- defaultConfig.host = host
187
+ defaultConfig.host = host;
144
188
 
145
- initial(defaultConfig)
146
- .then(() => {
147
- return resolve()
148
- }).catch((error) => {
149
- return reject()
150
- })
151
- })
152
- }
189
+ initial(defaultConfig).then(resolve).catch(reject);
190
+ });
191
+ };
@@ -5,179 +5,183 @@
5
5
  * MIT Licensed
6
6
  */
7
7
 
8
- var _ = require('lodash')
9
- var fs = require('./fs')
10
- var path = require('path')
11
- var chalk = require('chalk')
12
- var {addlogs} = require('./log')
13
- var request = require('./request')
14
- var defaultConfig = require('../../config/default')
15
- const stack = require('./contentstack-management-sdk')
16
- var config
8
+ var _ = require('lodash');
9
+ const { HttpClient } = require('@contentstack/cli-utilities');
10
+ var fs = require('./fs');
11
+ var path = require('path');
12
+ var chalk = require('chalk');
13
+ var { addlogs } = require('./log');
14
+ var defaultConfig = require('../../config/default');
15
+ const stack = require('./contentstack-management-sdk');
16
+ var config;
17
17
 
18
- exports.initialization = function(configData) {
19
- config = this.buildAppConfig(configData)
20
- var res = this.validateConfig(config)
18
+ exports.initialization = function (configData) {
19
+ config = this.buildAppConfig(configData);
20
+ var res = this.validateConfig(config);
21
21
 
22
- if (res && res !== 'error' || res === undefined) {
23
- return config
22
+ if ((res && res !== 'error') || res === undefined) {
23
+ return config;
24
24
  }
25
- }
25
+ };
26
26
 
27
- exports.validateConfig = function (config) {
28
- if (config.email && config.password && !config.target_stack) {
29
- addlogs(config, chalk.red('Kindly provide api_token'), 'error')
30
- return 'error'
31
- } if(!config.email && !config.password && !config.management_token && config.target_stack && !config.auth_token) {
32
- addlogs(config, chalk.red('Kindly provide management_token or email and password'), 'error')
33
- return 'error'
34
- } else if(!config.email && !config.password && config.preserveStackVersion) {
35
- addlogs(config, chalk.red('Kindly provide Email and password for old version stack'), 'error')
36
- return 'error'
37
- } else if(config.email && !config.password || !config.email && config.password) {
38
- addlogs(config, chalk.red('Kindly provide Email and password'), 'error')
39
- return 'error'
27
+ exports.validateConfig = function (importConfig) {
28
+ if (importConfig.email && importConfig.password && !importConfig.target_stack) {
29
+ addlogs(importConfig, chalk.red('Kindly provide api_token'), 'error');
30
+ return 'error';
31
+ } else if (
32
+ !importConfig.email &&
33
+ !importConfig.password &&
34
+ !importConfig.management_token &&
35
+ importConfig.target_stack &&
36
+ !importConfig.auth_token
37
+ ) {
38
+ addlogs(importConfig, chalk.red('Kindly provide management_token or email and password'), 'error');
39
+ return 'error';
40
+ } else if (!importConfig.email && !importConfig.password && importConfig.preserveStackVersion) {
41
+ addlogs(importConfig, chalk.red('Kindly provide Email and password for old version stack'), 'error');
42
+ return 'error';
43
+ } else if ((importConfig.email && !importConfig.password) || (!importConfig.email && importConfig.password)) {
44
+ addlogs(importConfig, chalk.red('Kindly provide Email and password'), 'error');
45
+ return 'error';
40
46
  }
41
- // if(!config.languagesCode.includes(config.master_locale.code)) {
42
- // addlogs(config, chalk.red('Kindly provide valid master_locale code'), 'error')
43
- // return 'error'
44
- // }
45
- }
47
+ };
46
48
 
47
- exports.buildAppConfig = function (config) {
48
- config = _.merge(defaultConfig, config)
49
- return config
49
+ exports.buildAppConfig = function (importConfig) {
50
+ importConfig = _.merge(defaultConfig, importConfig);
51
+ return importConfig;
50
52
  };
51
53
 
52
- exports.sanitizeStack = function (config) {
53
- if (typeof config.preserveStackVersion !== 'boolean' || !config.preserveStackVersion) {
54
- return Promise.resolve()
55
- }
56
- addlogs(config, 'Running script to maintain stack version.', 'success')
57
- var getStackOptions = {
58
- url: config.host + config.apis.stacks,
59
- method: 'GET',
60
- headers: config.headers,
61
- json: true
54
+ exports.sanitizeStack = function (importConfig) {
55
+ if (typeof importConfig.preserveStackVersion !== 'boolean' || !importConfig.preserveStackVersion) {
56
+ return Promise.resolve();
62
57
  }
63
-
58
+ addlogs(importConfig, 'Running script to maintain stack version.', 'success');
64
59
  try {
65
- return request(getStackOptions)
66
- .then((stackDetails) => {
67
- if (stackDetails.body && stackDetails.body.stack && stackDetails.body.stack.settings) {
68
- const newStackVersion = stackDetails.body.stack.settings.version
69
- const newStackDate = new Date(newStackVersion).toString()
70
- const stackFilePath = path.join(config.data, config.modules.stack.dirName, config.modules.stack.fileName)
60
+ const httpClient = HttpClient.create();
61
+ httpClient.headers(importConfig.headers);
62
+ return httpClient.get(`https://${importConfig.host}/v3${importConfig.apis.stacks}`).then((stackDetails) => {
63
+ if (stackDetails.data && stackDetails.data.stack && stackDetails.data.stack.settings) {
64
+ const newStackVersion = stackDetails.data.stack.settings.version;
65
+ const newStackDate = new Date(newStackVersion).toString();
66
+ const stackFilePath = path.join(
67
+ importConfig.data,
68
+ importConfig.modules.stack.dirName,
69
+ importConfig.modules.stack.fileName,
70
+ );
71
71
 
72
- const oldStackDetails = fs.readFile(stackFilePath)
73
- if (!oldStackDetails || !oldStackDetails.settings || !oldStackDetails.settings.hasOwnProperty('version')) {
74
- throw new Error(`${JSON.stringify(oldStackDetails)} is invalid!`)
75
- }
76
- const oldStackDate = new Date(oldStackDetails.settings.version).toString()
72
+ const oldStackDetails = fs.readFile(stackFilePath);
73
+ if (!oldStackDetails || !oldStackDetails.settings || !oldStackDetails.settings.hasOwnProperty('version')) {
74
+ throw new Error(`${JSON.stringify(oldStackDetails)} is invalid!`);
75
+ }
76
+ const oldStackDate = new Date(oldStackDetails.settings.version).toString();
77
77
 
78
- if (oldStackDate > newStackDate) {
79
- throw new Error('Migration Error. You cannot migrate data from new stack onto old. Kindly contact support@contentstack.com for more details.')
80
- } else if (oldStackDate === newStackDate) {
81
- addlogs(config, 'The version of both the stacks are same.', 'success')
82
- return Promise.resolve()
83
- }
84
- addlogs(config, 'Updating stack version.', 'success')
85
- // Update the new stack
86
- var updateStackOptions = {
87
- url: config.host + config.apis.stacks + 'settings/set-version',
88
- method: 'PUT',
89
- headers: config.headers,
90
- body: {
91
- stack_settings: {
92
- version: '2017-10-14' // This can be used as a variable
93
- }
94
- }
95
- }
78
+ if (oldStackDate > newStackDate) {
79
+ throw new Error(
80
+ 'Migration Error. You cannot migrate data from new stack onto old. Kindly contact support@contentstack.com for more details.',
81
+ );
82
+ } else if (oldStackDate === newStackDate) {
83
+ addlogs(importConfig, 'The version of both the stacks are same.', 'success');
84
+ return Promise.resolve();
85
+ }
86
+ addlogs(importConfig, 'Updating stack version.', 'success');
96
87
 
97
- return request(updateStackOptions)
98
- .then((response) => {
99
- addlogs(config, `Stack version preserved successfully!\n${JSON.stringify(response.body)}`, 'success')
100
- return;
101
- })
102
- }
103
- throw new Error(`Unexpected stack details ${stackDetails}. 'stackDetails.body.stack' not found!!`)
104
- })
105
- } catch(error) {
106
- console.log(error)
88
+ return httpClient
89
+ .put(`https://${importConfig.host}/v3${importConfig.apis.stacks}settings/set-version`, {
90
+ stack_settings: {
91
+ version: '2017-10-14', // This can be used as a variable
92
+ },
93
+ })
94
+ .then((response) => {
95
+ addlogs(importConfig, `Stack version preserved successfully!\n${JSON.stringify(response.data)}`, 'success');
96
+ });
97
+ }
98
+ throw new Error(`Unexpected stack details ${stackDetails && JSON.stringify(stackDetails.data)}`);
99
+ });
100
+ } catch (error) {
101
+ console.log(error);
107
102
  }
108
- }
103
+ };
109
104
 
110
- exports.masterLocalDetails = function(credentialConfig) {
111
- let client = stack.Client(credentialConfig)
105
+ exports.masterLocalDetails = function (credentialConfig) {
106
+ let client = stack.Client(credentialConfig);
112
107
  return new Promise((resolve, reject) => {
113
- var result = client.stack({ api_key: credentialConfig.target_stack, management_token: credentialConfig.management_token }).locale().query()
114
- result.find()
115
- .then(response => {
116
- var masterLocalObj = response.items.filter(obj => {
117
- if (obj.fallback_locale === null) {
118
- return obj
119
- }
120
- });
121
- return resolve(masterLocalObj[0])
122
- }).catch(error => {
123
- return reject(error)
108
+ var result = client
109
+ .stack({ api_key: credentialConfig.target_stack, management_token: credentialConfig.management_token })
110
+ .locale()
111
+ .query();
112
+ result
113
+ .find()
114
+ .then((response) => {
115
+ var masterLocalObj = response.items.filter((obj) => {
116
+ if (obj.fallback_locale === null) {
117
+ return obj;
118
+ }
119
+ });
120
+ return resolve(masterLocalObj[0]);
124
121
  })
125
- })
122
+ .catch((error) => {
123
+ return reject(error);
124
+ });
125
+ });
126
126
  };
127
127
 
128
- exports.field_rules_update = function(config, ctPath) {
128
+ exports.field_rules_update = function (importConfig, ctPath) {
129
129
  return new Promise(function (resolve, reject) {
130
- let client = stack.Client(config)
131
-
130
+ let client = stack.Client(importConfig);
131
+
132
132
  fs.readFile(path.join(ctPath + '/field_rules_uid.json'), async (err, data) => {
133
133
  if (err) {
134
134
  throw err;
135
135
  }
136
- var ct_field_visibility_uid = JSON.parse(data)
137
- let ct_files = fs.readdirSync(ctPath)
136
+ var ct_field_visibility_uid = JSON.parse(data);
137
+ let ct_files = fs.readdirSync(ctPath);
138
138
  if (ct_field_visibility_uid && ct_field_visibility_uid != 'undefined') {
139
139
  for (let index = 0; index < ct_field_visibility_uid.length; index++) {
140
140
  if (ct_files.indexOf(ct_field_visibility_uid[index] + '.json') > -1) {
141
- let schema = require(path.resolve(ctPath, ct_field_visibility_uid[index]))
141
+ let schema = require(path.resolve(ctPath, ct_field_visibility_uid[index]));
142
142
  // await field_rules_update(schema)
143
- let fieldRuleLength = schema.field_rules.length
143
+ let fieldRuleLength = schema.field_rules.length;
144
144
  for (let k = 0; k < fieldRuleLength; k++) {
145
- let fieldRuleConditionLength = schema.field_rules[k].conditions.length
145
+ let fieldRuleConditionLength = schema.field_rules[k].conditions.length;
146
146
  for (let i = 0; i < fieldRuleConditionLength; i++) {
147
147
  if (schema.field_rules[k].conditions[i].operand_field === 'reference') {
148
- let entryMapperPath = path.resolve(config.data, 'mapper', 'entries')
149
- let entryUidMapperPath = path.join(entryMapperPath, 'uid-mapping.json')
150
- let fieldRulesValue = schema.field_rules[k].conditions[i].value
151
- let fieldRulesArray = fieldRulesValue.split('.')
152
- let updatedValue = []
148
+ let entryMapperPath = path.resolve(importConfig.data, 'mapper', 'entries');
149
+ let entryUidMapperPath = path.join(entryMapperPath, 'uid-mapping.json');
150
+ let fieldRulesValue = schema.field_rules[k].conditions[i].value;
151
+ let fieldRulesArray = fieldRulesValue.split('.');
152
+ let updatedValue = [];
153
153
  for (let j = 0; j < fieldRulesArray.length; j++) {
154
- let splitedFieldRulesValue = fieldRulesArray[j]
155
- let oldUid = helper.readFile(path.join(entryUidMapperPath))
154
+ let splitedFieldRulesValue = fieldRulesArray[j];
155
+ let oldUid = helper.readFile(path.join(entryUidMapperPath));
156
156
  if (oldUid.hasOwnProperty(splitedFieldRulesValue)) {
157
- updatedValue.push(oldUid[splitedFieldRulesValue])
157
+ updatedValue.push(oldUid[splitedFieldRulesValue]);
158
158
  } else {
159
- updatedValue.push(fieldRulesArray[j])
159
+ updatedValue.push(fieldRulesArray[j]);
160
160
  }
161
161
  }
162
- schema.field_rules[k].conditions[i].value = updatedValue.join('.')
162
+ schema.field_rules[k].conditions[i].value = updatedValue.join('.');
163
163
  }
164
164
  }
165
165
  }
166
- let ctObj = client.stack({ api_key: config.target_stack, management_token: config.management_token }).contentType(schema.uid)
167
- Object.assign(ctObj, _.cloneDeep(schema))
168
- ctObj.update()
166
+ let ctObj = client
167
+ .stack({ api_key: importConfig.target_stack, management_token: importConfig.management_token })
168
+ .contentType(schema.uid);
169
+ Object.assign(ctObj, _.cloneDeep(schema));
170
+ ctObj
171
+ .update()
169
172
  .then(() => {
170
- return resolve()
171
- }).catch(function (error) {
172
- return reject(error)
173
+ return resolve();
173
174
  })
175
+ .catch(function (error) {
176
+ return reject(error);
177
+ });
174
178
  }
175
179
  }
176
180
  }
177
- })
178
- })
179
- }
181
+ });
182
+ });
183
+ };
180
184
 
181
- exports.getConfig = function() {
182
- return config
185
+ exports.getConfig = function () {
186
+ return config;
183
187
  };