@contentstack/cli-cm-import 2.0.0-beta.5 → 2.0.0-beta.6

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
@@ -47,7 +47,7 @@ $ npm install -g @contentstack/cli-cm-import
47
47
  $ csdx COMMAND
48
48
  running command...
49
49
  $ csdx (--version)
50
- @contentstack/cli-cm-import/2.0.0-beta.5 linux-x64 node-v22.22.0
50
+ @contentstack/cli-cm-import/2.0.0-beta.6 linux-x64 node-v22.22.0
51
51
  $ csdx --help [COMMAND]
52
52
  USAGE
53
53
  $ csdx COMMAND
@@ -4,6 +4,12 @@ import { ImportConfig, ModuleClassParams } from '../../types';
4
4
  export type AdditionalKeys = {
5
5
  backupDir: string;
6
6
  };
7
+ export type CompleteProgressOptions = {
8
+ moduleName?: string;
9
+ customSuccessMessage?: string;
10
+ customWarningMessage?: string;
11
+ context?: Record<string, any>;
12
+ };
7
13
  export type ApiModuleType = 'create-assets' | 'replace-assets' | 'publish-assets' | 'create-assets-folder' | 'create-extensions' | 'update-extensions' | 'create-locale' | 'update-locale' | 'create-gfs' | 'create-cts' | 'update-cts' | 'update-gfs' | 'create-environments' | 'create-labels' | 'update-labels' | 'create-webhooks' | 'create-workflows' | 'create-custom-role' | 'create-entries' | 'update-entries' | 'publish-entries' | 'delete-entries' | 'create-taxonomies' | 'create-terms' | 'import-taxonomy';
8
14
  export type ApiOptions = {
9
15
  uid?: string;
@@ -55,6 +61,17 @@ export default abstract class BaseClass {
55
61
  * Complete progress manager
56
62
  */
57
63
  protected completeProgress(success?: boolean, error?: string): void;
64
+ /**
65
+ * Complete progress and log success/warning message based on errors
66
+ * Checks the progress manager's failure count to determine if errors occurred
67
+ * @param options - Options object containing:
68
+ * - moduleName: The module name to generate the message (e.g., 'Content types', 'Entries')
69
+ * If not provided, uses this.currentModuleName
70
+ * - customSuccessMessage: Optional custom success message. If not provided, generates: "{moduleName} have been imported successfully!"
71
+ * - customWarningMessage: Optional custom warning message. If not provided, generates: "{moduleName} have been imported with some errors. Please check the logs for details."
72
+ * - context: Optional context for logging
73
+ */
74
+ protected completeProgressWithMessage(options?: CompleteProgressOptions): void;
58
75
  protected withLoadingSpinner<T>(message: string, action: () => Promise<T>): Promise<T>;
59
76
  /**
60
77
  * @method delay
@@ -54,6 +54,33 @@ class BaseClass {
54
54
  (_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.complete(success, error);
55
55
  this.progressManager = null;
56
56
  }
57
+ /**
58
+ * Complete progress and log success/warning message based on errors
59
+ * Checks the progress manager's failure count to determine if errors occurred
60
+ * @param options - Options object containing:
61
+ * - moduleName: The module name to generate the message (e.g., 'Content types', 'Entries')
62
+ * If not provided, uses this.currentModuleName
63
+ * - customSuccessMessage: Optional custom success message. If not provided, generates: "{moduleName} have been imported successfully!"
64
+ * - customWarningMessage: Optional custom warning message. If not provided, generates: "{moduleName} have been imported with some errors. Please check the logs for details."
65
+ * - context: Optional context for logging
66
+ */
67
+ completeProgressWithMessage(options) {
68
+ var _a, _b;
69
+ const logContext = (options === null || options === void 0 ? void 0 : options.context) || ((_a = this.importConfig) === null || _a === void 0 ? void 0 : _a.context) || {};
70
+ const failureCount = ((_b = this.progressManager) === null || _b === void 0 ? void 0 : _b.getFailureCount()) || 0;
71
+ const hasErrors = failureCount > 0;
72
+ const name = (options === null || options === void 0 ? void 0 : options.moduleName) || this.currentModuleName || 'Module';
73
+ // Generate default messages if not provided
74
+ const successMessage = (options === null || options === void 0 ? void 0 : options.customSuccessMessage) || `${name} have been imported successfully!`;
75
+ const warningMessage = (options === null || options === void 0 ? void 0 : options.customWarningMessage) || `${name} have been imported with some errors. Please check the logs for details.`;
76
+ this.completeProgress(true);
77
+ if (hasErrors) {
78
+ cli_utilities_1.log.warn(warningMessage, logContext);
79
+ }
80
+ else {
81
+ cli_utilities_1.log.success(successMessage, logContext);
82
+ }
83
+ }
57
84
  async withLoadingSpinner(message, action) {
58
85
  var _a;
59
86
  const logConfig = cli_utilities_1.configHandler.get('log') || {};
@@ -107,8 +107,7 @@ class ContentTypesImport extends base_class_1.default {
107
107
  if (this.pendingGFs.length > 0) {
108
108
  await this.handlePendingGlobalFields(progress);
109
109
  }
110
- this.completeProgress(true);
111
- cli_utilities_1.log.success('Content types have been imported successfully!', this.importConfig.context);
110
+ this.completeProgressWithMessage();
112
111
  }
113
112
  catch (error) {
114
113
  this.completeProgress(false, (error === null || error === void 0 ? void 0 : error.message) || 'Content types import failed');
@@ -84,8 +84,7 @@ class ImportCustomRoles extends base_class_1.default {
84
84
  progress.updateStatus(utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.CUSTOM_ROLES_IMPORT].IMPORTING);
85
85
  await this.importCustomRoles();
86
86
  this.handleImportResults();
87
- this.completeProgress(true);
88
- cli_utilities_1.log.success('Custom roles have been imported successfully!', this.importConfig.context);
87
+ this.completeProgressWithMessage();
89
88
  }
90
89
  catch (error) {
91
90
  this.completeProgress(false, (error === null || error === void 0 ? void 0 : error.message) || 'Custom roles import failed');
@@ -123,8 +123,7 @@ class EntriesImport extends base_class_1.default {
123
123
  .updateStatus(utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.CLEANUP].CLEANING, utils_1.PROCESS_NAMES.CLEANUP);
124
124
  await this.processCleanup();
125
125
  progress.completeProcess(utils_1.PROCESS_NAMES.CLEANUP, true);
126
- this.completeProgress(true);
127
- cli_utilities_1.log.success('Entries imported successfully', this.importConfig.context);
126
+ this.completeProgressWithMessage();
128
127
  }
129
128
  catch (error) {
130
129
  this.createEntryDataForVariantEntry();
@@ -39,8 +39,7 @@ class ImportEnvironments extends base_class_1.default {
39
39
  progress.updateStatus(utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.ENVIRONMENTS_IMPORT].IMPORTING);
40
40
  await this.importEnvironments();
41
41
  await this.processImportResults();
42
- this.completeProgress(true);
43
- cli_utilities_1.log.success('Environments have been imported successfully!', this.importConfig.context);
42
+ this.completeProgressWithMessage();
44
43
  }
45
44
  catch (error) {
46
45
  this.completeProgress(false, (error === null || error === void 0 ? void 0 : error.message) || 'Environments import failed');
@@ -60,8 +60,7 @@ class ImportExtensions extends base_class_1.default {
60
60
  progress.completeProcess(utils_1.PROCESS_NAMES.EXTENSIONS_REPLACE_EXISTING, true);
61
61
  }
62
62
  await this.processExtensionResults();
63
- this.completeProgress(true);
64
- cli_utilities_1.log.success('Extensions have been imported successfully!', this.importConfig.context);
63
+ this.completeProgressWithMessage();
65
64
  }
66
65
  catch (error) {
67
66
  this.completeProgress(false, (error === null || error === void 0 ? void 0 : error.message) || 'Create failed');
@@ -76,8 +76,7 @@ class ImportGlobalFields extends base_class_1.default {
76
76
  progress.completeProcess(utils_1.PROCESS_NAMES.GLOBAL_FIELDS_REPLACE_EXISTING, true);
77
77
  }
78
78
  await this.processGlobalFieldResults();
79
- this.completeProgress(true);
80
- cli_utilities_1.log.success('Global fields import has been completed!', this.importConfig.context);
79
+ this.completeProgressWithMessage();
81
80
  }
82
81
  catch (error) {
83
82
  this.completeProgress(false, (error === null || error === void 0 ? void 0 : error.message) || 'Global fields import failed');
@@ -55,8 +55,7 @@ class ImportLabels extends base_class_1.default {
55
55
  await this.updateLabels();
56
56
  progress.completeProcess(utils_1.PROCESS_NAMES.LABELS_UPDATE, true);
57
57
  this.processLabelResults();
58
- this.completeProgress(true);
59
- cli_utilities_1.log.success('Labels have been imported successfully!', this.importConfig.context);
58
+ this.completeProgressWithMessage();
60
59
  }
61
60
  catch (error) {
62
61
  this.completeProgress(false, (error === null || error === void 0 ? void 0 : error.message) || 'Labels import failed');
@@ -49,8 +49,7 @@ class ImportLocales extends base_class_1.default {
49
49
  cli_utilities_1.log.debug('Writing failed locales to file', this.config.context);
50
50
  utils_1.fsUtil.writeFile(this.langFailsPath, this.failedLocales);
51
51
  cli_utilities_1.log.debug(`Written ${this.failedLocales.length} failed locales to file`, this.config.context);
52
- this.completeProgress(true);
53
- cli_utilities_1.log.success('Languages have been imported successfully!', this.config.context);
52
+ this.completeProgressWithMessage({ context: this.config.context });
54
53
  }
55
54
  catch (error) {
56
55
  this.completeProgress(false, (error === null || error === void 0 ? void 0 : error.message) || 'Locales import failed');
@@ -85,8 +85,7 @@ class ImportMarketplaceApps extends base_class_1.default {
85
85
  .updateStatus(utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.INSTALL_APPS].INSTALLING, utils_1.PROCESS_NAMES.INSTALL_APPS);
86
86
  await this.importMarketplaceApps();
87
87
  progress.completeProcess(utils_1.PROCESS_NAMES.INSTALL_APPS, true);
88
- this.completeProgress(true);
89
- cli_utilities_1.log.success('Marketplace apps have been imported successfully!', this.importConfig.context);
88
+ this.completeProgressWithMessage();
90
89
  }
91
90
  catch (error) {
92
91
  this.completeProgress(false, (error === null || error === void 0 ? void 0 : error.message) || 'Marketplace apps import failed');
@@ -46,8 +46,7 @@ class ImportPersonalize extends base_class_1.default {
46
46
  else {
47
47
  cli_utilities_1.log.debug('No personalize modules configured for processing', this.config.context);
48
48
  }
49
- this.completeProgress(true);
50
- cli_utilities_1.log.success('Personalize import completed successfully', this.config.context);
49
+ this.completeProgressWithMessage();
51
50
  }
52
51
  catch (error) {
53
52
  this.personalizeConfig.importData = false; // Stop personalize import if project creation fails
@@ -35,8 +35,7 @@ class ImportStack extends base_class_1.default {
35
35
  progress.updateStatus(utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.STACK_IMPORT].IMPORTING);
36
36
  cli_utilities_1.log.info('Starting stack settings import process', this.importConfig.context);
37
37
  await this.importStackSettings();
38
- this.completeProgress(true);
39
- cli_utilities_1.log.success('Stack settings imported successfully!', this.importConfig.context);
38
+ this.completeProgressWithMessage();
40
39
  }
41
40
  catch (error) {
42
41
  this.completeProgress(false, 'Stack settings import failed');
@@ -43,8 +43,7 @@ class ImportTaxonomies extends base_class_1.default {
43
43
  cli_utilities_1.log.debug('Starting taxonomies import', this.importConfig.context);
44
44
  await this.importTaxonomies();
45
45
  this.createSuccessAndFailedFile();
46
- this.completeProgress(true);
47
- cli_utilities_1.log.success('Taxonomies imported successfully!', this.importConfig.context);
46
+ this.completeProgressWithMessage();
48
47
  }
49
48
  catch (error) {
50
49
  this.completeProgress(false, (error === null || error === void 0 ? void 0 : error.message) || 'Taxonomies import failed');
@@ -34,8 +34,7 @@ class ImportVariantEntries extends base_class_1.default {
34
34
  progress.updateStatus(utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.VARIANT_ENTRIES_IMPORT].IMPORTING, utils_1.PROCESS_NAMES.VARIANT_ENTRIES_IMPORT);
35
35
  cli_utilities_1.log.info('Starting variant entries import process', this.config.context);
36
36
  await this.importVariantEntries();
37
- this.completeProgress(true);
38
- cli_utilities_1.log.success('Variant entries imported successfully', this.config.context);
37
+ this.completeProgressWithMessage();
39
38
  }
40
39
  catch (error) {
41
40
  this.completeProgress(false, (error === null || error === void 0 ? void 0 : error.message) || 'Variant entries import failed');
@@ -40,8 +40,7 @@ class ImportWebhooks extends base_class_1.default {
40
40
  progress.updateStatus(utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.WEBHOOKS_IMPORT].IMPORTING);
41
41
  await this.importWebhooks();
42
42
  this.processWebhookResults();
43
- this.completeProgress(true);
44
- cli_utilities_1.log.success('Webhooks have been imported successfully!', this.importConfig.context);
43
+ this.completeProgressWithMessage();
45
44
  }
46
45
  catch (error) {
47
46
  this.completeProgress(false, (error === null || error === void 0 ? void 0 : error.message) || 'Webhooks import failed');
@@ -61,8 +61,7 @@ class ImportWorkflows extends base_class_1.default {
61
61
  await this.importWorkflows();
62
62
  progress.completeProcess(utils_1.PROCESS_NAMES.WORKFLOWS_CREATE, true);
63
63
  this.processWorkflowResults();
64
- this.completeProgress(true);
65
- cli_utilities_1.log.success('Workflows have been imported successfully!', this.importConfig.context);
64
+ this.completeProgressWithMessage();
66
65
  }
67
66
  catch (error) {
68
67
  this.completeProgress(false, (error === null || error === void 0 ? void 0 : error.message) || 'Workflows import failed');
@@ -168,5 +168,5 @@
168
168
  ]
169
169
  }
170
170
  },
171
- "version": "2.0.0-beta.5"
171
+ "version": "2.0.0-beta.6"
172
172
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@contentstack/cli-cm-import",
3
3
  "description": "Contentstack CLI plugin to import content into stack",
4
- "version": "2.0.0-beta.5",
4
+ "version": "2.0.0-beta.6",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {
8
- "@contentstack/cli-audit": "~2.0.0-beta.1",
9
- "@contentstack/cli-command": "~1.7.0",
10
- "@contentstack/cli-utilities": "~1.17.0",
8
+ "@contentstack/cli-audit": "~1.17.1",
9
+ "@contentstack/cli-command": "~1.7.1",
10
+ "@contentstack/cli-utilities": "~1.17.2",
11
11
  "@contentstack/management": "~1.27.3",
12
12
  "@contentstack/cli-variants": "~2.0.0-beta.4",
13
13
  "@oclif/core": "^4.3.0",