@contentstack/cli-cm-export 2.0.0-beta.6 → 2.0.0-beta.8
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/commands/cm/stacks/export.js +5 -3
- package/lib/constants/index.d.ts +57 -0
- package/lib/constants/index.js +59 -0
- package/lib/export/modules/assets.js +4 -4
- package/lib/export/modules/base-class.d.ts +17 -0
- package/lib/export/modules/base-class.js +28 -0
- package/lib/export/modules/content-types.js +3 -3
- package/lib/export/modules/custom-roles.js +1 -1
- package/lib/export/modules/entries.js +9 -10
- package/lib/export/modules/environments.js +1 -2
- package/lib/export/modules/extensions.js +1 -2
- package/lib/export/modules/global-fields.js +1 -2
- package/lib/export/modules/labels.js +1 -2
- package/lib/export/modules/locales.js +1 -2
- package/lib/export/modules/marketplace-apps.js +1 -2
- package/lib/export/modules/personalize.js +1 -2
- package/lib/export/modules/stack.js +3 -3
- package/lib/export/modules/taxonomies.d.ts +20 -0
- package/lib/export/modules/taxonomies.js +123 -24
- package/lib/export/modules/webhooks.js +1 -2
- package/lib/export/modules/workflows.js +1 -2
- package/oclif.manifest.json +1 -1
- package/package.json +4 -4
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.
|
|
51
|
+
@contentstack/cli-cm-export/2.0.0-beta.8 linux-x64 node-v22.22.0
|
|
52
52
|
$ csdx --help [COMMAND]
|
|
53
53
|
USAGE
|
|
54
54
|
$ csdx COMMAND
|
|
@@ -20,14 +20,15 @@ class ExportCommand extends cli_command_1.Command {
|
|
|
20
20
|
const managementAPIClient = await (0, cli_utilities_1.managementSDKClient)(exportConfig);
|
|
21
21
|
const moduleExporter = new export_1.ModuleExporter(managementAPIClient, exportConfig);
|
|
22
22
|
await moduleExporter.start();
|
|
23
|
+
const sessionLogPath = (0, cli_utilities_1.getSessionLogPath)();
|
|
23
24
|
cli_utilities_1.log.success(`The content of the stack ${exportConfig.apiKey} has been exported successfully!`);
|
|
24
25
|
cli_utilities_1.log.info(`The exported content has been stored at '${exportDir}'`, exportConfig.context);
|
|
25
|
-
cli_utilities_1.log.success(`The log has been stored at '${
|
|
26
|
+
cli_utilities_1.log.success(`The log has been stored at '${sessionLogPath}'`, exportConfig.context);
|
|
26
27
|
// Print comprehensive summary at the end
|
|
27
28
|
if (!exportConfig.branches)
|
|
28
29
|
cli_utilities_1.CLIProgressManager.printGlobalSummary();
|
|
29
30
|
if (!((_a = cli_utilities_1.configHandler.get('log')) === null || _a === void 0 ? void 0 : _a.showConsoleLogs)) {
|
|
30
|
-
cli_utilities_1.cliux.print(`The log has been stored at '${
|
|
31
|
+
cli_utilities_1.cliux.print(`The log has been stored at '${sessionLogPath}'`, { color: 'green' });
|
|
31
32
|
}
|
|
32
33
|
// Clear progress module setting now that export is complete
|
|
33
34
|
(0, cli_utilities_1.clearProgressModuleSetting)();
|
|
@@ -36,9 +37,10 @@ class ExportCommand extends cli_command_1.Command {
|
|
|
36
37
|
// Clear progress module setting even on error
|
|
37
38
|
(0, cli_utilities_1.clearProgressModuleSetting)();
|
|
38
39
|
(0, cli_utilities_1.handleAndLogError)(error);
|
|
40
|
+
const sessionLogPath = (0, cli_utilities_1.getSessionLogPath)();
|
|
39
41
|
if (!((_b = cli_utilities_1.configHandler.get('log')) === null || _b === void 0 ? void 0 : _b.showConsoleLogs)) {
|
|
40
42
|
cli_utilities_1.cliux.print(`Error: ${error}`, { color: 'red' });
|
|
41
|
-
cli_utilities_1.cliux.print(`The log has been stored at '${
|
|
43
|
+
cli_utilities_1.cliux.print(`The log has been stored at '${sessionLogPath}'`, { color: 'green' });
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
46
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export declare const PATH_CONSTANTS: {
|
|
2
|
+
/** Root mapper directory (contains module-specific mapper subdirs) */
|
|
3
|
+
readonly MAPPER: "mapper";
|
|
4
|
+
/** Common mapper file names */
|
|
5
|
+
readonly FILES: {
|
|
6
|
+
readonly SUCCESS: "success.json";
|
|
7
|
+
readonly FAILS: "fails.json";
|
|
8
|
+
readonly UID_MAPPING: "uid-mapping.json";
|
|
9
|
+
readonly URL_MAPPING: "url-mapping.json";
|
|
10
|
+
readonly UID_MAPPER: "uid-mapper.json";
|
|
11
|
+
readonly SCHEMA: "schema.json";
|
|
12
|
+
readonly SETTINGS: "settings.json";
|
|
13
|
+
readonly MODIFIED_SCHEMAS: "modified-schemas.json";
|
|
14
|
+
readonly UNIQUE_MAPPING: "unique-mapping.json";
|
|
15
|
+
readonly TAXONOMIES: "taxonomies.json";
|
|
16
|
+
readonly ENVIRONMENTS: "environments.json";
|
|
17
|
+
readonly PENDING_EXTENSIONS: "pending_extensions.js";
|
|
18
|
+
readonly PENDING_GLOBAL_FIELDS: "pending_global_fields.js";
|
|
19
|
+
readonly INDEX: "index.json";
|
|
20
|
+
readonly FOLDER_MAPPING: "folder-mapping.json";
|
|
21
|
+
readonly VERSIONED_ASSETS: "versioned-assets.json";
|
|
22
|
+
};
|
|
23
|
+
/** Module subdirectory names within mapper */
|
|
24
|
+
readonly MAPPER_MODULES: {
|
|
25
|
+
readonly ASSETS: "assets";
|
|
26
|
+
readonly ENTRIES: "entries";
|
|
27
|
+
readonly CONTENT_TYPES: "content_types";
|
|
28
|
+
readonly TAXONOMIES: "taxonomies";
|
|
29
|
+
readonly TAXONOMY_TERMS: "terms";
|
|
30
|
+
readonly GLOBAL_FIELDS: "global_fields";
|
|
31
|
+
readonly EXTENSIONS: "extensions";
|
|
32
|
+
readonly WORKFLOWS: "workflows";
|
|
33
|
+
readonly WEBHOOKS: "webhooks";
|
|
34
|
+
readonly LABELS: "labels";
|
|
35
|
+
readonly ENVIRONMENTS: "environments";
|
|
36
|
+
readonly MARKETPLACE_APPS: "marketplace_apps";
|
|
37
|
+
readonly CUSTOM_ROLES: "custom-roles";
|
|
38
|
+
readonly LANGUAGES: "languages";
|
|
39
|
+
};
|
|
40
|
+
/** Content directory names (used in both import and export) */
|
|
41
|
+
readonly CONTENT_DIRS: {
|
|
42
|
+
readonly ASSETS: "assets";
|
|
43
|
+
readonly ENTRIES: "entries";
|
|
44
|
+
readonly CONTENT_TYPES: "content_types";
|
|
45
|
+
readonly TAXONOMIES: "taxonomies";
|
|
46
|
+
readonly GLOBAL_FIELDS: "global_fields";
|
|
47
|
+
readonly EXTENSIONS: "extensions";
|
|
48
|
+
readonly WEBHOOKS: "webhooks";
|
|
49
|
+
readonly WORKFLOWS: "workflows";
|
|
50
|
+
readonly LABELS: "labels";
|
|
51
|
+
readonly ENVIRONMENTS: "environments";
|
|
52
|
+
readonly STACK: "stack";
|
|
53
|
+
readonly LOCALES: "locales";
|
|
54
|
+
readonly MARKETPLACE_APPS: "marketplace_apps";
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export type PathConstants = typeof PATH_CONSTANTS;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PATH_CONSTANTS = void 0;
|
|
4
|
+
exports.PATH_CONSTANTS = {
|
|
5
|
+
/** Root mapper directory (contains module-specific mapper subdirs) */
|
|
6
|
+
MAPPER: 'mapper',
|
|
7
|
+
/** Common mapper file names */
|
|
8
|
+
FILES: {
|
|
9
|
+
SUCCESS: 'success.json',
|
|
10
|
+
FAILS: 'fails.json',
|
|
11
|
+
UID_MAPPING: 'uid-mapping.json',
|
|
12
|
+
URL_MAPPING: 'url-mapping.json',
|
|
13
|
+
UID_MAPPER: 'uid-mapper.json',
|
|
14
|
+
SCHEMA: 'schema.json',
|
|
15
|
+
SETTINGS: 'settings.json',
|
|
16
|
+
MODIFIED_SCHEMAS: 'modified-schemas.json',
|
|
17
|
+
UNIQUE_MAPPING: 'unique-mapping.json',
|
|
18
|
+
TAXONOMIES: 'taxonomies.json',
|
|
19
|
+
ENVIRONMENTS: 'environments.json',
|
|
20
|
+
PENDING_EXTENSIONS: 'pending_extensions.js',
|
|
21
|
+
PENDING_GLOBAL_FIELDS: 'pending_global_fields.js',
|
|
22
|
+
INDEX: 'index.json',
|
|
23
|
+
FOLDER_MAPPING: 'folder-mapping.json',
|
|
24
|
+
VERSIONED_ASSETS: 'versioned-assets.json',
|
|
25
|
+
},
|
|
26
|
+
/** Module subdirectory names within mapper */
|
|
27
|
+
MAPPER_MODULES: {
|
|
28
|
+
ASSETS: 'assets',
|
|
29
|
+
ENTRIES: 'entries',
|
|
30
|
+
CONTENT_TYPES: 'content_types',
|
|
31
|
+
TAXONOMIES: 'taxonomies',
|
|
32
|
+
TAXONOMY_TERMS: 'terms',
|
|
33
|
+
GLOBAL_FIELDS: 'global_fields',
|
|
34
|
+
EXTENSIONS: 'extensions',
|
|
35
|
+
WORKFLOWS: 'workflows',
|
|
36
|
+
WEBHOOKS: 'webhooks',
|
|
37
|
+
LABELS: 'labels',
|
|
38
|
+
ENVIRONMENTS: 'environments',
|
|
39
|
+
MARKETPLACE_APPS: 'marketplace_apps',
|
|
40
|
+
CUSTOM_ROLES: 'custom-roles',
|
|
41
|
+
LANGUAGES: 'languages',
|
|
42
|
+
},
|
|
43
|
+
/** Content directory names (used in both import and export) */
|
|
44
|
+
CONTENT_DIRS: {
|
|
45
|
+
ASSETS: 'assets',
|
|
46
|
+
ENTRIES: 'entries',
|
|
47
|
+
CONTENT_TYPES: 'content_types',
|
|
48
|
+
TAXONOMIES: 'taxonomies',
|
|
49
|
+
GLOBAL_FIELDS: 'global_fields',
|
|
50
|
+
EXTENSIONS: 'extensions',
|
|
51
|
+
WEBHOOKS: 'webhooks',
|
|
52
|
+
WORKFLOWS: 'workflows',
|
|
53
|
+
LABELS: 'labels',
|
|
54
|
+
ENVIRONMENTS: 'environments',
|
|
55
|
+
STACK: 'stack',
|
|
56
|
+
LOCALES: 'locales',
|
|
57
|
+
MARKETPLACE_APPS: 'marketplace_apps',
|
|
58
|
+
},
|
|
59
|
+
};
|
|
@@ -16,6 +16,7 @@ const progress_stream_1 = tslib_1.__importDefault(require("progress-stream"));
|
|
|
16
16
|
const node_fs_1 = require("node:fs");
|
|
17
17
|
const node_path_1 = require("node:path");
|
|
18
18
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
19
|
+
const constants_1 = require("../../constants");
|
|
19
20
|
const config_1 = tslib_1.__importDefault(require("../../config"));
|
|
20
21
|
const base_class_1 = tslib_1.__importDefault(require("./base-class"));
|
|
21
22
|
const utils_1 = require("../../utils");
|
|
@@ -83,8 +84,7 @@ class ExportAssets extends base_class_1.default {
|
|
|
83
84
|
await this.downloadAssets();
|
|
84
85
|
progress.completeProcess(utils_1.PROCESS_NAMES.ASSET_DOWNLOADS, true);
|
|
85
86
|
}
|
|
86
|
-
this.
|
|
87
|
-
cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('ASSET_EXPORT_COMPLETE'), this.exportConfig.context);
|
|
87
|
+
this.completeProgressWithMessage();
|
|
88
88
|
}
|
|
89
89
|
catch (error) {
|
|
90
90
|
this.completeProgress(false, (error === null || error === void 0 ? void 0 : error.message) || 'Asset export failed');
|
|
@@ -171,7 +171,7 @@ class ExportAssets extends base_class_1.default {
|
|
|
171
171
|
fs = new cli_utilities_1.FsUtility({
|
|
172
172
|
metaHandler,
|
|
173
173
|
moduleName: 'assets',
|
|
174
|
-
indexFileName:
|
|
174
|
+
indexFileName: this.assetConfig.fileName,
|
|
175
175
|
basePath: this.assetsRootPath,
|
|
176
176
|
chunkFileSize: this.assetConfig.chunkFileSize,
|
|
177
177
|
metaPickKeys: (0, merge_1.default)(['uid', 'url', 'filename', 'parent_uid'], this.assetConfig.assetsMetaKeys),
|
|
@@ -236,7 +236,7 @@ class ExportAssets extends base_class_1.default {
|
|
|
236
236
|
if (!fs && !(0, isEmpty_1.default)(response)) {
|
|
237
237
|
fs = new cli_utilities_1.FsUtility({
|
|
238
238
|
moduleName: 'assets',
|
|
239
|
-
indexFileName:
|
|
239
|
+
indexFileName: constants_1.PATH_CONSTANTS.FILES.VERSIONED_ASSETS,
|
|
240
240
|
chunkFileSize: this.assetConfig.chunkFileSize,
|
|
241
241
|
basePath: (0, node_path_1.resolve)(this.assetsRootPath, 'versions'),
|
|
242
242
|
metaPickKeys: (0, merge_1.default)(['uid', 'url', 'filename', '_version', 'parent_uid'], this.assetConfig.assetsMetaKeys),
|
|
@@ -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 at: {sessionLogPath}"
|
|
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,34 @@ 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 at: {sessionLogPath}"
|
|
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 sessionLogPath = (0, cli_utilities_1.getSessionLogPath)();
|
|
71
|
+
const warningMessage = (options === null || options === void 0 ? void 0 : options.customWarningMessage) || `${name} have been exported with some errors. Please check the logs at: ${sessionLogPath}`;
|
|
72
|
+
this.completeProgress(true);
|
|
73
|
+
if (hasErrors) {
|
|
74
|
+
cli_utilities_1.log.warn(warningMessage, logContext);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
cli_utilities_1.log.success(successMessage, logContext);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
52
80
|
async withLoadingSpinner(message, action) {
|
|
53
81
|
var _a;
|
|
54
82
|
const logConfig = cli_utilities_1.configHandler.get('log') || {};
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const path = tslib_1.__importStar(require("path"));
|
|
5
5
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
6
|
+
const constants_1 = require("../../constants");
|
|
6
7
|
const base_class_1 = tslib_1.__importDefault(require("./base-class"));
|
|
7
8
|
const utils_1 = require("../../utils");
|
|
8
9
|
class ContentTypesExport extends base_class_1.default {
|
|
@@ -50,8 +51,7 @@ class ContentTypesExport extends base_class_1.default {
|
|
|
50
51
|
progress.updateStatus('Fetching content types...');
|
|
51
52
|
await this.getContentTypes();
|
|
52
53
|
await this.writeContentTypes(this.contentTypes);
|
|
53
|
-
|
|
54
|
-
this.completeProgress(true);
|
|
54
|
+
this.completeProgressWithMessage();
|
|
55
55
|
}
|
|
56
56
|
catch (error) {
|
|
57
57
|
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
|
|
@@ -106,7 +106,7 @@ class ContentTypesExport extends base_class_1.default {
|
|
|
106
106
|
await (0, utils_1.executeTask)(contentTypes, writeWithProgress.bind(this), {
|
|
107
107
|
concurrency: this.exportConfig.writeConcurrency,
|
|
108
108
|
});
|
|
109
|
-
const schemaFilePath = path.join(this.contentTypesDirPath,
|
|
109
|
+
const schemaFilePath = path.join(this.contentTypesDirPath, constants_1.PATH_CONSTANTS.FILES.SCHEMA);
|
|
110
110
|
cli_utilities_1.log.debug(`Writing aggregate schema to: ${schemaFilePath}`, this.exportConfig.context);
|
|
111
111
|
return utils_1.fsUtil.writeFile(schemaFilePath, contentTypes);
|
|
112
112
|
}
|
|
@@ -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.
|
|
63
|
+
this.completeProgressWithMessage();
|
|
64
64
|
}
|
|
65
65
|
catch (error) {
|
|
66
66
|
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const path = tslib_1.__importStar(require("path"));
|
|
5
5
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
6
|
+
const constants_1 = require("../../constants");
|
|
6
7
|
const cli_variants_1 = require("@contentstack/cli-variants");
|
|
7
|
-
const cli_utilities_2 = require("@contentstack/cli-utilities");
|
|
8
8
|
const utils_1 = require("../../utils");
|
|
9
9
|
const base_class_1 = tslib_1.__importDefault(require("./base-class"));
|
|
10
10
|
class EntriesExport extends base_class_1.default {
|
|
@@ -14,9 +14,9 @@ class EntriesExport extends base_class_1.default {
|
|
|
14
14
|
this.stackAPIClient = stackAPIClient;
|
|
15
15
|
this.exportConfig = exportConfig;
|
|
16
16
|
this.entriesConfig = exportConfig.modules.entries;
|
|
17
|
-
this.entriesDirPath = path.resolve((0,
|
|
18
|
-
this.localesFilePath = path.resolve((0,
|
|
19
|
-
this.schemaFilePath = path.resolve((0,
|
|
17
|
+
this.entriesDirPath = path.resolve((0, cli_utilities_1.sanitizePath)(exportConfig.exportDir), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.entriesConfig.dirName));
|
|
18
|
+
this.localesFilePath = path.resolve((0, cli_utilities_1.sanitizePath)(exportConfig.exportDir), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(exportConfig.modules.locales.dirName), (0, cli_utilities_1.sanitizePath)(exportConfig.modules.locales.fileName));
|
|
19
|
+
this.schemaFilePath = path.resolve((0, cli_utilities_1.sanitizePath)(exportConfig.exportDir), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(exportConfig.modules.content_types.dirName), constants_1.PATH_CONSTANTS.FILES.SCHEMA);
|
|
20
20
|
this.projectInstance = new cli_variants_1.ExportProjects(this.exportConfig);
|
|
21
21
|
this.exportConfig.context.module = utils_1.MODULE_CONTEXTS.ENTRIES;
|
|
22
22
|
this.currentModuleName = utils_1.MODULE_NAMES[utils_1.MODULE_CONTEXTS.ENTRIES];
|
|
@@ -86,8 +86,7 @@ class EntriesExport extends base_class_1.default {
|
|
|
86
86
|
this.variantEntries.completeExport();
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
this.
|
|
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));
|
|
@@ -206,12 +205,12 @@ class EntriesExport extends base_class_1.default {
|
|
|
206
205
|
}
|
|
207
206
|
if (Array.isArray(entriesSearchResponse === null || entriesSearchResponse === void 0 ? void 0 : entriesSearchResponse.items) && ((_b = entriesSearchResponse === null || entriesSearchResponse === void 0 ? void 0 : entriesSearchResponse.items) === null || _b === void 0 ? void 0 : _b.length) > 0) {
|
|
208
207
|
if (options.skip === 0) {
|
|
209
|
-
const entryBasePath = path.join((0,
|
|
208
|
+
const entryBasePath = path.join((0, cli_utilities_1.sanitizePath)(this.entriesDirPath), (0, cli_utilities_1.sanitizePath)(options.contentType), (0, cli_utilities_1.sanitizePath)(options.locale));
|
|
210
209
|
cli_utilities_1.log.debug(`Creating directory for entries at: ${entryBasePath}`, this.exportConfig.context);
|
|
211
210
|
await utils_1.fsUtil.makeDirectory(entryBasePath);
|
|
212
211
|
this.entriesFileHelper = new cli_utilities_1.FsUtility({
|
|
213
212
|
moduleName: 'entries',
|
|
214
|
-
indexFileName:
|
|
213
|
+
indexFileName: constants_1.PATH_CONSTANTS.FILES.INDEX,
|
|
215
214
|
basePath: entryBasePath,
|
|
216
215
|
chunkFileSize: this.entriesConfig.chunkFileSize,
|
|
217
216
|
keepMetadata: false,
|
|
@@ -228,7 +227,7 @@ class EntriesExport extends base_class_1.default {
|
|
|
228
227
|
});
|
|
229
228
|
if (this.entriesConfig.exportVersions) {
|
|
230
229
|
cli_utilities_1.log.debug('Exporting entry versions is enabled.', this.exportConfig.context);
|
|
231
|
-
let versionedEntryPath = path.join((0,
|
|
230
|
+
let versionedEntryPath = path.join((0, cli_utilities_1.sanitizePath)(this.entriesDirPath), (0, cli_utilities_1.sanitizePath)(options.contentType), (0, cli_utilities_1.sanitizePath)(options.locale), 'versions');
|
|
232
231
|
cli_utilities_1.log.debug(`Creating versioned entries directory at: ${versionedEntryPath}.`, this.exportConfig.context);
|
|
233
232
|
utils_1.fsUtil.makeDirectory(versionedEntryPath);
|
|
234
233
|
await this.fetchEntriesVersions(entriesSearchResponse.items, {
|
|
@@ -272,7 +271,7 @@ class EntriesExport extends base_class_1.default {
|
|
|
272
271
|
cli_utilities_1.log.debug(`Fetching versions for ${entries.length} entries...`, this.exportConfig.context);
|
|
273
272
|
const onSuccess = ({ response, apiData: entry }) => {
|
|
274
273
|
var _a;
|
|
275
|
-
const versionFilePath = path.join((0,
|
|
274
|
+
const versionFilePath = path.join((0, cli_utilities_1.sanitizePath)(options.versionedEntryPath), (0, cli_utilities_1.sanitizePath)(`${entry.uid}.json`));
|
|
276
275
|
cli_utilities_1.log.debug(`Writing versioned entry to: ${versionFilePath}`, this.exportConfig.context);
|
|
277
276
|
utils_1.fsUtil.writeFile(versionFilePath, response);
|
|
278
277
|
// Track version progress if the process exists
|
|
@@ -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.
|
|
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.
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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') {
|
|
@@ -4,6 +4,7 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const find_1 = tslib_1.__importDefault(require("lodash/find"));
|
|
5
5
|
const node_path_1 = require("node:path");
|
|
6
6
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
7
|
+
const constants_1 = require("../../constants");
|
|
7
8
|
const base_class_1 = tslib_1.__importDefault(require("./base-class"));
|
|
8
9
|
const utils_1 = require("../../utils");
|
|
9
10
|
class ExportStack extends base_class_1.default {
|
|
@@ -81,8 +82,7 @@ class ExportStack extends base_class_1.default {
|
|
|
81
82
|
else {
|
|
82
83
|
cli_utilities_1.log.debug('Locale locale already set, skipping locale fetch', this.exportConfig.context);
|
|
83
84
|
}
|
|
84
|
-
this.
|
|
85
|
-
cli_utilities_1.log.success('Stack export completed successfully', this.exportConfig.context);
|
|
85
|
+
this.completeProgressWithMessage();
|
|
86
86
|
}
|
|
87
87
|
catch (error) {
|
|
88
88
|
cli_utilities_1.log.debug('Error occurred during stack export', this.exportConfig.context);
|
|
@@ -192,7 +192,7 @@ class ExportStack extends base_class_1.default {
|
|
|
192
192
|
.settings()
|
|
193
193
|
.then((resp) => {
|
|
194
194
|
var _a;
|
|
195
|
-
utils_1.fsUtil.writeFile((0, node_path_1.resolve)(this.stackFolderPath,
|
|
195
|
+
utils_1.fsUtil.writeFile((0, node_path_1.resolve)(this.stackFolderPath, constants_1.PATH_CONSTANTS.FILES.SETTINGS), resp);
|
|
196
196
|
// Track progress for stack settings completion
|
|
197
197
|
(_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.tick(true, 'stack settings', null, utils_1.PROCESS_NAMES.STACK_SETTINGS);
|
|
198
198
|
cli_utilities_1.log.success('Exported stack settings successfully!', this.exportConfig.context);
|
|
@@ -10,6 +10,26 @@ export default class ExportTaxonomies extends BaseClass {
|
|
|
10
10
|
private localesFilePath;
|
|
11
11
|
constructor({ exportConfig, stackAPIClient }: ModuleClassParams);
|
|
12
12
|
start(): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Initialize export setup (create directories, get initial count)
|
|
15
|
+
*/
|
|
16
|
+
private initializeExport;
|
|
17
|
+
/**
|
|
18
|
+
* Setup progress manager with processes
|
|
19
|
+
*/
|
|
20
|
+
private setupProgress;
|
|
21
|
+
/**
|
|
22
|
+
* Determine if locale-based export is supported
|
|
23
|
+
*/
|
|
24
|
+
private determineExportStrategy;
|
|
25
|
+
/**
|
|
26
|
+
* Fetch all taxonomies based on export strategy
|
|
27
|
+
*/
|
|
28
|
+
private fetchAllTaxonomies;
|
|
29
|
+
/**
|
|
30
|
+
* Export all taxonomies with detailed information
|
|
31
|
+
*/
|
|
32
|
+
private exportAllTaxonomies;
|
|
13
33
|
/**
|
|
14
34
|
* Process and export taxonomies for a specific locale
|
|
15
35
|
*/
|
|
@@ -17,44 +17,131 @@ class ExportTaxonomies extends base_class_1.default {
|
|
|
17
17
|
this.taxonomiesConfig = exportConfig.modules.taxonomies;
|
|
18
18
|
this.qs = { include_count: true, limit: this.taxonomiesConfig.limit || 100, skip: 0 };
|
|
19
19
|
this.applyQueryFilters(this.qs, 'taxonomies');
|
|
20
|
-
this.exportConfig.context.module =
|
|
20
|
+
this.exportConfig.context.module = utils_1.MODULE_CONTEXTS.TAXONOMIES;
|
|
21
|
+
this.currentModuleName = utils_1.MODULE_NAMES[utils_1.MODULE_CONTEXTS.TAXONOMIES];
|
|
21
22
|
this.localesFilePath = (0, node_path_1.resolve)((0, cli_utilities_1.sanitizePath)(exportConfig.exportDir), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(exportConfig.modules.locales.dirName), (0, cli_utilities_1.sanitizePath)(exportConfig.modules.locales.fileName));
|
|
22
23
|
}
|
|
23
24
|
async start() {
|
|
24
25
|
var _a;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
try {
|
|
27
|
+
cli_utilities_1.log.debug('Starting export process for taxonomies...', this.exportConfig.context);
|
|
28
|
+
const totalCount = await this.initializeExport();
|
|
29
|
+
if (totalCount === 0) {
|
|
30
|
+
cli_utilities_1.log.info(cli_utilities_1.messageHandler.parse('TAXONOMY_NOT_FOUND'), this.exportConfig.context);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const progress = this.setupProgress(totalCount);
|
|
34
|
+
const localesToExport = this.getLocalesToExport();
|
|
35
|
+
if (localesToExport.length === 0) {
|
|
36
|
+
cli_utilities_1.log.warn('No locales found to export', this.exportConfig.context);
|
|
37
|
+
this.completeProgress(true);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
// Start fetch process
|
|
41
|
+
progress
|
|
42
|
+
.startProcess(utils_1.PROCESS_NAMES.FETCH_TAXONOMIES)
|
|
43
|
+
.updateStatus(utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.FETCH_TAXONOMIES].FETCHING, utils_1.PROCESS_NAMES.FETCH_TAXONOMIES);
|
|
44
|
+
// Determine export strategy and fetch taxonomies
|
|
45
|
+
await this.determineExportStrategy((_a = this.exportConfig.master_locale) === null || _a === void 0 ? void 0 : _a.code);
|
|
46
|
+
await this.fetchAllTaxonomies(localesToExport);
|
|
47
|
+
progress.completeProcess(utils_1.PROCESS_NAMES.FETCH_TAXONOMIES, true);
|
|
48
|
+
// Export taxonomies with detailed information
|
|
49
|
+
const actualCount = await this.exportAllTaxonomies(progress, localesToExport, totalCount);
|
|
50
|
+
// Write metadata and complete
|
|
51
|
+
await this.writeTaxonomiesMetadata();
|
|
52
|
+
cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('TAXONOMY_EXPORT_COMPLETE', actualCount), this.exportConfig.context);
|
|
53
|
+
this.completeProgress(true);
|
|
36
54
|
}
|
|
37
|
-
|
|
38
|
-
|
|
55
|
+
catch (error) {
|
|
56
|
+
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
|
|
57
|
+
this.completeProgress(false, (error === null || error === void 0 ? void 0 : error.message) || 'Taxonomies export failed');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Initialize export setup (create directories, get initial count)
|
|
62
|
+
*/
|
|
63
|
+
async initializeExport() {
|
|
64
|
+
return this.withLoadingSpinner('TAXONOMIES: Analyzing taxonomy structure...', async () => {
|
|
65
|
+
this.taxonomiesFolderPath = (0, node_path_1.resolve)(this.exportConfig.exportDir, this.exportConfig.branchName || '', this.taxonomiesConfig.dirName);
|
|
66
|
+
cli_utilities_1.log.debug(`Taxonomies folder path: '${this.taxonomiesFolderPath}'`, this.exportConfig.context);
|
|
67
|
+
await utils_1.fsUtil.makeDirectory(this.taxonomiesFolderPath);
|
|
68
|
+
cli_utilities_1.log.debug('Created taxonomies directory.', this.exportConfig.context);
|
|
69
|
+
// Get count first for progress tracking
|
|
70
|
+
const countResponse = await this.stack
|
|
71
|
+
.taxonomy()
|
|
72
|
+
.query(Object.assign(Object.assign({}, this.qs), { include_count: true, limit: 1 }))
|
|
73
|
+
.find();
|
|
74
|
+
return countResponse.count || 0;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Setup progress manager with processes
|
|
79
|
+
*/
|
|
80
|
+
setupProgress(totalCount) {
|
|
81
|
+
const progress = this.createNestedProgress(this.currentModuleName);
|
|
82
|
+
// For fetch: count API calls, not individual taxonomies
|
|
83
|
+
const fetchApiCallsCount = Math.ceil(totalCount / (this.qs.limit || 100));
|
|
84
|
+
progress.addProcess(utils_1.PROCESS_NAMES.FETCH_TAXONOMIES, fetchApiCallsCount);
|
|
85
|
+
progress.addProcess(utils_1.PROCESS_NAMES.EXPORT_TAXONOMIES_TERMS, totalCount);
|
|
86
|
+
return progress;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Determine if locale-based export is supported
|
|
90
|
+
*/
|
|
91
|
+
async determineExportStrategy(masterLocale) {
|
|
39
92
|
await this.fetchTaxonomies(masterLocale, true);
|
|
40
93
|
if (!this.isLocaleBasedExportSupported) {
|
|
94
|
+
cli_utilities_1.log.debug('Falling back to legacy export (non-localized)', this.exportConfig.context);
|
|
41
95
|
this.taxonomies = {};
|
|
42
96
|
this.taxonomiesByLocale = {};
|
|
43
|
-
// Fetch taxonomies without locale parameter
|
|
44
|
-
await this.fetchTaxonomies();
|
|
45
|
-
await this.exportTaxonomies();
|
|
46
|
-
await this.writeTaxonomiesMetadata();
|
|
47
97
|
}
|
|
48
98
|
else {
|
|
49
|
-
// Process all locales with locale-based export
|
|
50
99
|
cli_utilities_1.log.debug('Localization enabled, proceeding with locale-based export', this.exportConfig.context);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Fetch all taxonomies based on export strategy
|
|
104
|
+
*/
|
|
105
|
+
async fetchAllTaxonomies(localesToExport) {
|
|
106
|
+
if (!this.isLocaleBasedExportSupported) {
|
|
107
|
+
await this.fetchTaxonomies();
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
51
110
|
for (const localeCode of localesToExport) {
|
|
52
111
|
await this.fetchTaxonomies(localeCode);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Export all taxonomies with detailed information
|
|
117
|
+
*/
|
|
118
|
+
async exportAllTaxonomies(progress, localesToExport, totalCount) {
|
|
119
|
+
var _a;
|
|
120
|
+
const actualCount = (_a = Object.keys(this.taxonomies || {})) === null || _a === void 0 ? void 0 : _a.length;
|
|
121
|
+
cli_utilities_1.log.debug(`Found ${actualCount} taxonomies to export (API reported ${totalCount})`, this.exportConfig.context);
|
|
122
|
+
if (actualCount === 0) {
|
|
123
|
+
cli_utilities_1.log.info('No taxonomies found to export detailed information', this.exportConfig.context);
|
|
124
|
+
return 0;
|
|
125
|
+
}
|
|
126
|
+
// Update progress total if needed
|
|
127
|
+
if (actualCount !== totalCount) {
|
|
128
|
+
progress.updateProcessTotal(utils_1.PROCESS_NAMES.EXPORT_TAXONOMIES_TERMS, actualCount);
|
|
129
|
+
}
|
|
130
|
+
// Start export process
|
|
131
|
+
progress
|
|
132
|
+
.startProcess(utils_1.PROCESS_NAMES.EXPORT_TAXONOMIES_TERMS)
|
|
133
|
+
.updateStatus(utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.EXPORT_TAXONOMIES_TERMS].EXPORTING, utils_1.PROCESS_NAMES.EXPORT_TAXONOMIES_TERMS);
|
|
134
|
+
// Export based on strategy
|
|
135
|
+
if (!this.isLocaleBasedExportSupported) {
|
|
136
|
+
await this.exportTaxonomies();
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
for (const localeCode of localesToExport) {
|
|
53
140
|
await this.processLocaleExport(localeCode);
|
|
54
141
|
}
|
|
55
|
-
await this.writeTaxonomiesMetadata();
|
|
56
142
|
}
|
|
57
|
-
|
|
143
|
+
progress.completeProcess(utils_1.PROCESS_NAMES.EXPORT_TAXONOMIES_TERMS, true);
|
|
144
|
+
return actualCount;
|
|
58
145
|
}
|
|
59
146
|
/**
|
|
60
147
|
* Process and export taxonomies for a specific locale
|
|
@@ -77,7 +164,7 @@ class ExportTaxonomies extends base_class_1.default {
|
|
|
77
164
|
cli_utilities_1.log.info(cli_utilities_1.messageHandler.parse('TAXONOMY_NOT_FOUND'), this.exportConfig.context);
|
|
78
165
|
return;
|
|
79
166
|
}
|
|
80
|
-
const taxonomiesFilePath = (0, node_path_1.resolve)(this.taxonomiesFolderPath,
|
|
167
|
+
const taxonomiesFilePath = (0, node_path_1.resolve)(this.taxonomiesFolderPath, this.taxonomiesConfig.fileName);
|
|
81
168
|
cli_utilities_1.log.debug(`Writing taxonomies metadata to: ${taxonomiesFilePath}`, this.exportConfig.context);
|
|
82
169
|
utils_1.fsUtil.writeFile(taxonomiesFilePath, this.taxonomies);
|
|
83
170
|
}
|
|
@@ -90,7 +177,7 @@ class ExportTaxonomies extends base_class_1.default {
|
|
|
90
177
|
* @returns {Promise<void>}
|
|
91
178
|
*/
|
|
92
179
|
async fetchTaxonomies(localeCode, checkLocaleSupport = false) {
|
|
93
|
-
var _a;
|
|
180
|
+
var _a, _b;
|
|
94
181
|
let skip = 0;
|
|
95
182
|
const localeInfo = localeCode ? `for locale: ${localeCode}` : '';
|
|
96
183
|
if (localeCode && !this.taxonomiesByLocale[localeCode]) {
|
|
@@ -117,6 +204,10 @@ class ExportTaxonomies extends base_class_1.default {
|
|
|
117
204
|
this.isLocaleBasedExportSupported = false;
|
|
118
205
|
}
|
|
119
206
|
this.sanitizeTaxonomiesAttribs(items, localeCode);
|
|
207
|
+
// Track progress per API call (only for actual fetch, not locale support check)
|
|
208
|
+
if (!checkLocaleSupport) {
|
|
209
|
+
(_b = this.progressManager) === null || _b === void 0 ? void 0 : _b.tick(true, `fetched ${items.length} taxonomies${localeInfo}`, null, utils_1.PROCESS_NAMES.FETCH_TAXONOMIES);
|
|
210
|
+
}
|
|
120
211
|
skip += this.qs.limit || 100;
|
|
121
212
|
if (skip >= taxonomiesCount) {
|
|
122
213
|
cli_utilities_1.log.debug(`Completed fetching all taxonomies ${localeInfo}`, this.exportConfig.context);
|
|
@@ -183,13 +274,21 @@ class ExportTaxonomies extends base_class_1.default {
|
|
|
183
274
|
cli_utilities_1.log.debug(`Created locale folder: ${exportFolderPath}`, this.exportConfig.context);
|
|
184
275
|
}
|
|
185
276
|
const onSuccess = ({ response, uid }) => {
|
|
277
|
+
var _a, _b;
|
|
278
|
+
const taxonomyName = (_a = this.taxonomies[uid]) === null || _a === void 0 ? void 0 : _a.name;
|
|
186
279
|
const filePath = (0, node_path_1.resolve)(exportFolderPath, `${uid}.json`);
|
|
187
280
|
cli_utilities_1.log.debug(`Writing detailed taxonomy data to: ${filePath}`, this.exportConfig.context);
|
|
188
281
|
utils_1.fsUtil.writeFile(filePath, response);
|
|
189
|
-
|
|
282
|
+
// Track progress for each exported taxonomy
|
|
283
|
+
(_b = this.progressManager) === null || _b === void 0 ? void 0 : _b.tick(true, `taxonomy: ${taxonomyName || uid}`, null, utils_1.PROCESS_NAMES.EXPORT_TAXONOMIES_TERMS);
|
|
284
|
+
cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('TAXONOMY_EXPORT_SUCCESS', taxonomyName || uid), this.exportConfig.context);
|
|
190
285
|
};
|
|
191
286
|
const onReject = ({ error, uid }) => {
|
|
287
|
+
var _a, _b;
|
|
288
|
+
const taxonomyName = (_a = this.taxonomies[uid]) === null || _a === void 0 ? void 0 : _a.name;
|
|
192
289
|
cli_utilities_1.log.debug(`Failed to export detailed data for taxonomy: ${uid}${localeInfo}`, this.exportConfig.context);
|
|
290
|
+
// Track failure
|
|
291
|
+
(_b = this.progressManager) === null || _b === void 0 ? void 0 : _b.tick(false, `taxonomy: ${taxonomyName || uid}`, (error === null || error === void 0 ? void 0 : error.message) || utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.EXPORT_TAXONOMIES_TERMS].FAILED, utils_1.PROCESS_NAMES.EXPORT_TAXONOMIES_TERMS);
|
|
193
292
|
(0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign(Object.assign({}, this.exportConfig.context), { uid }), (localeCode && { locale: localeCode })));
|
|
194
293
|
};
|
|
195
294
|
for (const taxonomyUID of taxonomiesUID) {
|
|
@@ -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.
|
|
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.
|
|
50
|
+
this.completeProgressWithMessage();
|
|
52
51
|
}
|
|
53
52
|
catch (error) {
|
|
54
53
|
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
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.
|
|
4
|
+
"version": "2.0.0-beta.8",
|
|
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.
|
|
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",
|
|
13
13
|
"big-json": "^3.2.0",
|
|
14
14
|
"bluebird": "^3.7.2",
|
|
15
15
|
"chalk": "^4.1.2",
|
|
16
|
-
"lodash": "^4.17.
|
|
16
|
+
"lodash": "^4.17.23",
|
|
17
17
|
"merge": "^2.1.1",
|
|
18
18
|
"mkdirp": "^1.0.4",
|
|
19
19
|
"progress-stream": "^2.0.0",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@contentstack/cli-auth": "~2.0.0-beta.4",
|
|
25
|
-
"@contentstack/cli-config": "~
|
|
25
|
+
"@contentstack/cli-config": "~2.0.0-beta",
|
|
26
26
|
"@contentstack/cli-dev-dependencies": "~1.3.1",
|
|
27
27
|
"@oclif/plugin-help": "^6.2.28",
|
|
28
28
|
"@oclif/test": "^4.1.13",
|