@contentstack/cli-cm-export-to-csv 1.2.0 → 1.3.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/oclif.manifest.json +1 -1
- package/package.json +8 -6
- package/src/commands/cm/export-to-csv.js +3 -3
- package/src/util/index.js +12 -2
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-cm-export-to-csv",
|
|
3
3
|
"description": "Export entities to csv",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0",
|
|
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.
|
|
9
|
-
"@contentstack/cli-utilities": "^1.2.
|
|
8
|
+
"@contentstack/cli-command": "^1.2.1",
|
|
9
|
+
"@contentstack/cli-utilities": "^1.2.1",
|
|
10
10
|
"chalk": "^4.1.0",
|
|
11
11
|
"fast-csv": "^4.3.6",
|
|
12
12
|
"inquirer": "8.2.4",
|
|
@@ -47,9 +47,6 @@
|
|
|
47
47
|
"version": "oclif readme && git add README.md",
|
|
48
48
|
"clean": "rm -rf ./node_modules tsconfig.build.tsbuildinfo"
|
|
49
49
|
},
|
|
50
|
-
"csdxConfig": {
|
|
51
|
-
"expiredCommands": {}
|
|
52
|
-
},
|
|
53
50
|
"main": "./src/commands/cm/export-to-csv.js",
|
|
54
51
|
"license": "MIT",
|
|
55
52
|
"oclif": {
|
|
@@ -57,5 +54,10 @@
|
|
|
57
54
|
"bin": "csdx",
|
|
58
55
|
"repositoryPrefix": "<%- repo %>/blob/main/packages/contentstack-export-to-csv/<%- commandPath %>"
|
|
59
56
|
},
|
|
57
|
+
"csdxConfig": {
|
|
58
|
+
"shortCommandName": {
|
|
59
|
+
"cm:export-to-csv": "EXPRTCSV"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
60
62
|
"repository": "https://github.com/contentstack/cli"
|
|
61
63
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { Command } = require('@contentstack/cli-command');
|
|
2
|
-
const { configHandler, managementSDKClient, flags } = require('@contentstack/cli-utilities');
|
|
2
|
+
const { configHandler, managementSDKClient, flags, isAuthenticated } = require('@contentstack/cli-utilities');
|
|
3
3
|
const util = require('../../util');
|
|
4
4
|
const config = require('../../util/config');
|
|
5
5
|
|
|
@@ -93,7 +93,7 @@ class ExportToCsvCommand extends Command {
|
|
|
93
93
|
} else {
|
|
94
94
|
let organization;
|
|
95
95
|
|
|
96
|
-
if (!
|
|
96
|
+
if (!isAuthenticated()) {
|
|
97
97
|
this.error(config.CLI_EXPORT_CSV_ENTRIES_ERROR, {
|
|
98
98
|
exit: 2,
|
|
99
99
|
suggestions: ['https://www.contentstack.com/docs/developers/cli/authentication/'],
|
|
@@ -164,7 +164,7 @@ class ExportToCsvCommand extends Command {
|
|
|
164
164
|
case config.exportUsers:
|
|
165
165
|
case 'users': {
|
|
166
166
|
try {
|
|
167
|
-
if (!
|
|
167
|
+
if (!isAuthenticated()) {
|
|
168
168
|
this.error(config.CLI_EXPORT_CSV_LOGIN_FAILED, {
|
|
169
169
|
exit: 2,
|
|
170
170
|
suggestions: ['https://www.contentstack.com/docs/developers/cli/authentication/'],
|
package/src/util/index.js
CHANGED
|
@@ -514,8 +514,8 @@ function cleanOrgUsers(orgUsers, mappedUsers, mappedRoles) {
|
|
|
514
514
|
formattedUser['Organization Role'] = determineUserOrgRole(user, mappedRoles);
|
|
515
515
|
formattedUser['Status'] = user['status'];
|
|
516
516
|
formattedUser['Invited By'] = invitedBy;
|
|
517
|
-
formattedUser['Created Time'] = user['created_at'];
|
|
518
|
-
formattedUser['Updated Time'] = user['updated_at'];
|
|
517
|
+
formattedUser['Created Time'] = getFormattedDate(user['created_at']);
|
|
518
|
+
formattedUser['Updated Time'] = getFormattedDate(user['updated_at']);
|
|
519
519
|
userList.push(formattedUser);
|
|
520
520
|
});
|
|
521
521
|
return userList;
|
|
@@ -528,6 +528,16 @@ function kebabize(str) {
|
|
|
528
528
|
.join('-');
|
|
529
529
|
}
|
|
530
530
|
|
|
531
|
+
function getFormattedDate(date) {
|
|
532
|
+
if (!(date instanceof Date)) {
|
|
533
|
+
date = new Date(date);
|
|
534
|
+
}
|
|
535
|
+
const year = date.getFullYear();
|
|
536
|
+
const month = (1 + date.getMonth()).toString().padStart(2, '0');
|
|
537
|
+
const day = date.getDate().toString().padStart(2, '0');
|
|
538
|
+
return month + '/' + day + '/' + year;
|
|
539
|
+
}
|
|
540
|
+
|
|
531
541
|
// https://stackoverflow.com/questions/19098797/fastest-way-to-flatten-un-flatten-nested-json-objects
|
|
532
542
|
function flatten(data) {
|
|
533
543
|
let result = {};
|