@contentstack/cli-cm-export-to-csv 1.12.0-beta.0 → 2.0.0-beta.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.
@@ -1,581 +0,0 @@
1
- "use strict";
2
- /**
3
- * Export to CSV command.
4
- * Migrated from: packages/contentstack-export-to-csv/src/commands/cm/export-to-csv.js
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- const tslib_1 = require("tslib");
8
- const cli_utilities_1 = require("@contentstack/cli-utilities");
9
- const config_1 = tslib_1.__importDefault(require("../../config"));
10
- const messages_1 = require("../../messages");
11
- const base_command_1 = require("../../base-command");
12
- const utils_1 = require("../../utils");
13
- class ExportToCsvCommand extends base_command_1.BaseCommand {
14
- async run() {
15
- var _a, _b;
16
- cli_utilities_1.log.debug('ExportToCsvCommand run started', this.commandContext);
17
- try {
18
- let action;
19
- let managementAPIClient;
20
- const { flags: parsedFlags } = await this.parse(ExportToCsvCommand);
21
- cli_utilities_1.log.debug('Flags parsed', Object.assign(Object.assign({}, this.commandContext), { flags: parsedFlags }));
22
- const flagsData = parsedFlags;
23
- const org = flagsData.org;
24
- const actionFlag = flagsData.action;
25
- const orgName = flagsData['org-name'];
26
- const stackName = flagsData['stack-name'];
27
- const stackAPIKey = flagsData['stack-api-key'];
28
- const locale = flagsData.locale;
29
- const contentTypesFlag = flagsData['content-type'];
30
- const managementTokenAlias = flagsData.alias;
31
- const branchUid = flagsData.branch;
32
- const teamUid = flagsData['team-uid'];
33
- const taxonomyUID = flagsData['taxonomy-uid'];
34
- const includeFallback = (_a = flagsData['include-fallback']) !== null && _a !== void 0 ? _a : false;
35
- const fallbackLocale = flagsData['fallback-locale'];
36
- const delimiter = (_b = flagsData.delimiter) !== null && _b !== void 0 ? _b : ',';
37
- if (!managementTokenAlias) {
38
- cli_utilities_1.log.debug('Initializing Management API client', this.commandContext);
39
- managementAPIClient = await (0, cli_utilities_1.managementSDKClient)({ host: this.cmaHost });
40
- cli_utilities_1.log.debug('Management API client initialized', this.commandContext);
41
- if (!(0, cli_utilities_1.isAuthenticated)()) {
42
- cli_utilities_1.log.debug('User not authenticated', this.commandContext);
43
- this.error(messages_1.messages.ERROR_NOT_LOGGED_IN, {
44
- exit: 2,
45
- suggestions: ['https://www.contentstack.com/docs/developers/cli/authentication/'],
46
- });
47
- }
48
- }
49
- if (actionFlag) {
50
- action = actionFlag;
51
- cli_utilities_1.log.debug(`Action provided via flag: ${action}`, this.commandContext);
52
- }
53
- else {
54
- action = await (0, utils_1.startupQuestions)();
55
- cli_utilities_1.log.debug(`Action selected interactively: ${action}`, this.commandContext);
56
- }
57
- switch (action) {
58
- case messages_1.messages.ACTION_EXPORT_ENTRIES:
59
- case 'entries': {
60
- await this.exportEntries({
61
- managementAPIClient: managementAPIClient,
62
- managementTokenAlias,
63
- stackName,
64
- stackAPIKey,
65
- org,
66
- branchUid,
67
- locale,
68
- contentTypesFlag,
69
- delimiter,
70
- });
71
- break;
72
- }
73
- case messages_1.messages.ACTION_EXPORT_USERS:
74
- case 'users': {
75
- await this.exportUsers({
76
- managementAPIClient: managementAPIClient,
77
- org,
78
- orgName,
79
- action,
80
- delimiter,
81
- });
82
- break;
83
- }
84
- case messages_1.messages.ACTION_EXPORT_TEAMS:
85
- case 'teams': {
86
- await this.exportTeamsData({
87
- managementAPIClient: managementAPIClient,
88
- org,
89
- orgName,
90
- action,
91
- teamUid,
92
- delimiter,
93
- });
94
- break;
95
- }
96
- case messages_1.messages.ACTION_EXPORT_TAXONOMIES:
97
- case 'taxonomies': {
98
- await this.exportTaxonomiesData({
99
- managementAPIClient: managementAPIClient,
100
- managementTokenAlias,
101
- stackName,
102
- stackAPIKey,
103
- org,
104
- locale,
105
- branchUid,
106
- taxonomyUID,
107
- includeFallback,
108
- fallbackLocale,
109
- delimiter,
110
- });
111
- break;
112
- }
113
- }
114
- cli_utilities_1.log.success('Export completed successfully', this.commandContext);
115
- }
116
- catch (error) {
117
- cli_utilities_1.log.debug('Export failed', Object.assign(Object.assign({}, this.commandContext), { error }));
118
- (0, cli_utilities_1.handleAndLogError)(error, this.commandContext);
119
- cli_utilities_1.ux.action.stop('Export failed');
120
- this.exit(1);
121
- }
122
- }
123
- /**
124
- * Export entries to CSV.
125
- */
126
- async exportEntries(options) {
127
- const { managementAPIClient, managementTokenAlias, stackName, stackAPIKey, org, branchUid, locale, contentTypesFlag, delimiter, } = options;
128
- cli_utilities_1.log.debug('Starting entries export', this.commandContext);
129
- try {
130
- let stack;
131
- let stackAPIClient;
132
- let language;
133
- let contentTypes = [];
134
- let apiClient = managementAPIClient;
135
- if (managementTokenAlias) {
136
- cli_utilities_1.log.debug(`Using management token alias: ${managementTokenAlias}`, this.commandContext);
137
- const { stackDetails, apiClient: client } = await this.getAliasDetails(managementTokenAlias, stackName);
138
- apiClient = client;
139
- stack = stackDetails;
140
- }
141
- else {
142
- stack = await this.getStackDetails(managementAPIClient, stackAPIKey, org);
143
- }
144
- // Update context with stack API key
145
- this.commandContext.apiKey = stack.apiKey;
146
- cli_utilities_1.log.debug(`Stack selected: ${stack.name}`, this.commandContext);
147
- stackAPIClient = this.getStackClient(apiClient, stack);
148
- stackAPIClient = await this.checkAndUpdateBranchDetail(branchUid, stack, stackAPIClient, apiClient);
149
- cli_utilities_1.cliux.loader('Fetching content types...');
150
- const contentTypeCount = await (0, utils_1.getContentTypeCount)(stackAPIClient);
151
- const environments = await (0, utils_1.getEnvironments)(stackAPIClient);
152
- cli_utilities_1.cliux.loader('Content types fetched');
153
- cli_utilities_1.log.debug(`Found ${contentTypeCount} content types`, this.commandContext);
154
- if (contentTypesFlag) {
155
- contentTypes = contentTypesFlag.split(',').map(this.snakeCase);
156
- cli_utilities_1.log.debug(`Content types from flag: ${contentTypes.join(', ')}`, this.commandContext);
157
- const contentTypesResponse = await stackAPIClient
158
- .contentType()
159
- .query()
160
- .find();
161
- const contentTypesArray = contentTypesResponse.items.map((ct) => ct.uid);
162
- const doesContentTypeExist = contentTypesArray.includes(contentTypesFlag);
163
- if (!doesContentTypeExist) {
164
- throw new Error(`The Content Type ${contentTypesFlag} was not found. Please try again. Content Type is not valid.`);
165
- }
166
- }
167
- else {
168
- for (let index = 0; index <= contentTypeCount / 100; index++) {
169
- const contentTypesMap = await (0, utils_1.getContentTypes)(stackAPIClient, index);
170
- contentTypes = contentTypes.concat(Object.values(contentTypesMap));
171
- }
172
- }
173
- if (contentTypes.length <= 0) {
174
- cli_utilities_1.cliux.print('No content types found for the given stack', { color: 'yellow' });
175
- cli_utilities_1.log.info('No content types found', this.commandContext);
176
- return;
177
- }
178
- if (!contentTypesFlag) {
179
- contentTypes = await (0, utils_1.chooseInMemContentTypes)(contentTypes);
180
- cli_utilities_1.log.debug(`Content types selected: ${contentTypes.join(', ')}`, this.commandContext);
181
- }
182
- if (locale) {
183
- language = { code: locale };
184
- }
185
- else {
186
- language = await (0, utils_1.chooseLanguage)(stackAPIClient);
187
- }
188
- cli_utilities_1.log.debug(`Locale: ${language.code}`, this.commandContext);
189
- while (contentTypes.length > 0) {
190
- const contentType = contentTypes.pop();
191
- cli_utilities_1.log.debug(`Processing content type: ${contentType}`, this.commandContext);
192
- cli_utilities_1.cliux.loader(`Fetching entries for ${contentType}...`);
193
- const entriesCount = await (0, utils_1.getEntriesCount)(stackAPIClient, contentType, language.code);
194
- let flatEntries = [];
195
- for (let index = 0; index < entriesCount / 100; index++) {
196
- const entriesResult = await (0, utils_1.getEntries)(stackAPIClient, contentType, language.code, index, 100);
197
- const flatEntriesResult = (0, utils_1.cleanEntries)(entriesResult.items, language.code, environments, contentType);
198
- flatEntries = flatEntries.concat(flatEntriesResult);
199
- }
200
- cli_utilities_1.cliux.loader();
201
- cli_utilities_1.log.info(`Exporting ${flatEntries.length} entries for ${contentType}`, this.commandContext);
202
- const fileName = `${stackName || stack.name}_${contentType}_${language.code}_entries_export.csv`;
203
- (0, utils_1.write)(this, flatEntries, fileName, 'entries', delimiter);
204
- }
205
- cli_utilities_1.log.success('Entries exported successfully', this.commandContext);
206
- }
207
- catch (error) {
208
- cli_utilities_1.log.debug('Entries export failed', Object.assign(Object.assign({}, this.commandContext), { error }));
209
- (0, cli_utilities_1.handleAndLogError)(error, this.commandContext, 'Failed to export entries');
210
- throw error;
211
- }
212
- }
213
- /**
214
- * Export organization users to CSV.
215
- */
216
- async exportUsers(options) {
217
- const { managementAPIClient, org, orgName, action, delimiter } = options;
218
- cli_utilities_1.log.debug('Starting users export', this.commandContext);
219
- try {
220
- let organization;
221
- if (org) {
222
- organization = { uid: org, name: orgName || org };
223
- cli_utilities_1.log.debug(`Organization from flag: ${organization.name}`, this.commandContext);
224
- }
225
- else {
226
- organization = await (0, utils_1.chooseOrganization)(managementAPIClient, action);
227
- cli_utilities_1.log.debug(`Organization selected: ${organization.name}`, this.commandContext);
228
- }
229
- // Update context with org ID
230
- this.commandContext.orgId = organization.uid;
231
- cli_utilities_1.cliux.loader('Fetching organization users...');
232
- const orgUsers = await (0, utils_1.getOrgUsers)(managementAPIClient, organization.uid);
233
- const orgRoles = await (0, utils_1.getOrgRoles)(managementAPIClient, organization.uid);
234
- cli_utilities_1.cliux.loader();
235
- const mappedUsers = (0, utils_1.getMappedUsers)(orgUsers);
236
- const mappedRoles = (0, utils_1.getMappedRoles)(orgRoles);
237
- const listOfUsers = (0, utils_1.cleanOrgUsers)(orgUsers, mappedUsers, mappedRoles);
238
- cli_utilities_1.log.info(`Exporting ${listOfUsers.length} users`, this.commandContext);
239
- const fileName = `${(0, utils_1.kebabize)((orgName || organization.name).replace(config_1.default.organizationNameRegex, ''))}_users_export.csv`;
240
- (0, utils_1.write)(this, listOfUsers, fileName, 'organization details', delimiter);
241
- cli_utilities_1.log.success('Users exported successfully', this.commandContext);
242
- }
243
- catch (error) {
244
- cli_utilities_1.log.debug('Users export failed', Object.assign(Object.assign({}, this.commandContext), { error }));
245
- (0, cli_utilities_1.handleAndLogError)(error, this.commandContext, 'Failed to export users');
246
- throw error;
247
- }
248
- }
249
- /**
250
- * Export organization teams to CSV.
251
- */
252
- async exportTeamsData(options) {
253
- const { managementAPIClient, org, orgName, action, teamUid, delimiter } = options;
254
- cli_utilities_1.log.debug('Starting teams export', this.commandContext);
255
- try {
256
- let organization;
257
- if (org) {
258
- organization = { uid: org, name: orgName || org };
259
- cli_utilities_1.log.debug(`Organization from flag: ${organization.name}`, this.commandContext);
260
- }
261
- else {
262
- organization = await (0, utils_1.chooseOrganization)(managementAPIClient, action);
263
- cli_utilities_1.log.debug(`Organization selected: ${organization.name}`, this.commandContext);
264
- }
265
- // Update context with org ID
266
- this.commandContext.orgId = organization.uid;
267
- await (0, utils_1.exportTeams)(managementAPIClient, organization, teamUid, delimiter);
268
- cli_utilities_1.log.success('Teams exported successfully', this.commandContext);
269
- }
270
- catch (error) {
271
- cli_utilities_1.log.debug('Teams export failed', Object.assign(Object.assign({}, this.commandContext), { error }));
272
- (0, cli_utilities_1.handleAndLogError)(error, this.commandContext, 'Failed to export teams');
273
- throw error;
274
- }
275
- }
276
- /**
277
- * Export taxonomies to CSV.
278
- */
279
- async exportTaxonomiesData(options) {
280
- const { managementAPIClient, managementTokenAlias, stackName, stackAPIKey, org, locale, branchUid, taxonomyUID, includeFallback, fallbackLocale, delimiter, } = options;
281
- cli_utilities_1.log.debug('Starting taxonomies export', this.commandContext);
282
- try {
283
- let stack;
284
- let language;
285
- let stackAPIClient;
286
- let apiClient = managementAPIClient;
287
- if (managementTokenAlias) {
288
- cli_utilities_1.log.debug(`Using management token alias: ${managementTokenAlias}`, this.commandContext);
289
- const { stackDetails, apiClient: client } = await this.getAliasDetails(managementTokenAlias, stackName);
290
- apiClient = client;
291
- stack = stackDetails;
292
- }
293
- else {
294
- stack = await this.getStackDetails(managementAPIClient, stackAPIKey, org);
295
- }
296
- // Update context with stack API key
297
- this.commandContext.apiKey = stack.apiKey;
298
- cli_utilities_1.log.debug(`Stack selected: ${stack.name}`, this.commandContext);
299
- stackAPIClient = this.getStackClient(apiClient, stack);
300
- if (locale) {
301
- language = { code: locale };
302
- }
303
- else {
304
- language = await (0, utils_1.chooseLanguage)(stackAPIClient);
305
- }
306
- cli_utilities_1.log.debug(`Locale: ${language.code}`, this.commandContext);
307
- await this.createTaxonomyAndTermCsvFile(stackAPIClient, stackName, stack, taxonomyUID, delimiter, {
308
- locale: language.code,
309
- branch: branchUid,
310
- include_fallback: includeFallback,
311
- fallback_locale: fallbackLocale,
312
- });
313
- cli_utilities_1.log.success('Taxonomies exported successfully', this.commandContext);
314
- }
315
- catch (error) {
316
- cli_utilities_1.log.debug('Taxonomies export failed', Object.assign(Object.assign({}, this.commandContext), { error }));
317
- (0, cli_utilities_1.handleAndLogError)(error, this.commandContext, 'Failed to export taxonomies');
318
- throw error;
319
- }
320
- }
321
- snakeCase(string) {
322
- return (string || '').split(' ').join('_').toLowerCase();
323
- }
324
- getStackClient(managementAPIClient, stack) {
325
- const stackInit = {
326
- api_key: stack.apiKey,
327
- };
328
- if (stack === null || stack === void 0 ? void 0 : stack.branch_uid) {
329
- stackInit.branch_uid = stack.branch_uid;
330
- }
331
- if (stack.token) {
332
- return managementAPIClient.stack(Object.assign(Object.assign({}, stackInit), { management_token: stack.token }));
333
- }
334
- return managementAPIClient.stack(stackInit);
335
- }
336
- getStackBranches(stackAPIClient) {
337
- return stackAPIClient
338
- .branch()
339
- .query()
340
- .find()
341
- .then(({ items }) => (items !== undefined ? items : []))
342
- .catch(() => []);
343
- }
344
- /**
345
- * Check whether branch enabled org or not and update branch details.
346
- */
347
- async checkAndUpdateBranchDetail(branchUid, stack, stackAPIClient, managementAPIClient) {
348
- if (branchUid) {
349
- cli_utilities_1.log.debug(`Checking branch: ${branchUid}`, this.commandContext);
350
- try {
351
- const branchExists = await (0, cli_utilities_1.doesBranchExist)(stackAPIClient, branchUid);
352
- if (branchExists === null || branchExists === void 0 ? void 0 : branchExists.errorCode) {
353
- throw new Error(branchExists.errorMessage);
354
- }
355
- stack.branch_uid = branchUid;
356
- stackAPIClient = this.getStackClient(managementAPIClient, stack);
357
- cli_utilities_1.log.debug(`Branch validated: ${branchUid}`, this.commandContext);
358
- }
359
- catch (error) {
360
- cli_utilities_1.log.debug('Branch validation failed', Object.assign(Object.assign({}, this.commandContext), { error }));
361
- (0, cli_utilities_1.handleAndLogError)(error, this.commandContext, 'Invalid branch');
362
- this.exit(1);
363
- }
364
- }
365
- else {
366
- const stackBranches = await this.getStackBranches(stackAPIClient);
367
- if (stackBranches === undefined || stackBranches.length === 0) {
368
- stackAPIClient = this.getStackClient(managementAPIClient, stack);
369
- }
370
- else {
371
- const { branch } = await (0, utils_1.chooseBranch)(stackBranches);
372
- stack.branch_uid = branch;
373
- stackAPIClient = this.getStackClient(managementAPIClient, stack);
374
- cli_utilities_1.log.debug(`Branch selected: ${branch}`, this.commandContext);
375
- }
376
- }
377
- return stackAPIClient;
378
- }
379
- /**
380
- * Fetch stack details from alias token.
381
- */
382
- async getAliasDetails(managementTokenAlias, stackName) {
383
- cli_utilities_1.log.debug(`Resolving alias: ${managementTokenAlias}`, this.commandContext);
384
- const listOfTokens = cli_utilities_1.configHandler.get('tokens');
385
- if (managementTokenAlias && (listOfTokens === null || listOfTokens === void 0 ? void 0 : listOfTokens[managementTokenAlias])) {
386
- const tokenConfig = listOfTokens[managementTokenAlias];
387
- cli_utilities_1.cliux.loader('Validating management token...');
388
- const checkManagementTokenValidity = await (0, cli_utilities_1.isManagementTokenValid)(tokenConfig.apiKey, tokenConfig.token);
389
- cli_utilities_1.cliux.loader();
390
- if (Object.prototype.hasOwnProperty.call(checkManagementTokenValidity, 'message')) {
391
- const errorMsg = checkManagementTokenValidity.valid === 'failedToCheck'
392
- ? checkManagementTokenValidity.message
393
- : `Management token or stack API key is invalid. ${checkManagementTokenValidity.message}`;
394
- cli_utilities_1.log.debug('Token validation failed', Object.assign(Object.assign({}, this.commandContext), { error: errorMsg }));
395
- throw new Error(errorMsg);
396
- }
397
- cli_utilities_1.log.debug('Token validated successfully', this.commandContext);
398
- const apiClient = await (0, cli_utilities_1.managementSDKClient)({
399
- host: this.cmaHost,
400
- management_token: tokenConfig.token,
401
- });
402
- const stackDetails = {
403
- name: stackName || managementTokenAlias,
404
- apiKey: tokenConfig.apiKey,
405
- token: tokenConfig.token,
406
- };
407
- return { apiClient, stackDetails };
408
- }
409
- else if (managementTokenAlias) {
410
- cli_utilities_1.log.debug('Alias not found in config', this.commandContext);
411
- this.error('The provided management token alias was not found in your config.', {
412
- exit: 1,
413
- suggestions: ['Use "csdx auth:tokens:add" to add a new token'],
414
- });
415
- }
416
- throw new Error('Management token alias is required.');
417
- }
418
- /**
419
- * Fetch stack details on basis of the selected org and stack.
420
- */
421
- async getStackDetails(managementAPIClient, stackAPIKey, org) {
422
- cli_utilities_1.log.debug('Getting stack details', this.commandContext);
423
- if (!(0, cli_utilities_1.isAuthenticated)()) {
424
- cli_utilities_1.log.debug('User not authenticated', this.commandContext);
425
- this.error(messages_1.messages.ERROR_NOT_LOGGED_IN, {
426
- exit: 2,
427
- suggestions: ['https://www.contentstack.com/docs/developers/cli/authentication/'],
428
- });
429
- }
430
- let organization;
431
- let stackDetails;
432
- if (org) {
433
- organization = { uid: org, name: org };
434
- }
435
- else {
436
- organization = await (0, utils_1.chooseOrganization)(managementAPIClient);
437
- }
438
- cli_utilities_1.log.debug(`Organization: ${organization.name}`, this.commandContext);
439
- if (!stackAPIKey) {
440
- stackDetails = await (0, utils_1.chooseStack)(managementAPIClient, organization.uid);
441
- }
442
- else {
443
- stackDetails = await (0, utils_1.chooseStack)(managementAPIClient, organization.uid, stackAPIKey);
444
- }
445
- cli_utilities_1.log.debug(`Stack: ${stackDetails.name}`, this.commandContext);
446
- return {
447
- name: stackDetails.name,
448
- apiKey: stackDetails.apiKey,
449
- };
450
- }
451
- /**
452
- * Create a taxonomies csv file for stack and a terms csv file for associated taxonomies.
453
- */
454
- async createTaxonomyAndTermCsvFile(stackAPIClient, stackName, stack, taxUID, delimiter, localeOptions = {}) {
455
- cli_utilities_1.log.debug('Creating taxonomy CSV', this.commandContext);
456
- const payload = Object.assign({ stackAPIClient, limit: config_1.default.limit || 100 }, localeOptions);
457
- let taxonomies = [];
458
- cli_utilities_1.cliux.loader('Fetching taxonomies...');
459
- if (taxUID) {
460
- payload.taxonomyUID = taxUID;
461
- const taxonomy = await (0, utils_1.getTaxonomy)(payload);
462
- taxonomies.push(taxonomy);
463
- cli_utilities_1.log.debug(`Single taxonomy fetched: ${taxUID}`, this.commandContext);
464
- }
465
- else {
466
- taxonomies = await (0, utils_1.getAllTaxonomies)(payload);
467
- cli_utilities_1.log.debug(`Fetched ${taxonomies.length} taxonomies`, this.commandContext);
468
- }
469
- cli_utilities_1.cliux.loader();
470
- if (!(taxonomies === null || taxonomies === void 0 ? void 0 : taxonomies.length)) {
471
- cli_utilities_1.cliux.print('No taxonomies found!', { color: 'yellow' });
472
- cli_utilities_1.log.info('No taxonomies found', this.commandContext);
473
- return;
474
- }
475
- cli_utilities_1.cliux.loader('Generating CSV...');
476
- const fileName = `${stackName !== null && stackName !== void 0 ? stackName : stack.name}_taxonomies.csv`;
477
- const { taxonomiesData, headers } = await (0, utils_1.createImportableCSV)(payload, taxonomies);
478
- cli_utilities_1.cliux.loader();
479
- if (taxonomiesData === null || taxonomiesData === void 0 ? void 0 : taxonomiesData.length) {
480
- cli_utilities_1.log.info(`Exporting ${taxonomiesData.length} taxonomy records`, this.commandContext);
481
- (0, utils_1.write)(this, taxonomiesData, fileName, 'taxonomies', delimiter, headers);
482
- }
483
- }
484
- }
485
- ExportToCsvCommand.description = 'Export entries, taxonomies, terms or organization users to csv using this command';
486
- ExportToCsvCommand.aliases = ['cm:export-to-csv'];
487
- ExportToCsvCommand.examples = [
488
- '$ <%= config.bin %> <%= command.id %>',
489
- '',
490
- 'Exporting entries to CSV',
491
- '$ <%= config.bin %> <%= command.id %> --action entries --locale <locale> --alias <management-token-alias> --content-type <content-type>',
492
- '',
493
- 'Exporting entries to CSV with stack name and branch',
494
- '$ <%= config.bin %> <%= command.id %> --action entries --locale <locale> --alias <management-token-alias> --content-type <content-type> --stack-name <stack-name> --branch <branch-name>',
495
- '',
496
- 'Exporting organization users to CSV',
497
- '$ <%= config.bin %> <%= command.id %> --action users --org <org-uid>',
498
- '',
499
- 'Exporting organization teams to CSV',
500
- '$ <%= config.bin %> <%= command.id %> --action teams --org <org-uid>',
501
- '',
502
- 'Exporting teams with specific team UID',
503
- '$ <%= config.bin %> <%= command.id %> --action teams --org <org-uid> --team-uid <team-uid>',
504
- '',
505
- 'Exporting taxonomies to CSV',
506
- '$ <%= config.bin %> <%= command.id %> --action taxonomies --alias <management-token-alias>',
507
- '',
508
- 'Exporting specific taxonomy with locale',
509
- '$ <%= config.bin %> <%= command.id %> --action taxonomies --alias <management-token-alias> --taxonomy-uid <taxonomy-uid> --locale <locale>',
510
- '',
511
- 'Exporting taxonomies with fallback locale',
512
- '$ <%= config.bin %> <%= command.id %> --action taxonomies --alias <management-token-alias> --locale <locale> --include-fallback --fallback-locale <fallback-locale>',
513
- ];
514
- ExportToCsvCommand.flags = {
515
- action: cli_utilities_1.flags.string({
516
- required: false,
517
- multiple: false,
518
- options: ['entries', 'users', 'teams', 'taxonomies'],
519
- description: 'Option to export data (entries, users, teams, taxonomies). <options: entries|users|teams|taxonomies>',
520
- }),
521
- alias: cli_utilities_1.flags.string({
522
- char: 'a',
523
- description: 'Alias of the management token.',
524
- }),
525
- org: cli_utilities_1.flags.string({
526
- multiple: false,
527
- required: false,
528
- description: 'Provide organization UID to clone org users.',
529
- }),
530
- 'stack-name': cli_utilities_1.flags.string({
531
- char: 'n',
532
- multiple: false,
533
- required: false,
534
- description: 'Name of the stack that needs to be created as CSV filename.',
535
- }),
536
- 'stack-api-key': cli_utilities_1.flags.string({
537
- char: 'k',
538
- multiple: false,
539
- required: false,
540
- description: 'API Key of the source stack.',
541
- }),
542
- 'org-name': cli_utilities_1.flags.string({
543
- multiple: false,
544
- required: false,
545
- description: 'Name of the organization that needs to be created as CSV filename.',
546
- }),
547
- locale: cli_utilities_1.flags.string({
548
- required: false,
549
- multiple: false,
550
- description: 'Locale of entries that will be exported.',
551
- }),
552
- 'content-type': cli_utilities_1.flags.string({
553
- description: 'Content type of entries that will be exported.',
554
- required: false,
555
- multiple: false,
556
- }),
557
- branch: cli_utilities_1.flags.string({
558
- description: 'Branch from which entries will be exported.',
559
- multiple: false,
560
- required: false,
561
- }),
562
- 'team-uid': cli_utilities_1.flags.string({
563
- description: 'Provide the UID of a specific team in an organization.',
564
- }),
565
- 'taxonomy-uid': cli_utilities_1.flags.string({
566
- description: 'Provide the taxonomy UID of the related terms you want to export.',
567
- }),
568
- 'include-fallback': cli_utilities_1.flags.boolean({
569
- description: "[Optional] Include fallback locale data when exporting taxonomies. When enabled, if a taxonomy term doesn't exist in the specified locale, it will fallback to the hierarchy defined in the branch settings.",
570
- default: false,
571
- }),
572
- 'fallback-locale': cli_utilities_1.flags.string({
573
- description: "[Optional] Specify a specific fallback locale for taxonomy export. This locale will be used when a taxonomy term doesn't exist in the primary locale. Takes priority over branch fallback hierarchy when both are specified.",
574
- required: false,
575
- }),
576
- delimiter: cli_utilities_1.flags.string({
577
- description: "[optional] Provide a delimiter to separate individual data fields within the CSV file. For example: cm:export-to-csv --delimiter '|'",
578
- default: ',',
579
- }),
580
- };
581
- exports.default = ExportToCsvCommand;
@@ -1,9 +0,0 @@
1
- /**
2
- * Configuration constants for export-to-csv command.
3
- * Migrated from: packages/contentstack-export-to-csv/src/util/config.js
4
- */
5
- declare const config: {
6
- limit: number;
7
- organizationNameRegex: RegExp;
8
- };
9
- export default config;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- /**
3
- * Configuration constants for export-to-csv command.
4
- * Migrated from: packages/contentstack-export-to-csv/src/util/config.js
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- const config = {
8
- limit: 100,
9
- organizationNameRegex: /'/g,
10
- };
11
- exports.default = config;
package/lib/index.d.ts DELETED
@@ -1,13 +0,0 @@
1
- /**
2
- * @contentstack/cli-cm-export-to-csv
3
- *
4
- * Export entries, taxonomies, terms, or organization users to CSV files.
5
- * Migrated from: packages/contentstack-export-to-csv
6
- */
7
- import ExportToCsv from './commands/cm/export-to-csv';
8
- export { ExportToCsv };
9
- export { BaseCommand } from './base-command';
10
- export type { CommandContext } from './base-command';
11
- export * from './utils';
12
- export * from './types';
13
- export { default as config } from './config';
package/lib/index.js DELETED
@@ -1,19 +0,0 @@
1
- "use strict";
2
- /**
3
- * @contentstack/cli-cm-export-to-csv
4
- *
5
- * Export entries, taxonomies, terms, or organization users to CSV files.
6
- * Migrated from: packages/contentstack-export-to-csv
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.config = exports.BaseCommand = exports.ExportToCsv = void 0;
10
- const tslib_1 = require("tslib");
11
- const export_to_csv_1 = tslib_1.__importDefault(require("./commands/cm/export-to-csv"));
12
- exports.ExportToCsv = export_to_csv_1.default;
13
- var base_command_1 = require("./base-command");
14
- Object.defineProperty(exports, "BaseCommand", { enumerable: true, get: function () { return base_command_1.BaseCommand; } });
15
- // Re-export utilities for external use
16
- tslib_1.__exportStar(require("./utils"), exports);
17
- tslib_1.__exportStar(require("./types"), exports);
18
- var config_1 = require("./config");
19
- Object.defineProperty(exports, "config", { enumerable: true, get: function () { return tslib_1.__importDefault(config_1).default; } });