@contentstack/cli-cm-export 2.0.0-beta.1 → 2.0.0-beta.10
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/LICENSE +1 -1
- package/README.md +11 -65
- package/lib/commands/cm/stacks/export.d.ts +0 -1
- package/lib/commands/cm/stacks/export.js +12 -37
- package/lib/config/index.js +7 -0
- package/lib/constants/index.d.ts +57 -0
- package/lib/constants/index.js +59 -0
- package/lib/export/module-exporter.js +3 -2
- package/lib/export/modules/assets.js +5 -5
- package/lib/export/modules/base-class.d.ts +17 -0
- package/lib/export/modules/base-class.js +29 -1
- package/lib/export/modules/composable-studio.d.ts +15 -0
- package/lib/export/modules/composable-studio.js +87 -0
- package/lib/export/modules/content-types.js +6 -8
- package/lib/export/modules/custom-roles.js +2 -2
- package/lib/export/modules/entries.d.ts +1 -1
- package/lib/export/modules/entries.js +18 -19
- package/lib/export/modules/environments.js +2 -3
- package/lib/export/modules/extensions.js +2 -3
- package/lib/export/modules/global-fields.js +8 -5
- package/lib/export/modules/labels.js +2 -3
- package/lib/export/modules/locales.js +2 -3
- package/lib/export/modules/marketplace-apps.js +36 -25
- package/lib/export/modules/personalize.js +1 -2
- package/lib/export/modules/stack.js +29 -29
- package/lib/export/modules/taxonomies.d.ts +52 -8
- package/lib/export/modules/taxonomies.js +278 -104
- package/lib/export/modules/webhooks.js +2 -3
- package/lib/export/modules/workflows.js +3 -4
- package/lib/types/default-config.d.ts +6 -0
- package/lib/types/index.d.ts +27 -2
- package/lib/utils/basic-login.d.ts +1 -1
- package/lib/utils/basic-login.js +5 -5
- package/lib/utils/common-helper.d.ts +1 -1
- package/lib/utils/common-helper.js +4 -4
- package/lib/utils/export-config-handler.js +10 -13
- package/lib/utils/file-helper.js +1 -1
- package/lib/utils/logger.d.ts +1 -1
- package/lib/utils/logger.js +2 -2
- package/lib/utils/marketplace-app-helper.js +2 -4
- package/messages/index.json +73 -67
- package/oclif.manifest.json +4 -42
- package/package.json +18 -15
|
@@ -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 {
|
|
@@ -11,7 +12,7 @@ class ExportStack extends base_class_1.default {
|
|
|
11
12
|
super({ exportConfig, stackAPIClient });
|
|
12
13
|
this.stackConfig = exportConfig.modules.stack;
|
|
13
14
|
this.qs = { include_count: true };
|
|
14
|
-
this.stackFolderPath = (0, node_path_1.resolve)(this.exportConfig.
|
|
15
|
+
this.stackFolderPath = (0, node_path_1.resolve)(this.exportConfig.exportDir, this.exportConfig.branchName || '', this.stackConfig.dirName);
|
|
15
16
|
this.exportConfig.context.module = utils_1.MODULE_CONTEXTS.STACK;
|
|
16
17
|
this.currentModuleName = utils_1.MODULE_NAMES[utils_1.MODULE_CONTEXTS.STACK];
|
|
17
18
|
}
|
|
@@ -28,7 +29,7 @@ class ExportStack extends base_class_1.default {
|
|
|
28
29
|
// Add processes based on configuration
|
|
29
30
|
let processCount = 0;
|
|
30
31
|
if (stackData === null || stackData === void 0 ? void 0 : stackData.org_uid) {
|
|
31
|
-
cli_utilities_1.log.debug(`Found organization UID: ${stackData.org_uid}
|
|
32
|
+
cli_utilities_1.log.debug(`Found organization UID: '${stackData.org_uid}'.`, this.exportConfig.context);
|
|
32
33
|
this.exportConfig.org_uid = stackData.org_uid;
|
|
33
34
|
this.exportConfig.sourceStackName = stackData.name;
|
|
34
35
|
cli_utilities_1.log.debug(`Set source stack name: ${stackData.name}`, this.exportConfig.context);
|
|
@@ -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);
|
|
@@ -92,30 +92,30 @@ class ExportStack extends base_class_1.default {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
async getStack() {
|
|
95
|
-
cli_utilities_1.log.debug(`Fetching stack data for
|
|
95
|
+
cli_utilities_1.log.debug(`Fetching stack data for: '${this.exportConfig.apiKey}'...`, this.exportConfig.context);
|
|
96
96
|
const tempAPIClient = await (0, cli_utilities_1.managementSDKClient)({ host: this.exportConfig.host });
|
|
97
|
-
cli_utilities_1.log.debug(`Created
|
|
97
|
+
cli_utilities_1.log.debug(`Created Management SDK client with host: '${this.exportConfig.host}'.`, this.exportConfig.context);
|
|
98
98
|
return await tempAPIClient
|
|
99
|
-
.stack({ api_key: this.exportConfig.
|
|
99
|
+
.stack({ api_key: this.exportConfig.apiKey })
|
|
100
100
|
.fetch()
|
|
101
101
|
.then((data) => {
|
|
102
|
-
cli_utilities_1.log.debug(`Successfully fetched stack data for: ${this.exportConfig.
|
|
102
|
+
cli_utilities_1.log.debug(`Successfully fetched stack data for: '${this.exportConfig.apiKey}'.`, this.exportConfig.context);
|
|
103
103
|
return data;
|
|
104
104
|
})
|
|
105
105
|
.catch((error) => {
|
|
106
|
-
cli_utilities_1.log.debug(`Failed to fetch stack data for: ${this.exportConfig.
|
|
106
|
+
cli_utilities_1.log.debug(`Failed to fetch stack data for: '${this.exportConfig.apiKey}'.`, this.exportConfig.context);
|
|
107
107
|
return {};
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
110
|
async getLocales(skip = 0) {
|
|
111
111
|
if (skip) {
|
|
112
112
|
this.qs.skip = skip;
|
|
113
|
-
cli_utilities_1.log.debug(`Fetching locales with skip: ${skip}
|
|
113
|
+
cli_utilities_1.log.debug(`Fetching locales with skip: ${skip}.`, this.exportConfig.context);
|
|
114
114
|
}
|
|
115
115
|
else {
|
|
116
|
-
cli_utilities_1.log.debug('Fetching locales with initial query', this.exportConfig.context);
|
|
116
|
+
cli_utilities_1.log.debug('Fetching locales with initial query...', this.exportConfig.context);
|
|
117
117
|
}
|
|
118
|
-
cli_utilities_1.log.debug(`Query parameters: ${JSON.stringify(this.qs)}
|
|
118
|
+
cli_utilities_1.log.debug(`Query parameters: ${JSON.stringify(this.qs)}.`, this.exportConfig.context);
|
|
119
119
|
return await this.stack
|
|
120
120
|
.locale()
|
|
121
121
|
.query(this.qs)
|
|
@@ -123,7 +123,7 @@ class ExportStack extends base_class_1.default {
|
|
|
123
123
|
.then(async (data) => {
|
|
124
124
|
var _a;
|
|
125
125
|
const { items, count } = data;
|
|
126
|
-
cli_utilities_1.log.debug(`Fetched ${(items === null || items === void 0 ? void 0 : items.length) || 0} locales out of
|
|
126
|
+
cli_utilities_1.log.debug(`Fetched ${(items === null || items === void 0 ? void 0 : items.length) || 0} locales out of ${count}.`, this.exportConfig.context);
|
|
127
127
|
if (items === null || items === void 0 ? void 0 : items.length) {
|
|
128
128
|
cli_utilities_1.log.debug(`Processing ${items.length} locales to find master locale`, this.exportConfig.context);
|
|
129
129
|
// Track progress for each locale processed
|
|
@@ -131,17 +131,17 @@ class ExportStack extends base_class_1.default {
|
|
|
131
131
|
skip += this.stackConfig.limit || 100;
|
|
132
132
|
const masterLocalObj = (0, find_1.default)(items, (locale) => {
|
|
133
133
|
if (locale.fallback_locale === null) {
|
|
134
|
-
cli_utilities_1.log.debug(`Found master locale: ${locale.name} (${locale.code})
|
|
134
|
+
cli_utilities_1.log.debug(`Found master locale: '${locale.name}' (code: ${locale.code}).`, this.exportConfig.context);
|
|
135
135
|
return locale;
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
138
|
if (masterLocalObj) {
|
|
139
|
-
cli_utilities_1.log.debug(`Returning master locale: ${masterLocalObj.name}
|
|
139
|
+
cli_utilities_1.log.debug(`Returning master locale: '${masterLocalObj.name}'.`, this.exportConfig.context);
|
|
140
140
|
return masterLocalObj;
|
|
141
141
|
}
|
|
142
142
|
else if (skip >= count) {
|
|
143
|
-
cli_utilities_1.log.error(`Locale locale not found in the stack ${this.exportConfig.
|
|
144
|
-
cli_utilities_1.log.debug('Completed
|
|
143
|
+
cli_utilities_1.log.error(`Locale locale not found in the stack ${this.exportConfig.apiKey}. Please ensure that the stack has a master locale.`, this.exportConfig.context);
|
|
144
|
+
cli_utilities_1.log.debug('Completed search. Master locale not found.', this.exportConfig.context);
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
147
147
|
else {
|
|
@@ -150,49 +150,49 @@ class ExportStack extends base_class_1.default {
|
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
else {
|
|
153
|
-
cli_utilities_1.log.debug('No locales found to process', this.exportConfig.context);
|
|
153
|
+
cli_utilities_1.log.debug('No locales found to process.', this.exportConfig.context);
|
|
154
154
|
}
|
|
155
155
|
})
|
|
156
156
|
.catch((error) => {
|
|
157
157
|
var _a;
|
|
158
|
-
cli_utilities_1.log.debug(`Error occurred while fetching locales for stack: ${this.exportConfig.
|
|
158
|
+
cli_utilities_1.log.debug(`Error occurred while fetching locales for stack: ${this.exportConfig.apiKey}`, this.exportConfig.context);
|
|
159
159
|
(_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.tick(false, 'locale fetch', (error === null || error === void 0 ? void 0 : error.message) || utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.STACK_LOCALE].FAILED, utils_1.PROCESS_NAMES.STACK_LOCALE);
|
|
160
|
-
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context), `Failed to fetch locales for stack ${this.exportConfig.
|
|
160
|
+
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context), `Failed to fetch locales for stack ${this.exportConfig.apiKey}`);
|
|
161
161
|
throw error;
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
164
|
async exportStack() {
|
|
165
|
-
cli_utilities_1.log.debug(`Starting stack export for: ${this.exportConfig.
|
|
165
|
+
cli_utilities_1.log.debug(`Starting stack export for: '${this.exportConfig.apiKey}'...`, this.exportConfig.context);
|
|
166
166
|
await utils_1.fsUtil.makeDirectory(this.stackFolderPath);
|
|
167
|
-
cli_utilities_1.log.debug(`Created stack directory at: ${this.stackFolderPath}`, this.exportConfig.context);
|
|
167
|
+
cli_utilities_1.log.debug(`Created stack directory at: '${this.stackFolderPath}'`, this.exportConfig.context);
|
|
168
168
|
return this.stack
|
|
169
169
|
.fetch()
|
|
170
170
|
.then((resp) => {
|
|
171
171
|
var _a;
|
|
172
172
|
const stackFilePath = (0, node_path_1.resolve)(this.stackFolderPath, this.stackConfig.fileName);
|
|
173
|
-
cli_utilities_1.log.debug(`Writing stack data to: ${stackFilePath}`, this.exportConfig.context);
|
|
173
|
+
cli_utilities_1.log.debug(`Writing stack data to: '${stackFilePath}'`, this.exportConfig.context);
|
|
174
174
|
utils_1.fsUtil.writeFile(stackFilePath, resp);
|
|
175
175
|
// Track progress for stack export completion
|
|
176
|
-
(_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.tick(true, `stack: ${this.exportConfig.
|
|
177
|
-
cli_utilities_1.log.success(`Stack details exported successfully for stack ${this.exportConfig.
|
|
178
|
-
cli_utilities_1.log.debug('Stack export completed successfully', this.exportConfig.context);
|
|
176
|
+
(_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.tick(true, `stack: ${this.exportConfig.apiKey}`, null, utils_1.PROCESS_NAMES.STACK_DETAILS);
|
|
177
|
+
cli_utilities_1.log.success(`Stack details exported successfully for stack ${this.exportConfig.apiKey}`, this.exportConfig.context);
|
|
178
|
+
cli_utilities_1.log.debug('Stack export completed successfully.', this.exportConfig.context);
|
|
179
179
|
return resp;
|
|
180
180
|
})
|
|
181
181
|
.catch((error) => {
|
|
182
182
|
var _a;
|
|
183
|
-
cli_utilities_1.log.debug(`Error occurred while exporting stack: ${this.exportConfig.
|
|
183
|
+
cli_utilities_1.log.debug(`Error occurred while exporting stack: ${this.exportConfig.apiKey}`, this.exportConfig.context);
|
|
184
184
|
(_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.tick(false, 'stack export', (error === null || error === void 0 ? void 0 : error.message) || utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.STACK_DETAILS].FAILED, utils_1.PROCESS_NAMES.STACK_DETAILS);
|
|
185
185
|
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
188
|
async exportStackSettings() {
|
|
189
|
-
cli_utilities_1.log.info('Exporting stack settings', this.exportConfig.context);
|
|
189
|
+
cli_utilities_1.log.info('Exporting stack settings...', this.exportConfig.context);
|
|
190
190
|
await utils_1.fsUtil.makeDirectory(this.stackFolderPath);
|
|
191
191
|
return this.stack
|
|
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);
|
|
@@ -2,21 +2,65 @@ import BaseClass from './base-class';
|
|
|
2
2
|
import { ModuleClassParams } from '../../types';
|
|
3
3
|
export default class ExportTaxonomies extends BaseClass {
|
|
4
4
|
private taxonomies;
|
|
5
|
+
private taxonomiesByLocale;
|
|
5
6
|
private taxonomiesConfig;
|
|
7
|
+
private isLocaleBasedExportSupported;
|
|
6
8
|
private qs;
|
|
7
9
|
taxonomiesFolderPath: string;
|
|
10
|
+
private localesFilePath;
|
|
8
11
|
constructor({ exportConfig, stackAPIClient }: ModuleClassParams);
|
|
9
12
|
start(): Promise<void>;
|
|
10
13
|
/**
|
|
11
|
-
*
|
|
12
|
-
* @param {number} skip
|
|
13
|
-
* @returns {Promise<any>}
|
|
14
|
+
* Initialize export setup (create directories, get initial count)
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
|
-
sanitizeTaxonomiesAttribs(taxonomies: Record<string, any>[]): void;
|
|
16
|
+
private initializeExport;
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
19
|
-
* @returns {Promise<any>}
|
|
18
|
+
* Setup progress manager with processes
|
|
20
19
|
*/
|
|
21
|
-
|
|
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;
|
|
33
|
+
/**
|
|
34
|
+
* Process and export taxonomies for a specific locale
|
|
35
|
+
*/
|
|
36
|
+
processLocaleExport(localeCode: string): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Write taxonomies metadata file
|
|
39
|
+
*/
|
|
40
|
+
writeTaxonomiesMetadata(): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Fetch taxonomies
|
|
43
|
+
*
|
|
44
|
+
* @async
|
|
45
|
+
* @param {?string} [localeCode]
|
|
46
|
+
* @param {boolean} [checkLocaleSupport=false]
|
|
47
|
+
* @returns {Promise<void>}
|
|
48
|
+
*/
|
|
49
|
+
fetchTaxonomies(localeCode?: string, checkLocaleSupport?: boolean): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* remove invalid keys and write data into taxonomies
|
|
52
|
+
* @function sanitizeTaxonomiesAttribs
|
|
53
|
+
* @param {Record<string, string>[]} taxonomies
|
|
54
|
+
* @param {?string} [localeCode]
|
|
55
|
+
*/
|
|
56
|
+
sanitizeTaxonomiesAttribs(taxonomies: Record<string, string>[], localeCode?: string): void;
|
|
57
|
+
/**
|
|
58
|
+
* Export taxonomies - supports both locale-based and legacy export
|
|
59
|
+
*/
|
|
60
|
+
exportTaxonomies(localeCode?: string): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Get all locales to export
|
|
63
|
+
*/
|
|
64
|
+
getLocalesToExport(): string[];
|
|
65
|
+
private isLocalePlanLimitationError;
|
|
22
66
|
}
|