@contentstack/cli-cm-export 2.0.0-beta.5 → 2.0.0-beta.7

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/README.md CHANGED
@@ -48,7 +48,7 @@ $ npm install -g @contentstack/cli-cm-export
48
48
  $ csdx COMMAND
49
49
  running command...
50
50
  $ csdx (--version)
51
- @contentstack/cli-cm-export/2.0.0-beta.5 linux-x64 node-v22.22.0
51
+ @contentstack/cli-cm-export/2.0.0-beta.7 linux-x64 node-v22.22.0
52
52
  $ csdx --help [COMMAND]
53
53
  USAGE
54
54
  $ csdx COMMAND
@@ -83,8 +83,7 @@ class ExportAssets extends base_class_1.default {
83
83
  await this.downloadAssets();
84
84
  progress.completeProcess(utils_1.PROCESS_NAMES.ASSET_DOWNLOADS, true);
85
85
  }
86
- this.completeProgress(true);
87
- cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('ASSET_EXPORT_COMPLETE'), this.exportConfig.context);
86
+ this.completeProgressWithMessage();
88
87
  }
89
88
  catch (error) {
90
89
  this.completeProgress(false, (error === null || error === void 0 ? void 0 : error.message) || 'Asset export failed');
@@ -9,6 +9,12 @@ export type ApiOptions = {
9
9
  reject: (error: any) => void;
10
10
  additionalInfo?: Record<any, any>;
11
11
  };
12
+ export type CompleteProgressOptions = {
13
+ moduleName?: string;
14
+ customSuccessMessage?: string;
15
+ customWarningMessage?: string;
16
+ context?: Record<string, any>;
17
+ };
12
18
  export type EnvType = {
13
19
  module: string;
14
20
  totalCount: number;
@@ -44,6 +50,17 @@ export default abstract class BaseClass {
44
50
  * Complete progress manager
45
51
  */
46
52
  protected completeProgress(success?: boolean, error?: string): void;
53
+ /**
54
+ * Complete progress and log success/warning message based on errors
55
+ * Checks the progress manager's failure count to determine if errors occurred
56
+ * @param options - Options object containing:
57
+ * - moduleName: The module name to generate the message (e.g., 'Assets', 'Entries')
58
+ * If not provided, uses this.currentModuleName
59
+ * - customSuccessMessage: Optional custom success message. If not provided, generates: "{moduleName} have been exported successfully!"
60
+ * - customWarningMessage: Optional custom warning message. If not provided, generates: "{moduleName} have been exported with some errors. Please check the logs for details."
61
+ * - context: Optional context for logging
62
+ */
63
+ protected completeProgressWithMessage(options?: CompleteProgressOptions): void;
47
64
  protected withLoadingSpinner<T>(message: string, action: () => Promise<T>): Promise<T>;
48
65
  get stack(): any;
49
66
  delay(ms: number): Promise<void>;
@@ -49,6 +49,33 @@ class BaseClass {
49
49
  (_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.complete(success, error);
50
50
  this.progressManager = null;
51
51
  }
52
+ /**
53
+ * Complete progress and log success/warning message based on errors
54
+ * Checks the progress manager's failure count to determine if errors occurred
55
+ * @param options - Options object containing:
56
+ * - moduleName: The module name to generate the message (e.g., 'Assets', 'Entries')
57
+ * If not provided, uses this.currentModuleName
58
+ * - customSuccessMessage: Optional custom success message. If not provided, generates: "{moduleName} have been exported successfully!"
59
+ * - customWarningMessage: Optional custom warning message. If not provided, generates: "{moduleName} have been exported with some errors. Please check the logs for details."
60
+ * - context: Optional context for logging
61
+ */
62
+ completeProgressWithMessage(options) {
63
+ var _a, _b;
64
+ const logContext = (options === null || options === void 0 ? void 0 : options.context) || ((_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context) || {};
65
+ const failureCount = ((_b = this.progressManager) === null || _b === void 0 ? void 0 : _b.getFailureCount()) || 0;
66
+ const hasErrors = failureCount > 0;
67
+ const name = (options === null || options === void 0 ? void 0 : options.moduleName) || this.currentModuleName || 'Module';
68
+ // Generate default messages if not provided
69
+ const successMessage = (options === null || options === void 0 ? void 0 : options.customSuccessMessage) || `${name} have been exported successfully!`;
70
+ const warningMessage = (options === null || options === void 0 ? void 0 : options.customWarningMessage) || `${name} have been exported with some errors. Please check the logs for details.`;
71
+ this.completeProgress(true);
72
+ if (hasErrors) {
73
+ cli_utilities_1.log.warn(warningMessage, logContext);
74
+ }
75
+ else {
76
+ cli_utilities_1.log.success(successMessage, logContext);
77
+ }
78
+ }
52
79
  async withLoadingSpinner(message, action) {
53
80
  var _a;
54
81
  const logConfig = cli_utilities_1.configHandler.get('log') || {};
@@ -50,8 +50,7 @@ class ContentTypesExport extends base_class_1.default {
50
50
  progress.updateStatus('Fetching content types...');
51
51
  await this.getContentTypes();
52
52
  await this.writeContentTypes(this.contentTypes);
53
- cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('CONTENT_TYPE_EXPORT_COMPLETE'), this.exportConfig.context);
54
- this.completeProgress(true);
53
+ this.completeProgressWithMessage();
55
54
  }
56
55
  catch (error) {
57
56
  (0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
@@ -60,7 +60,7 @@ class ExportCustomRoles extends base_class_1.default {
60
60
  await this.getCustomRolesLocales();
61
61
  progress.completeProcess(utils_1.PROCESS_NAMES.PROCESS_MAPPINGS, true);
62
62
  cli_utilities_1.log.debug(`Custom roles export completed. Total custom roles: ${Object.keys(this.customRoles || {}).length}`, this.exportConfig.context);
63
- this.completeProgress(true);
63
+ this.completeProgressWithMessage();
64
64
  }
65
65
  catch (error) {
66
66
  (0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
@@ -86,8 +86,7 @@ class EntriesExport extends base_class_1.default {
86
86
  this.variantEntries.completeExport();
87
87
  }
88
88
  }
89
- this.completeProgress(true);
90
- cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('ENTRIES_EXPORT_SUCCESS'), this.exportConfig.context);
89
+ this.completeProgressWithMessage();
91
90
  }
92
91
  catch (error) {
93
92
  (0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
@@ -47,9 +47,8 @@ class ExportEnvironments extends base_class_1.default {
47
47
  const environmentsFilePath = (0, node_path_1.resolve)(this.environmentsFolderPath, this.environmentConfig.fileName);
48
48
  cli_utilities_1.log.debug(`Writing environments to: ${environmentsFilePath}`, this.exportConfig.context);
49
49
  utils_1.fsUtil.writeFile(environmentsFilePath, this.environments);
50
- cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('ENVIRONMENT_EXPORT_COMPLETE', Object.keys(this.environments || {}).length), this.exportConfig.context);
51
50
  }
52
- this.completeProgress(true);
51
+ this.completeProgressWithMessage();
53
52
  }
54
53
  catch (error) {
55
54
  (0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
@@ -48,9 +48,8 @@ class ExportExtensions extends base_class_1.default {
48
48
  const extensionsFilePath = (0, node_path_1.resolve)(this.extensionsFolderPath, this.extensionConfig.fileName);
49
49
  cli_utilities_1.log.debug(`Writing extensions to: ${extensionsFilePath}`, this.exportConfig.context);
50
50
  utils_1.fsUtil.writeFile(extensionsFilePath, this.extensions);
51
- cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('EXTENSION_EXPORT_COMPLETE', Object.keys(this.extensions || {}).length), this.exportConfig.context);
52
51
  }
53
- this.completeProgress(true);
52
+ this.completeProgressWithMessage();
54
53
  }
55
54
  catch (error) {
56
55
  (0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
@@ -50,8 +50,7 @@ class GlobalFieldsExport extends base_class_1.default {
50
50
  const globalFieldsFilePath = path.join(this.globalFieldsDirPath, this.globalFieldsConfig.fileName);
51
51
  cli_utilities_1.log.debug(`Writing global fields to: ${globalFieldsFilePath}`, this.exportConfig.context);
52
52
  utils_1.fsUtil.writeFile(globalFieldsFilePath, this.globalFields);
53
- cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('GLOBAL_FIELDS_EXPORT_COMPLETE', this.globalFields.length), this.exportConfig.context);
54
- this.completeProgress(true);
53
+ this.completeProgressWithMessage();
55
54
  }
56
55
  catch (error) {
57
56
  cli_utilities_1.log.debug('Error occurred during global fields export', this.exportConfig.context);
@@ -47,9 +47,8 @@ class ExportLabels extends base_class_1.default {
47
47
  const labelsFilePath = (0, node_path_1.resolve)(this.labelsFolderPath, this.labelConfig.fileName);
48
48
  cli_utilities_1.log.debug(`Writing labels to: ${labelsFilePath}`, this.exportConfig.context);
49
49
  utils_1.fsUtil.writeFile(labelsFilePath, this.labels);
50
- cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('LABELS_EXPORT_COMPLETE', Object.keys(this.labels || {}).length), this.exportConfig.context);
51
50
  }
52
- this.completeProgress(true);
51
+ this.completeProgressWithMessage();
53
52
  }
54
53
  catch (error) {
55
54
  (0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
@@ -49,8 +49,7 @@ class LocaleExport extends base_class_1.default {
49
49
  utils_1.fsUtil.writeFile(localesFilePath, this.locales);
50
50
  cli_utilities_1.log.debug(`Writing master locale to: ${masterLocaleFilePath}`, this.exportConfig.context);
51
51
  utils_1.fsUtil.writeFile(masterLocaleFilePath, this.masterLocale);
52
- cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('LOCALES_EXPORT_COMPLETE', Object.keys(this.locales || {}).length, Object.keys(this.masterLocale || {}).length), this.exportConfig.context);
53
- this.completeProgress(true);
52
+ this.completeProgressWithMessage();
54
53
  }
55
54
  catch (error) {
56
55
  (0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
@@ -64,8 +64,7 @@ class ExportMarketplaceApps extends base_class_1.default {
64
64
  await this.getAppManifestAndAppConfig();
65
65
  progress.completeProcess(utils_1.PROCESS_NAMES.FETCH_CONFIG_MANIFEST, true);
66
66
  }
67
- this.completeProgress(true);
68
- cli_utilities_1.log.success('Marketplace apps export completed successfully', this.exportConfig.context);
67
+ this.completeProgressWithMessage();
69
68
  }
70
69
  catch (error) {
71
70
  cli_utilities_1.log.debug('Error occurred during marketplace apps export', this.exportConfig.context);
@@ -64,8 +64,7 @@ class ExportPersonalize extends base_class_1.default {
64
64
  else {
65
65
  cli_utilities_1.log.debug('No personalize modules configured for processing', this.exportConfig.context);
66
66
  }
67
- this.completeProgress(true);
68
- cli_utilities_1.log.success('Personalize export completed successfully', this.exportConfig.context);
67
+ this.completeProgressWithMessage();
69
68
  }
70
69
  catch (moduleError) {
71
70
  if (moduleError === 'Forbidden') {
@@ -81,8 +81,7 @@ class ExportStack extends base_class_1.default {
81
81
  else {
82
82
  cli_utilities_1.log.debug('Locale locale already set, skipping locale fetch', this.exportConfig.context);
83
83
  }
84
- this.completeProgress(true);
85
- cli_utilities_1.log.success('Stack export completed successfully', this.exportConfig.context);
84
+ this.completeProgressWithMessage();
86
85
  }
87
86
  catch (error) {
88
87
  cli_utilities_1.log.debug('Error occurred during stack export', this.exportConfig.context);
@@ -54,7 +54,7 @@ class ExportTaxonomies extends base_class_1.default {
54
54
  }
55
55
  await this.writeTaxonomiesMetadata();
56
56
  }
57
- cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('TAXONOMY_EXPORT_COMPLETE', (0, keys_1.default)(this.taxonomies || {}).length), this.exportConfig.context);
57
+ this.completeProgressWithMessage();
58
58
  }
59
59
  /**
60
60
  * Process and export taxonomies for a specific locale
@@ -43,9 +43,8 @@ class ExportWebhooks extends base_class_1.default {
43
43
  const webhooksFilePath = (0, node_path_1.resolve)(this.webhooksFolderPath, this.webhookConfig.fileName);
44
44
  cli_utilities_1.log.debug(`Writing webhooks to: ${webhooksFilePath}`, this.exportConfig.context);
45
45
  utils_1.fsUtil.writeFile(webhooksFilePath, this.webhooks);
46
- cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('WEBHOOK_EXPORT_COMPLETE', Object.keys(this.webhooks || {}).length), this.exportConfig.context);
47
46
  }
48
- this.completeProgress(true);
47
+ this.completeProgressWithMessage();
49
48
  }
50
49
  catch (error) {
51
50
  (0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
@@ -46,9 +46,8 @@ class ExportWorkFlows extends base_class_1.default {
46
46
  const workflowsFilePath = (0, node_path_1.resolve)(this.webhooksFolderPath, this.workflowConfig.fileName);
47
47
  cli_utilities_1.log.debug(`Writing workflows to: ${workflowsFilePath}`, this.exportConfig.context);
48
48
  utils_1.fsUtil.writeFile(workflowsFilePath, this.workflows);
49
- cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('WORKFLOW_EXPORT_COMPLETE', Object.keys(this.workflows || {}).length), this.exportConfig.context);
50
49
  }
51
- this.completeProgress(true);
50
+ this.completeProgressWithMessage();
52
51
  }
53
52
  catch (error) {
54
53
  (0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
@@ -121,5 +121,5 @@
121
121
  ]
122
122
  }
123
123
  },
124
- "version": "2.0.0-beta.5"
124
+ "version": "2.0.0-beta.7"
125
125
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@contentstack/cli-cm-export",
3
3
  "description": "Contentstack CLI plugin to export content from stack",
4
- "version": "2.0.0-beta.5",
4
+ "version": "2.0.0-beta.7",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {
8
8
  "@contentstack/cli-command": "~1.7.2",
9
- "@contentstack/cli-utilities": "~1.17.0",
9
+ "@contentstack/cli-utilities": "~1.17.2",
10
10
  "@contentstack/cli-variants": "~2.0.0-beta.4",
11
11
  "@oclif/core": "^4.8.0",
12
12
  "async": "^3.2.6",
@@ -21,8 +21,8 @@
21
21
  "winston": "^3.17.0"
22
22
  },
23
23
  "devDependencies": {
24
- "@contentstack/cli-auth": "~2.0.0-beta.1",
25
- "@contentstack/cli-config": "~1.18.0",
24
+ "@contentstack/cli-auth": "~2.0.0-beta.4",
25
+ "@contentstack/cli-config": "~1.19.0",
26
26
  "@contentstack/cli-dev-dependencies": "~1.3.1",
27
27
  "@oclif/plugin-help": "^6.2.28",
28
28
  "@oclif/test": "^4.1.13",