@contentstack/cli-cm-import 2.0.0-beta.4 → 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 +1 -1
- package/lib/import/modules/base-class.d.ts +17 -0
- package/lib/import/modules/base-class.js +27 -0
- package/lib/import/modules/content-types.js +5 -4
- package/lib/import/modules/custom-roles.js +1 -2
- package/lib/import/modules/entries.js +5 -4
- package/lib/import/modules/environments.js +1 -2
- package/lib/import/modules/extensions.js +1 -2
- package/lib/import/modules/global-fields.js +1 -2
- package/lib/import/modules/labels.js +1 -2
- package/lib/import/modules/locales.js +1 -2
- package/lib/import/modules/marketplace-apps.js +1 -2
- package/lib/import/modules/personalize.js +1 -2
- package/lib/import/modules/stack.js +1 -2
- package/lib/import/modules/taxonomies.js +1 -2
- package/lib/import/modules/variant-entries.js +1 -2
- package/lib/import/modules/webhooks.js +1 -2
- package/lib/import/modules/workflows.js +1 -2
- package/oclif.manifest.json +1 -1
- package/package.json +4 -4
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.
|
|
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') || {};
|
|
@@ -37,8 +37,10 @@ class ContentTypesImport extends base_class_1.default {
|
|
|
37
37
|
]);
|
|
38
38
|
// Initialize composable studio paths if config exists
|
|
39
39
|
if (this.importConfig.modules['composable-studio']) {
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
// Use contentDir as fallback if data is not available
|
|
41
|
+
const basePath = this.importConfig.data || this.importConfig.contentDir;
|
|
42
|
+
this.composableStudioSuccessPath = path.join((0, cli_utilities_1.sanitizePath)(basePath), 'mapper', this.importConfig.modules['composable-studio'].dirName, this.importConfig.modules['composable-studio'].fileName);
|
|
43
|
+
this.composableStudioExportPath = path.join((0, cli_utilities_1.sanitizePath)(basePath), this.importConfig.modules['composable-studio'].dirName, this.importConfig.modules['composable-studio'].fileName);
|
|
42
44
|
}
|
|
43
45
|
else {
|
|
44
46
|
this.composableStudioSuccessPath = '';
|
|
@@ -105,8 +107,7 @@ class ContentTypesImport extends base_class_1.default {
|
|
|
105
107
|
if (this.pendingGFs.length > 0) {
|
|
106
108
|
await this.handlePendingGlobalFields(progress);
|
|
107
109
|
}
|
|
108
|
-
this.
|
|
109
|
-
cli_utilities_1.log.success('Content types have been imported successfully!', this.importConfig.context);
|
|
110
|
+
this.completeProgressWithMessage();
|
|
110
111
|
}
|
|
111
112
|
catch (error) {
|
|
112
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.
|
|
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');
|
|
@@ -34,8 +34,10 @@ class EntriesImport extends base_class_1.default {
|
|
|
34
34
|
this.localesPath = path.resolve((0, cli_utilities_1.sanitizePath)(importConfig.contentDir), (0, cli_utilities_1.sanitizePath)(importConfig.modules.locales.dirName), (0, cli_utilities_1.sanitizePath)(importConfig.modules.locales.fileName));
|
|
35
35
|
// Initialize composable studio paths if config exists
|
|
36
36
|
if (this.importConfig.modules['composable-studio']) {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
// Use contentDir as fallback if data is not available
|
|
38
|
+
const basePath = this.importConfig.data || this.importConfig.contentDir;
|
|
39
|
+
this.composableStudioSuccessPath = path.join((0, cli_utilities_1.sanitizePath)(basePath), 'mapper', this.importConfig.modules['composable-studio'].dirName, this.importConfig.modules['composable-studio'].fileName);
|
|
40
|
+
this.composableStudioExportPath = path.join((0, cli_utilities_1.sanitizePath)(basePath), this.importConfig.modules['composable-studio'].dirName, this.importConfig.modules['composable-studio'].fileName);
|
|
39
41
|
}
|
|
40
42
|
else {
|
|
41
43
|
this.composableStudioSuccessPath = '';
|
|
@@ -121,8 +123,7 @@ class EntriesImport extends base_class_1.default {
|
|
|
121
123
|
.updateStatus(utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.CLEANUP].CLEANING, utils_1.PROCESS_NAMES.CLEANUP);
|
|
122
124
|
await this.processCleanup();
|
|
123
125
|
progress.completeProcess(utils_1.PROCESS_NAMES.CLEANUP, true);
|
|
124
|
-
this.
|
|
125
|
-
cli_utilities_1.log.success('Entries imported successfully', this.importConfig.context);
|
|
126
|
+
this.completeProgressWithMessage();
|
|
126
127
|
}
|
|
127
128
|
catch (error) {
|
|
128
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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');
|
package/oclif.manifest.json
CHANGED
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.
|
|
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": "~
|
|
9
|
-
"@contentstack/cli-command": "~1.7.
|
|
10
|
-
"@contentstack/cli-utilities": "~1.17.
|
|
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",
|