@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.
Files changed (43) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +11 -65
  3. package/lib/commands/cm/stacks/export.d.ts +0 -1
  4. package/lib/commands/cm/stacks/export.js +12 -37
  5. package/lib/config/index.js +7 -0
  6. package/lib/constants/index.d.ts +57 -0
  7. package/lib/constants/index.js +59 -0
  8. package/lib/export/module-exporter.js +3 -2
  9. package/lib/export/modules/assets.js +5 -5
  10. package/lib/export/modules/base-class.d.ts +17 -0
  11. package/lib/export/modules/base-class.js +29 -1
  12. package/lib/export/modules/composable-studio.d.ts +15 -0
  13. package/lib/export/modules/composable-studio.js +87 -0
  14. package/lib/export/modules/content-types.js +6 -8
  15. package/lib/export/modules/custom-roles.js +2 -2
  16. package/lib/export/modules/entries.d.ts +1 -1
  17. package/lib/export/modules/entries.js +18 -19
  18. package/lib/export/modules/environments.js +2 -3
  19. package/lib/export/modules/extensions.js +2 -3
  20. package/lib/export/modules/global-fields.js +8 -5
  21. package/lib/export/modules/labels.js +2 -3
  22. package/lib/export/modules/locales.js +2 -3
  23. package/lib/export/modules/marketplace-apps.js +36 -25
  24. package/lib/export/modules/personalize.js +1 -2
  25. package/lib/export/modules/stack.js +29 -29
  26. package/lib/export/modules/taxonomies.d.ts +52 -8
  27. package/lib/export/modules/taxonomies.js +278 -104
  28. package/lib/export/modules/webhooks.js +2 -3
  29. package/lib/export/modules/workflows.js +3 -4
  30. package/lib/types/default-config.d.ts +6 -0
  31. package/lib/types/index.d.ts +27 -2
  32. package/lib/utils/basic-login.d.ts +1 -1
  33. package/lib/utils/basic-login.js +5 -5
  34. package/lib/utils/common-helper.d.ts +1 -1
  35. package/lib/utils/common-helper.js +4 -4
  36. package/lib/utils/export-config-handler.js +10 -13
  37. package/lib/utils/file-helper.js +1 -1
  38. package/lib/utils/logger.d.ts +1 -1
  39. package/lib/utils/logger.js +2 -2
  40. package/lib/utils/marketplace-app-helper.js +2 -4
  41. package/messages/index.json +73 -67
  42. package/oclif.manifest.json +4 -42
  43. package/package.json +18 -15
@@ -22,7 +22,7 @@ class ContentTypesExport extends base_class_1.default {
22
22
  }
23
23
  // Add after existing qs setup and before contentTypesDirPath
24
24
  this.applyQueryFilters(this.qs, 'content-types');
25
- this.contentTypesDirPath = path.resolve((0, cli_utilities_1.sanitizePath)(exportConfig.data), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.contentTypesConfig.dirName));
25
+ this.contentTypesDirPath = path.resolve((0, cli_utilities_1.sanitizePath)(exportConfig.exportDir), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.contentTypesConfig.dirName));
26
26
  this.contentTypes = [];
27
27
  this.exportConfig.context.module = utils_1.MODULE_CONTEXTS.CONTENT_TYPES;
28
28
  this.currentModuleName = utils_1.MODULE_NAMES[utils_1.MODULE_CONTEXTS.CONTENT_TYPES];
@@ -39,17 +39,18 @@ class ContentTypesExport extends base_class_1.default {
39
39
  .find();
40
40
  return [countResponse.count || 0];
41
41
  });
42
+ // Create simple progress manager with total count
43
+ const progress = this.createSimpleProgress(this.currentModuleName, totalCount);
42
44
  if (totalCount === 0) {
43
45
  cli_utilities_1.log.info(cli_utilities_1.messageHandler.parse('CONTENT_TYPE_NO_TYPES'), this.exportConfig.context);
46
+ await this.writeContentTypes(this.contentTypes);
47
+ this.completeProgress(true);
44
48
  return;
45
49
  }
46
- // Create simple progress manager with total count
47
- const progress = this.createSimpleProgress(this.currentModuleName, totalCount);
48
50
  progress.updateStatus('Fetching content types...');
49
51
  await this.getContentTypes();
50
52
  await this.writeContentTypes(this.contentTypes);
51
- cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('CONTENT_TYPE_EXPORT_COMPLETE'), this.exportConfig.context);
52
- this.completeProgress(true);
53
+ this.completeProgressWithMessage();
53
54
  }
54
55
  catch (error) {
55
56
  (0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
@@ -104,9 +105,6 @@ class ContentTypesExport extends base_class_1.default {
104
105
  await (0, utils_1.executeTask)(contentTypes, writeWithProgress.bind(this), {
105
106
  concurrency: this.exportConfig.writeConcurrency,
106
107
  });
107
- const schemaFilePath = path.join(this.contentTypesDirPath, 'schema.json');
108
- cli_utilities_1.log.debug(`Writing aggregate schema to: ${schemaFilePath}`, this.exportConfig.context);
109
- return utils_1.fsUtil.writeFile(schemaFilePath, contentTypes);
110
108
  }
111
109
  }
112
110
  exports.default = ContentTypesExport;
@@ -25,7 +25,7 @@ class ExportCustomRoles extends base_class_1.default {
25
25
  cli_utilities_1.log.debug('Starting custom roles export process...', this.exportConfig.context);
26
26
  const [totalRoles, totalLocales] = await this.withLoadingSpinner('CUSTOM-ROLES: Analyzing roles and locales...', async () => {
27
27
  var _a;
28
- this.rolesFolderPath = (0, node_path_1.resolve)(this.exportConfig.data, this.exportConfig.branchName || '', this.customRolesConfig.dirName);
28
+ this.rolesFolderPath = (0, node_path_1.resolve)(this.exportConfig.exportDir, this.exportConfig.branchName || '', this.customRolesConfig.dirName);
29
29
  await utils_1.fsUtil.makeDirectory(this.rolesFolderPath);
30
30
  this.customRolesLocalesFilepath = (0, node_path_1.resolve)(this.rolesFolderPath, this.customRolesConfig.customRolesLocalesFileName);
31
31
  // Get counts for progress tracking
@@ -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.completeProgress(true);
63
+ this.completeProgressWithMessage();
64
64
  }
65
65
  catch (error) {
66
66
  (0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
@@ -7,7 +7,7 @@ export default class EntriesExport extends BaseClass {
7
7
  private variantEntries;
8
8
  private entriesDirPath;
9
9
  private localesFilePath;
10
- private schemaFilePath;
10
+ private contentTypesDirPath;
11
11
  private entriesFileHelper;
12
12
  private projectInstance;
13
13
  exportVariantEntry: boolean;
@@ -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, cli_utilities_2.sanitizePath)(exportConfig.data), (0, cli_utilities_2.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_2.sanitizePath)(this.entriesConfig.dirName));
18
- this.localesFilePath = path.resolve((0, cli_utilities_2.sanitizePath)(exportConfig.data), (0, cli_utilities_2.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_2.sanitizePath)(exportConfig.modules.locales.dirName), (0, cli_utilities_2.sanitizePath)(exportConfig.modules.locales.fileName));
19
- this.schemaFilePath = path.resolve((0, cli_utilities_2.sanitizePath)(exportConfig.data), (0, cli_utilities_2.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_2.sanitizePath)(exportConfig.modules.content_types.dirName), 'schema.json');
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.contentTypesDirPath = 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));
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];
@@ -28,7 +28,7 @@ class EntriesExport extends base_class_1.default {
28
28
  // Initial analysis with loading spinner
29
29
  const [locales, contentTypes, entryRequestOptions, totalEntriesCount, variantInfo] = await this.withLoadingSpinner('ENTRIES: Analyzing content structure and entries...', async () => {
30
30
  const locales = utils_1.fsUtil.readFile(this.localesFilePath);
31
- const contentTypes = utils_1.fsUtil.readFile(this.schemaFilePath);
31
+ const contentTypes = (0, cli_utilities_1.readContentTypeSchemas)(this.contentTypesDirPath);
32
32
  if (!Array.isArray(locales) || (locales === null || locales === void 0 ? void 0 : locales.length) === 0) {
33
33
  cli_utilities_1.log.debug(`No locales found in ${this.localesFilePath}`, this.exportConfig.context);
34
34
  }
@@ -39,7 +39,7 @@ class EntriesExport extends base_class_1.default {
39
39
  cli_utilities_1.log.info(cli_utilities_1.messageHandler.parse('CONTENT_TYPE_NO_TYPES'), this.exportConfig.context);
40
40
  return [locales, contentTypes, [], 0, null];
41
41
  }
42
- cli_utilities_1.log.debug(`Loaded ${contentTypes === null || contentTypes === void 0 ? void 0 : contentTypes.length} content types from ${this.schemaFilePath}`, this.exportConfig.context);
42
+ cli_utilities_1.log.debug(`Loaded ${contentTypes === null || contentTypes === void 0 ? void 0 : contentTypes.length} content types from individual files in ${this.contentTypesDirPath}`, this.exportConfig.context);
43
43
  // Create entry request objects
44
44
  const entryRequestOptions = this.createRequestObjects(locales, contentTypes);
45
45
  cli_utilities_1.log.debug(`Created ${entryRequestOptions.length} entry request objects for processing`, this.exportConfig.context);
@@ -86,8 +86,7 @@ class EntriesExport extends base_class_1.default {
86
86
  this.variantEntries.completeExport();
87
87
  }
88
88
  }
89
- this.completeProgress(true);
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, cli_utilities_2.sanitizePath)(this.entriesDirPath), (0, cli_utilities_2.sanitizePath)(options.contentType), (0, cli_utilities_2.sanitizePath)(options.locale));
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: 'index.json',
213
+ indexFileName: constants_1.PATH_CONSTANTS.FILES.INDEX,
215
214
  basePath: entryBasePath,
216
215
  chunkFileSize: this.entriesConfig.chunkFileSize,
217
216
  keepMetadata: false,
@@ -219,7 +218,7 @@ class EntriesExport extends base_class_1.default {
219
218
  });
220
219
  cli_utilities_1.log.debug('Initialized FsUtility for writing entries', this.exportConfig.context);
221
220
  }
222
- cli_utilities_1.log.debug(`Writing ${entriesSearchResponse.items.length} entries to file`, this.exportConfig.context);
221
+ cli_utilities_1.log.debug(`Writing ${entriesSearchResponse.items.length} entries to file...`, this.exportConfig.context);
223
222
  this.entriesFileHelper.writeIntoFile(entriesSearchResponse.items, { mapKeyVal: true });
224
223
  // Track progress for individual entries
225
224
  entriesSearchResponse.items.forEach((entry) => {
@@ -227,9 +226,9 @@ class EntriesExport extends base_class_1.default {
227
226
  (_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.tick(true, `entry: ${entry.uid}`, null, utils_1.PROCESS_NAMES.ENTRIES);
228
227
  });
229
228
  if (this.entriesConfig.exportVersions) {
230
- cli_utilities_1.log.debug('Exporting entry versions is enabled', this.exportConfig.context);
231
- let versionedEntryPath = path.join((0, cli_utilities_2.sanitizePath)(this.entriesDirPath), (0, cli_utilities_2.sanitizePath)(options.contentType), (0, cli_utilities_2.sanitizePath)(options.locale), 'versions');
232
- cli_utilities_1.log.debug(`Creating versioned entries directory at: ${versionedEntryPath}`, this.exportConfig.context);
229
+ cli_utilities_1.log.debug('Exporting entry versions is enabled.', this.exportConfig.context);
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');
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, {
235
234
  locale: options.locale,
@@ -269,10 +268,10 @@ class EntriesExport extends base_class_1.default {
269
268
  }
270
269
  }
271
270
  async fetchEntriesVersions(entries, options) {
272
- cli_utilities_1.log.debug(`Fetching versions for ${entries.length} entries`, this.exportConfig.context);
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, cli_utilities_2.sanitizePath)(options.versionedEntryPath), (0, cli_utilities_2.sanitizePath)(`${entry.uid}.json`));
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
@@ -305,7 +304,7 @@ class EntriesExport extends base_class_1.default {
305
304
  return new Promise(async (resolve, reject) => {
306
305
  return await this.getEntryByVersion(apiParams.queryParam, entry)
307
306
  .then((response) => {
308
- cli_utilities_1.log.debug(`Successfully fetched versions for entry: ${entry.uid}`, this.exportConfig.context);
307
+ cli_utilities_1.log.debug(`Successfully fetched versions for entry UID: ${entry.uid}`, this.exportConfig.context);
309
308
  apiParams.resolve({
310
309
  response,
311
310
  apiData: entry,
@@ -313,7 +312,7 @@ class EntriesExport extends base_class_1.default {
313
312
  resolve(true);
314
313
  })
315
314
  .catch((error) => {
316
- cli_utilities_1.log.debug(`Failed to fetch versions for entry: ${entry.uid}`, this.exportConfig.context);
315
+ cli_utilities_1.log.debug(`Failed to fetch versions for entry UID: ${entry.uid}`, this.exportConfig.context);
317
316
  apiParams.reject({
318
317
  error,
319
318
  apiData: entry,
@@ -330,7 +329,7 @@ class EntriesExport extends base_class_1.default {
330
329
  },
331
330
  version: entry._version,
332
331
  };
333
- cli_utilities_1.log.debug(`Fetching entry version ${entry._version} for uid: ${entry.uid}`, this.exportConfig.context);
332
+ cli_utilities_1.log.debug(`Fetching entry version ${entry._version} for entry UID: '${entry.uid}'.`, this.exportConfig.context);
334
333
  const entryResponse = await this.stackAPIClient
335
334
  .contentType(options.contentType)
336
335
  .entry(entry.uid)
@@ -21,7 +21,7 @@ class ExportEnvironments extends base_class_1.default {
21
21
  cli_utilities_1.log.debug('Starting environment export process...', this.exportConfig.context);
22
22
  // Setup with loading spinner
23
23
  const [totalCount] = await this.withLoadingSpinner('ENVIRONMENTS: Analyzing environments...', async () => {
24
- this.environmentsFolderPath = (0, node_path_1.resolve)(this.exportConfig.data, this.exportConfig.branchName || '', this.environmentConfig.dirName);
24
+ this.environmentsFolderPath = (0, node_path_1.resolve)(this.exportConfig.exportDir, this.exportConfig.branchName || '', this.environmentConfig.dirName);
25
25
  await utils_1.fsUtil.makeDirectory(this.environmentsFolderPath);
26
26
  cli_utilities_1.log.debug(`Environments folder path: ${this.environmentsFolderPath}`, this.exportConfig.context);
27
27
  // Get count for progress tracking
@@ -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.completeProgress(true);
51
+ this.completeProgressWithMessage();
53
52
  }
54
53
  catch (error) {
55
54
  (0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
@@ -22,7 +22,7 @@ class ExportExtensions extends base_class_1.default {
22
22
  cli_utilities_1.log.debug('Starting extensions export process...', this.exportConfig.context);
23
23
  // Setup with loading spinner
24
24
  const [totalCount] = await this.withLoadingSpinner('EXTENSIONS: Analyzing extensions...', async () => {
25
- this.extensionsFolderPath = (0, node_path_1.resolve)(this.exportConfig.data, this.exportConfig.branchName || '', this.extensionConfig.dirName);
25
+ this.extensionsFolderPath = (0, node_path_1.resolve)(this.exportConfig.exportDir, this.exportConfig.branchName || '', this.extensionConfig.dirName);
26
26
  await utils_1.fsUtil.makeDirectory(this.extensionsFolderPath);
27
27
  cli_utilities_1.log.debug(`Extensions folder path: ${this.extensionsFolderPath}`, this.exportConfig.context);
28
28
  // Get count for progress tracking
@@ -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.completeProgress(true);
52
+ this.completeProgressWithMessage();
54
53
  }
55
54
  catch (error) {
56
55
  (0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
@@ -17,7 +17,7 @@ class GlobalFieldsExport extends base_class_1.default {
17
17
  limit: this.globalFieldsConfig.limit,
18
18
  include_global_field_schema: true,
19
19
  };
20
- this.globalFieldsDirPath = path.resolve((0, cli_utilities_1.sanitizePath)(exportConfig.data), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.globalFieldsConfig.dirName));
20
+ this.globalFieldsDirPath = path.resolve((0, cli_utilities_1.sanitizePath)(exportConfig.exportDir), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.globalFieldsConfig.dirName));
21
21
  this.globalFields = [];
22
22
  this.applyQueryFilters(this.qs, 'global-fields');
23
23
  this.exportConfig.context.module = utils_1.MODULE_CONTEXTS.GLOBAL_FIELDS;
@@ -35,19 +35,22 @@ class GlobalFieldsExport extends base_class_1.default {
35
35
  .find();
36
36
  return [countResponse.count || 0];
37
37
  });
38
+ // Create simple progress manager for global fields
39
+ const progress = this.createSimpleProgress(this.currentModuleName, totalCount);
38
40
  if (totalCount === 0) {
39
41
  cli_utilities_1.log.info(cli_utilities_1.messageHandler.parse('GLOBAL_FIELDS_NOT_FOUND'), this.exportConfig.context);
42
+ const globalFieldsFilePath = path.join(this.globalFieldsDirPath, this.globalFieldsConfig.fileName);
43
+ cli_utilities_1.log.debug(`Writing global fields to: ${globalFieldsFilePath}`, this.exportConfig.context);
44
+ utils_1.fsUtil.writeFile(globalFieldsFilePath, this.globalFields);
45
+ this.completeProgress(true);
40
46
  return;
41
47
  }
42
- // Create simple progress manager for global fields
43
- const progress = this.createSimpleProgress(this.currentModuleName, totalCount);
44
48
  progress.updateStatus('Fetching global fields...');
45
49
  await this.getGlobalFields();
46
50
  const globalFieldsFilePath = path.join(this.globalFieldsDirPath, this.globalFieldsConfig.fileName);
47
51
  cli_utilities_1.log.debug(`Writing global fields to: ${globalFieldsFilePath}`, this.exportConfig.context);
48
52
  utils_1.fsUtil.writeFile(globalFieldsFilePath, this.globalFields);
49
- cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('GLOBAL_FIELDS_EXPORT_COMPLETE', this.globalFields.length), this.exportConfig.context);
50
- this.completeProgress(true);
53
+ this.completeProgressWithMessage();
51
54
  }
52
55
  catch (error) {
53
56
  cli_utilities_1.log.debug('Error occurred during global fields export', this.exportConfig.context);
@@ -21,7 +21,7 @@ class ExportLabels extends base_class_1.default {
21
21
  cli_utilities_1.log.debug('Starting labels export process...', this.exportConfig.context);
22
22
  // Setup with loading spinner
23
23
  const [totalCount] = await this.withLoadingSpinner('LABELS: Analyzing labels...', async () => {
24
- this.labelsFolderPath = (0, node_path_1.resolve)(this.exportConfig.data, this.exportConfig.branchName || '', this.labelConfig.dirName);
24
+ this.labelsFolderPath = (0, node_path_1.resolve)(this.exportConfig.exportDir, this.exportConfig.branchName || '', this.labelConfig.dirName);
25
25
  await utils_1.fsUtil.makeDirectory(this.labelsFolderPath);
26
26
  cli_utilities_1.log.debug(`Labels folder path: ${this.labelsFolderPath}`, this.exportConfig.context);
27
27
  // Get count for progress tracking
@@ -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.completeProgress(true);
51
+ this.completeProgressWithMessage();
53
52
  }
54
53
  catch (error) {
55
54
  (0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
@@ -18,7 +18,7 @@ class LocaleExport extends base_class_1.default {
18
18
  BASE: this.localeConfig.requiredKeys,
19
19
  },
20
20
  };
21
- this.localesPath = path.resolve((0, cli_utilities_1.sanitizePath)(exportConfig.data), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.localeConfig.dirName));
21
+ this.localesPath = path.resolve((0, cli_utilities_1.sanitizePath)(exportConfig.exportDir), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.localeConfig.dirName));
22
22
  this.locales = {};
23
23
  this.masterLocale = {};
24
24
  this.exportConfig.context.module = utils_1.MODULE_CONTEXTS.LOCALES;
@@ -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
- 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);
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.completeProgress(true);
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);
@@ -74,18 +73,18 @@ class ExportMarketplaceApps extends base_class_1.default {
74
73
  }
75
74
  }
76
75
  async setupPaths() {
77
- this.marketplaceAppPath = (0, node_path_1.resolve)(this.exportConfig.data, this.exportConfig.branchName || '', this.marketplaceAppConfig.dirName);
78
- cli_utilities_1.log.debug(`Marketplace apps folder path: ${this.marketplaceAppPath}`, this.exportConfig.context);
76
+ this.marketplaceAppPath = (0, node_path_1.resolve)(this.exportConfig.exportDir, this.exportConfig.branchName || '', this.marketplaceAppConfig.dirName);
77
+ cli_utilities_1.log.debug(`Marketplace apps folder path: '${this.marketplaceAppPath}'`, this.exportConfig.context);
79
78
  await utils_1.fsUtil.makeDirectory(this.marketplaceAppPath);
80
79
  cli_utilities_1.log.debug('Created marketplace apps directory', this.exportConfig.context);
81
80
  this.developerHubBaseUrl = this.exportConfig.developerHubBaseUrl || (await (0, utils_1.getDeveloperHubUrl)(this.exportConfig));
82
- cli_utilities_1.log.debug(`Developer hub base URL: ${this.developerHubBaseUrl}`, this.exportConfig.context);
81
+ cli_utilities_1.log.debug(`Developer hub base URL: '${this.developerHubBaseUrl}'`, this.exportConfig.context);
83
82
  this.exportConfig.org_uid = await (0, utils_1.getOrgUid)(this.exportConfig);
84
- this.query = { target_uids: this.exportConfig.source_stack };
85
- cli_utilities_1.log.debug(`Organization UID: ${this.exportConfig.org_uid}`, this.exportConfig.context);
83
+ this.query = { target_uids: this.exportConfig.apiKey };
84
+ cli_utilities_1.log.debug(`Organization UID: '${this.exportConfig.org_uid}'.`, this.exportConfig.context);
86
85
  // NOTE init marketplace app sdk
87
86
  const host = this.developerHubBaseUrl.split('://').pop();
88
- cli_utilities_1.log.debug(`Initializing marketplace SDK with host: ${host}`, this.exportConfig.context);
87
+ cli_utilities_1.log.debug(`Initializing Marketplace SDK with host: '${host}'...`, this.exportConfig.context);
89
88
  this.appSdk = await (0, cli_utilities_1.marketplaceSDKClient)({ host });
90
89
  }
91
90
  async getAppsCount() {
@@ -119,17 +118,28 @@ class ExportMarketplaceApps extends base_class_1.default {
119
118
  * library if it is available.
120
119
  */
121
120
  async exportApps() {
121
+ var _a, _b, _c, _d, _e;
122
122
  cli_utilities_1.log.debug('Starting apps export process...', this.exportConfig.context);
123
+ // Process external query if provided
124
+ const externalQuery = (_a = this.exportConfig.query) === null || _a === void 0 ? void 0 : _a.modules['marketplace-apps'];
125
+ if (externalQuery) {
126
+ if (((_c = (_b = externalQuery.app_uid) === null || _b === void 0 ? void 0 : _b.$in) === null || _c === void 0 ? void 0 : _c.length) > 0) {
127
+ this.query.app_uids = externalQuery.app_uid.$in.join(',');
128
+ }
129
+ if (((_e = (_d = externalQuery.installation_uid) === null || _d === void 0 ? void 0 : _d.$in) === null || _e === void 0 ? void 0 : _e.length) > 0) {
130
+ this.query.installation_uids = externalQuery.installation_uid.$in.join(',');
131
+ }
132
+ }
123
133
  await this.getStackSpecificApps();
124
134
  cli_utilities_1.log.debug(`Retrieved ${this.installedApps.length} stack-specific apps`, this.exportConfig.context);
125
135
  if (!this.nodeCrypto && (0, find_1.default)(this.installedApps, (app) => !(0, isEmpty_1.default)(app.configuration))) {
126
- cli_utilities_1.log.debug('Initializing NodeCrypto for app configuration encryption', this.exportConfig.context);
136
+ cli_utilities_1.log.debug('Initializing NodeCrypto for app configuration encryption...', this.exportConfig.context);
127
137
  this.nodeCrypto = await (0, utils_1.createNodeCryptoInstance)(this.exportConfig);
128
138
  }
129
139
  this.installedApps = (0, map_1.default)(this.installedApps, (app) => {
130
140
  var _a;
131
141
  if ((0, has_1.default)(app, 'configuration')) {
132
- 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);
142
+ 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);
133
143
  app['configuration'] = this.nodeCrypto.encrypt(app.configuration);
134
144
  }
135
145
  return app;
@@ -149,18 +159,18 @@ class ExportMarketplaceApps extends base_class_1.default {
149
159
  cli_utilities_1.log.debug(`Processing ${this.installedApps.length} installed apps`, this.exportConfig.context);
150
160
  for (const [index, app] of (0, entries_1.default)(this.installedApps)) {
151
161
  if (app.manifest.visibility === 'private') {
152
- cli_utilities_1.log.debug(`Processing private app manifest: ${app.manifest.name}`, this.exportConfig.context);
162
+ cli_utilities_1.log.debug(`Processing private app manifest: '${app.manifest.name}'...`, this.exportConfig.context);
153
163
  await this.getPrivateAppsManifest(+index, app);
154
164
  }
155
165
  }
156
166
  for (const [index, app] of (0, entries_1.default)(this.installedApps)) {
157
- cli_utilities_1.log.debug(`Processing app configurations: ${((_a = app.manifest) === null || _a === void 0 ? void 0 : _a.name) || app.uid}`, this.exportConfig.context);
167
+ 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);
158
168
  await this.getAppConfigurations(+index, app);
159
169
  // Track progress for each app processed
160
170
  (_b = this.progressManager) === null || _b === void 0 ? void 0 : _b.tick(true, `app: ${((_c = app.manifest) === null || _c === void 0 ? void 0 : _c.name) || app.uid}`, null, utils_1.PROCESS_NAMES.FETCH_CONFIG_MANIFEST);
161
171
  }
162
172
  const marketplaceAppsFilePath = (0, node_path_1.resolve)(this.marketplaceAppPath, this.marketplaceAppConfig.fileName);
163
- cli_utilities_1.log.debug(`Writing marketplace apps to: ${marketplaceAppsFilePath}`, this.exportConfig.context);
173
+ cli_utilities_1.log.debug(`Writing Marketplace Apps to: '${marketplaceAppsFilePath}'`, this.exportConfig.context);
164
174
  utils_1.fsUtil.writeFile(marketplaceAppsFilePath, this.installedApps);
165
175
  cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('MARKETPLACE_APPS_EXPORT_COMPLETE', Object.keys(this.installedApps || {}).length), this.exportConfig.context);
166
176
  }
@@ -175,17 +185,17 @@ class ExportMarketplaceApps extends base_class_1.default {
175
185
  * app's manifest.
176
186
  */
177
187
  async getPrivateAppsManifest(index, appInstallation) {
178
- cli_utilities_1.log.debug(`Fetching private app manifest for: ${appInstallation.manifest.name} (${appInstallation.manifest.uid})`, this.exportConfig.context);
188
+ cli_utilities_1.log.debug(`Fetching private app manifest for: '${appInstallation.manifest.name}' (${appInstallation.manifest.uid})`, this.exportConfig.context);
179
189
  const manifest = await this.appSdk
180
190
  .marketplace(this.exportConfig.org_uid)
181
191
  .app(appInstallation.manifest.uid)
182
192
  .fetch({ include_oauth: true })
183
193
  .catch((error) => {
184
- cli_utilities_1.log.debug(`Failed to fetch private app manifest for: ${appInstallation.manifest.name}`, this.exportConfig.context);
194
+ cli_utilities_1.log.debug(`Failed to fetch private app manifest for: '${appInstallation.manifest.name}'`, this.exportConfig.context);
185
195
  (0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context), cli_utilities_1.messageHandler.parse('MARKETPLACE_APP_MANIFEST_EXPORT_FAILED', appInstallation.manifest.name));
186
196
  });
187
197
  if (manifest) {
188
- cli_utilities_1.log.debug(`Successfully fetched private app manifest for: ${appInstallation.manifest.name}`, this.exportConfig.context);
198
+ cli_utilities_1.log.debug(`Successfully fetched private app manifest for: '${appInstallation.manifest.name}'`, this.exportConfig.context);
189
199
  this.installedApps[index].manifest = manifest;
190
200
  }
191
201
  }
@@ -204,7 +214,7 @@ class ExportMarketplaceApps extends base_class_1.default {
204
214
  const appName = (_a = appInstallation === null || appInstallation === void 0 ? void 0 : appInstallation.manifest) === null || _a === void 0 ? void 0 : _a.name;
205
215
  const appUid = (_b = appInstallation === null || appInstallation === void 0 ? void 0 : appInstallation.manifest) === null || _b === void 0 ? void 0 : _b.uid;
206
216
  const app = appName || appUid;
207
- cli_utilities_1.log.debug(`Fetching app configuration for: ${app}`, this.exportConfig.context);
217
+ cli_utilities_1.log.debug(`Fetching app configuration for: '${app}'...`, this.exportConfig.context);
208
218
  cli_utilities_1.log.info(cli_utilities_1.messageHandler.parse('MARKETPLACE_APP_CONFIG_EXPORT', app), this.exportConfig.context);
209
219
  await this.appSdk
210
220
  .marketplace(this.exportConfig.org_uid)
@@ -214,17 +224,18 @@ class ExportMarketplaceApps extends base_class_1.default {
214
224
  var _a;
215
225
  const { data, error } = result;
216
226
  if ((0, has_1.default)(data, 'server_configuration') || (0, has_1.default)(data, 'configuration')) {
217
- cli_utilities_1.log.debug(`Found configuration data for app: ${app}`, this.exportConfig.context);
227
+ cli_utilities_1.log.debug(`Found configuration data for app: '${app}'`, this.exportConfig.context);
218
228
  if (!this.nodeCrypto && ((0, has_1.default)(data, 'server_configuration') || (0, has_1.default)(data, 'configuration'))) {
229
+ cli_utilities_1.log.debug(`Initializing NodeCrypto for app: '${app}'...`, this.exportConfig.context);
219
230
  this.nodeCrypto = await (0, utils_1.createNodeCryptoInstance)(this.exportConfig);
220
231
  (_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.updateStatus(utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.FETCH_CONFIG_MANIFEST].PROCESSING, utils_1.PROCESS_NAMES.FETCH_CONFIG_MANIFEST);
221
232
  }
222
233
  if (!(0, isEmpty_1.default)(data === null || data === void 0 ? void 0 : data.configuration)) {
223
- cli_utilities_1.log.debug(`Encrypting configuration for app: ${app}`, this.exportConfig.context);
234
+ cli_utilities_1.log.debug(`Encrypting configuration for app: '${app}'...`, this.exportConfig.context);
224
235
  this.installedApps[index]['configuration'] = this.nodeCrypto.encrypt(data.configuration);
225
236
  }
226
237
  if (!(0, isEmpty_1.default)(data === null || data === void 0 ? void 0 : data.server_configuration)) {
227
- cli_utilities_1.log.debug(`Encrypting server configuration for app: ${app}`, this.exportConfig.context);
238
+ cli_utilities_1.log.debug(`Encrypting server configuration for app: '${app}'...`, this.exportConfig.context);
228
239
  this.installedApps[index]['server_configuration'] = this.nodeCrypto.encrypt(data.server_configuration);
229
240
  cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('MARKETPLACE_APP_CONFIG_SUCCESS', app), this.exportConfig.context);
230
241
  }
@@ -233,12 +244,12 @@ class ExportMarketplaceApps extends base_class_1.default {
233
244
  }
234
245
  }
235
246
  else if (error) {
236
- cli_utilities_1.log.debug(`Error in app configuration data for: ${app}`, this.exportConfig.context);
247
+ cli_utilities_1.log.debug(`Error in app configuration data for: '${app}'.`, this.exportConfig.context);
237
248
  (0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context), cli_utilities_1.messageHandler.parse('MARKETPLACE_APP_CONFIG_EXPORT_FAILED', app));
238
249
  }
239
250
  })
240
251
  .catch((error) => {
241
- cli_utilities_1.log.debug(`Failed to fetch app configuration for: ${app}`, this.exportConfig.context);
252
+ cli_utilities_1.log.debug(`Failed to fetch app configuration for: '${app}'.`, this.exportConfig.context);
242
253
  (0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context), cli_utilities_1.messageHandler.parse('MARKETPLACE_APP_CONFIG_EXPORT_FAILED', app));
243
254
  });
244
255
  }
@@ -256,7 +267,7 @@ class ExportMarketplaceApps extends base_class_1.default {
256
267
  .installation()
257
268
  .fetchAll(Object.assign(Object.assign({}, this.query), { skip }))
258
269
  .catch((error) => {
259
- cli_utilities_1.log.debug('Error occurred while fetching stack-specific apps', this.exportConfig.context);
270
+ cli_utilities_1.log.debug('An error occurred while fetching stack-specific apps.', this.exportConfig.context);
260
271
  (0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
261
272
  });
262
273
  if (collection) {
@@ -276,11 +287,11 @@ class ExportMarketplaceApps extends base_class_1.default {
276
287
  });
277
288
  this.installedApps = this.installedApps.concat(installation);
278
289
  if (count - (skip + 50) > 0) {
279
- cli_utilities_1.log.debug(`Continuing to fetch apps with skip: ${skip + 50}`, this.exportConfig.context);
290
+ cli_utilities_1.log.debug(`Continuing to fetch apps with skip: ${skip + 50}.`, this.exportConfig.context);
280
291
  await this.getStackSpecificApps(skip + 50);
281
292
  }
282
293
  else {
283
- cli_utilities_1.log.debug('Completed fetching all stack-specific apps', this.exportConfig.context);
294
+ cli_utilities_1.log.debug('Completed fetching all stack-specific apps.', this.exportConfig.context);
284
295
  }
285
296
  }
286
297
  }
@@ -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.completeProgress(true);
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') {