@contentstack/cli-cm-export 0.1.1-beta.7 → 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.
- package/LICENSE +21 -0
- package/README.md +44 -24
- package/oclif.manifest.json +1 -1
- package/package.json +72 -68
- package/src/app.js +120 -66
- package/src/commands/cm/stacks/export.js +177 -0
- package/src/config/default.js +18 -58
- package/src/lib/export/assets.js +325 -223
- package/src/lib/export/content-types.js +76 -66
- package/src/lib/export/entries.js +190 -135
- package/src/lib/export/environments.js +52 -45
- package/src/lib/export/extensions.js +50 -43
- package/src/lib/export/global-fields.js +92 -80
- package/src/lib/export/labels.js +52 -44
- package/src/lib/export/locales.js +74 -41
- package/src/lib/export/stack.js +72 -47
- package/src/lib/export/webhooks.js +58 -48
- package/src/lib/export/workflows.js +55 -44
- package/src/lib/util/contentstack-management-sdk.js +30 -4
- package/src/lib/util/export-flags.js +158 -87
- package/src/lib/util/helper.js +20 -20
- package/src/lib/util/index.js +32 -19
- package/src/lib/util/log.js +109 -53
- package/src/lib/util/login.js +56 -41
- package/src/lib/util/setup-branches.js +53 -0
- package/src/commands/cm/export.js +0 -123
- package/src/lib/util/request.js +0 -83
|
@@ -4,24 +4,23 @@
|
|
|
4
4
|
* MIT Licensed
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
const mkdirp = require('mkdirp')
|
|
8
|
-
const path = require('path')
|
|
9
|
-
const chalk = require('chalk')
|
|
10
|
-
const Promise = require('bluebird')
|
|
7
|
+
const mkdirp = require('mkdirp');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const chalk = require('chalk');
|
|
10
|
+
const Promise = require('bluebird');
|
|
11
11
|
|
|
12
|
-
const helper = require('../util/helper')
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
const {addlogs} = require('../util/log')
|
|
12
|
+
const helper = require('../util/helper');
|
|
13
|
+
const stack = require('../util/contentstack-management-sdk');
|
|
14
|
+
const { addlogs } = require('../util/log');
|
|
16
15
|
|
|
17
|
-
let config = require('../../config/default')
|
|
18
|
-
const contentTypeConfig = config.modules.content_types
|
|
19
|
-
const validKeys = contentTypeConfig.validKeys
|
|
20
|
-
let client
|
|
21
|
-
let contentTypesFolderPath
|
|
16
|
+
let config = require('../../config/default');
|
|
17
|
+
const contentTypeConfig = config.modules.content_types;
|
|
18
|
+
const validKeys = contentTypeConfig.validKeys;
|
|
19
|
+
let client;
|
|
20
|
+
let contentTypesFolderPath;
|
|
22
21
|
|
|
23
22
|
function ExportContentTypes() {
|
|
24
|
-
this.content_types = []
|
|
23
|
+
this.content_types = [];
|
|
25
24
|
|
|
26
25
|
this.requestOptions = {
|
|
27
26
|
qs: {
|
|
@@ -30,77 +29,88 @@ function ExportContentTypes() {
|
|
|
30
29
|
limit: config.modules.content_types.limit,
|
|
31
30
|
include_global_field_schema: true,
|
|
32
31
|
},
|
|
33
|
-
}
|
|
32
|
+
};
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
ExportContentTypes.prototype = {
|
|
37
36
|
start: function (credentialConfig) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
this.content_types = [];
|
|
38
|
+
let self = this;
|
|
39
|
+
config = credentialConfig;
|
|
40
|
+
contentTypesFolderPath = path.resolve(config.data, config.branchName || '', contentTypeConfig.dirName);
|
|
41
|
+
|
|
42
|
+
client = stack.Client(config);
|
|
43
|
+
// If content type id is provided then use it as part of query
|
|
44
|
+
if (Array.isArray(config.contentTypes) && config.contentTypes.length > 0) {
|
|
45
|
+
self.requestOptions.qs.uid = { $in: config.contentTypes };
|
|
46
|
+
}
|
|
42
47
|
// Create folder for content types
|
|
43
|
-
mkdirp.sync(contentTypesFolderPath)
|
|
44
|
-
addlogs(config, 'Starting content type export', 'success')
|
|
48
|
+
mkdirp.sync(contentTypesFolderPath);
|
|
49
|
+
addlogs(config, 'Starting content type export', 'success');
|
|
45
50
|
return new Promise(function (resolve, reject) {
|
|
46
|
-
return self
|
|
47
|
-
|
|
48
|
-
.then(
|
|
49
|
-
return
|
|
51
|
+
return self
|
|
52
|
+
.getContentTypes()
|
|
53
|
+
.then(function () {
|
|
54
|
+
return self
|
|
55
|
+
.writeContentTypes()
|
|
56
|
+
.then(() => {
|
|
57
|
+
return resolve();
|
|
58
|
+
})
|
|
59
|
+
.catch((error) => {
|
|
60
|
+
return reject(error);
|
|
61
|
+
});
|
|
50
62
|
})
|
|
51
|
-
.catch(
|
|
52
|
-
|
|
53
|
-
})
|
|
54
|
-
}).catch(reject)
|
|
55
|
-
})
|
|
63
|
+
.catch(reject);
|
|
64
|
+
});
|
|
56
65
|
},
|
|
57
66
|
getContentTypes: function (skip) {
|
|
58
|
-
let self = this
|
|
67
|
+
let self = this;
|
|
59
68
|
if (typeof skip !== 'number') {
|
|
60
|
-
skip = 0
|
|
61
|
-
self.requestOptions.qs.skip = skip
|
|
69
|
+
skip = 0;
|
|
70
|
+
self.requestOptions.qs.skip = skip;
|
|
62
71
|
} else {
|
|
63
|
-
self.requestOptions.qs.skip = skip
|
|
72
|
+
self.requestOptions.qs.skip = skip;
|
|
64
73
|
}
|
|
65
74
|
|
|
66
75
|
return new Promise(function (resolve, reject) {
|
|
67
|
-
client
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
delete content_type[key]
|
|
77
|
-
}
|
|
76
|
+
client
|
|
77
|
+
.stack({ api_key: config.source_stack, management_token: config.management_token })
|
|
78
|
+
.contentType()
|
|
79
|
+
.query(self.requestOptions.qs)
|
|
80
|
+
.find()
|
|
81
|
+
.then((contenttypeResponse) => {
|
|
82
|
+
if (contenttypeResponse.items.length === 0) {
|
|
83
|
+
addlogs(config, 'No content types were found in the Stack', 'success');
|
|
84
|
+
return resolve();
|
|
78
85
|
}
|
|
79
|
-
|
|
80
|
-
|
|
86
|
+
contenttypeResponse.items.forEach(function (content_type) {
|
|
87
|
+
for (let key in content_type) {
|
|
88
|
+
if (validKeys.indexOf(key) === -1) {
|
|
89
|
+
delete content_type[key];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
self.content_types.push(content_type);
|
|
93
|
+
});
|
|
81
94
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
})
|
|
90
|
-
})
|
|
95
|
+
skip += config.modules.content_types.limit;
|
|
96
|
+
if (skip > contenttypeResponse.count) {
|
|
97
|
+
return resolve();
|
|
98
|
+
}
|
|
99
|
+
return self.getContentTypes(skip).then(resolve).catch(reject);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
91
102
|
},
|
|
92
103
|
writeContentTypes: function () {
|
|
93
|
-
let self = this
|
|
104
|
+
let self = this;
|
|
94
105
|
return new Promise(function (resolve) {
|
|
95
|
-
helper.writeFile(path.join(contentTypesFolderPath, 'schema.json'), self.content_types)
|
|
106
|
+
helper.writeFile(path.join(contentTypesFolderPath, 'schema.json'), self.content_types);
|
|
96
107
|
self.content_types.forEach(function (content_type) {
|
|
97
|
-
helper.writeFile(path.join(contentTypesFolderPath, content_type.uid + '.json'),
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
})
|
|
108
|
+
helper.writeFile(path.join(contentTypesFolderPath, content_type.uid + '.json'), content_type);
|
|
109
|
+
});
|
|
110
|
+
addlogs(config, chalk.green('Content type(s) exported successfully'), 'success');
|
|
111
|
+
return resolve();
|
|
112
|
+
});
|
|
103
113
|
},
|
|
104
|
-
}
|
|
114
|
+
};
|
|
105
115
|
|
|
106
|
-
module.exports = new ExportContentTypes()
|
|
116
|
+
module.exports = new ExportContentTypes();
|
|
@@ -4,28 +4,28 @@
|
|
|
4
4
|
* MIT Licensed
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
const fs = require('fs')
|
|
8
|
-
const path = require('path')
|
|
9
|
-
const _ = require('lodash')
|
|
10
|
-
const Promise = require('bluebird')
|
|
11
|
-
const chalk = require('chalk')
|
|
12
|
-
const mkdirp = require('mkdirp')
|
|
13
|
-
const {addlogs} = require('../util/log')
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const _ = require('lodash');
|
|
10
|
+
const Promise = require('bluebird');
|
|
11
|
+
const chalk = require('chalk');
|
|
12
|
+
const mkdirp = require('mkdirp');
|
|
13
|
+
const { addlogs } = require('../util/log');
|
|
14
14
|
|
|
15
|
-
const helper = require('../util/helper')
|
|
16
|
-
const log = require('../util/log')
|
|
17
|
-
const stack = require('../util/contentstack-management-sdk')
|
|
15
|
+
const helper = require('../util/helper');
|
|
16
|
+
const log = require('../util/log');
|
|
17
|
+
const stack = require('../util/contentstack-management-sdk');
|
|
18
18
|
|
|
19
|
-
let config = require('../../config/default')
|
|
20
|
-
let entriesConfig = config.modules.entries
|
|
21
|
-
let invalidKeys = entriesConfig.invalidKeys
|
|
22
|
-
let limit = entriesConfig.limit
|
|
23
|
-
let content_types
|
|
24
|
-
let locales
|
|
25
|
-
let entryFolderPath
|
|
26
|
-
let localesFilePath
|
|
27
|
-
let schemaFilePath
|
|
28
|
-
let client
|
|
19
|
+
let config = require('../../config/default');
|
|
20
|
+
let entriesConfig = config.modules.entries;
|
|
21
|
+
let invalidKeys = entriesConfig.invalidKeys;
|
|
22
|
+
let limit = entriesConfig.limit;
|
|
23
|
+
let content_types;
|
|
24
|
+
let locales;
|
|
25
|
+
let entryFolderPath;
|
|
26
|
+
let localesFilePath;
|
|
27
|
+
let schemaFilePath;
|
|
28
|
+
let client;
|
|
29
29
|
|
|
30
30
|
function exportEntries() {
|
|
31
31
|
this.requestOptions = {
|
|
@@ -36,52 +36,70 @@ function exportEntries() {
|
|
|
36
36
|
limit: limit,
|
|
37
37
|
},
|
|
38
38
|
json: true,
|
|
39
|
-
}
|
|
39
|
+
};
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
exportEntries.prototype.start = function (credentialConfig) {
|
|
43
|
-
let self = this
|
|
44
|
-
config = credentialConfig
|
|
45
|
-
entryFolderPath = path.resolve(config.data, config.modules.entries.dirName)
|
|
46
|
-
localesFilePath = path.resolve(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
let self = this;
|
|
44
|
+
config = credentialConfig;
|
|
45
|
+
entryFolderPath = path.resolve(config.data, config.branchName || '', config.modules.entries.dirName);
|
|
46
|
+
localesFilePath = path.resolve(
|
|
47
|
+
config.data,
|
|
48
|
+
config.branchName || '',
|
|
49
|
+
config.modules.locales.dirName,
|
|
50
|
+
config.modules.locales.fileName,
|
|
51
|
+
);
|
|
52
|
+
schemaFilePath = path.resolve(
|
|
53
|
+
config.data,
|
|
54
|
+
config.branchName || '',
|
|
55
|
+
config.modules.content_types.dirName,
|
|
56
|
+
'schema.json',
|
|
57
|
+
);
|
|
58
|
+
client = stack.Client(config);
|
|
59
|
+
addlogs(config, 'Starting entry migration', 'success');
|
|
60
|
+
return new Promise(function (resolve) {
|
|
61
|
+
locales = helper.readFile(localesFilePath);
|
|
62
|
+
let apiBucket = [];
|
|
63
|
+
content_types = helper.readFile(schemaFilePath);
|
|
54
64
|
if (content_types.length !== 0) {
|
|
55
|
-
content_types.forEach(content_type => {
|
|
65
|
+
content_types.forEach((content_type) => {
|
|
56
66
|
if (Object.keys(locales).length !== 0) {
|
|
57
67
|
for (let _locale in locales) {
|
|
58
68
|
apiBucket.push({
|
|
59
69
|
content_type: content_type.uid,
|
|
60
70
|
locale: locales[_locale].code,
|
|
61
|
-
})
|
|
71
|
+
});
|
|
62
72
|
}
|
|
63
73
|
}
|
|
64
74
|
apiBucket.push({
|
|
65
75
|
content_type: content_type.uid,
|
|
66
76
|
locale: config.master_locale.code,
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
return Promise.map(
|
|
80
|
+
apiBucket,
|
|
81
|
+
function (apiDetails) {
|
|
82
|
+
return self.getEntries(apiDetails);
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
concurrency: 1,
|
|
86
|
+
},
|
|
87
|
+
)
|
|
88
|
+
.then(function () {
|
|
89
|
+
addlogs(config, 'Entry migration completed successfully', 'success');
|
|
90
|
+
return resolve();
|
|
67
91
|
})
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}, {
|
|
72
|
-
concurrency: 1,
|
|
73
|
-
}).then(function () {
|
|
74
|
-
addlogs(config, 'Entry migration completed successfully', 'success')
|
|
75
|
-
return resolve()
|
|
76
|
-
}).catch(reject)
|
|
92
|
+
.catch((error) => {
|
|
93
|
+
console.log('Error getting entries', error && error.message);
|
|
94
|
+
});
|
|
77
95
|
}
|
|
78
|
-
addlogs(config, 'No content_types were found in the Stack', 'success')
|
|
79
|
-
return resolve()
|
|
80
|
-
})
|
|
81
|
-
}
|
|
96
|
+
addlogs(config, 'No content_types were found in the Stack', 'success');
|
|
97
|
+
return resolve();
|
|
98
|
+
});
|
|
99
|
+
};
|
|
82
100
|
|
|
83
101
|
exportEntries.prototype.getEntry = function (apiDetails) {
|
|
84
|
-
let self = this
|
|
102
|
+
let self = this;
|
|
85
103
|
return new Promise(function (resolve, reject) {
|
|
86
104
|
let queryRequestObject = {
|
|
87
105
|
locale: apiDetails.locale,
|
|
@@ -89,34 +107,42 @@ exportEntries.prototype.getEntry = function (apiDetails) {
|
|
|
89
107
|
BASE: invalidKeys,
|
|
90
108
|
},
|
|
91
109
|
version: apiDetails.version,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
};
|
|
111
|
+
client
|
|
112
|
+
.stack({ api_key: config.source_stack, management_token: config.management_token })
|
|
113
|
+
.contentType(apiDetails.content_type)
|
|
114
|
+
.entry(apiDetails.uid)
|
|
115
|
+
.fetch(queryRequestObject)
|
|
116
|
+
.then((singleEntry) => {
|
|
117
|
+
let entryPath = path.join(entryFolderPath, apiDetails.locale, apiDetails.content_type, singleEntry.uid);
|
|
118
|
+
mkdirp.sync(entryPath);
|
|
119
|
+
helper.writeFile(path.join(entryPath, 'version-' + singleEntry._version + '.json'), singleEntry);
|
|
120
|
+
addlogs(
|
|
121
|
+
config,
|
|
122
|
+
'Completed version backup of entry: ' +
|
|
123
|
+
singleEntry.uid +
|
|
124
|
+
', version: ' +
|
|
125
|
+
singleEntry._version +
|
|
126
|
+
', content type: ' +
|
|
127
|
+
apiDetails.content_type,
|
|
128
|
+
'success',
|
|
129
|
+
);
|
|
130
|
+
if (--apiDetails.version !== 0) {
|
|
131
|
+
return self.getEntry(apiDetails).then(resolve).catch(reject);
|
|
132
|
+
}
|
|
133
|
+
return resolve();
|
|
134
|
+
})
|
|
135
|
+
.catch((error) => {
|
|
136
|
+
addlogs(config, error, 'error');
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
};
|
|
114
140
|
|
|
115
141
|
exportEntries.prototype.getEntries = function (apiDetails) {
|
|
116
|
-
let self = this
|
|
142
|
+
let self = this;
|
|
117
143
|
return new Promise(function (resolve, reject) {
|
|
118
144
|
if (typeof apiDetails.skip !== 'number') {
|
|
119
|
-
apiDetails.skip = 0
|
|
145
|
+
apiDetails.skip = 0;
|
|
120
146
|
}
|
|
121
147
|
|
|
122
148
|
let queryrequestObject = {
|
|
@@ -128,70 +154,99 @@ exportEntries.prototype.getEntries = function (apiDetails) {
|
|
|
128
154
|
query: {
|
|
129
155
|
locale: apiDetails.locale,
|
|
130
156
|
},
|
|
131
|
-
}
|
|
132
|
-
client
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
invalidKeys.forEach(e => delete entry[e])
|
|
143
|
-
entries[entry.uid] = entry
|
|
144
|
-
})
|
|
145
|
-
helper.writeFile(entriesFilePath, entries)
|
|
146
|
-
|
|
147
|
-
if (typeof config.versioning === 'boolean' && config.versioning) {
|
|
148
|
-
for (let locale in locales) {
|
|
149
|
-
// make folders for each language
|
|
150
|
-
content_types.forEach(function (content_type) {
|
|
151
|
-
// make folder for each content type
|
|
152
|
-
let versionedEntryFolderPath = path.join(entryFolderPath, locales[locale].code,content_type.uid)
|
|
153
|
-
mkdirp.sync(versionedEntryFolderPath)
|
|
154
|
-
})
|
|
157
|
+
};
|
|
158
|
+
client
|
|
159
|
+
.stack({ api_key: config.source_stack, management_token: config.management_token })
|
|
160
|
+
.contentType(apiDetails.content_type)
|
|
161
|
+
.entry()
|
|
162
|
+
.query(queryrequestObject)
|
|
163
|
+
.find()
|
|
164
|
+
.then((entriesList) => {
|
|
165
|
+
// /entries/content_type_uid/locale.json
|
|
166
|
+
if (!fs.existsSync(path.join(entryFolderPath, apiDetails.content_type))) {
|
|
167
|
+
mkdirp.sync(path.join(entryFolderPath, apiDetails.content_type));
|
|
155
168
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
169
|
+
let entriesFilePath = path.join(entryFolderPath, apiDetails.content_type, apiDetails.locale + '.json');
|
|
170
|
+
let entries = helper.readFile(entriesFilePath);
|
|
171
|
+
entries = entries || {};
|
|
172
|
+
entriesList.items.forEach(function (entry) {
|
|
173
|
+
invalidKeys.forEach((e) => delete entry[e]);
|
|
174
|
+
entries[entry.uid] = entry;
|
|
175
|
+
});
|
|
176
|
+
helper.writeFile(entriesFilePath, entries);
|
|
164
177
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
178
|
+
if (typeof config.versioning === 'boolean' && config.versioning) {
|
|
179
|
+
for (let locale in locales) {
|
|
180
|
+
// make folders for each language
|
|
181
|
+
content_types.forEach(function (content_type) {
|
|
182
|
+
// make folder for each content type
|
|
183
|
+
let versionedEntryFolderPath = path.join(entryFolderPath, locales[locale].code, content_type.uid);
|
|
184
|
+
mkdirp.sync(versionedEntryFolderPath);
|
|
185
|
+
});
|
|
173
186
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
187
|
+
return Promise.map(
|
|
188
|
+
entriesList.items,
|
|
189
|
+
function (entry) {
|
|
190
|
+
let entryDetails = {
|
|
191
|
+
content_type: apiDetails.content_type,
|
|
192
|
+
uid: entry.uid,
|
|
193
|
+
version: entry._version,
|
|
194
|
+
locale: apiDetails.locale,
|
|
195
|
+
};
|
|
196
|
+
return self.getEntry(entryDetails).catch(reject);
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
concurrency: 1,
|
|
200
|
+
},
|
|
201
|
+
).then(function () {
|
|
202
|
+
if (apiDetails.skip > entriesList.items.length) {
|
|
203
|
+
addlogs(
|
|
204
|
+
config,
|
|
205
|
+
'Completed fetching ' +
|
|
206
|
+
apiDetails.content_type +
|
|
207
|
+
" content type's entries in " +
|
|
208
|
+
apiDetails.locale +
|
|
209
|
+
' locale',
|
|
210
|
+
'success',
|
|
211
|
+
);
|
|
212
|
+
return resolve();
|
|
213
|
+
}
|
|
214
|
+
apiDetails.skip += limit;
|
|
215
|
+
return self
|
|
216
|
+
.getEntries(apiDetails)
|
|
217
|
+
.then(function () {
|
|
218
|
+
return resolve();
|
|
219
|
+
})
|
|
220
|
+
.catch(function (error) {
|
|
221
|
+
return reject(error);
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
if (apiDetails.skip > entriesList.count) {
|
|
226
|
+
addlogs(
|
|
227
|
+
config,
|
|
228
|
+
'Exported entries of ' +
|
|
229
|
+
apiDetails.content_type +
|
|
230
|
+
' to the ' +
|
|
231
|
+
apiDetails.locale +
|
|
232
|
+
' language successfully',
|
|
233
|
+
'success',
|
|
234
|
+
);
|
|
235
|
+
return resolve();
|
|
236
|
+
}
|
|
237
|
+
apiDetails.skip += limit;
|
|
238
|
+
return self
|
|
239
|
+
.getEntries(apiDetails)
|
|
240
|
+
.then(resolve)
|
|
241
|
+
.catch((error) => {
|
|
242
|
+
console.log('Get Entries errror', error && error.message);
|
|
243
|
+
});
|
|
244
|
+
})
|
|
245
|
+
.catch((error) => {
|
|
246
|
+
console.log('Entries fetch errror', error && error.message);
|
|
247
|
+
addlogs(config, error, 'error');
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
};
|
|
196
251
|
|
|
197
|
-
module.exports = new exportEntries()
|
|
252
|
+
module.exports = new exportEntries();
|