@contentstack/cli-cm-export-to-csv 1.4.0 → 1.4.1

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/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@contentstack/cli-cm-export-to-csv",
3
3
  "description": "Export entities to csv",
4
- "version": "1.4.0",
4
+ "version": "1.4.1",
5
5
  "author": "Abhinav Gupta @abhinav-from-contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {
8
- "@contentstack/cli-command": "~1.2.11",
9
- "@contentstack/cli-utilities": "~1.5.1",
8
+ "@contentstack/cli-command": "~1.2.12",
9
+ "@contentstack/cli-utilities": "~1.5.2",
10
10
  "chalk": "^4.1.0",
11
11
  "fast-csv": "^4.3.6",
12
12
  "inquirer": "8.2.4",
13
13
  "inquirer-checkbox-plus-prompt": "1.0.1",
14
- "mkdirp": "^1.0.4"
14
+ "mkdirp": "^3.0.1"
15
15
  },
16
16
  "devDependencies": {
17
17
  "@oclif/test": "^2.2.10",
@@ -207,7 +207,7 @@ class ExportToCsvCommand extends Command {
207
207
  const entriesCount = await util.getEntriesCount(stackAPIClient, contentType, language.code);
208
208
  let flatEntries = [];
209
209
  for (let index = 0; index < entriesCount / 100; index++) {
210
- const entriesResult = await util.getEntries(stackAPIClient, contentType, language.code, index);
210
+ const entriesResult = await util.getEntries(stackAPIClient, contentType, language.code, index, 100);
211
211
  const flatEntriesResult = util.cleanEntries(
212
212
  entriesResult.items,
213
213
  language.code,
package/src/util/index.js CHANGED
@@ -199,7 +199,7 @@ function chooseContentType(stackAPIClient, skip) {
199
199
  let _chooseContentType = [
200
200
  {
201
201
  type: 'checkbox',
202
- message: 'Choose Content Type',
202
+ message: 'Choose Content Type (Press Space to select the content types) ',
203
203
  choices: contentTypesList,
204
204
  name: 'chosenContentTypes',
205
205
  loop: false,
@@ -218,7 +218,7 @@ function chooseInMemContentTypes(contentTypesList) {
218
218
  let _chooseContentType = [
219
219
  {
220
220
  type: 'checkbox-plus',
221
- message: 'Choose Content Type',
221
+ message: 'Choose Content Type (Press Space to select the content types)',
222
222
  choices: contentTypesList,
223
223
  name: 'chosenContentTypes',
224
224
  loop: false,
@@ -316,12 +316,12 @@ function getLanguages(stackAPIClient) {
316
316
  });
317
317
  }
318
318
 
319
- function getEntries(stackAPIClient, contentType, language, skip) {
319
+ function getEntries(stackAPIClient, contentType, language, skip, limit) {
320
320
  return new Promise((resolve, reject) => {
321
321
  stackAPIClient
322
322
  .contentType(contentType)
323
323
  .entry()
324
- .query({ include_publish_details: true, locale: language, skip: skip * 100 })
324
+ .query({ include_publish_details: true, locale: language, skip: skip * 100, limit: limit, include_workflow: true })
325
325
  .find()
326
326
  .then((entries) => resolve(entries))
327
327
  .catch((error) => reject(error));
@@ -373,25 +373,31 @@ function exitProgram() {
373
373
 
374
374
  function cleanEntries(entries, language, environments, contentTypeUid) {
375
375
  const filteredEntries = entries.filter((entry) => {
376
- return entry['locale'] === language && entry.publish_details.length > 0;
376
+ return entry['locale'] === language;
377
377
  });
378
-
379
378
  return filteredEntries.map((entry) => {
380
379
  let workflow = '';
381
380
  const envArr = [];
382
- entry.publish_details.forEach((env) => {
383
- envArr.push(JSON.stringify([environments[env['environment']], env['locale'], env['time']]));
384
- });
381
+ if(entry.publish_details.length) {
382
+ entry.publish_details.forEach((env) => {
383
+ envArr.push(JSON.stringify([environments[env['environment']], env['locale'], env['time']]));
384
+ });
385
+ }
386
+
385
387
  delete entry.publish_details;
388
+ delete entry.setWorkflowStage;
386
389
  if ('_workflow' in entry) {
387
- workflow = entry['_workflow']['name'];
388
- delete entry['_workflow'];
390
+ if(entry._workflow?.name) {
391
+ workflow = entry['_workflow']['name'];
392
+ delete entry['_workflow'];
393
+ }
389
394
  }
390
395
  entry = flatten(entry);
391
396
  entry['publish_details'] = envArr;
392
397
  entry['_workflow'] = workflow;
393
398
  entry['ACL'] = JSON.stringify({}); // setting ACL to empty obj
394
399
  entry['content_type_uid'] = contentTypeUid; // content_type_uid is being returned as 'uid' from the sdk for some reason
400
+
395
401
  // entry['url'] might also be wrong
396
402
  delete entry.stackHeaders;
397
403
  delete entry.update;
@@ -403,6 +409,7 @@ function cleanEntries(entries, language, environments, contentTypeUid) {
403
409
  delete entry.publishRequest;
404
410
  return entry;
405
411
  });
412
+ console.log(filteredEntries.length);
406
413
  }
407
414
 
408
415
  function getDateTime() {