@contentstack/cli-cm-import-setup 1.7.2 → 2.0.0-beta.1

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.
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
3
4
  const utils_1 = require("../../utils");
4
5
  const path_1 = require("path");
5
6
  const lodash_1 = require("lodash");
6
7
  const cli_utilities_1 = require("@contentstack/cli-utilities");
7
- class marketplaceAppImportSetup {
8
- constructor({ config, stackAPIClient, dependencies }) {
9
- this.config = config;
10
- if (this.config.context) {
11
- this.config.context.module = 'marketplace-apps';
12
- }
13
- this.stackAPIClient = stackAPIClient;
8
+ const base_setup_1 = tslib_1.__importDefault(require("./base-setup"));
9
+ const utils_2 = require("../../utils");
10
+ class marketplaceAppImportSetup extends base_setup_1.default {
11
+ constructor({ config, stackAPIClient }) {
12
+ super({ config, stackAPIClient, dependencies: [] });
13
+ this.currentModuleName = utils_2.MODULE_NAMES[utils_2.MODULE_CONTEXTS.MARKETPLACE_APPS];
14
14
  this.marketplaceAppsFilePath = (0, path_1.join)((0, cli_utilities_1.sanitizePath)(this.config.contentDir), 'marketplace_apps', 'marketplace_apps.json');
15
15
  this.marketplaceAppsConfig = config.modules['marketplace-apps'];
16
16
  this.marketplaceAppsUidMapperPath = (0, path_1.join)((0, cli_utilities_1.sanitizePath)(this.config.backupDir), 'mapper', 'marketplace_apps');
@@ -22,29 +22,47 @@ class marketplaceAppImportSetup {
22
22
  * @returns {Promise<void>}
23
23
  */
24
24
  async start() {
25
+ var _a, _b;
25
26
  try {
26
- if (!utils_1.fileHelper.fileExistsSync(this.marketplaceAppsFilePath)) {
27
- cli_utilities_1.log.info('No Marketplace apps found in the content folder.');
28
- return;
29
- }
30
- const sourceMarketplaceApps = await utils_1.fsUtil.readFile(this.marketplaceAppsFilePath);
27
+ const sourceMarketplaceApps = await this.withLoadingSpinner('MARKETPLACE APPS: Analyzing import data...', async () => {
28
+ return await utils_1.fsUtil.readFile(this.marketplaceAppsFilePath);
29
+ });
31
30
  if (!(0, lodash_1.isEmpty)(sourceMarketplaceApps)) {
32
- utils_1.fsUtil.makeDirectory(this.marketplaceAppsUidMapperPath); // Use fsUtil
31
+ const appsArray = Array.isArray(sourceMarketplaceApps) ? sourceMarketplaceApps : Object.values(sourceMarketplaceApps);
32
+ const progress = this.createNestedProgress(this.currentModuleName);
33
+ // Add processes
34
+ progress.addProcess(utils_2.PROCESS_NAMES.MARKETPLACE_APPS_MAPPER_GENERATION, 1);
35
+ progress.addProcess(utils_2.PROCESS_NAMES.MARKETPLACE_APPS_FETCH, appsArray.length);
36
+ // Create mapper directory
37
+ progress
38
+ .startProcess(utils_2.PROCESS_NAMES.MARKETPLACE_APPS_MAPPER_GENERATION)
39
+ .updateStatus(utils_2.PROCESS_STATUS.MARKETPLACE_APPS_MAPPER_GENERATION.GENERATING, utils_2.PROCESS_NAMES.MARKETPLACE_APPS_MAPPER_GENERATION);
40
+ utils_1.fsUtil.makeDirectory(this.marketplaceAppsUidMapperPath);
41
+ (_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.tick(true, 'mapper directory created', null, utils_2.PROCESS_NAMES.MARKETPLACE_APPS_MAPPER_GENERATION);
42
+ progress.completeProcess(utils_2.PROCESS_NAMES.MARKETPLACE_APPS_MAPPER_GENERATION, true);
43
+ // Fetch marketplace apps
44
+ progress
45
+ .startProcess(utils_2.PROCESS_NAMES.MARKETPLACE_APPS_FETCH)
46
+ .updateStatus(utils_2.PROCESS_STATUS.MARKETPLACE_APPS_FETCH.FETCHING, utils_2.PROCESS_NAMES.MARKETPLACE_APPS_FETCH);
33
47
  this.developerHubBaseUrl = this.config.developerHubBaseUrl || (await (0, cli_utilities_1.createDeveloperHubUrl)(this.config.host));
34
48
  // NOTE init marketplace app sdk
35
49
  const host = this.developerHubBaseUrl.split('://').pop();
36
50
  this.appSdk = await (0, cli_utilities_1.marketplaceSDKClient)({ host });
37
51
  const targetMarketplaceApps = await this.getMarketplaceApps();
52
+ (_b = this.progressManager) === null || _b === void 0 ? void 0 : _b.tick(true, 'marketplace apps fetched', null, utils_2.PROCESS_NAMES.MARKETPLACE_APPS_FETCH);
38
53
  this.createMapper(sourceMarketplaceApps, targetMarketplaceApps);
39
54
  await utils_1.fsUtil.writeFile((0, path_1.join)(this.marketplaceAppsUidMapperPath, 'uid-mapping.json'), this.marketplaceAppMapper);
40
- cli_utilities_1.log.success(`The required setup files for Marketplace apps have been generated successfully.`);
55
+ progress.completeProcess(utils_2.PROCESS_NAMES.MARKETPLACE_APPS_FETCH, true);
56
+ this.completeProgress(true);
57
+ (0, utils_1.log)(this.config, `The required setup files for Marketplace apps have been generated successfully.`, 'success');
41
58
  }
42
59
  else {
43
- cli_utilities_1.log.info('No Marketplace apps found in the content folder.');
60
+ (0, utils_1.log)(this.config, 'No Marketplace apps found in the content folder.', 'info');
44
61
  }
45
62
  }
46
63
  catch (error) {
47
- (0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.config.context), 'Error occurred while generating the Marketplace app mapper');
64
+ this.completeProgress(false, (error === null || error === void 0 ? void 0 : error.message) || 'Marketplace apps mapper generation failed');
65
+ (0, utils_1.log)(this.config, `Error occurred while generating the Marketplace app mapper: ${error.message}.`, 'error');
48
66
  }
49
67
  }
50
68
  async getMarketplaceApps() {
@@ -61,7 +79,9 @@ class marketplaceAppImportSetup {
61
79
  });
62
80
  }
63
81
  createMapper(sourceMarketplaceApps, targetMarketplaceApps) {
64
- sourceMarketplaceApps.forEach((sourceApp) => {
82
+ const appsArray = Array.isArray(sourceMarketplaceApps) ? sourceMarketplaceApps : Object.values(sourceMarketplaceApps);
83
+ appsArray.forEach((sourceApp) => {
84
+ var _a, _b;
65
85
  // Find matching target item based on manifest.name
66
86
  // TBD: This logic is not foolproof, need to find a better way to match source and target apps
67
87
  // Reason: While importing apps, if an app exist in the target with the same name, it will be a conflict and will not be imported
@@ -86,9 +106,11 @@ class marketplaceAppImportSetup {
86
106
  });
87
107
  }
88
108
  });
109
+ (_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.tick(true, `app: ${sourceAppName}`, null, utils_2.PROCESS_NAMES.MARKETPLACE_APPS_FETCH);
89
110
  }
90
111
  else {
91
- cli_utilities_1.log.info(`No matching Marketplace app found in the target stack with name ${sourceAppName}`);
112
+ (_b = this.progressManager) === null || _b === void 0 ? void 0 : _b.tick(false, `app: ${sourceAppName}`, 'Not found in target stack', utils_2.PROCESS_NAMES.MARKETPLACE_APPS_FETCH);
113
+ (0, utils_1.log)(this.config, `No matching Marketplace app found in the target stack with name ${sourceAppName}`, 'info');
92
114
  }
93
115
  });
94
116
  }
@@ -1,11 +1,9 @@
1
1
  /// <reference types="lodash" />
2
2
  import { ModuleClassParams } from '../../types';
3
- export default class TaxonomiesImportSetup {
4
- private config;
3
+ import BaseImportSetup from './base-setup';
4
+ export default class TaxonomiesImportSetup extends BaseImportSetup {
5
5
  private taxonomiesFilePath;
6
6
  private taxonomiesFolderPath;
7
- private stackAPIClient;
8
- private dependencies;
9
7
  private taxonomiesConfig;
10
8
  private termsSuccessPath;
11
9
  private taxSuccessPath;
@@ -16,7 +14,7 @@ export default class TaxonomiesImportSetup {
16
14
  taxonomiesMapper: Record<string, unknown>;
17
15
  termsMapper: Record<string, unknown>;
18
16
  masterLocaleFilePath: string;
19
- constructor({ config, stackAPIClient, dependencies }: ModuleClassParams);
17
+ constructor({ config, stackAPIClient }: ModuleClassParams);
20
18
  /**
21
19
  * Start the taxonomies import setup
22
20
  * This method reads the taxonomies from the content folder and generates a mapper file
@@ -26,12 +24,12 @@ export default class TaxonomiesImportSetup {
26
24
  /**
27
25
  * Setup taxonomies using legacy format (root-level taxonomy files)
28
26
  */
29
- setupTaxonomiesLegacy(taxonomies: any): Promise<void>;
27
+ setupTaxonomiesLegacy(taxonomies: any, progress: any): Promise<void>;
30
28
  /**
31
29
  * Setup taxonomies using locale-based format (taxonomies organized by locale)
32
30
  * For locale-based structure, we query the target stack for each taxonomy+locale combination
33
31
  */
34
- setupTaxonomiesByLocale(taxonomies: any): Promise<void>;
32
+ setupTaxonomiesByLocale(taxonomies: any, progress: any): Promise<void>;
35
33
  /**
36
34
  * Detect if locale-based folder structure exists
37
35
  * @returns {boolean} true if locale-based structure detected, false otherwise
@@ -6,17 +6,16 @@ const omit_1 = tslib_1.__importDefault(require("lodash/omit"));
6
6
  const isEmpty_1 = tslib_1.__importDefault(require("lodash/isEmpty"));
7
7
  const utils_1 = require("../../utils");
8
8
  const cli_utilities_1 = require("@contentstack/cli-utilities");
9
- class TaxonomiesImportSetup {
10
- constructor({ config, stackAPIClient, dependencies }) {
9
+ const base_setup_1 = tslib_1.__importDefault(require("./base-setup"));
10
+ const utils_2 = require("../../utils");
11
+ class TaxonomiesImportSetup extends base_setup_1.default {
12
+ constructor({ config, stackAPIClient }) {
11
13
  var _a, _b, _c;
14
+ super({ config, stackAPIClient, dependencies: [] });
12
15
  this.isLocaleBasedStructure = false;
13
16
  this.taxonomiesMapper = {};
14
17
  this.termsMapper = {};
15
- this.config = config;
16
- if (this.config.context) {
17
- this.config.context.module = 'taxonomies';
18
- }
19
- this.stackAPIClient = stackAPIClient;
18
+ this.currentModuleName = utils_2.MODULE_NAMES[utils_2.MODULE_CONTEXTS.TAXONOMIES];
20
19
  this.taxonomiesFolderPath = (0, path_1.join)((0, cli_utilities_1.sanitizePath)(this.config.contentDir), 'taxonomies');
21
20
  this.taxonomiesFilePath = (0, path_1.join)(this.taxonomiesFolderPath, 'taxonomies.json');
22
21
  this.taxonomiesConfig = config.modules.taxonomies;
@@ -35,58 +34,90 @@ class TaxonomiesImportSetup {
35
34
  * @returns {Promise<void>}
36
35
  */
37
36
  async start() {
37
+ var _a;
38
38
  try {
39
- const taxonomies = utils_1.fsUtil.readFile(this.taxonomiesFilePath);
39
+ const taxonomies = await this.withLoadingSpinner('TAXONOMIES: Analyzing import data...', async () => {
40
+ return utils_1.fsUtil.readFile(this.taxonomiesFilePath);
41
+ });
40
42
  if (!(0, isEmpty_1.default)(taxonomies)) {
41
- // 1. Detect locale-based structure
43
+ const taxonomiesArray = Object.values(taxonomies);
44
+ const progress = this.createNestedProgress(this.currentModuleName);
45
+ // Detect locale-based structure
42
46
  this.isLocaleBasedStructure = this.detectLocaleBasedStructure();
43
- // 2. Create mapper directory
47
+ // Add processes
48
+ progress.addProcess(utils_2.PROCESS_NAMES.TAXONOMIES_MAPPER_GENERATION, 1);
49
+ progress.addProcess(utils_2.PROCESS_NAMES.TAXONOMIES_FETCH, taxonomiesArray.length);
50
+ progress.addProcess(utils_2.PROCESS_NAMES.TAXONOMIES_TERMS_FETCH, taxonomiesArray.length);
51
+ // Create mapper directory
52
+ progress
53
+ .startProcess(utils_2.PROCESS_NAMES.TAXONOMIES_MAPPER_GENERATION)
54
+ .updateStatus(utils_2.PROCESS_STATUS.TAXONOMIES_MAPPER_GENERATION.GENERATING, utils_2.PROCESS_NAMES.TAXONOMIES_MAPPER_GENERATION);
44
55
  utils_1.fsUtil.makeDirectory(this.taxonomiesMapperDirPath);
45
56
  utils_1.fsUtil.makeDirectory(this.termsMapperDirPath);
57
+ (_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.tick(true, 'mapper directories created', null, utils_2.PROCESS_NAMES.TAXONOMIES_MAPPER_GENERATION);
58
+ progress.completeProcess(utils_2.PROCESS_NAMES.TAXONOMIES_MAPPER_GENERATION, true);
59
+ // Fetch taxonomies
60
+ progress
61
+ .startProcess(utils_2.PROCESS_NAMES.TAXONOMIES_FETCH)
62
+ .updateStatus(utils_2.PROCESS_STATUS.TAXONOMIES_FETCH.FETCHING, utils_2.PROCESS_NAMES.TAXONOMIES_FETCH);
46
63
  if (this.isLocaleBasedStructure) {
47
- cli_utilities_1.log.info('Detected locale-based folder structure for taxonomies');
48
- await this.setupTaxonomiesByLocale(taxonomies);
64
+ (0, utils_1.log)(this.config, 'Detected locale-based folder structure for taxonomies', 'info');
65
+ await this.setupTaxonomiesByLocale(taxonomies, progress);
49
66
  }
50
67
  else {
51
- cli_utilities_1.log.info('Using legacy folder structure for taxonomies');
52
- await this.setupTaxonomiesLegacy(taxonomies);
68
+ (0, utils_1.log)(this.config, 'Using legacy folder structure for taxonomies', 'info');
69
+ await this.setupTaxonomiesLegacy(taxonomies, progress);
53
70
  }
71
+ progress.completeProcess(utils_2.PROCESS_NAMES.TAXONOMIES_FETCH, true);
72
+ progress.completeProcess(utils_2.PROCESS_NAMES.TAXONOMIES_TERMS_FETCH, true);
54
73
  if (this.taxonomiesMapper !== undefined && !(0, isEmpty_1.default)(this.taxonomiesMapper)) {
55
74
  utils_1.fsUtil.writeFile(this.taxSuccessPath, this.taxonomiesMapper);
56
75
  }
57
76
  if (this.termsMapper !== undefined && !(0, isEmpty_1.default)(this.termsMapper)) {
58
77
  utils_1.fsUtil.writeFile(this.termsSuccessPath, this.termsMapper);
59
78
  }
60
- cli_utilities_1.log.success(`The required setup files for taxonomies have been generated successfully.`);
79
+ this.completeProgress(true);
80
+ (0, utils_1.log)(this.config, `The required setup files for taxonomies have been generated successfully.`, 'success');
61
81
  }
62
82
  else {
63
- cli_utilities_1.log.info('No taxonomies found in the content folder.');
83
+ (0, utils_1.log)(this.config, 'No taxonomies found in the content folder.', 'info');
64
84
  }
65
85
  }
66
86
  catch (error) {
67
- (0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.config.context), 'Error generating taxonomies mapper');
87
+ this.completeProgress(false, (error === null || error === void 0 ? void 0 : error.message) || 'Taxonomies mapper generation failed');
88
+ (0, utils_1.log)(this.config, `Error generating taxonomies mapper: ${error.message}`, 'error');
68
89
  }
69
90
  }
70
91
  /**
71
92
  * Setup taxonomies using legacy format (root-level taxonomy files)
72
93
  */
73
- async setupTaxonomiesLegacy(taxonomies) {
94
+ async setupTaxonomiesLegacy(taxonomies, progress) {
95
+ var _a, _b, _c, _d, _e;
74
96
  for (const taxonomy of Object.values(taxonomies)) {
75
- let targetTaxonomy = await this.getTaxonomies(taxonomy);
76
- if (!targetTaxonomy) {
77
- cli_utilities_1.log.info(`Taxonomies with uid '${taxonomy.uid}' not found in the stack!`);
78
- continue;
79
- }
80
- targetTaxonomy = this.sanitizeTaxonomyAttribs(targetTaxonomy);
81
- this.taxonomiesMapper[taxonomy.uid] = targetTaxonomy;
82
- const terms = await this.getAllTermsOfTaxonomy(targetTaxonomy);
83
- if (Array.isArray(terms) && terms.length > 0) {
84
- cli_utilities_1.log.info(`Terms found for taxonomy '${taxonomy.uid}', processing...`);
85
- const sanitizedTerms = this.sanitizeTermsAttribs(terms);
86
- this.termsMapper[taxonomy.uid] = sanitizedTerms;
97
+ try {
98
+ let targetTaxonomy = await this.getTaxonomies(taxonomy);
99
+ if (!targetTaxonomy) {
100
+ (_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.tick(false, `taxonomy: ${taxonomy.uid}`, 'Not found in stack', utils_2.PROCESS_NAMES.TAXONOMIES_FETCH);
101
+ (0, utils_1.log)(this.config, `Taxonomies with uid '${taxonomy.uid}' not found in the stack!`, 'info');
102
+ continue;
103
+ }
104
+ targetTaxonomy = this.sanitizeTaxonomyAttribs(targetTaxonomy);
105
+ this.taxonomiesMapper[taxonomy.uid] = targetTaxonomy;
106
+ (_b = this.progressManager) === null || _b === void 0 ? void 0 : _b.tick(true, `taxonomy: ${taxonomy.uid}`, null, utils_2.PROCESS_NAMES.TAXONOMIES_FETCH);
107
+ const terms = await this.getAllTermsOfTaxonomy(targetTaxonomy);
108
+ if (Array.isArray(terms) && terms.length > 0) {
109
+ (0, utils_1.log)(this.config, `Terms found for taxonomy '${taxonomy.uid}', processing...`, 'info');
110
+ const sanitizedTerms = this.sanitizeTermsAttribs(terms);
111
+ this.termsMapper[taxonomy.uid] = sanitizedTerms;
112
+ (_c = this.progressManager) === null || _c === void 0 ? void 0 : _c.tick(true, `terms: ${taxonomy.uid} (${terms.length})`, null, utils_2.PROCESS_NAMES.TAXONOMIES_TERMS_FETCH);
113
+ }
114
+ else {
115
+ (0, utils_1.log)(this.config, `No terms found for taxonomy '${taxonomy.uid}', skipping...`, 'info');
116
+ (_d = this.progressManager) === null || _d === void 0 ? void 0 : _d.tick(true, `terms: ${taxonomy.uid} (none)`, null, utils_2.PROCESS_NAMES.TAXONOMIES_TERMS_FETCH);
117
+ }
87
118
  }
88
- else {
89
- cli_utilities_1.log.info(`No terms found for taxonomy '${taxonomy.uid}', skipping...`);
119
+ catch (error) {
120
+ (_e = this.progressManager) === null || _e === void 0 ? void 0 : _e.tick(false, `taxonomy: ${taxonomy.uid}`, (error === null || error === void 0 ? void 0 : error.message) || 'Failed to fetch', utils_2.PROCESS_NAMES.TAXONOMIES_FETCH);
90
121
  }
91
122
  }
92
123
  }
@@ -94,29 +125,39 @@ class TaxonomiesImportSetup {
94
125
  * Setup taxonomies using locale-based format (taxonomies organized by locale)
95
126
  * For locale-based structure, we query the target stack for each taxonomy+locale combination
96
127
  */
97
- async setupTaxonomiesByLocale(taxonomies) {
128
+ async setupTaxonomiesByLocale(taxonomies, progress) {
129
+ var _a, _b, _c, _d, _e;
98
130
  const locales = this.loadAvailableLocales();
99
131
  for (const localeCode of Object.keys(locales)) {
100
- cli_utilities_1.log.info(`Processing taxonomies for locale: ${localeCode}`);
132
+ (0, utils_1.log)(this.config, `Processing taxonomies for locale: ${localeCode}`, 'info');
101
133
  for (const taxonomy of Object.values(taxonomies)) {
102
- // Query target stack for this taxonomy in this locale
103
- let targetTaxonomy = await this.getTaxonomies(taxonomy, localeCode);
104
- if (!targetTaxonomy) {
105
- cli_utilities_1.log.info(`Taxonomy '${taxonomy.uid}' not found in target stack for locale: ${localeCode}`);
106
- continue;
134
+ try {
135
+ // Query target stack for this taxonomy in this locale
136
+ let targetTaxonomy = await this.getTaxonomies(taxonomy, localeCode);
137
+ if (!targetTaxonomy) {
138
+ (_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.tick(false, `taxonomy: ${taxonomy.uid} (${localeCode})`, 'Not found in stack', utils_2.PROCESS_NAMES.TAXONOMIES_FETCH);
139
+ (0, utils_1.log)(this.config, `Taxonomy '${taxonomy.uid}' not found in target stack for locale: ${localeCode}`, 'info');
140
+ continue;
141
+ }
142
+ targetTaxonomy = this.sanitizeTaxonomyAttribs(targetTaxonomy);
143
+ // Store with composite key: taxonomyUID_locale
144
+ // const mapperKey = `${taxonomy.uid}_${localeCode}`; // TODO: Unsure about this required or not
145
+ this.taxonomiesMapper[taxonomy.uid] = targetTaxonomy;
146
+ (_b = this.progressManager) === null || _b === void 0 ? void 0 : _b.tick(true, `taxonomy: ${taxonomy.uid} (${localeCode})`, null, utils_2.PROCESS_NAMES.TAXONOMIES_FETCH);
147
+ const terms = await this.getAllTermsOfTaxonomy(targetTaxonomy, localeCode);
148
+ if (Array.isArray(terms) && terms.length > 0) {
149
+ (0, utils_1.log)(this.config, `Terms found for taxonomy '${taxonomy.uid} for locale: ${localeCode}', processing...`, 'info');
150
+ const sanitizedTerms = this.sanitizeTermsAttribs(terms);
151
+ this.termsMapper[taxonomy.uid] = sanitizedTerms;
152
+ (_c = this.progressManager) === null || _c === void 0 ? void 0 : _c.tick(true, `terms: ${taxonomy.uid} (${localeCode}, ${terms.length})`, null, utils_2.PROCESS_NAMES.TAXONOMIES_TERMS_FETCH);
153
+ }
154
+ else {
155
+ (0, utils_1.log)(this.config, `No terms found for taxonomy '${taxonomy.uid} for locale: ${localeCode}', skipping...`, 'info');
156
+ (_d = this.progressManager) === null || _d === void 0 ? void 0 : _d.tick(true, `terms: ${taxonomy.uid} (${localeCode}, none)`, null, utils_2.PROCESS_NAMES.TAXONOMIES_TERMS_FETCH);
157
+ }
107
158
  }
108
- targetTaxonomy = this.sanitizeTaxonomyAttribs(targetTaxonomy);
109
- // Store with composite key: taxonomyUID_locale
110
- // const mapperKey = `${taxonomy.uid}_${localeCode}`; // TODO: Unsure about this required or not
111
- this.taxonomiesMapper[taxonomy.uid] = targetTaxonomy;
112
- const terms = await this.getAllTermsOfTaxonomy(targetTaxonomy, localeCode);
113
- if (Array.isArray(terms) && terms.length > 0) {
114
- cli_utilities_1.log.info(`Terms found for taxonomy '${taxonomy.uid} for locale: ${localeCode}', processing...`);
115
- const sanitizedTerms = this.sanitizeTermsAttribs(terms);
116
- this.termsMapper[taxonomy.uid] = sanitizedTerms;
117
- }
118
- else {
119
- cli_utilities_1.log.info(`No terms found for taxonomy '${taxonomy.uid} for locale: ${localeCode}', skipping...`);
159
+ catch (error) {
160
+ (_e = this.progressManager) === null || _e === void 0 ? void 0 : _e.tick(false, `taxonomy: ${taxonomy.uid} (${localeCode})`, (error === null || error === void 0 ? void 0 : error.message) || 'Failed to fetch', utils_2.PROCESS_NAMES.TAXONOMIES_FETCH);
120
161
  }
121
162
  }
122
163
  }
@@ -130,10 +171,10 @@ class TaxonomiesImportSetup {
130
171
  const masterLocaleFolder = (0, path_1.join)(this.taxonomiesFolderPath, masterLocaleCode);
131
172
  // Check if master locale folder exists (indicates new locale-based structure)
132
173
  if (!utils_1.fileHelper.fileExistsSync(masterLocaleFolder)) {
133
- cli_utilities_1.log.info('No locale-based folder structure detected');
174
+ (0, utils_1.log)(this.config, 'No locale-based folder structure detected', 'info');
134
175
  return false;
135
176
  }
136
- cli_utilities_1.log.info('Locale-based folder structure detected');
177
+ (0, utils_1.log)(this.config, 'Locale-based folder structure detected', 'info');
137
178
  return true;
138
179
  }
139
180
  /**
@@ -150,17 +191,17 @@ class TaxonomiesImportSetup {
150
191
  // The file contains an object with UID as key, extract the code
151
192
  const firstLocale = Object.values(masterLocaleData)[0];
152
193
  if (firstLocale === null || firstLocale === void 0 ? void 0 : firstLocale.code) {
153
- cli_utilities_1.log.info(`Master locale loaded from file: ${firstLocale.code}`);
194
+ (0, utils_1.log)(this.config, `Master locale loaded from file: ${firstLocale.code}`, 'info');
154
195
  return firstLocale.code;
155
196
  }
156
197
  }
157
198
  catch (error) {
158
- cli_utilities_1.log.warn('Error reading master-locale.json, using fallback', { error });
199
+ (0, utils_1.log)(this.config, 'Error reading master-locale.json, using fallback', 'warn');
159
200
  }
160
201
  }
161
202
  // Fallback to config or default
162
203
  const fallbackCode = ((_a = this.config.master_locale) === null || _a === void 0 ? void 0 : _a.code) || 'en-us';
163
- cli_utilities_1.log.info(`Using fallback master locale: ${fallbackCode}`);
204
+ (0, utils_1.log)(this.config, `Using fallback master locale: ${fallbackCode}`, 'info');
164
205
  return fallbackCode;
165
206
  }
166
207
  /**
@@ -174,7 +215,7 @@ class TaxonomiesImportSetup {
174
215
  locales[masterLocaleCode] = masterLocaleCode;
175
216
  // Then load additional locales from locales.json if it exists
176
217
  if (!utils_1.fileHelper.fileExistsSync(this.localesFilePath)) {
177
- cli_utilities_1.log.info('No locales file found, using only master locale');
218
+ (0, utils_1.log)(this.config, 'No locales file found, using only master locale', 'info');
178
219
  return locales;
179
220
  }
180
221
  try {
@@ -184,11 +225,11 @@ class TaxonomiesImportSetup {
184
225
  locales[locale.code] = locale.code;
185
226
  }
186
227
  }
187
- cli_utilities_1.log.info(`Loaded ${Object.keys(locales).length} locales (1 master + ${Object.keys(locales).length - 1} additional)`);
228
+ (0, utils_1.log)(this.config, `Loaded ${Object.keys(locales).length} locales (1 master + ${Object.keys(locales).length - 1} additional)`, 'info');
188
229
  return locales;
189
230
  }
190
231
  catch (error) {
191
- cli_utilities_1.log.error('Error loading locales file, using only master locale', { error });
232
+ (0, utils_1.log)(this.config, 'Error loading locales file, using only master locale', 'error');
192
233
  return locales;
193
234
  }
194
235
  }
@@ -270,10 +311,11 @@ class TaxonomiesImportSetup {
270
311
  const taxInfo = taxonomyUid ? ` (${taxonomyUid}${context})` : '';
271
312
  if ((err === null || err === void 0 ? void 0 : err.errorMessage) || (err === null || err === void 0 ? void 0 : err.message)) {
272
313
  const errorMsg = (err === null || err === void 0 ? void 0 : err.errorMessage) || ((_a = err === null || err === void 0 ? void 0 : err.errors) === null || _a === void 0 ? void 0 : _a.taxonomy) || ((_b = err === null || err === void 0 ? void 0 : err.errors) === null || _b === void 0 ? void 0 : _b.term) || (err === null || err === void 0 ? void 0 : err.message);
273
- cli_utilities_1.log.error(`${errorMsg}${taxInfo}`, { error: err, taxonomyUid, locale });
314
+ (0, utils_1.log)(this.config, `${errorMsg}${taxInfo}`, 'error');
274
315
  }
275
316
  else {
276
- cli_utilities_1.log.error(`Error fetching taxonomy data${taxInfo}!`, { error: err, taxonomyUid, locale });
317
+ (0, utils_1.log)(this.config, `Error fetching taxonomy data${taxInfo}!`, 'error');
318
+ (0, utils_1.log)(this.config, err, 'error');
277
319
  }
278
320
  }
279
321
  }
@@ -38,7 +38,6 @@ export default interface ImportConfig extends DefaultConfig, ExternalConfig {
38
38
  authtoken?: string;
39
39
  destinationStackName?: string;
40
40
  org_uid?: string;
41
- contentVersion: number;
42
41
  stackName?: string;
43
42
  branchName: string;
44
43
  selectedModules: Modules[];
@@ -46,6 +45,7 @@ export default interface ImportConfig extends DefaultConfig, ExternalConfig {
46
45
  backupDir: string;
47
46
  createBackupDir?: string;
48
47
  region: any;
48
+ authenticationMethod?: string;
49
49
  }
50
50
  type branch = {
51
51
  uid: string;
@@ -115,5 +115,12 @@ export type TaxonomyQueryParams = {
115
115
  locale?: string;
116
116
  };
117
117
  export interface Context {
118
+ command: string;
118
119
  module: string;
120
+ userId: string | undefined;
121
+ email: string | undefined;
122
+ sessionId: string | undefined;
123
+ apiKey: string;
124
+ orgId: string;
125
+ authenticationMethod?: string;
119
126
  }
@@ -0,0 +1,39 @@
1
+ export declare const PROCESS_NAMES: {
2
+ readonly ENTRIES_MAPPER_GENERATION: "Mapper Generation";
3
+ readonly CONTENT_TYPES_MAPPER_GENERATION: "Mapper Generation";
4
+ readonly CONTENT_TYPES_DEPENDENCY_SETUP: "Dependency Setup";
5
+ readonly GLOBAL_FIELDS_MAPPER_GENERATION: "Mapper Generation";
6
+ readonly GLOBAL_FIELDS_DEPENDENCY_SETUP: "Dependency Setup";
7
+ readonly EXTENSIONS_MAPPER_GENERATION: "Mapper Generation";
8
+ readonly ASSETS_MAPPER_GENERATION: "Mapper Generation";
9
+ readonly ASSETS_FETCH_AND_MAP: "Fetch and Map";
10
+ readonly CUSTOM_ROLES_MAPPER_GENERATION: "Mapper Generation";
11
+ readonly MARKETPLACE_APPS_MAPPER_GENERATION: "Mapper Generation";
12
+ readonly MARKETPLACE_APPS_FETCH: "Fetch Apps";
13
+ readonly TAXONOMIES_MAPPER_GENERATION: "Mapper Generation";
14
+ readonly TAXONOMIES_FETCH: "Fetch Taxonomies";
15
+ readonly TAXONOMIES_TERMS_FETCH: "Fetch Terms";
16
+ };
17
+ export declare const MODULE_CONTEXTS: {
18
+ readonly ENTRIES: "entries";
19
+ readonly CONTENT_TYPES: "content-types";
20
+ readonly GLOBAL_FIELDS: "global-fields";
21
+ readonly EXTENSIONS: "extensions";
22
+ readonly ASSETS: "assets";
23
+ readonly CUSTOM_ROLES: "custom-roles";
24
+ readonly MARKETPLACE_APPS: "marketplace-apps";
25
+ readonly TAXONOMIES: "taxonomies";
26
+ };
27
+ export declare const MODULE_NAMES: {
28
+ readonly entries: "Entries";
29
+ readonly "content-types": "Content Types";
30
+ readonly "global-fields": "Global Fields";
31
+ readonly extensions: "Extensions";
32
+ readonly assets: "Assets";
33
+ readonly "custom-roles": "Custom Roles";
34
+ readonly "marketplace-apps": "Marketplace Apps";
35
+ readonly taxonomies: "Taxonomies";
36
+ };
37
+ export declare const PROCESS_STATUS: Record<keyof typeof PROCESS_NAMES, Record<string, string>>;
38
+ export type ImportSetupProcessName = (typeof PROCESS_NAMES)[keyof typeof PROCESS_NAMES];
39
+ export type ImportSetupModuleContext = (typeof MODULE_CONTEXTS)[keyof typeof MODULE_CONTEXTS];
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PROCESS_STATUS = exports.MODULE_NAMES = exports.MODULE_CONTEXTS = exports.PROCESS_NAMES = void 0;
4
+ exports.PROCESS_NAMES = {
5
+ // Entries module
6
+ ENTRIES_MAPPER_GENERATION: 'Mapper Generation',
7
+ // Content Types module
8
+ CONTENT_TYPES_MAPPER_GENERATION: 'Mapper Generation',
9
+ CONTENT_TYPES_DEPENDENCY_SETUP: 'Dependency Setup',
10
+ // Global Fields module
11
+ GLOBAL_FIELDS_MAPPER_GENERATION: 'Mapper Generation',
12
+ GLOBAL_FIELDS_DEPENDENCY_SETUP: 'Dependency Setup',
13
+ // Extensions module
14
+ EXTENSIONS_MAPPER_GENERATION: 'Mapper Generation',
15
+ // Assets module
16
+ ASSETS_MAPPER_GENERATION: 'Mapper Generation',
17
+ ASSETS_FETCH_AND_MAP: 'Fetch and Map',
18
+ // Custom Roles module
19
+ CUSTOM_ROLES_MAPPER_GENERATION: 'Mapper Generation',
20
+ // Marketplace Apps module
21
+ MARKETPLACE_APPS_MAPPER_GENERATION: 'Mapper Generation',
22
+ MARKETPLACE_APPS_FETCH: 'Fetch Apps',
23
+ // Taxonomies module
24
+ TAXONOMIES_MAPPER_GENERATION: 'Mapper Generation',
25
+ TAXONOMIES_FETCH: 'Fetch Taxonomies',
26
+ TAXONOMIES_TERMS_FETCH: 'Fetch Terms',
27
+ };
28
+ exports.MODULE_CONTEXTS = {
29
+ ENTRIES: 'entries',
30
+ CONTENT_TYPES: 'content-types',
31
+ GLOBAL_FIELDS: 'global-fields',
32
+ EXTENSIONS: 'extensions',
33
+ ASSETS: 'assets',
34
+ CUSTOM_ROLES: 'custom-roles',
35
+ MARKETPLACE_APPS: 'marketplace-apps',
36
+ TAXONOMIES: 'taxonomies',
37
+ };
38
+ // Display names for modules to avoid scattering user-facing strings
39
+ exports.MODULE_NAMES = {
40
+ [exports.MODULE_CONTEXTS.ENTRIES]: 'Entries',
41
+ [exports.MODULE_CONTEXTS.CONTENT_TYPES]: 'Content Types',
42
+ [exports.MODULE_CONTEXTS.GLOBAL_FIELDS]: 'Global Fields',
43
+ [exports.MODULE_CONTEXTS.EXTENSIONS]: 'Extensions',
44
+ [exports.MODULE_CONTEXTS.ASSETS]: 'Assets',
45
+ [exports.MODULE_CONTEXTS.CUSTOM_ROLES]: 'Custom Roles',
46
+ [exports.MODULE_CONTEXTS.MARKETPLACE_APPS]: 'Marketplace Apps',
47
+ [exports.MODULE_CONTEXTS.TAXONOMIES]: 'Taxonomies',
48
+ };
49
+ exports.PROCESS_STATUS = {
50
+ // Entries
51
+ ENTRIES_MAPPER_GENERATION: {
52
+ GENERATING: 'Generating mapper files...',
53
+ FAILED: 'Failed to generate mapper files.',
54
+ },
55
+ // Content Types
56
+ CONTENT_TYPES_MAPPER_GENERATION: {
57
+ GENERATING: 'Generating mapper files...',
58
+ FAILED: 'Failed to generate mapper files.',
59
+ },
60
+ CONTENT_TYPES_DEPENDENCY_SETUP: {
61
+ SETTING_UP: 'Setting up dependencies...',
62
+ FAILED: 'Failed to setup dependencies.',
63
+ },
64
+ // Global Fields
65
+ GLOBAL_FIELDS_MAPPER_GENERATION: {
66
+ GENERATING: 'Generating mapper files...',
67
+ FAILED: 'Failed to generate mapper files.',
68
+ },
69
+ GLOBAL_FIELDS_DEPENDENCY_SETUP: {
70
+ SETTING_UP: 'Setting up dependencies...',
71
+ FAILED: 'Failed to setup dependencies.',
72
+ },
73
+ // Extensions
74
+ EXTENSIONS_MAPPER_GENERATION: {
75
+ GENERATING: 'Generating mapper files...',
76
+ FAILED: 'Failed to generate mapper files.',
77
+ },
78
+ // Assets
79
+ ASSETS_MAPPER_GENERATION: {
80
+ GENERATING: 'Generating mapper files...',
81
+ FAILED: 'Failed to generate mapper files.',
82
+ },
83
+ ASSETS_FETCH_AND_MAP: {
84
+ FETCHING: 'Fetching and mapping assets...',
85
+ FAILED: 'Failed to fetch and map assets.',
86
+ },
87
+ // Custom Roles
88
+ CUSTOM_ROLES_MAPPER_GENERATION: {
89
+ GENERATING: 'Generating mapper files...',
90
+ FAILED: 'Failed to generate mapper files.',
91
+ },
92
+ // Marketplace Apps
93
+ MARKETPLACE_APPS_MAPPER_GENERATION: {
94
+ GENERATING: 'Generating mapper files...',
95
+ FAILED: 'Failed to generate mapper files.',
96
+ },
97
+ MARKETPLACE_APPS_FETCH: {
98
+ FETCHING: 'Fetching marketplace apps...',
99
+ FAILED: 'Failed to fetch marketplace apps.',
100
+ },
101
+ // Taxonomies
102
+ TAXONOMIES_MAPPER_GENERATION: {
103
+ GENERATING: 'Generating mapper files...',
104
+ FAILED: 'Failed to generate mapper files.',
105
+ },
106
+ TAXONOMIES_FETCH: {
107
+ FETCHING: 'Fetching taxonomies...',
108
+ FAILED: 'Failed to fetch taxonomies.',
109
+ },
110
+ TAXONOMIES_TERMS_FETCH: {
111
+ FETCHING: 'Fetching terms...',
112
+ FAILED: 'Failed to fetch terms.',
113
+ },
114
+ };
@@ -5,7 +5,6 @@ const merge_1 = tslib_1.__importDefault(require("merge"));
5
5
  const path = tslib_1.__importStar(require("path"));
6
6
  const cli_utilities_1 = require("@contentstack/cli-utilities");
7
7
  const config_1 = tslib_1.__importDefault(require("../config"));
8
- const file_helper_1 = require("./file-helper");
9
8
  const interactive_1 = require("./interactive");
10
9
  const login_handler_1 = tslib_1.__importDefault(require("./login-handler"));
11
10
  const setupConfig = async (importCmdFlags) => {
@@ -32,13 +31,6 @@ const setupConfig = async (importCmdFlags) => {
32
31
  config.contentDir = path.resolve(config.contentDir);
33
32
  //Note to support the old key
34
33
  config.data = config.contentDir;
35
- if ((0, file_helper_1.fileExistsSync)(path.join(config.contentDir, 'export-info.json'))) {
36
- config.contentVersion =
37
- ((await (0, file_helper_1.readFile)(path.join(config.contentDir, 'export-info.json'))) || {}).contentVersion || 2;
38
- }
39
- else {
40
- config.contentVersion = 1;
41
- }
42
34
  const managementTokenAlias = importCmdFlags['management-token-alias'] || importCmdFlags['alias'];
43
35
  if (managementTokenAlias) {
44
36
  const { token, apiKey } = (_a = cli_utilities_1.configHandler.get(`tokens.${managementTokenAlias}`)) !== null && _a !== void 0 ? _a : {};
@@ -7,3 +7,4 @@ export { log, unlinkFileLogger } from './logger';
7
7
  export * from './log';
8
8
  export * from './common-helper';
9
9
  export { setupBranchConfig } from './setup-branch';
10
+ export { MODULE_CONTEXTS, MODULE_NAMES, PROCESS_NAMES, PROCESS_STATUS } from './constants';