@contentstack/cli-cm-export 1.21.0 → 1.22.0
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 +3 -3
- package/lib/commands/cm/stacks/export.js +7 -4
- package/lib/config/index.js +7 -0
- package/lib/export/module-exporter.js +4 -3
- 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 +3 -3
- package/lib/export/modules/custom-roles.js +18 -20
- package/lib/export/modules/entries.js +7 -7
- package/lib/export/modules/environments.js +13 -13
- package/lib/export/modules/extensions.js +16 -16
- package/lib/export/modules/global-fields.js +16 -16
- package/lib/export/modules/labels.js +17 -17
- package/lib/export/modules/locales.js +17 -17
- package/lib/export/modules/marketplace-apps.js +32 -32
- package/lib/export/modules/personalize.js +14 -14
- package/lib/export/modules/stack.js +26 -26
- package/lib/export/modules/taxonomies.d.ts +1 -0
- package/lib/export/modules/taxonomies.js +23 -6
- package/lib/export/modules-js/assets.js +3 -3
- package/lib/types/default-config.d.ts +6 -0
- package/lib/types/index.d.ts +27 -1
- package/lib/utils/basic-login.js +1 -1
- package/lib/utils/export-config-handler.js +5 -5
- package/lib/utils/file-helper.js +1 -1
- package/messages/index.json +6 -0
- package/oclif.manifest.json +2 -2
- package/package.json +6 -6
|
@@ -24,19 +24,19 @@ class GlobalFieldsExport extends base_class_1.default {
|
|
|
24
24
|
}
|
|
25
25
|
async start() {
|
|
26
26
|
try {
|
|
27
|
-
cli_utilities_1.log.debug('Starting global fields
|
|
28
|
-
cli_utilities_1.log.debug(`Global fields directory path: ${this.globalFieldsDirPath}`, this.exportConfig.context);
|
|
27
|
+
cli_utilities_1.log.debug('Starting export process for global fields...', this.exportConfig.context);
|
|
28
|
+
cli_utilities_1.log.debug(`Global fields directory path: '${this.globalFieldsDirPath}'`, this.exportConfig.context);
|
|
29
29
|
await utils_1.fsUtil.makeDirectory(this.globalFieldsDirPath);
|
|
30
|
-
cli_utilities_1.log.debug('Created global fields directory', this.exportConfig.context);
|
|
30
|
+
cli_utilities_1.log.debug('Created global fields directory.', this.exportConfig.context);
|
|
31
31
|
await this.getGlobalFields();
|
|
32
|
-
cli_utilities_1.log.debug(`Retrieved ${this.globalFields.length} global fields
|
|
32
|
+
cli_utilities_1.log.debug(`Retrieved ${this.globalFields.length} global fields.`, this.exportConfig.context);
|
|
33
33
|
const globalFieldsFilePath = path.join(this.globalFieldsDirPath, this.globalFieldsConfig.fileName);
|
|
34
|
-
cli_utilities_1.log.debug(`Writing global fields to: ${globalFieldsFilePath}`, this.exportConfig.context);
|
|
34
|
+
cli_utilities_1.log.debug(`Writing global fields to: '${globalFieldsFilePath}'`, this.exportConfig.context);
|
|
35
35
|
utils_1.fsUtil.writeFile(globalFieldsFilePath, this.globalFields);
|
|
36
36
|
cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('GLOBAL_FIELDS_EXPORT_COMPLETE', this.globalFields.length), this.exportConfig.context);
|
|
37
37
|
}
|
|
38
38
|
catch (error) {
|
|
39
|
-
cli_utilities_1.log.debug('
|
|
39
|
+
cli_utilities_1.log.debug('An error occurred during global fields export.', this.exportConfig.context);
|
|
40
40
|
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -44,30 +44,30 @@ class GlobalFieldsExport extends base_class_1.default {
|
|
|
44
44
|
var _a;
|
|
45
45
|
if (skip) {
|
|
46
46
|
this.qs.skip = skip;
|
|
47
|
-
cli_utilities_1.log.debug(`Fetching global fields with skip: ${skip}
|
|
47
|
+
cli_utilities_1.log.debug(`Fetching global fields with skip: ${skip}.`, this.exportConfig.context);
|
|
48
48
|
}
|
|
49
|
-
cli_utilities_1.log.debug(`Query parameters: ${JSON.stringify(this.qs)}
|
|
49
|
+
cli_utilities_1.log.debug(`Query parameters: ${JSON.stringify(this.qs)}.`, this.exportConfig.context);
|
|
50
50
|
let globalFieldsFetchResponse = await this.stackAPIClient.globalField({ api_version: '3.2' }).query(this.qs).find();
|
|
51
|
-
cli_utilities_1.log.debug(`Fetched ${((_a = globalFieldsFetchResponse.items) === null || _a === void 0 ? void 0 : _a.length) || 0} global fields out of
|
|
51
|
+
cli_utilities_1.log.debug(`Fetched ${((_a = globalFieldsFetchResponse.items) === null || _a === void 0 ? void 0 : _a.length) || 0} global fields out of ${globalFieldsFetchResponse.count}.`, this.exportConfig.context);
|
|
52
52
|
if (Array.isArray(globalFieldsFetchResponse.items) && globalFieldsFetchResponse.items.length > 0) {
|
|
53
|
-
cli_utilities_1.log.debug(`Processing ${globalFieldsFetchResponse.items.length} global fields
|
|
53
|
+
cli_utilities_1.log.debug(`Processing ${globalFieldsFetchResponse.items.length} global fields...`, this.exportConfig.context);
|
|
54
54
|
this.sanitizeAttribs(globalFieldsFetchResponse.items);
|
|
55
55
|
skip += this.globalFieldsConfig.limit || 100;
|
|
56
56
|
if (skip >= globalFieldsFetchResponse.count) {
|
|
57
|
-
cli_utilities_1.log.debug('Completed fetching all global fields', this.exportConfig.context);
|
|
57
|
+
cli_utilities_1.log.debug('Completed fetching all global fields.', this.exportConfig.context);
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
|
-
cli_utilities_1.log.debug(`Continuing to fetch global fields with skip: ${skip}
|
|
60
|
+
cli_utilities_1.log.debug(`Continuing to fetch global fields with skip: ${skip}.`, this.exportConfig.context);
|
|
61
61
|
return await this.getGlobalFields(skip);
|
|
62
62
|
}
|
|
63
63
|
else {
|
|
64
|
-
cli_utilities_1.log.debug('No global fields found to process', this.exportConfig.context);
|
|
64
|
+
cli_utilities_1.log.debug('No global fields found to process.', this.exportConfig.context);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
sanitizeAttribs(globalFields) {
|
|
68
|
-
cli_utilities_1.log.debug(`Sanitizing ${globalFields.length} global fields
|
|
68
|
+
cli_utilities_1.log.debug(`Sanitizing ${globalFields.length} global fields...`, this.exportConfig.context);
|
|
69
69
|
globalFields.forEach((globalField) => {
|
|
70
|
-
cli_utilities_1.log.debug(`Processing global field: ${globalField.uid || 'unknown'}
|
|
70
|
+
cli_utilities_1.log.debug(`Processing global field: '${globalField.uid || 'unknown'}'...`, this.exportConfig.context);
|
|
71
71
|
for (let key in globalField) {
|
|
72
72
|
if (this.globalFieldsConfig.validKeys.indexOf(key) === -1) {
|
|
73
73
|
delete globalField[key];
|
|
@@ -75,7 +75,7 @@ class GlobalFieldsExport extends base_class_1.default {
|
|
|
75
75
|
}
|
|
76
76
|
this.globalFields.push(globalField);
|
|
77
77
|
});
|
|
78
|
-
cli_utilities_1.log.debug(`Sanitization complete. Total global fields processed: ${this.globalFields.length}
|
|
78
|
+
cli_utilities_1.log.debug(`Sanitization complete. Total global fields processed: ${this.globalFields.length}.`, this.exportConfig.context);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
exports.default = GlobalFieldsExport;
|
|
@@ -16,19 +16,19 @@ class ExportLabels extends base_class_1.default {
|
|
|
16
16
|
this.exportConfig.context.module = 'labels';
|
|
17
17
|
}
|
|
18
18
|
async start() {
|
|
19
|
-
cli_utilities_1.log.debug('Starting
|
|
19
|
+
cli_utilities_1.log.debug('Starting export process for labels...', this.exportConfig.context);
|
|
20
20
|
this.labelsFolderPath = (0, node_path_1.resolve)(this.exportConfig.data, this.exportConfig.branchName || '', this.labelConfig.dirName);
|
|
21
|
-
cli_utilities_1.log.debug(`Labels folder path: ${this.labelsFolderPath}`, this.exportConfig.context);
|
|
21
|
+
cli_utilities_1.log.debug(`Labels folder path: '${this.labelsFolderPath}'`, this.exportConfig.context);
|
|
22
22
|
await utils_1.fsUtil.makeDirectory(this.labelsFolderPath);
|
|
23
|
-
cli_utilities_1.log.debug('Created labels directory', this.exportConfig.context);
|
|
23
|
+
cli_utilities_1.log.debug('Created labels directory.', this.exportConfig.context);
|
|
24
24
|
await this.getLabels();
|
|
25
|
-
cli_utilities_1.log.debug(`Retrieved ${Object.keys(this.labels).length} labels
|
|
25
|
+
cli_utilities_1.log.debug(`Retrieved ${Object.keys(this.labels).length} labels.`, this.exportConfig.context);
|
|
26
26
|
if (this.labels === undefined || (0, isEmpty_1.default)(this.labels)) {
|
|
27
27
|
cli_utilities_1.log.info(cli_utilities_1.messageHandler.parse('LABELS_NOT_FOUND'), this.exportConfig.context);
|
|
28
28
|
}
|
|
29
29
|
else {
|
|
30
30
|
const labelsFilePath = (0, node_path_1.resolve)(this.labelsFolderPath, this.labelConfig.fileName);
|
|
31
|
-
cli_utilities_1.log.debug(`Writing labels to: ${labelsFilePath}
|
|
31
|
+
cli_utilities_1.log.debug(`Writing labels to: '${labelsFilePath}'.`, this.exportConfig.context);
|
|
32
32
|
utils_1.fsUtil.writeFile(labelsFilePath, this.labels);
|
|
33
33
|
cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('LABELS_EXPORT_COMPLETE', Object.keys(this.labels).length), this.exportConfig.context);
|
|
34
34
|
}
|
|
@@ -36,50 +36,50 @@ class ExportLabels extends base_class_1.default {
|
|
|
36
36
|
async getLabels(skip = 0) {
|
|
37
37
|
if (skip) {
|
|
38
38
|
this.qs.skip = skip;
|
|
39
|
-
cli_utilities_1.log.debug(`Fetching labels with skip: ${skip}
|
|
39
|
+
cli_utilities_1.log.debug(`Fetching labels with skip: ${skip}.`, this.exportConfig.context);
|
|
40
40
|
}
|
|
41
41
|
else {
|
|
42
|
-
cli_utilities_1.log.debug('Fetching labels with initial query', this.exportConfig.context);
|
|
42
|
+
cli_utilities_1.log.debug('Fetching labels with initial query...', this.exportConfig.context);
|
|
43
43
|
}
|
|
44
|
-
cli_utilities_1.log.debug(`Query parameters: ${JSON.stringify(this.qs)}
|
|
44
|
+
cli_utilities_1.log.debug(`Query parameters: ${JSON.stringify(this.qs)}.`, this.exportConfig.context);
|
|
45
45
|
await this.stack
|
|
46
46
|
.label()
|
|
47
47
|
.query(this.qs)
|
|
48
48
|
.find()
|
|
49
49
|
.then(async (data) => {
|
|
50
50
|
const { items, count } = data;
|
|
51
|
-
cli_utilities_1.log.debug(`Fetched ${(items === null || items === void 0 ? void 0 : items.length) || 0} labels out of
|
|
51
|
+
cli_utilities_1.log.debug(`Fetched ${(items === null || items === void 0 ? void 0 : items.length) || 0} labels out of ${count}.`, this.exportConfig.context);
|
|
52
52
|
if (items === null || items === void 0 ? void 0 : items.length) {
|
|
53
|
-
cli_utilities_1.log.debug(`Processing ${items.length} labels
|
|
53
|
+
cli_utilities_1.log.debug(`Processing ${items.length} labels...`, this.exportConfig.context);
|
|
54
54
|
this.sanitizeAttribs(items);
|
|
55
55
|
skip += this.labelConfig.limit || 100;
|
|
56
56
|
if (skip >= count) {
|
|
57
|
-
cli_utilities_1.log.debug('Completed fetching all labels', this.exportConfig.context);
|
|
57
|
+
cli_utilities_1.log.debug('Completed fetching all labels.', this.exportConfig.context);
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
|
-
cli_utilities_1.log.debug(`Continuing to fetch labels with skip: ${skip}
|
|
60
|
+
cli_utilities_1.log.debug(`Continuing to fetch labels with skip: ${skip}.`, this.exportConfig.context);
|
|
61
61
|
return await this.getLabels(skip);
|
|
62
62
|
}
|
|
63
63
|
else {
|
|
64
|
-
cli_utilities_1.log.debug('No labels found to process', this.exportConfig.context);
|
|
64
|
+
cli_utilities_1.log.debug('No labels found to process.', this.exportConfig.context);
|
|
65
65
|
}
|
|
66
66
|
})
|
|
67
67
|
.catch((error) => {
|
|
68
|
-
cli_utilities_1.log.debug('
|
|
68
|
+
cli_utilities_1.log.debug('An error occurred while fetching labels.', this.exportConfig.context);
|
|
69
69
|
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
sanitizeAttribs(labels) {
|
|
73
73
|
var _a;
|
|
74
|
-
cli_utilities_1.log.debug(`Sanitizing ${labels.length} labels
|
|
74
|
+
cli_utilities_1.log.debug(`Sanitizing ${labels.length} labels...`, this.exportConfig.context);
|
|
75
75
|
for (let index = 0; index < (labels === null || labels === void 0 ? void 0 : labels.length); index++) {
|
|
76
76
|
const labelUid = labels[index].uid;
|
|
77
77
|
const labelName = (_a = labels[index]) === null || _a === void 0 ? void 0 : _a.name;
|
|
78
|
-
cli_utilities_1.log.debug(`Processing label: ${labelName} (${labelUid})
|
|
78
|
+
cli_utilities_1.log.debug(`Processing label: '${labelName}' (UID: ${labelUid})...`, this.exportConfig.context);
|
|
79
79
|
this.labels[labelUid] = (0, omit_1.default)(labels[index], this.labelConfig.invalidKeys);
|
|
80
80
|
cli_utilities_1.log.info(cli_utilities_1.messageHandler.parse('LABEL_EXPORT_SUCCESS', labelName), this.exportConfig.context);
|
|
81
81
|
}
|
|
82
|
-
cli_utilities_1.log.debug(`Sanitization complete. Total labels processed: ${Object.keys(this.labels).length}
|
|
82
|
+
cli_utilities_1.log.debug(`Sanitization complete. Total labels processed: ${Object.keys(this.labels).length}.`, this.exportConfig.context);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
exports.default = ExportLabels;
|
|
@@ -25,17 +25,17 @@ class LocaleExport extends base_class_1.default {
|
|
|
25
25
|
}
|
|
26
26
|
async start() {
|
|
27
27
|
try {
|
|
28
|
-
cli_utilities_1.log.debug('Starting
|
|
29
|
-
cli_utilities_1.log.debug(`Locales path: ${this.localesPath}`, this.exportConfig.context);
|
|
28
|
+
cli_utilities_1.log.debug('Starting export process for locales...', this.exportConfig.context);
|
|
29
|
+
cli_utilities_1.log.debug(`Locales path: '${this.localesPath}'`, this.exportConfig.context);
|
|
30
30
|
await utils_1.fsUtil.makeDirectory(this.localesPath);
|
|
31
|
-
cli_utilities_1.log.debug('Created locales directory', this.exportConfig.context);
|
|
31
|
+
cli_utilities_1.log.debug('Created locales directory.', this.exportConfig.context);
|
|
32
32
|
await this.getLocales();
|
|
33
|
-
cli_utilities_1.log.debug(`Retrieved ${Object.keys(this.locales).length} locales and ${Object.keys(this.masterLocale).length} master locales
|
|
33
|
+
cli_utilities_1.log.debug(`Retrieved ${Object.keys(this.locales).length} locales and ${Object.keys(this.masterLocale).length} master locales.`, this.exportConfig.context);
|
|
34
34
|
const localesFilePath = path.join(this.localesPath, this.localeConfig.fileName);
|
|
35
35
|
const masterLocaleFilePath = path.join(this.localesPath, this.masterLocaleConfig.fileName);
|
|
36
|
-
cli_utilities_1.log.debug(`Writing locales to: ${localesFilePath}`, this.exportConfig.context);
|
|
36
|
+
cli_utilities_1.log.debug(`Writing locales to: '${localesFilePath}'`, this.exportConfig.context);
|
|
37
37
|
utils_1.fsUtil.writeFile(localesFilePath, this.locales);
|
|
38
|
-
cli_utilities_1.log.debug(`Writing master locale to: ${masterLocaleFilePath}`, this.exportConfig.context);
|
|
38
|
+
cli_utilities_1.log.debug(`Writing master locale to: '${masterLocaleFilePath}'`, this.exportConfig.context);
|
|
39
39
|
utils_1.fsUtil.writeFile(masterLocaleFilePath, this.masterLocale);
|
|
40
40
|
cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('LOCALES_EXPORT_COMPLETE', Object.keys(this.locales).length, Object.keys(this.masterLocale).length), this.exportConfig.context);
|
|
41
41
|
}
|
|
@@ -48,28 +48,28 @@ class LocaleExport extends base_class_1.default {
|
|
|
48
48
|
var _a;
|
|
49
49
|
if (skip) {
|
|
50
50
|
this.qs.skip = skip;
|
|
51
|
-
cli_utilities_1.log.debug(`Fetching locales with skip: ${skip}
|
|
51
|
+
cli_utilities_1.log.debug(`Fetching locales with skip: ${skip}.`, this.exportConfig.context);
|
|
52
52
|
}
|
|
53
|
-
cli_utilities_1.log.debug(`Query parameters: ${JSON.stringify(this.qs)}
|
|
53
|
+
cli_utilities_1.log.debug(`Query parameters: ${JSON.stringify(this.qs)}.`, this.exportConfig.context);
|
|
54
54
|
let localesFetchResponse = await this.stackAPIClient.locale().query(this.qs).find();
|
|
55
|
-
cli_utilities_1.log.debug(`Fetched ${((_a = localesFetchResponse.items) === null || _a === void 0 ? void 0 : _a.length) || 0} locales out of
|
|
55
|
+
cli_utilities_1.log.debug(`Fetched ${((_a = localesFetchResponse.items) === null || _a === void 0 ? void 0 : _a.length) || 0} locales out of ${localesFetchResponse.count}.`, this.exportConfig.context);
|
|
56
56
|
if (Array.isArray(localesFetchResponse.items) && localesFetchResponse.items.length > 0) {
|
|
57
|
-
cli_utilities_1.log.debug(`Processing ${localesFetchResponse.items.length} locales
|
|
57
|
+
cli_utilities_1.log.debug(`Processing ${localesFetchResponse.items.length} locales...`, this.exportConfig.context);
|
|
58
58
|
this.sanitizeAttribs(localesFetchResponse.items);
|
|
59
59
|
skip += this.localeConfig.limit || 100;
|
|
60
60
|
if (skip > localesFetchResponse.count) {
|
|
61
|
-
cli_utilities_1.log.debug('Completed fetching all locales', this.exportConfig.context);
|
|
61
|
+
cli_utilities_1.log.debug('Completed fetching all locales.', this.exportConfig.context);
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
|
-
cli_utilities_1.log.debug(`Continuing to fetch locales with skip: ${skip}
|
|
64
|
+
cli_utilities_1.log.debug(`Continuing to fetch locales with skip: ${skip}.`, this.exportConfig.context);
|
|
65
65
|
return await this.getLocales(skip);
|
|
66
66
|
}
|
|
67
67
|
else {
|
|
68
|
-
cli_utilities_1.log.debug('No locales found to process', this.exportConfig.context);
|
|
68
|
+
cli_utilities_1.log.debug('No locales found to process.', this.exportConfig.context);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
sanitizeAttribs(locales) {
|
|
72
|
-
cli_utilities_1.log.debug(`Sanitizing ${locales.length} locales
|
|
72
|
+
cli_utilities_1.log.debug(`Sanitizing ${locales.length} locales...`, this.exportConfig.context);
|
|
73
73
|
locales.forEach((locale) => {
|
|
74
74
|
var _a, _b;
|
|
75
75
|
for (let key in locale) {
|
|
@@ -78,15 +78,15 @@ class LocaleExport extends base_class_1.default {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
if ((locale === null || locale === void 0 ? void 0 : locale.code) === ((_b = (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.master_locale) === null || _b === void 0 ? void 0 : _b.code)) {
|
|
81
|
-
cli_utilities_1.log.debug(`Adding locale ${locale.uid} to master locale
|
|
81
|
+
cli_utilities_1.log.debug(`Adding locale UID '${locale.uid}' to master locale.`, this.exportConfig.context);
|
|
82
82
|
this.masterLocale[locale.uid] = locale;
|
|
83
83
|
}
|
|
84
84
|
else {
|
|
85
|
-
cli_utilities_1.log.debug(`Adding locale ${locale.uid} to regular locales
|
|
85
|
+
cli_utilities_1.log.debug(`Adding locale UID '${locale.uid}' to regular locales.`, this.exportConfig.context);
|
|
86
86
|
this.locales[locale.uid] = locale;
|
|
87
87
|
}
|
|
88
88
|
});
|
|
89
|
-
cli_utilities_1.log.debug(`Sanitization complete. Master locales: ${Object.keys(this.masterLocale).length}, Regular locales: ${Object.keys(this.locales).length}
|
|
89
|
+
cli_utilities_1.log.debug(`Sanitization complete. Master locales: ${Object.keys(this.masterLocale).length}, Regular locales: ${Object.keys(this.locales).length}.`, this.exportConfig.context);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
exports.default = LocaleExport;
|
|
@@ -18,26 +18,26 @@ class ExportMarketplaceApps {
|
|
|
18
18
|
this.exportConfig.context.module = 'marketplace-apps';
|
|
19
19
|
}
|
|
20
20
|
async start() {
|
|
21
|
-
cli_utilities_1.log.debug('Starting
|
|
21
|
+
cli_utilities_1.log.debug('Starting export process for Marketplace Apps...', this.exportConfig.context);
|
|
22
22
|
if (!(0, cli_utilities_1.isAuthenticated)()) {
|
|
23
23
|
cli_utilities_1.cliux.print('WARNING!!! To export Marketplace apps, you must be logged in. Please check csdx auth:login --help to log in', { color: 'yellow' });
|
|
24
24
|
return Promise.resolve();
|
|
25
25
|
}
|
|
26
26
|
this.marketplaceAppPath = (0, node_path_1.resolve)(this.exportConfig.data, this.exportConfig.branchName || '', this.marketplaceAppConfig.dirName);
|
|
27
|
-
cli_utilities_1.log.debug(`Marketplace apps folder path: ${this.marketplaceAppPath}`, this.exportConfig.context);
|
|
27
|
+
cli_utilities_1.log.debug(`Marketplace apps folder path: '${this.marketplaceAppPath}'`, this.exportConfig.context);
|
|
28
28
|
await utils_1.fsUtil.makeDirectory(this.marketplaceAppPath);
|
|
29
|
-
cli_utilities_1.log.debug('Created
|
|
29
|
+
cli_utilities_1.log.debug('Created Marketplace Apps directory.', this.exportConfig.context);
|
|
30
30
|
this.developerHubBaseUrl = this.exportConfig.developerHubBaseUrl || (await (0, utils_1.getDeveloperHubUrl)(this.exportConfig));
|
|
31
|
-
cli_utilities_1.log.debug(`Developer
|
|
31
|
+
cli_utilities_1.log.debug(`Developer Hub base URL: '${this.developerHubBaseUrl}'`, this.exportConfig.context);
|
|
32
32
|
this.exportConfig.org_uid = await (0, utils_1.getOrgUid)(this.exportConfig);
|
|
33
33
|
this.query = { target_uids: this.exportConfig.source_stack };
|
|
34
|
-
cli_utilities_1.log.debug(`Organization UID: ${this.exportConfig.org_uid}
|
|
34
|
+
cli_utilities_1.log.debug(`Organization UID: '${this.exportConfig.org_uid}'.`, this.exportConfig.context);
|
|
35
35
|
// NOTE init marketplace app sdk
|
|
36
36
|
const host = this.developerHubBaseUrl.split('://').pop();
|
|
37
|
-
cli_utilities_1.log.debug(`Initializing
|
|
37
|
+
cli_utilities_1.log.debug(`Initializing Marketplace SDK with host: '${host}'...`, this.exportConfig.context);
|
|
38
38
|
this.appSdk = await (0, cli_utilities_1.marketplaceSDKClient)({ host });
|
|
39
39
|
await this.exportApps();
|
|
40
|
-
cli_utilities_1.log.debug('Marketplace apps export process completed', this.exportConfig.context);
|
|
40
|
+
cli_utilities_1.log.debug('Marketplace apps export process completed.', this.exportConfig.context);
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* The function `exportApps` encrypts the configuration of installed apps using a Node.js crypto
|
|
@@ -45,7 +45,7 @@ class ExportMarketplaceApps {
|
|
|
45
45
|
*/
|
|
46
46
|
async exportApps() {
|
|
47
47
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
48
|
-
cli_utilities_1.log.debug('Starting
|
|
48
|
+
cli_utilities_1.log.debug('Starting export process for apps...', this.exportConfig.context);
|
|
49
49
|
// currently support only app_uids or installation_uids
|
|
50
50
|
const externalQuery = (_a = this.exportConfig.query) === null || _a === void 0 ? void 0 : _a.modules['marketplace-apps'];
|
|
51
51
|
if (externalQuery) {
|
|
@@ -57,22 +57,22 @@ class ExportMarketplaceApps {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
await this.getStackSpecificApps();
|
|
60
|
-
cli_utilities_1.log.debug(`Retrieved ${this.installedApps.length} stack-specific apps
|
|
60
|
+
cli_utilities_1.log.debug(`Retrieved ${this.installedApps.length} stack-specific apps.`, this.exportConfig.context);
|
|
61
61
|
await this.getAppManifestAndAppConfig();
|
|
62
|
-
cli_utilities_1.log.debug('Completed app manifest and configuration processing', this.exportConfig.context);
|
|
62
|
+
cli_utilities_1.log.debug('Completed app manifest and configuration processing.', this.exportConfig.context);
|
|
63
63
|
if (!this.nodeCrypto && (0, find_1.default)(this.installedApps, (app) => !(0, isEmpty_1.default)(app.configuration))) {
|
|
64
|
-
cli_utilities_1.log.debug('Initializing NodeCrypto for app configuration encryption', this.exportConfig.context);
|
|
64
|
+
cli_utilities_1.log.debug('Initializing NodeCrypto for app configuration encryption...', this.exportConfig.context);
|
|
65
65
|
this.nodeCrypto = await (0, utils_1.createNodeCryptoInstance)(this.exportConfig);
|
|
66
66
|
}
|
|
67
67
|
this.installedApps = (0, map_1.default)(this.installedApps, (app) => {
|
|
68
68
|
var _a;
|
|
69
69
|
if ((0, has_1.default)(app, 'configuration')) {
|
|
70
|
-
cli_utilities_1.log.debug(`Encrypting configuration for app: ${((_a = app.manifest) === null || _a === void 0 ? void 0 : _a.name) || app.uid}
|
|
70
|
+
cli_utilities_1.log.debug(`Encrypting configuration for app: '${((_a = app.manifest) === null || _a === void 0 ? void 0 : _a.name) || app.uid}'...`, this.exportConfig.context);
|
|
71
71
|
app['configuration'] = this.nodeCrypto.encrypt(app.configuration);
|
|
72
72
|
}
|
|
73
73
|
return app;
|
|
74
74
|
});
|
|
75
|
-
cli_utilities_1.log.debug(`Processed ${this.installedApps.length}
|
|
75
|
+
cli_utilities_1.log.debug(`Processed ${this.installedApps.length} Marketplace Apps.`, this.exportConfig.context);
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
78
|
* The function `getAppManifestAndAppConfig` exports the manifest and configurations of installed
|
|
@@ -84,19 +84,19 @@ class ExportMarketplaceApps {
|
|
|
84
84
|
cli_utilities_1.log.info(cli_utilities_1.messageHandler.parse('MARKETPLACE_APPS_NOT_FOUND'), this.exportConfig.context);
|
|
85
85
|
}
|
|
86
86
|
else {
|
|
87
|
-
cli_utilities_1.log.debug(`Processing ${this.installedApps.length} installed apps
|
|
87
|
+
cli_utilities_1.log.debug(`Processing ${this.installedApps.length} installed apps...`, this.exportConfig.context);
|
|
88
88
|
for (const [index, app] of (0, entries_1.default)(this.installedApps)) {
|
|
89
89
|
if (app.manifest.visibility === 'private') {
|
|
90
|
-
cli_utilities_1.log.debug(`Processing private app manifest: ${app.manifest.name}
|
|
90
|
+
cli_utilities_1.log.debug(`Processing private app manifest: '${app.manifest.name}'...`, this.exportConfig.context);
|
|
91
91
|
await this.getPrivateAppsManifest(+index, app);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
for (const [index, app] of (0, entries_1.default)(this.installedApps)) {
|
|
95
|
-
cli_utilities_1.log.debug(`Processing app configurations: ${((_a = app.manifest) === null || _a === void 0 ? void 0 : _a.name) || app.uid}
|
|
95
|
+
cli_utilities_1.log.debug(`Processing app configurations for: '${((_a = app.manifest) === null || _a === void 0 ? void 0 : _a.name) || app.uid}'...`, this.exportConfig.context);
|
|
96
96
|
await this.getAppConfigurations(+index, app);
|
|
97
97
|
}
|
|
98
98
|
const marketplaceAppsFilePath = (0, node_path_1.resolve)(this.marketplaceAppPath, this.marketplaceAppConfig.fileName);
|
|
99
|
-
cli_utilities_1.log.debug(`Writing
|
|
99
|
+
cli_utilities_1.log.debug(`Writing Marketplace Apps to: '${marketplaceAppsFilePath}'`, this.exportConfig.context);
|
|
100
100
|
utils_1.fsUtil.writeFile(marketplaceAppsFilePath, this.installedApps);
|
|
101
101
|
cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('MARKETPLACE_APPS_EXPORT_COMPLETE', Object.keys(this.installedApps).length), this.exportConfig.context);
|
|
102
102
|
}
|
|
@@ -111,17 +111,17 @@ class ExportMarketplaceApps {
|
|
|
111
111
|
* app's manifest.
|
|
112
112
|
*/
|
|
113
113
|
async getPrivateAppsManifest(index, appInstallation) {
|
|
114
|
-
cli_utilities_1.log.debug(`Fetching private app manifest for: ${appInstallation.manifest.name} (${appInstallation.manifest.uid})
|
|
114
|
+
cli_utilities_1.log.debug(`Fetching private app manifest for: '${appInstallation.manifest.name}' (UID: ${appInstallation.manifest.uid})...`, this.exportConfig.context);
|
|
115
115
|
const manifest = await this.appSdk
|
|
116
116
|
.marketplace(this.exportConfig.org_uid)
|
|
117
117
|
.app(appInstallation.manifest.uid)
|
|
118
118
|
.fetch({ include_oauth: true })
|
|
119
119
|
.catch((error) => {
|
|
120
|
-
cli_utilities_1.log.debug(`Failed to fetch private app manifest for: ${appInstallation.manifest.name}
|
|
120
|
+
cli_utilities_1.log.debug(`Failed to fetch private app manifest for: '${appInstallation.manifest.name}'.`, this.exportConfig.context);
|
|
121
121
|
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context), cli_utilities_1.messageHandler.parse('MARKETPLACE_APP_MANIFEST_EXPORT_FAILED', appInstallation.manifest.name));
|
|
122
122
|
});
|
|
123
123
|
if (manifest) {
|
|
124
|
-
cli_utilities_1.log.debug(`Successfully fetched private app manifest for: ${appInstallation.manifest.name}
|
|
124
|
+
cli_utilities_1.log.debug(`Successfully fetched private app manifest for: '${appInstallation.manifest.name}'.`, this.exportConfig.context);
|
|
125
125
|
this.installedApps[index].manifest = manifest;
|
|
126
126
|
}
|
|
127
127
|
}
|
|
@@ -140,7 +140,7 @@ class ExportMarketplaceApps {
|
|
|
140
140
|
const appName = (_a = appInstallation === null || appInstallation === void 0 ? void 0 : appInstallation.manifest) === null || _a === void 0 ? void 0 : _a.name;
|
|
141
141
|
const appUid = (_b = appInstallation === null || appInstallation === void 0 ? void 0 : appInstallation.manifest) === null || _b === void 0 ? void 0 : _b.uid;
|
|
142
142
|
const app = appName || appUid;
|
|
143
|
-
cli_utilities_1.log.debug(`Fetching app configuration for: ${app}
|
|
143
|
+
cli_utilities_1.log.debug(`Fetching app configuration for: '${app}'...`, this.exportConfig.context);
|
|
144
144
|
cli_utilities_1.log.info(cli_utilities_1.messageHandler.parse('MARKETPLACE_APP_CONFIG_EXPORT', app), this.exportConfig.context);
|
|
145
145
|
await this.appSdk
|
|
146
146
|
.marketplace(this.exportConfig.org_uid)
|
|
@@ -149,17 +149,17 @@ class ExportMarketplaceApps {
|
|
|
149
149
|
.then(async (result) => {
|
|
150
150
|
const { data, error } = result;
|
|
151
151
|
if ((0, has_1.default)(data, 'server_configuration') || (0, has_1.default)(data, 'configuration')) {
|
|
152
|
-
cli_utilities_1.log.debug(`Found configuration data for app: ${app}
|
|
152
|
+
cli_utilities_1.log.debug(`Found configuration data for app: '${app}'.`, this.exportConfig.context);
|
|
153
153
|
if (!this.nodeCrypto && ((0, has_1.default)(data, 'server_configuration') || (0, has_1.default)(data, 'configuration'))) {
|
|
154
|
-
cli_utilities_1.log.debug(`Initializing NodeCrypto for app: ${app}
|
|
154
|
+
cli_utilities_1.log.debug(`Initializing NodeCrypto for app: '${app}'...`, this.exportConfig.context);
|
|
155
155
|
this.nodeCrypto = await (0, utils_1.createNodeCryptoInstance)(this.exportConfig);
|
|
156
156
|
}
|
|
157
157
|
if (!(0, isEmpty_1.default)(data === null || data === void 0 ? void 0 : data.configuration)) {
|
|
158
|
-
cli_utilities_1.log.debug(`Encrypting configuration for app: ${app}
|
|
158
|
+
cli_utilities_1.log.debug(`Encrypting configuration for app: '${app}'...`, this.exportConfig.context);
|
|
159
159
|
this.installedApps[index]['configuration'] = this.nodeCrypto.encrypt(data.configuration);
|
|
160
160
|
}
|
|
161
161
|
if (!(0, isEmpty_1.default)(data === null || data === void 0 ? void 0 : data.server_configuration)) {
|
|
162
|
-
cli_utilities_1.log.debug(`Encrypting server configuration for app: ${app}
|
|
162
|
+
cli_utilities_1.log.debug(`Encrypting server configuration for app: '${app}'...`, this.exportConfig.context);
|
|
163
163
|
this.installedApps[index]['server_configuration'] = this.nodeCrypto.encrypt(data.server_configuration);
|
|
164
164
|
cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('MARKETPLACE_APP_CONFIG_SUCCESS', app), this.exportConfig.context);
|
|
165
165
|
}
|
|
@@ -168,12 +168,12 @@ class ExportMarketplaceApps {
|
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
else if (error) {
|
|
171
|
-
cli_utilities_1.log.debug(`Error in app configuration data for: ${app}
|
|
171
|
+
cli_utilities_1.log.debug(`Error in app configuration data for: '${app}'.`, this.exportConfig.context);
|
|
172
172
|
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context), cli_utilities_1.messageHandler.parse('MARKETPLACE_APP_CONFIG_EXPORT_FAILED', app));
|
|
173
173
|
}
|
|
174
174
|
})
|
|
175
175
|
.catch((error) => {
|
|
176
|
-
cli_utilities_1.log.debug(`Failed to fetch app configuration for: ${app}
|
|
176
|
+
cli_utilities_1.log.debug(`Failed to fetch app configuration for: '${app}'.`, this.exportConfig.context);
|
|
177
177
|
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context), cli_utilities_1.messageHandler.parse('MARKETPLACE_APP_CONFIG_EXPORT_FAILED', app));
|
|
178
178
|
});
|
|
179
179
|
}
|
|
@@ -191,26 +191,26 @@ class ExportMarketplaceApps {
|
|
|
191
191
|
.installation()
|
|
192
192
|
.fetchAll(Object.assign(Object.assign({}, this.query), { skip }))
|
|
193
193
|
.catch((error) => {
|
|
194
|
-
cli_utilities_1.log.debug('
|
|
194
|
+
cli_utilities_1.log.debug('An error occurred while fetching stack-specific apps.', this.exportConfig.context);
|
|
195
195
|
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
|
|
196
196
|
});
|
|
197
197
|
if (collection) {
|
|
198
198
|
const { items: apps, count } = collection;
|
|
199
|
-
cli_utilities_1.log.debug(`Fetched ${(apps === null || apps === void 0 ? void 0 : apps.length) || 0} apps out of
|
|
199
|
+
cli_utilities_1.log.debug(`Fetched ${(apps === null || apps === void 0 ? void 0 : apps.length) || 0} apps out of ${count}.`, this.exportConfig.context);
|
|
200
200
|
// NOTE Remove all the chain functions
|
|
201
201
|
const installation = (0, map_1.default)(apps, (app) => (0, omitBy_1.default)(app, (val, _key) => {
|
|
202
202
|
if (val instanceof Function)
|
|
203
203
|
return true;
|
|
204
204
|
return false;
|
|
205
205
|
}));
|
|
206
|
-
cli_utilities_1.log.debug(`Processed ${installation.length} app installations
|
|
206
|
+
cli_utilities_1.log.debug(`Processed ${installation.length} app installations.`, this.exportConfig.context);
|
|
207
207
|
this.installedApps = this.installedApps.concat(installation);
|
|
208
208
|
if (count - (skip + 50) > 0) {
|
|
209
|
-
cli_utilities_1.log.debug(`Continuing to fetch apps with skip: ${skip + 50}
|
|
209
|
+
cli_utilities_1.log.debug(`Continuing to fetch apps with skip: ${skip + 50}.`, this.exportConfig.context);
|
|
210
210
|
await this.getStackSpecificApps(skip + 50);
|
|
211
211
|
}
|
|
212
212
|
else {
|
|
213
|
-
cli_utilities_1.log.debug('Completed fetching all stack-specific apps', this.exportConfig.context);
|
|
213
|
+
cli_utilities_1.log.debug('Completed fetching all stack-specific apps.', this.exportConfig.context);
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
}
|
|
@@ -10,23 +10,23 @@ class ExportPersonalize {
|
|
|
10
10
|
}
|
|
11
11
|
async start() {
|
|
12
12
|
try {
|
|
13
|
-
cli_utilities_1.log.debug('Starting
|
|
13
|
+
cli_utilities_1.log.debug('Starting export process for Personalize...', this.exportConfig.context);
|
|
14
14
|
if (!this.personalizeConfig.baseURL[this.exportConfig.region.name]) {
|
|
15
|
-
cli_utilities_1.log.debug(`Personalize URL not set for region: ${this.exportConfig.region.name}
|
|
15
|
+
cli_utilities_1.log.debug(`Personalize URL not set for region: '${this.exportConfig.region.name}'.`, this.exportConfig.context);
|
|
16
16
|
cli_utilities_1.log.info(cli_utilities_1.messageHandler.parse('PERSONALIZE_URL_NOT_SET'), this.exportConfig.context);
|
|
17
17
|
this.exportConfig.personalizationEnabled = false;
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
20
|
if (this.exportConfig.management_token) {
|
|
21
|
-
cli_utilities_1.log.debug('Management token detected, skipping personalize export', this.exportConfig.context);
|
|
21
|
+
cli_utilities_1.log.debug('Management token detected, skipping personalize export.', this.exportConfig.context);
|
|
22
22
|
cli_utilities_1.log.info(cli_utilities_1.messageHandler.parse('PERSONALIZE_SKIPPING_WITH_MANAGEMENT_TOKEN'), this.exportConfig.context);
|
|
23
23
|
this.exportConfig.personalizationEnabled = false;
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
cli_utilities_1.log.debug('Starting
|
|
26
|
+
cli_utilities_1.log.debug('Starting export process for personalization projects...', this.exportConfig.context);
|
|
27
27
|
await new cli_variants_1.ExportProjects(this.exportConfig).start();
|
|
28
28
|
if (this.exportConfig.personalizationEnabled) {
|
|
29
|
-
cli_utilities_1.log.debug('Personalization is enabled, processing personalize modules...', this.exportConfig.context);
|
|
29
|
+
cli_utilities_1.log.debug('Personalization is enabled, processing personalize modules... ' + this.exportConfig.modules.personalize.exportOrder.join(', '), this.exportConfig.context);
|
|
30
30
|
const moduleMapper = {
|
|
31
31
|
events: new cli_variants_1.ExportEvents(this.exportConfig),
|
|
32
32
|
attributes: new cli_variants_1.ExportAttributes(this.exportConfig),
|
|
@@ -35,32 +35,32 @@ class ExportPersonalize {
|
|
|
35
35
|
};
|
|
36
36
|
const order = this.exportConfig.modules.personalize
|
|
37
37
|
.exportOrder;
|
|
38
|
-
cli_utilities_1.log.debug(`Personalize export order: ${order.join(', ')}
|
|
38
|
+
cli_utilities_1.log.debug(`Personalize export order: ${order.join(', ')}.`, this.exportConfig.context);
|
|
39
39
|
for (const module of order) {
|
|
40
|
-
cli_utilities_1.log.debug(`Processing
|
|
40
|
+
cli_utilities_1.log.debug(`Processing personalization module: '${module}'...`, this.exportConfig.context);
|
|
41
41
|
if (moduleMapper[module]) {
|
|
42
|
-
cli_utilities_1.log.debug(`Starting export for module: ${module}
|
|
42
|
+
cli_utilities_1.log.debug(`Starting export for module: '${module}'...`, this.exportConfig.context);
|
|
43
43
|
await moduleMapper[module].start();
|
|
44
|
-
cli_utilities_1.log.debug(`Completed export for module: ${module}
|
|
44
|
+
cli_utilities_1.log.debug(`Completed export for module: '${module}'.`, this.exportConfig.context);
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
47
|
-
cli_utilities_1.log.debug(`Module not implemented: ${module}
|
|
47
|
+
cli_utilities_1.log.debug(`Module not implemented: '${module}'.`, this.exportConfig.context);
|
|
48
48
|
cli_utilities_1.log.info(cli_utilities_1.messageHandler.parse('PERSONALIZE_MODULE_NOT_IMPLEMENTED', module), this.exportConfig.context);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
cli_utilities_1.log.debug('Completed all
|
|
51
|
+
cli_utilities_1.log.debug('Completed all personalization module exports.', this.exportConfig.context);
|
|
52
52
|
}
|
|
53
53
|
else {
|
|
54
|
-
cli_utilities_1.log.debug('Personalization is disabled, skipping personalize module exports', this.exportConfig.context);
|
|
54
|
+
cli_utilities_1.log.debug('Personalization is disabled, skipping personalize module exports.', this.exportConfig.context);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
catch (error) {
|
|
58
58
|
if (error === 'Forbidden') {
|
|
59
|
-
cli_utilities_1.log.debug('
|
|
59
|
+
cli_utilities_1.log.debug('Personalization access forbidden.', this.exportConfig.context);
|
|
60
60
|
cli_utilities_1.log.info(cli_utilities_1.messageHandler.parse('PERSONALIZE_NOT_ENABLED'), this.exportConfig.context);
|
|
61
61
|
}
|
|
62
62
|
else {
|
|
63
|
-
cli_utilities_1.log.debug('
|
|
63
|
+
cli_utilities_1.log.debug('An error occurred during personalization export.', this.exportConfig.context);
|
|
64
64
|
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
|
|
65
65
|
}
|
|
66
66
|
this.exportConfig.personalizationEnabled = false;
|