@contentstack/cli-cm-import 2.0.0-beta.5 → 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.
@@ -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.contentDir), 'mapper', (0, cli_utilities_1.sanitizePath)(this.personalize.dirName), 'projects', 'projects.json');
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
@@ -34,8 +35,7 @@ class ImportVariantEntries extends base_class_1.default {
34
35
  progress.updateStatus(utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.VARIANT_ENTRIES_IMPORT].IMPORTING, utils_1.PROCESS_NAMES.VARIANT_ENTRIES_IMPORT);
35
36
  cli_utilities_1.log.info('Starting variant entries import process', this.config.context);
36
37
  await this.importVariantEntries();
37
- this.completeProgress(true);
38
- cli_utilities_1.log.success('Variant entries imported successfully', this.config.context);
38
+ this.completeProgressWithMessage();
39
39
  }
40
40
  catch (error) {
41
41
  this.completeProgress(false, (error === null || error === void 0 ? void 0 : error.message) || 'Variant entries import failed');
@@ -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, 'mapper', 'webhooks');
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, 'uid-mapping.json');
19
- this.createdWebhooksPath = (0, node_path_1.join)(this.mapperDirPath, 'success.json');
20
- this.failedWebhooksPath = (0, node_path_1.join)(this.mapperDirPath, 'fails.json');
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 = [];
@@ -40,8 +41,7 @@ class ImportWebhooks extends base_class_1.default {
40
41
  progress.updateStatus(utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.WEBHOOKS_IMPORT].IMPORTING);
41
42
  await this.importWebhooks();
42
43
  this.processWebhookResults();
43
- this.completeProgress(true);
44
- cli_utilities_1.log.success('Webhooks have been imported successfully!', this.importConfig.context);
44
+ this.completeProgressWithMessage();
45
45
  }
46
46
  catch (error) {
47
47
  this.completeProgress(false, (error === null || error === void 0 ? void 0 : error.message) || 'Webhooks import failed');
@@ -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<import("@contentstack/management/types/stack/workflow").Workflow>;
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, 'mapper', 'workflows');
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, 'uid-mapping.json');
25
- this.createdWorkflowsPath = (0, node_path_1.join)(this.mapperDirPath, 'success.json');
26
- this.failedWorkflowsPath = (0, node_path_1.join)(this.mapperDirPath, 'fails.json');
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 = [];
@@ -61,8 +62,7 @@ class ImportWorkflows extends base_class_1.default {
61
62
  await this.importWorkflows();
62
63
  progress.completeProcess(utils_1.PROCESS_NAMES.WORKFLOWS_CREATE, true);
63
64
  this.processWorkflowResults();
64
- this.completeProgress(true);
65
- cli_utilities_1.log.success('Workflows have been imported successfully!', this.importConfig.context);
65
+ this.completeProgressWithMessage();
66
66
  }
67
67
  catch (error) {
68
68
  this.completeProgress(false, (error === null || error === void 0 ? void 0 : error.message) || 'Workflows import failed');
@@ -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, 'mapper', 'entries');
141
- let entryUidMapperPath = path.join(entryMapperPath, 'uid-mapping.json');
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, 'mapper/extensions', 'uid-mapping.json');
19
- const globalfieldsPath = (0, node_path_1.join)(config.backupDir, 'mapper/globalfields', 'uid-mapping.json');
20
- const marketPlaceAppsPath = (0, node_path_1.join)(config.backupDir, 'mapper/marketplace_apps', 'uid-mapping.json');
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));
@@ -168,5 +168,5 @@
168
168
  ]
169
169
  }
170
170
  },
171
- "version": "2.0.0-beta.5"
171
+ "version": "2.0.0-beta.7"
172
172
  }
package/package.json CHANGED
@@ -1,22 +1,21 @@
1
1
  {
2
2
  "name": "@contentstack/cli-cm-import",
3
3
  "description": "Contentstack CLI plugin to import content into stack",
4
- "version": "2.0.0-beta.5",
4
+ "version": "2.0.0-beta.7",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {
8
- "@contentstack/cli-audit": "~2.0.0-beta.1",
9
- "@contentstack/cli-command": "~1.7.0",
10
- "@contentstack/cli-utilities": "~1.17.0",
11
- "@contentstack/management": "~1.27.3",
8
+ "@contentstack/cli-audit": "~2.0.0-beta.3",
9
+ "@contentstack/cli-command": "~1.7.2",
10
+ "@contentstack/cli-utilities": "~1.17.2",
12
11
  "@contentstack/cli-variants": "~2.0.0-beta.4",
13
12
  "@oclif/core": "^4.3.0",
14
13
  "big-json": "^3.2.0",
15
14
  "bluebird": "^3.7.2",
16
15
  "chalk": "^4.1.2",
17
- "debug": "^4.4.1",
18
- "fs-extra": "^11.3.0",
19
- "lodash": "^4.17.21",
16
+ "debug": "^4.4.3",
17
+ "fs-extra": "^11.3.3",
18
+ "lodash": "^4.17.23",
20
19
  "marked": "^4.3.0",
21
20
  "merge": "^2.1.1",
22
21
  "mkdirp": "^1.0.4",
@@ -25,7 +24,7 @@
25
24
  "winston": "^3.17.0"
26
25
  },
27
26
  "devDependencies": {
28
- "@oclif/test": "^4.1.13",
27
+ "@oclif/test": "^4.1.16",
29
28
  "@types/big-json": "^3.2.5",
30
29
  "@types/bluebird": "^3.5.42",
31
30
  "@types/fs-extra": "^11.0.4",