@contentstack/cli-cm-import 2.0.0-beta.6 → 2.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/commands/cm/stacks/import.js +4 -4
- package/lib/constants/index.d.ts +57 -0
- package/lib/constants/index.js +59 -0
- package/lib/import/modules/assets.js +18 -9
- package/lib/import/modules/base-class.d.ts +4 -5
- package/lib/import/modules/base-class.js +3 -2
- package/lib/import/modules/composable-studio.js +3 -2
- package/lib/import/modules/content-types.js +13 -14
- package/lib/import/modules/custom-roles.js +9 -8
- package/lib/import/modules/entries.js +24 -34
- package/lib/import/modules/environments.js +5 -4
- package/lib/import/modules/extensions.js +6 -5
- package/lib/import/modules/global-fields.js +7 -6
- package/lib/import/modules/labels.js +5 -4
- package/lib/import/modules/locales.js +5 -4
- package/lib/import/modules/marketplace-apps.js +3 -2
- package/lib/import/modules/stack.js +3 -2
- package/lib/import/modules/taxonomies.d.ts +26 -3
- package/lib/import/modules/taxonomies.js +179 -61
- package/lib/import/modules/variant-entries.js +2 -1
- package/lib/import/modules/webhooks.js +5 -4
- package/lib/import/modules/workflows.d.ts +1 -1
- package/lib/import/modules/workflows.js +5 -4
- package/lib/utils/common-helper.js +3 -2
- package/lib/utils/extension-helper.js +4 -3
- package/lib/utils/import-config-handler.js +0 -2
- package/oclif.manifest.json +1 -1
- package/package.json +7 -8
|
@@ -10,6 +10,7 @@ const tslib_1 = require("tslib");
|
|
|
10
10
|
const path = tslib_1.__importStar(require("path"));
|
|
11
11
|
const lodash_1 = require("lodash");
|
|
12
12
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
13
|
+
const constants_1 = require("../../constants");
|
|
13
14
|
const utils_1 = require("../../utils");
|
|
14
15
|
const base_class_1 = tslib_1.__importDefault(require("./base-class"));
|
|
15
16
|
const global_field_helper_1 = require("../../utils/global-field-helper");
|
|
@@ -27,13 +28,13 @@ class ImportGlobalFields extends base_class_1.default {
|
|
|
27
28
|
this.pendingGFs = [];
|
|
28
29
|
this.existingGFs = [];
|
|
29
30
|
this.reqConcurrency = this.gFsConfig.writeConcurrency || this.config.writeConcurrency;
|
|
30
|
-
this.gFsMapperPath = path.resolve((0, cli_utilities_1.sanitizePath)(this.config.contentDir),
|
|
31
|
+
this.gFsMapperPath = path.resolve((0, cli_utilities_1.sanitizePath)(this.config.contentDir), constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.GLOBAL_FIELDS);
|
|
31
32
|
this.gFsFolderPath = path.resolve((0, cli_utilities_1.sanitizePath)(this.config.contentDir), (0, cli_utilities_1.sanitizePath)(this.gFsConfig.dirName));
|
|
32
|
-
this.gFsFailsPath = path.resolve((0, cli_utilities_1.sanitizePath)(this.config.
|
|
33
|
-
this.gFsSuccessPath = path.resolve((0, cli_utilities_1.sanitizePath)(this.config.
|
|
34
|
-
this.gFsUidMapperPath = path.resolve((0, cli_utilities_1.sanitizePath)(this.config.
|
|
35
|
-
this.gFsPendingPath = path.resolve((0, cli_utilities_1.sanitizePath)(this.config.
|
|
36
|
-
this.marketplaceAppMapperPath = path.join((0, cli_utilities_1.sanitizePath)(this.config.
|
|
33
|
+
this.gFsFailsPath = path.resolve((0, cli_utilities_1.sanitizePath)(this.config.backupDir), constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.GLOBAL_FIELDS, constants_1.PATH_CONSTANTS.FILES.FAILS);
|
|
34
|
+
this.gFsSuccessPath = path.resolve((0, cli_utilities_1.sanitizePath)(this.config.backupDir), constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.GLOBAL_FIELDS, constants_1.PATH_CONSTANTS.FILES.SUCCESS);
|
|
35
|
+
this.gFsUidMapperPath = path.resolve((0, cli_utilities_1.sanitizePath)(this.config.backupDir), constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.GLOBAL_FIELDS, constants_1.PATH_CONSTANTS.FILES.UID_MAPPING);
|
|
36
|
+
this.gFsPendingPath = path.resolve((0, cli_utilities_1.sanitizePath)(this.config.backupDir), constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.GLOBAL_FIELDS, constants_1.PATH_CONSTANTS.FILES.PENDING_GLOBAL_FIELDS);
|
|
37
|
+
this.marketplaceAppMapperPath = path.join((0, cli_utilities_1.sanitizePath)(this.config.backupDir), constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.MARKETPLACE_APPS, constants_1.PATH_CONSTANTS.FILES.UID_MAPPING);
|
|
37
38
|
}
|
|
38
39
|
/**
|
|
39
40
|
* @method start
|
|
@@ -6,6 +6,7 @@ const node_path_1 = require("node:path");
|
|
|
6
6
|
const isEmpty_1 = tslib_1.__importDefault(require("lodash/isEmpty"));
|
|
7
7
|
const values_1 = tslib_1.__importDefault(require("lodash/values"));
|
|
8
8
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
9
|
+
const constants_1 = require("../../constants");
|
|
9
10
|
const utils_1 = require("../../utils");
|
|
10
11
|
const base_class_1 = tslib_1.__importDefault(require("./base-class"));
|
|
11
12
|
class ImportLabels extends base_class_1.default {
|
|
@@ -14,11 +15,11 @@ class ImportLabels extends base_class_1.default {
|
|
|
14
15
|
this.importConfig.context.module = utils_1.MODULE_CONTEXTS.LABELS;
|
|
15
16
|
this.currentModuleName = utils_1.MODULE_NAMES[utils_1.MODULE_CONTEXTS.LABELS];
|
|
16
17
|
this.labelsConfig = importConfig.modules.labels;
|
|
17
|
-
this.mapperDirPath = (0, node_path_1.join)(this.importConfig.backupDir,
|
|
18
|
+
this.mapperDirPath = (0, node_path_1.join)(this.importConfig.backupDir, constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.LABELS);
|
|
18
19
|
this.labelsFolderPath = (0, node_path_1.join)(this.importConfig.backupDir, this.labelsConfig.dirName);
|
|
19
|
-
this.labelUidMapperPath = (0, node_path_1.join)(this.mapperDirPath,
|
|
20
|
-
this.createdLabelPath = (0, node_path_1.join)(this.mapperDirPath,
|
|
21
|
-
this.labelFailsPath = (0, node_path_1.join)(this.mapperDirPath,
|
|
20
|
+
this.labelUidMapperPath = (0, node_path_1.join)(this.mapperDirPath, constants_1.PATH_CONSTANTS.FILES.UID_MAPPING);
|
|
21
|
+
this.createdLabelPath = (0, node_path_1.join)(this.mapperDirPath, constants_1.PATH_CONSTANTS.FILES.SUCCESS);
|
|
22
|
+
this.labelFailsPath = (0, node_path_1.join)(this.mapperDirPath, constants_1.PATH_CONSTANTS.FILES.FAILS);
|
|
22
23
|
this.labels = {};
|
|
23
24
|
this.failedLabel = [];
|
|
24
25
|
this.createdLabel = [];
|
|
@@ -10,6 +10,7 @@ const tslib_1 = require("tslib");
|
|
|
10
10
|
const path = tslib_1.__importStar(require("path"));
|
|
11
11
|
const lodash_1 = require("lodash");
|
|
12
12
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
13
|
+
const constants_1 = require("../../constants");
|
|
13
14
|
const base_class_1 = tslib_1.__importDefault(require("./base-class"));
|
|
14
15
|
const utils_1 = require("../../utils");
|
|
15
16
|
class ImportLocales extends base_class_1.default {
|
|
@@ -27,11 +28,11 @@ class ImportLocales extends base_class_1.default {
|
|
|
27
28
|
this.createdLocales = [];
|
|
28
29
|
this.failedLocales = [];
|
|
29
30
|
this.reqConcurrency = this.localeConfig.writeConcurrency || this.config.writeConcurrency;
|
|
30
|
-
this.langMapperPath = path.resolve((0, cli_utilities_1.sanitizePath)(this.config.
|
|
31
|
+
this.langMapperPath = path.resolve((0, cli_utilities_1.sanitizePath)(this.config.backupDir), constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.LANGUAGES);
|
|
31
32
|
this.langFolderPath = path.resolve((0, cli_utilities_1.sanitizePath)(this.config.contentDir), (0, cli_utilities_1.sanitizePath)(this.localeConfig.dirName));
|
|
32
|
-
this.langFailsPath = path.resolve((0, cli_utilities_1.sanitizePath)(this.config.
|
|
33
|
-
this.langSuccessPath = path.resolve((0, cli_utilities_1.sanitizePath)(this.config.
|
|
34
|
-
this.langUidMapperPath = path.resolve((0, cli_utilities_1.sanitizePath)(this.config.
|
|
33
|
+
this.langFailsPath = path.resolve((0, cli_utilities_1.sanitizePath)(this.config.backupDir), constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.LANGUAGES, constants_1.PATH_CONSTANTS.FILES.FAILS);
|
|
34
|
+
this.langSuccessPath = path.resolve((0, cli_utilities_1.sanitizePath)(this.config.backupDir), constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.LANGUAGES, constants_1.PATH_CONSTANTS.FILES.SUCCESS);
|
|
35
|
+
this.langUidMapperPath = path.resolve((0, cli_utilities_1.sanitizePath)(this.config.backupDir), constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.LANGUAGES, constants_1.PATH_CONSTANTS.FILES.UID_MAPPER);
|
|
35
36
|
}
|
|
36
37
|
async start() {
|
|
37
38
|
try {
|
|
@@ -13,6 +13,7 @@ const filter_1 = tslib_1.__importDefault(require("lodash/filter"));
|
|
|
13
13
|
const isEmpty_1 = tslib_1.__importDefault(require("lodash/isEmpty"));
|
|
14
14
|
const toLower_1 = tslib_1.__importDefault(require("lodash/toLower"));
|
|
15
15
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
16
|
+
const constants_1 = require("../../constants");
|
|
16
17
|
const interactive_1 = require("../../utils/interactive");
|
|
17
18
|
const utils_1 = require("../../utils");
|
|
18
19
|
const base_class_1 = tslib_1.__importDefault(require("./base-class"));
|
|
@@ -22,9 +23,9 @@ class ImportMarketplaceApps extends base_class_1.default {
|
|
|
22
23
|
this.importConfig.context.module = utils_1.MODULE_CONTEXTS.MARKETPLACE_APPS;
|
|
23
24
|
this.currentModuleName = utils_1.MODULE_NAMES[utils_1.MODULE_CONTEXTS.MARKETPLACE_APPS];
|
|
24
25
|
this.marketPlaceAppConfig = importConfig.modules.marketplace_apps;
|
|
25
|
-
this.mapperDirPath = (0, node_path_1.join)(this.importConfig.backupDir,
|
|
26
|
+
this.mapperDirPath = (0, node_path_1.join)(this.importConfig.backupDir, constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.MARKETPLACE_APPS);
|
|
26
27
|
this.marketPlaceFolderPath = (0, node_path_1.join)(this.importConfig.backupDir, this.marketPlaceAppConfig.dirName);
|
|
27
|
-
this.marketPlaceUidMapperPath = (0, node_path_1.join)(this.mapperDirPath,
|
|
28
|
+
this.marketPlaceUidMapperPath = (0, node_path_1.join)(this.mapperDirPath, constants_1.PATH_CONSTANTS.FILES.UID_MAPPING);
|
|
28
29
|
this.appNameMapping = {};
|
|
29
30
|
this.appUidMapping = {};
|
|
30
31
|
this.appOriginalName = undefined;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const node_path_1 = require("node:path");
|
|
5
5
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
6
|
+
const constants_1 = require("../../constants");
|
|
6
7
|
const base_class_1 = tslib_1.__importDefault(require("./base-class"));
|
|
7
8
|
const utils_1 = require("../../utils");
|
|
8
9
|
class ImportStack extends base_class_1.default {
|
|
@@ -12,8 +13,8 @@ class ImportStack extends base_class_1.default {
|
|
|
12
13
|
this.envUidMapper = {};
|
|
13
14
|
this.importConfig.context.module = utils_1.MODULE_CONTEXTS.STACK;
|
|
14
15
|
this.currentModuleName = utils_1.MODULE_NAMES[utils_1.MODULE_CONTEXTS.STACK];
|
|
15
|
-
this.stackSettingsPath = (0, node_path_1.join)(this.importConfig.backupDir,
|
|
16
|
-
this.envUidMapperPath = (0, node_path_1.join)(this.importConfig.backupDir,
|
|
16
|
+
this.stackSettingsPath = (0, node_path_1.join)(this.importConfig.backupDir, constants_1.PATH_CONSTANTS.CONTENT_DIRS.STACK, constants_1.PATH_CONSTANTS.FILES.SETTINGS);
|
|
17
|
+
this.envUidMapperPath = (0, node_path_1.join)(this.importConfig.backupDir, constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.ENVIRONMENTS, constants_1.PATH_CONSTANTS.FILES.UID_MAPPING);
|
|
17
18
|
}
|
|
18
19
|
/**
|
|
19
20
|
* @method start
|
|
@@ -10,6 +10,8 @@ export default class ImportTaxonomies extends BaseClass {
|
|
|
10
10
|
private termsMapperDirPath;
|
|
11
11
|
private termsSuccessPath;
|
|
12
12
|
private termsFailsPath;
|
|
13
|
+
private localesFilePath;
|
|
14
|
+
private isLocaleBasedStructure;
|
|
13
15
|
createdTaxonomies: Record<string, unknown>;
|
|
14
16
|
failedTaxonomies: Record<string, unknown>;
|
|
15
17
|
createdTerms: Record<string, Record<string, unknown>>;
|
|
@@ -26,13 +28,34 @@ export default class ImportTaxonomies extends BaseClass {
|
|
|
26
28
|
* @async
|
|
27
29
|
* @returns {Promise<any>} Promise<any>
|
|
28
30
|
*/
|
|
29
|
-
importTaxonomies(
|
|
31
|
+
importTaxonomies({ apiContent, localeCode }: {
|
|
32
|
+
apiContent: any[];
|
|
33
|
+
localeCode?: string;
|
|
34
|
+
}): Promise<void>;
|
|
30
35
|
/**
|
|
31
|
-
*
|
|
36
|
+
* Import taxonomies using legacy structure (taxonomies/{uid}.json)
|
|
37
|
+
*/
|
|
38
|
+
importTaxonomiesLegacy(): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Import taxonomies using locale-based structure (taxonomies/{locale}/{uid}.json)
|
|
41
|
+
*/
|
|
42
|
+
importTaxonomiesByLocale(): Promise<void>;
|
|
43
|
+
handleSuccess(apiData: any, locale?: string): void;
|
|
44
|
+
handleFailure(error: any, apiData: any, locale?: string): void;
|
|
45
|
+
/**
|
|
46
|
+
* @method serializeTaxonomy
|
|
32
47
|
* @param {ApiOptions} apiOptions ApiOptions
|
|
33
48
|
* @returns {ApiOptions} ApiOptions
|
|
34
49
|
*/
|
|
35
|
-
|
|
50
|
+
serializeTaxonomy(apiOptions: ApiOptions): ApiOptions;
|
|
51
|
+
loadTaxonomyFile(filePath: string): Record<string, unknown> | undefined;
|
|
52
|
+
findTaxonomyFilePath(taxonomyUID: string): string | undefined;
|
|
53
|
+
findTaxonomyInLocaleFolders(taxonomyUID: string): string | undefined;
|
|
54
|
+
loadAvailableLocales(): Record<string, string>;
|
|
55
|
+
/**
|
|
56
|
+
* Detect if locale-based folder structure exists (taxonomies/{locale}/{uid}.json)
|
|
57
|
+
*/
|
|
58
|
+
detectAndScanLocaleStructure(): boolean;
|
|
36
59
|
/**
|
|
37
60
|
* create taxonomies success and fail in (mapper/taxonomies)
|
|
38
61
|
* create terms success and fail in (mapper/taxonomies/terms)
|
|
@@ -5,11 +5,13 @@ const node_path_1 = require("node:path");
|
|
|
5
5
|
const values_1 = tslib_1.__importDefault(require("lodash/values"));
|
|
6
6
|
const isEmpty_1 = tslib_1.__importDefault(require("lodash/isEmpty"));
|
|
7
7
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
8
|
+
const constants_1 = require("../../constants");
|
|
8
9
|
const base_class_1 = tslib_1.__importDefault(require("./base-class"));
|
|
9
10
|
const utils_1 = require("../../utils");
|
|
10
11
|
class ImportTaxonomies extends base_class_1.default {
|
|
11
12
|
constructor({ importConfig, stackAPIClient }) {
|
|
12
13
|
super({ importConfig, stackAPIClient });
|
|
14
|
+
this.isLocaleBasedStructure = false;
|
|
13
15
|
this.createdTaxonomies = {};
|
|
14
16
|
this.failedTaxonomies = {};
|
|
15
17
|
this.createdTerms = {};
|
|
@@ -17,13 +19,14 @@ class ImportTaxonomies extends base_class_1.default {
|
|
|
17
19
|
this.importConfig.context.module = utils_1.MODULE_CONTEXTS.TAXONOMIES;
|
|
18
20
|
this.currentModuleName = utils_1.MODULE_NAMES[utils_1.MODULE_CONTEXTS.TAXONOMIES];
|
|
19
21
|
this.taxonomiesConfig = importConfig.modules.taxonomies;
|
|
20
|
-
this.taxonomiesMapperDirPath = (0, node_path_1.join)(importConfig.backupDir,
|
|
21
|
-
this.termsMapperDirPath = (0, node_path_1.join)(this.taxonomiesMapperDirPath,
|
|
22
|
-
this.taxonomiesFolderPath = (0, node_path_1.join)(importConfig.
|
|
23
|
-
this.taxSuccessPath = (0, node_path_1.join)(this.taxonomiesMapperDirPath,
|
|
24
|
-
this.taxFailsPath = (0, node_path_1.join)(this.taxonomiesMapperDirPath,
|
|
25
|
-
this.termsSuccessPath = (0, node_path_1.join)(this.termsMapperDirPath,
|
|
26
|
-
this.termsFailsPath = (0, node_path_1.join)(this.termsMapperDirPath,
|
|
22
|
+
this.taxonomiesMapperDirPath = (0, node_path_1.join)(importConfig.backupDir, constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.TAXONOMIES);
|
|
23
|
+
this.termsMapperDirPath = (0, node_path_1.join)(this.taxonomiesMapperDirPath, constants_1.PATH_CONSTANTS.MAPPER_MODULES.TAXONOMY_TERMS);
|
|
24
|
+
this.taxonomiesFolderPath = (0, node_path_1.join)(importConfig.contentDir, this.taxonomiesConfig.dirName);
|
|
25
|
+
this.taxSuccessPath = (0, node_path_1.join)(this.taxonomiesMapperDirPath, constants_1.PATH_CONSTANTS.FILES.SUCCESS);
|
|
26
|
+
this.taxFailsPath = (0, node_path_1.join)(this.taxonomiesMapperDirPath, constants_1.PATH_CONSTANTS.FILES.FAILS);
|
|
27
|
+
this.termsSuccessPath = (0, node_path_1.join)(this.termsMapperDirPath, constants_1.PATH_CONSTANTS.FILES.SUCCESS);
|
|
28
|
+
this.termsFailsPath = (0, node_path_1.join)(this.termsMapperDirPath, constants_1.PATH_CONSTANTS.FILES.FAILS);
|
|
29
|
+
this.localesFilePath = (0, node_path_1.join)(importConfig.backupDir, importConfig.modules.locales.dirName, importConfig.modules.locales.fileName);
|
|
27
30
|
}
|
|
28
31
|
/**
|
|
29
32
|
* @method start
|
|
@@ -37,11 +40,20 @@ class ImportTaxonomies extends base_class_1.default {
|
|
|
37
40
|
cli_utilities_1.log.info('No taxonomies found to import', this.importConfig.context);
|
|
38
41
|
return;
|
|
39
42
|
}
|
|
40
|
-
const progress = this.createSimpleProgress(this.currentModuleName, taxonomiesCount);
|
|
41
43
|
await this.prepareMapperDirectories();
|
|
44
|
+
// Check if locale-based structure exists before import
|
|
45
|
+
this.isLocaleBasedStructure = this.detectAndScanLocaleStructure();
|
|
46
|
+
const progress = this.createSimpleProgress(this.currentModuleName, taxonomiesCount);
|
|
42
47
|
progress.updateStatus(utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.TAXONOMIES_IMPORT].IMPORTING);
|
|
43
48
|
cli_utilities_1.log.debug('Starting taxonomies import', this.importConfig.context);
|
|
44
|
-
|
|
49
|
+
if (this.isLocaleBasedStructure) {
|
|
50
|
+
cli_utilities_1.log.debug('Detected locale-based folder structure for taxonomies', this.importConfig.context);
|
|
51
|
+
await this.importTaxonomiesByLocale();
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
cli_utilities_1.log.debug('Using legacy folder structure for taxonomies', this.importConfig.context);
|
|
55
|
+
await this.importTaxonomiesLegacy();
|
|
56
|
+
}
|
|
45
57
|
this.createSuccessAndFailedFile();
|
|
46
58
|
this.completeProgressWithMessage();
|
|
47
59
|
}
|
|
@@ -56,83 +68,189 @@ class ImportTaxonomies extends base_class_1.default {
|
|
|
56
68
|
* @async
|
|
57
69
|
* @returns {Promise<any>} Promise<any>
|
|
58
70
|
*/
|
|
59
|
-
async importTaxonomies() {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
cli_utilities_1.log.info('No Taxonomies Found!', this.importConfig.context);
|
|
71
|
+
async importTaxonomies({ apiContent, localeCode }) {
|
|
72
|
+
if (!apiContent || (apiContent === null || apiContent === void 0 ? void 0 : apiContent.length) === 0) {
|
|
73
|
+
cli_utilities_1.log.debug('No taxonomies to import', this.importConfig.context);
|
|
63
74
|
return;
|
|
64
75
|
}
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
const onSuccess = ({ apiData }) => {
|
|
68
|
-
var _a, _b, _c;
|
|
69
|
-
const taxonomyUID = (_a = apiData === null || apiData === void 0 ? void 0 : apiData.taxonomy) === null || _a === void 0 ? void 0 : _a.uid;
|
|
70
|
-
const taxonomyName = (_b = apiData === null || apiData === void 0 ? void 0 : apiData.taxonomy) === null || _b === void 0 ? void 0 : _b.name;
|
|
71
|
-
const termsCount = Object.keys((apiData === null || apiData === void 0 ? void 0 : apiData.terms) || {}).length;
|
|
72
|
-
this.createdTaxonomies[taxonomyUID] = apiData === null || apiData === void 0 ? void 0 : apiData.taxonomy;
|
|
73
|
-
this.createdTerms[taxonomyUID] = apiData === null || apiData === void 0 ? void 0 : apiData.terms;
|
|
74
|
-
(_c = this.progressManager) === null || _c === void 0 ? void 0 : _c.tick(true, null, `taxonomy: ${taxonomyName || taxonomyUID} (${termsCount} terms)`, utils_1.PROCESS_NAMES.TAXONOMIES_IMPORT);
|
|
75
|
-
cli_utilities_1.log.success(`Taxonomy '${taxonomyUID}' imported successfully!`, this.importConfig.context);
|
|
76
|
-
cli_utilities_1.log.debug(`Taxonomy '${taxonomyName}' imported with ${termsCount} terms successfully!`, this.importConfig.context);
|
|
77
|
-
};
|
|
78
|
-
const onReject = ({ error, apiData }) => {
|
|
79
|
-
var _a, _b, _c, _d;
|
|
80
|
-
const taxonomyUID = (_a = apiData === null || apiData === void 0 ? void 0 : apiData.taxonomy) === null || _a === void 0 ? void 0 : _a.uid;
|
|
81
|
-
const taxonomyName = (_b = apiData === null || apiData === void 0 ? void 0 : apiData.taxonomy) === null || _b === void 0 ? void 0 : _b.name;
|
|
82
|
-
if ((error === null || error === void 0 ? void 0 : error.status) === 409 && (error === null || error === void 0 ? void 0 : error.statusText) === 'Conflict') {
|
|
83
|
-
cli_utilities_1.log.info(`Taxonomy '${taxonomyUID}' already exists!`, this.importConfig.context);
|
|
84
|
-
cli_utilities_1.log.debug(`Adding existing taxonomy '${taxonomyUID}' to created list`, this.importConfig.context);
|
|
85
|
-
this.createdTaxonomies[taxonomyUID] = apiData === null || apiData === void 0 ? void 0 : apiData.taxonomy;
|
|
86
|
-
this.createdTerms[taxonomyUID] = apiData === null || apiData === void 0 ? void 0 : apiData.terms;
|
|
87
|
-
(_c = this.progressManager) === null || _c === void 0 ? void 0 : _c.tick(true, null, `taxonomy: ${taxonomyName || taxonomyUID} already exists`, utils_1.PROCESS_NAMES.TAXONOMIES_IMPORT);
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
this.failedTaxonomies[taxonomyUID] = apiData === null || apiData === void 0 ? void 0 : apiData.taxonomy;
|
|
91
|
-
this.failedTerms[taxonomyUID] = apiData === null || apiData === void 0 ? void 0 : apiData.terms;
|
|
92
|
-
(_d = this.progressManager) === null || _d === void 0 ? void 0 : _d.tick(false, `taxonomy: ${taxonomyName || taxonomyUID}`, (error === null || error === void 0 ? void 0 : error.message) || 'Failed to import taxonomy', utils_1.PROCESS_NAMES.TAXONOMIES_IMPORT);
|
|
93
|
-
(0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.importConfig.context), { taxonomyUID }), `Taxonomy '${taxonomyUID}' failed to be imported`);
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
cli_utilities_1.log.debug(`Using concurrency limit: ${this.importConfig.fetchConcurrency || 2}`, this.importConfig.context);
|
|
76
|
+
const onSuccess = ({ apiData }) => this.handleSuccess(apiData, localeCode);
|
|
77
|
+
const onReject = ({ error, apiData }) => this.handleFailure(error, apiData, localeCode);
|
|
97
78
|
await this.makeConcurrentCall({
|
|
98
79
|
apiContent,
|
|
99
80
|
processName: 'import taxonomies',
|
|
100
81
|
apiParams: {
|
|
101
|
-
serializeData: this.
|
|
82
|
+
serializeData: this.serializeTaxonomy.bind(this),
|
|
102
83
|
reject: onReject,
|
|
103
84
|
resolve: onSuccess,
|
|
104
85
|
entity: 'import-taxonomy',
|
|
105
86
|
includeParamOnCompletion: true,
|
|
87
|
+
queryParam: {
|
|
88
|
+
locale: localeCode,
|
|
89
|
+
},
|
|
106
90
|
},
|
|
107
91
|
concurrencyLimit: this.importConfig.concurrency || this.importConfig.fetchConcurrency || 1,
|
|
108
92
|
}, undefined, false);
|
|
109
|
-
cli_utilities_1.log.debug('Taxonomies import process completed', this.importConfig.context);
|
|
110
93
|
}
|
|
111
94
|
/**
|
|
112
|
-
*
|
|
95
|
+
* Import taxonomies using legacy structure (taxonomies/{uid}.json)
|
|
96
|
+
*/
|
|
97
|
+
async importTaxonomiesLegacy() {
|
|
98
|
+
const apiContent = (0, values_1.default)(this.taxonomies);
|
|
99
|
+
await this.importTaxonomies({ apiContent });
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Import taxonomies using locale-based structure (taxonomies/{locale}/{uid}.json)
|
|
103
|
+
*/
|
|
104
|
+
async importTaxonomiesByLocale() {
|
|
105
|
+
const locales = this.loadAvailableLocales();
|
|
106
|
+
const apiContent = (0, values_1.default)(this.taxonomies);
|
|
107
|
+
for (const localeCode of Object.keys(locales)) {
|
|
108
|
+
await this.importTaxonomies({ apiContent, localeCode });
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
handleSuccess(apiData, locale) {
|
|
112
|
+
var _a;
|
|
113
|
+
const { taxonomy, terms } = apiData || {};
|
|
114
|
+
const taxonomyUID = taxonomy === null || taxonomy === void 0 ? void 0 : taxonomy.uid;
|
|
115
|
+
const taxonomyName = taxonomy === null || taxonomy === void 0 ? void 0 : taxonomy.name;
|
|
116
|
+
const termsCount = Object.keys(terms || {}).length;
|
|
117
|
+
this.createdTaxonomies[taxonomyUID] = taxonomy;
|
|
118
|
+
this.createdTerms[taxonomyUID] = terms;
|
|
119
|
+
(_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.tick(true, `taxonomy: ${taxonomyName || taxonomyUID}`, null, utils_1.PROCESS_NAMES.TAXONOMIES_IMPORT);
|
|
120
|
+
cli_utilities_1.log.success(`Taxonomy '${taxonomyUID}' imported successfully${locale ? ` for locale: ${locale}` : ''}!`, this.importConfig.context);
|
|
121
|
+
cli_utilities_1.log.debug(`Created taxonomy '${taxonomyName}' with ${termsCount} terms${locale ? ` for locale: ${locale}` : ''}`, this.importConfig.context);
|
|
122
|
+
}
|
|
123
|
+
handleFailure(error, apiData, locale) {
|
|
124
|
+
var _a, _b, _c, _d, _e, _f;
|
|
125
|
+
const taxonomyUID = (_a = apiData === null || apiData === void 0 ? void 0 : apiData.taxonomy) === null || _a === void 0 ? void 0 : _a.uid;
|
|
126
|
+
const taxonomyName = (_b = apiData === null || apiData === void 0 ? void 0 : apiData.taxonomy) === null || _b === void 0 ? void 0 : _b.name;
|
|
127
|
+
if ((error === null || error === void 0 ? void 0 : error.status) === 409 && (error === null || error === void 0 ? void 0 : error.statusText) === 'Conflict') {
|
|
128
|
+
(_c = this.progressManager) === null || _c === void 0 ? void 0 : _c.tick(true, null, `taxonomy: ${taxonomyName || taxonomyUID} (already exists)`, utils_1.PROCESS_NAMES.TAXONOMIES_IMPORT);
|
|
129
|
+
cli_utilities_1.log.info(`Taxonomy '${taxonomyUID}' already exists ${locale ? ` for locale: ${locale}` : ''}!`, this.importConfig.context);
|
|
130
|
+
this.createdTaxonomies[taxonomyUID] = apiData === null || apiData === void 0 ? void 0 : apiData.taxonomy;
|
|
131
|
+
this.createdTerms[taxonomyUID] = apiData === null || apiData === void 0 ? void 0 : apiData.terms;
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const errMsg = (error === null || error === void 0 ? void 0 : error.errorMessage) || ((_d = error === null || error === void 0 ? void 0 : error.errors) === null || _d === void 0 ? void 0 : _d.taxonomy) || ((_e = error === null || error === void 0 ? void 0 : error.errors) === null || _e === void 0 ? void 0 : _e.term) || (error === null || error === void 0 ? void 0 : error.message);
|
|
135
|
+
(_f = this.progressManager) === null || _f === void 0 ? void 0 : _f.tick(false, `taxonomy: ${taxonomyName || taxonomyUID}`, errMsg || 'Failed to import taxonomy', utils_1.PROCESS_NAMES.TAXONOMIES_IMPORT);
|
|
136
|
+
if (errMsg) {
|
|
137
|
+
cli_utilities_1.log.error(`Taxonomy '${taxonomyUID}' failed to import${locale ? ` for locale: ${locale}` : ''}! ${errMsg}`, this.importConfig.context);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
(0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.importConfig.context), { taxonomyUID, locale }), `Taxonomy '${taxonomyUID}' failed`);
|
|
141
|
+
}
|
|
142
|
+
this.failedTaxonomies[taxonomyUID] = apiData === null || apiData === void 0 ? void 0 : apiData.taxonomy;
|
|
143
|
+
this.failedTerms[taxonomyUID] = apiData === null || apiData === void 0 ? void 0 : apiData.terms;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* @method serializeTaxonomy
|
|
113
147
|
* @param {ApiOptions} apiOptions ApiOptions
|
|
114
148
|
* @returns {ApiOptions} ApiOptions
|
|
115
149
|
*/
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
150
|
+
serializeTaxonomy(apiOptions) {
|
|
151
|
+
const { apiData, queryParam: { locale }, } = apiOptions;
|
|
152
|
+
const taxonomyUID = apiData === null || apiData === void 0 ? void 0 : apiData.uid;
|
|
153
|
+
if (!taxonomyUID) {
|
|
154
|
+
cli_utilities_1.log.debug('No taxonomy UID provided for serialization', this.importConfig.context);
|
|
155
|
+
apiOptions.apiData = undefined;
|
|
156
|
+
return apiOptions;
|
|
157
|
+
}
|
|
158
|
+
const context = locale ? ` for locale: ${locale}` : '';
|
|
159
|
+
cli_utilities_1.log.debug(`Serializing taxonomy: ${taxonomyUID}${context}`, this.importConfig.context);
|
|
160
|
+
// Determine file path - if locale is provided, use it directly, otherwise search
|
|
161
|
+
const filePath = locale
|
|
162
|
+
? (0, node_path_1.join)(this.taxonomiesFolderPath, locale, `${taxonomyUID}.json`)
|
|
163
|
+
: this.findTaxonomyFilePath(taxonomyUID);
|
|
164
|
+
if (!filePath || !utils_1.fileHelper.fileExistsSync(filePath)) {
|
|
165
|
+
cli_utilities_1.log.debug(`Taxonomy file not found for: ${taxonomyUID}${context}`, this.importConfig.context);
|
|
166
|
+
apiOptions.apiData = undefined;
|
|
167
|
+
return apiOptions;
|
|
168
|
+
}
|
|
169
|
+
const taxonomyDetails = this.loadTaxonomyFile(filePath);
|
|
170
|
+
if (taxonomyDetails) {
|
|
126
171
|
const termCount = Object.keys((taxonomyDetails === null || taxonomyDetails === void 0 ? void 0 : taxonomyDetails.terms) || {}).length;
|
|
127
|
-
cli_utilities_1.log.debug(`Taxonomy has ${termCount} term entries`, this.importConfig.context);
|
|
128
|
-
apiOptions.apiData = {
|
|
172
|
+
cli_utilities_1.log.debug(`Taxonomy has ${termCount} term entries${context}`, this.importConfig.context);
|
|
173
|
+
apiOptions.apiData = {
|
|
174
|
+
filePath,
|
|
175
|
+
taxonomy: taxonomyDetails === null || taxonomyDetails === void 0 ? void 0 : taxonomyDetails.taxonomy,
|
|
176
|
+
terms: taxonomyDetails === null || taxonomyDetails === void 0 ? void 0 : taxonomyDetails.terms,
|
|
177
|
+
};
|
|
129
178
|
}
|
|
130
179
|
else {
|
|
131
|
-
cli_utilities_1.log.debug(`File does not exist for taxonomy: ${taxonomyUID}`, this.importConfig.context);
|
|
132
180
|
apiOptions.apiData = undefined;
|
|
133
181
|
}
|
|
134
182
|
return apiOptions;
|
|
135
183
|
}
|
|
184
|
+
loadTaxonomyFile(filePath) {
|
|
185
|
+
if (!utils_1.fileHelper.fileExistsSync(filePath)) {
|
|
186
|
+
cli_utilities_1.log.debug(`File does not exist: ${filePath}`, this.importConfig.context);
|
|
187
|
+
return undefined;
|
|
188
|
+
}
|
|
189
|
+
try {
|
|
190
|
+
const taxonomyDetails = utils_1.fsUtil.readFile(filePath, true);
|
|
191
|
+
cli_utilities_1.log.debug(`Successfully loaded taxonomy from: ${filePath}`, this.importConfig.context);
|
|
192
|
+
return taxonomyDetails;
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
cli_utilities_1.log.debug(`Error loading taxonomy file: ${filePath}`, this.importConfig.context);
|
|
196
|
+
return undefined;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
findTaxonomyFilePath(taxonomyUID) {
|
|
200
|
+
if (this.isLocaleBasedStructure) {
|
|
201
|
+
return this.findTaxonomyInLocaleFolders(taxonomyUID);
|
|
202
|
+
}
|
|
203
|
+
const legacyPath = (0, node_path_1.join)(this.taxonomiesFolderPath, `${taxonomyUID}.json`);
|
|
204
|
+
return utils_1.fileHelper.fileExistsSync(legacyPath) ? legacyPath : undefined;
|
|
205
|
+
}
|
|
206
|
+
findTaxonomyInLocaleFolders(taxonomyUID) {
|
|
207
|
+
const locales = this.loadAvailableLocales();
|
|
208
|
+
for (const localeCode of Object.keys(locales)) {
|
|
209
|
+
const filePath = (0, node_path_1.join)(this.taxonomiesFolderPath, localeCode, `${taxonomyUID}.json`);
|
|
210
|
+
if (utils_1.fileHelper.fileExistsSync(filePath)) {
|
|
211
|
+
return filePath;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return undefined;
|
|
215
|
+
}
|
|
216
|
+
loadAvailableLocales() {
|
|
217
|
+
var _a;
|
|
218
|
+
if (!utils_1.fileHelper.fileExistsSync(this.localesFilePath)) {
|
|
219
|
+
cli_utilities_1.log.debug('No locales file found', this.importConfig.context);
|
|
220
|
+
return {};
|
|
221
|
+
}
|
|
222
|
+
try {
|
|
223
|
+
const localesData = utils_1.fsUtil.readFile(this.localesFilePath, true);
|
|
224
|
+
const locales = {};
|
|
225
|
+
const masterCode = ((_a = this.importConfig.master_locale) === null || _a === void 0 ? void 0 : _a.code) || 'en-us';
|
|
226
|
+
locales[masterCode] = masterCode;
|
|
227
|
+
for (const [, locale] of Object.entries(localesData || {})) {
|
|
228
|
+
if (locale === null || locale === void 0 ? void 0 : locale.code) {
|
|
229
|
+
locales[locale.code] = locale.code;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
cli_utilities_1.log.debug(`Loaded ${Object.keys(locales).length} locales from file`, this.importConfig.context);
|
|
233
|
+
return locales;
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
cli_utilities_1.log.debug('Error loading locales file', this.importConfig.context);
|
|
237
|
+
return {};
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Detect if locale-based folder structure exists (taxonomies/{locale}/{uid}.json)
|
|
242
|
+
*/
|
|
243
|
+
detectAndScanLocaleStructure() {
|
|
244
|
+
var _a;
|
|
245
|
+
const masterLocaleCode = ((_a = this.importConfig.master_locale) === null || _a === void 0 ? void 0 : _a.code) || 'en-us';
|
|
246
|
+
const masterLocaleFolder = (0, node_path_1.join)(this.taxonomiesFolderPath, masterLocaleCode);
|
|
247
|
+
if (!utils_1.fileHelper.fileExistsSync(masterLocaleFolder)) {
|
|
248
|
+
cli_utilities_1.log.debug('No locale-based folder structure detected', this.importConfig.context);
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
cli_utilities_1.log.debug('Locale-based folder structure detected', this.importConfig.context);
|
|
252
|
+
return true;
|
|
253
|
+
}
|
|
136
254
|
/**
|
|
137
255
|
* create taxonomies success and fail in (mapper/taxonomies)
|
|
138
256
|
* create terms success and fail in (mapper/taxonomies/terms)
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const path_1 = tslib_1.__importDefault(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
8
|
const utils_1 = require("../../utils");
|
|
8
9
|
const base_class_1 = tslib_1.__importDefault(require("./base-class"));
|
|
@@ -13,7 +14,7 @@ class ImportVariantEntries extends base_class_1.default {
|
|
|
13
14
|
this.config.context.module = utils_1.MODULE_CONTEXTS.VARIANT_ENTRIES;
|
|
14
15
|
this.currentModuleName = utils_1.MODULE_NAMES[utils_1.MODULE_CONTEXTS.VARIANT_ENTRIES];
|
|
15
16
|
this.personalize = importConfig.modules.personalize;
|
|
16
|
-
this.projectMapperFilePath = path_1.default.resolve((0, cli_utilities_1.sanitizePath)(this.config.
|
|
17
|
+
this.projectMapperFilePath = path_1.default.resolve((0, cli_utilities_1.sanitizePath)(this.config.backupDir), constants_1.PATH_CONSTANTS.MAPPER, (0, cli_utilities_1.sanitizePath)(this.personalize.dirName), 'projects', 'projects.json');
|
|
17
18
|
}
|
|
18
19
|
/**
|
|
19
20
|
* @method start
|
|
@@ -5,6 +5,7 @@ const isEmpty_1 = tslib_1.__importDefault(require("lodash/isEmpty"));
|
|
|
5
5
|
const values_1 = tslib_1.__importDefault(require("lodash/values"));
|
|
6
6
|
const node_path_1 = require("node:path");
|
|
7
7
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
8
|
+
const constants_1 = require("../../constants");
|
|
8
9
|
const utils_1 = require("../../utils");
|
|
9
10
|
const base_class_1 = tslib_1.__importDefault(require("./base-class"));
|
|
10
11
|
class ImportWebhooks extends base_class_1.default {
|
|
@@ -13,11 +14,11 @@ class ImportWebhooks extends base_class_1.default {
|
|
|
13
14
|
this.importConfig.context.module = utils_1.MODULE_CONTEXTS.WEBHOOKS;
|
|
14
15
|
this.currentModuleName = utils_1.MODULE_NAMES[utils_1.MODULE_CONTEXTS.WEBHOOKS];
|
|
15
16
|
this.webhooksConfig = importConfig.modules.webhooks;
|
|
16
|
-
this.mapperDirPath = (0, node_path_1.join)(this.importConfig.backupDir,
|
|
17
|
+
this.mapperDirPath = (0, node_path_1.join)(this.importConfig.backupDir, constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.WEBHOOKS);
|
|
17
18
|
this.webhooksFolderPath = (0, node_path_1.join)(this.importConfig.backupDir, this.webhooksConfig.dirName);
|
|
18
|
-
this.webhookUidMapperPath = (0, node_path_1.join)(this.mapperDirPath,
|
|
19
|
-
this.createdWebhooksPath = (0, node_path_1.join)(this.mapperDirPath,
|
|
20
|
-
this.failedWebhooksPath = (0, node_path_1.join)(this.mapperDirPath,
|
|
19
|
+
this.webhookUidMapperPath = (0, node_path_1.join)(this.mapperDirPath, constants_1.PATH_CONSTANTS.FILES.UID_MAPPING);
|
|
20
|
+
this.createdWebhooksPath = (0, node_path_1.join)(this.mapperDirPath, constants_1.PATH_CONSTANTS.FILES.SUCCESS);
|
|
21
|
+
this.failedWebhooksPath = (0, node_path_1.join)(this.mapperDirPath, constants_1.PATH_CONSTANTS.FILES.FAILS);
|
|
21
22
|
this.webhooks = {};
|
|
22
23
|
this.failedWebhooks = [];
|
|
23
24
|
this.createdWebhooks = [];
|
|
@@ -20,7 +20,7 @@ export default class ImportWorkflows extends BaseClass {
|
|
|
20
20
|
start(): Promise<void>;
|
|
21
21
|
getRoles(): Promise<void>;
|
|
22
22
|
importWorkflows(): Promise<void>;
|
|
23
|
-
updateNextAvailableStagesUid(workflow: Record<string, any>, newWorkflowStages: Record<string, any>[], oldWorkflowStages: Record<string, any>[]): Promise<
|
|
23
|
+
updateNextAvailableStagesUid(workflow: Record<string, any>, newWorkflowStages: Record<string, any>[], oldWorkflowStages: Record<string, any>[]): Promise<any>;
|
|
24
24
|
/**
|
|
25
25
|
* @method serializeWorkflows
|
|
26
26
|
* @param {ApiOptions} apiOptions ApiOptions
|
|
@@ -11,6 +11,7 @@ const isEmpty_1 = tslib_1.__importDefault(require("lodash/isEmpty"));
|
|
|
11
11
|
const cloneDeep_1 = tslib_1.__importDefault(require("lodash/cloneDeep"));
|
|
12
12
|
const findIndex_1 = tslib_1.__importDefault(require("lodash/findIndex"));
|
|
13
13
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
14
|
+
const constants_1 = require("../../constants");
|
|
14
15
|
const base_class_1 = tslib_1.__importDefault(require("./base-class"));
|
|
15
16
|
const utils_1 = require("../../utils");
|
|
16
17
|
class ImportWorkflows extends base_class_1.default {
|
|
@@ -19,11 +20,11 @@ class ImportWorkflows extends base_class_1.default {
|
|
|
19
20
|
this.importConfig.context.module = utils_1.MODULE_CONTEXTS.WORKFLOWS;
|
|
20
21
|
this.currentModuleName = utils_1.MODULE_NAMES[utils_1.MODULE_CONTEXTS.WORKFLOWS];
|
|
21
22
|
this.workflowsConfig = importConfig.modules.workflows;
|
|
22
|
-
this.mapperDirPath = (0, node_path_1.join)(this.importConfig.backupDir,
|
|
23
|
+
this.mapperDirPath = (0, node_path_1.join)(this.importConfig.backupDir, constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.WORKFLOWS);
|
|
23
24
|
this.workflowsFolderPath = (0, node_path_1.join)(this.importConfig.backupDir, this.workflowsConfig.dirName);
|
|
24
|
-
this.workflowUidMapperPath = (0, node_path_1.join)(this.mapperDirPath,
|
|
25
|
-
this.createdWorkflowsPath = (0, node_path_1.join)(this.mapperDirPath,
|
|
26
|
-
this.failedWorkflowsPath = (0, node_path_1.join)(this.mapperDirPath,
|
|
25
|
+
this.workflowUidMapperPath = (0, node_path_1.join)(this.mapperDirPath, constants_1.PATH_CONSTANTS.FILES.UID_MAPPING);
|
|
26
|
+
this.createdWorkflowsPath = (0, node_path_1.join)(this.mapperDirPath, constants_1.PATH_CONSTANTS.FILES.SUCCESS);
|
|
27
|
+
this.failedWorkflowsPath = (0, node_path_1.join)(this.mapperDirPath, constants_1.PATH_CONSTANTS.FILES.FAILS);
|
|
27
28
|
this.workflows = {};
|
|
28
29
|
this.failedWebhooks = [];
|
|
29
30
|
this.createdWorkflows = [];
|
|
@@ -11,6 +11,7 @@ const tslib_1 = require("tslib");
|
|
|
11
11
|
const _ = tslib_1.__importStar(require("lodash"));
|
|
12
12
|
const path = tslib_1.__importStar(require("path"));
|
|
13
13
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
14
|
+
const constants_1 = require("../constants");
|
|
14
15
|
const file_helper_1 = require("./file-helper");
|
|
15
16
|
const config_1 = tslib_1.__importDefault(require("../config"));
|
|
16
17
|
const promise_limit_1 = tslib_1.__importDefault(require("promise-limit"));
|
|
@@ -137,8 +138,8 @@ const field_rules_update = (importConfig, ctPath) => {
|
|
|
137
138
|
for (let i = 0; i < fieldRuleConditionLength; i++) {
|
|
138
139
|
if (schema.field_rules[k].conditions[i].operand_field === 'reference') {
|
|
139
140
|
cli_utilities_1.log.debug(`Processing reference field rule condition`);
|
|
140
|
-
let entryMapperPath = path.resolve(importConfig.contentDir,
|
|
141
|
-
let entryUidMapperPath = path.join(entryMapperPath,
|
|
141
|
+
let entryMapperPath = path.resolve(importConfig.contentDir, constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.ENTRIES);
|
|
142
|
+
let entryUidMapperPath = path.join(entryMapperPath, constants_1.PATH_CONSTANTS.FILES.UID_MAPPING);
|
|
142
143
|
let fieldRulesValue = schema.field_rules[k].conditions[i].value;
|
|
143
144
|
let fieldRulesArray = fieldRulesValue.split('.');
|
|
144
145
|
let updatedValue = [];
|
|
@@ -11,13 +11,14 @@ exports.lookupExtension = void 0;
|
|
|
11
11
|
*/
|
|
12
12
|
const node_path_1 = require("node:path");
|
|
13
13
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
14
|
+
const constants_1 = require("../constants");
|
|
14
15
|
// eslint-disable-next-line camelcase
|
|
15
16
|
const lookupExtension = function (config, schema, preserveStackVersion, installedExtensions) {
|
|
16
17
|
cli_utilities_1.log.debug('Starting extension lookup process...');
|
|
17
18
|
const fs = new cli_utilities_1.FsUtility({ basePath: config.backupDir });
|
|
18
|
-
const extensionPath = (0, node_path_1.join)(config.backupDir,
|
|
19
|
-
const globalfieldsPath = (0, node_path_1.join)(config.backupDir,
|
|
20
|
-
const marketPlaceAppsPath = (0, node_path_1.join)(config.backupDir,
|
|
19
|
+
const extensionPath = (0, node_path_1.join)(config.backupDir, constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.EXTENSIONS, constants_1.PATH_CONSTANTS.FILES.UID_MAPPING);
|
|
20
|
+
const globalfieldsPath = (0, node_path_1.join)(config.backupDir, constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.GLOBAL_FIELDS, constants_1.PATH_CONSTANTS.FILES.UID_MAPPING);
|
|
21
|
+
const marketPlaceAppsPath = (0, node_path_1.join)(config.backupDir, constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.MARKETPLACE_APPS, constants_1.PATH_CONSTANTS.FILES.UID_MAPPING);
|
|
21
22
|
cli_utilities_1.log.debug(`Extension mapping paths - Extensions: ${extensionPath}, Global fields: ${globalfieldsPath}, Marketplace apps: ${marketPlaceAppsPath}`);
|
|
22
23
|
for (let i in schema) {
|
|
23
24
|
if (schema[i].data_type === 'group') {
|
|
@@ -109,8 +109,6 @@ const setupConfig = async (importCmdFlags) => {
|
|
|
109
109
|
if (importCmdFlags['exclude-global-modules']) {
|
|
110
110
|
config['exclude-global-modules'] = importCmdFlags['exclude-global-modules'];
|
|
111
111
|
}
|
|
112
|
-
// Set progress supported module to check and display console logs
|
|
113
|
-
cli_utilities_1.configHandler.set('log.progressSupportedModule', 'import');
|
|
114
112
|
// Add authentication details to config for context tracking
|
|
115
113
|
config.authenticationMethod = authenticationMethod;
|
|
116
114
|
cli_utilities_1.log.debug('Import configuration setup completed.', Object.assign({}, config));
|
package/oclif.manifest.json
CHANGED