@contentstack/cli-cm-import 1.25.0 → 1.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +3 -3
  2. package/lib/commands/cm/stacks/import.d.ts +1 -0
  3. package/lib/commands/cm/stacks/import.js +33 -12
  4. package/lib/import/module-importer.js +1 -1
  5. package/lib/import/modules/assets.d.ts +1 -1
  6. package/lib/import/modules/assets.js +93 -39
  7. package/lib/import/modules/base-class.js +11 -3
  8. package/lib/import/modules/content-types.js +79 -28
  9. package/lib/import/modules/custom-roles.js +95 -19
  10. package/lib/import/modules/entries.js +128 -57
  11. package/lib/import/modules/environments.js +48 -14
  12. package/lib/import/modules/extensions.js +78 -16
  13. package/lib/import/modules/global-fields.js +86 -19
  14. package/lib/import/modules/labels.d.ts +4 -4
  15. package/lib/import/modules/labels.js +60 -18
  16. package/lib/import/modules/locales.js +63 -20
  17. package/lib/import/modules/marketplace-apps.js +160 -31
  18. package/lib/import/modules/personalize.js +33 -7
  19. package/lib/import/modules/stack.js +5 -0
  20. package/lib/import/modules/taxonomies.js +52 -13
  21. package/lib/import/modules/variant-entries.js +21 -3
  22. package/lib/import/modules/webhooks.js +44 -12
  23. package/lib/import/modules/workflows.js +65 -21
  24. package/lib/types/import-config.d.ts +3 -1
  25. package/lib/types/index.d.ts +22 -0
  26. package/lib/utils/asset-helper.js +24 -1
  27. package/lib/utils/backup-handler.js +15 -1
  28. package/lib/utils/common-helper.js +41 -16
  29. package/lib/utils/content-type-helper.js +35 -2
  30. package/lib/utils/entries-helper.js +24 -2
  31. package/lib/utils/extension-helper.js +35 -1
  32. package/lib/utils/global-field-helper.js +1 -1
  33. package/lib/utils/import-config-handler.js +21 -0
  34. package/lib/utils/login-handler.js +8 -4
  35. package/lib/utils/marketplace-app-helper.js +50 -11
  36. package/lib/utils/taxonomies-helper.js +22 -4
  37. package/oclif.manifest.json +2 -2
  38. package/package.json +5 -5
@@ -6,7 +6,7 @@ const tslib_1 = require("tslib");
6
6
  * taxonomy lookup
7
7
  */
8
8
  const find_1 = tslib_1.__importDefault(require("lodash/find"));
9
- const _1 = require("./");
9
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
10
10
  /**
11
11
  * check and remove if referenced taxonomy doesn't exists in stack
12
12
  * @param {any} schema content type schema
@@ -14,19 +14,24 @@ const _1 = require("./");
14
14
  * @param {ImportConfig} importConfig
15
15
  */
16
16
  const lookUpTaxonomy = function (importConfig, schema, taxonomies) {
17
+ cli_utilities_1.log.debug(`Starting taxonomy lookup for schema with ${Object.keys(schema).length} fields`);
17
18
  for (let i in schema) {
18
19
  if (schema[i].data_type === 'taxonomy') {
20
+ cli_utilities_1.log.debug(`Processing taxonomy field: ${schema[i].uid}`);
19
21
  const taxonomyFieldData = schema[i].taxonomies;
20
22
  const { updatedTaxonomyData, isTaxonomyFieldRemoved } = verifyAndRemoveTaxonomy(taxonomyFieldData, taxonomies, importConfig);
21
23
  //Handle API error -> The 'taxonomies' property must have atleast one taxonomy object. Remove taxonomy field from schema.
22
24
  if (isTaxonomyFieldRemoved) {
25
+ cli_utilities_1.log.debug(`Removing taxonomy field from schema: ${schema[i].uid}`);
23
26
  schema.splice(i, 1);
24
27
  }
25
28
  else {
29
+ cli_utilities_1.log.debug(`Updated taxonomy field data: ${schema[i].uid}`);
26
30
  schema[i].taxonomies = updatedTaxonomyData;
27
31
  }
28
32
  }
29
33
  }
34
+ cli_utilities_1.log.debug('Taxonomy lookup completed');
30
35
  };
31
36
  exports.lookUpTaxonomy = lookUpTaxonomy;
32
37
  /**
@@ -37,20 +42,25 @@ exports.lookUpTaxonomy = lookUpTaxonomy;
37
42
  * @returns
38
43
  */
39
44
  const verifyAndRemoveTaxonomy = function (taxonomyFieldData, taxonomies, importConfig) {
45
+ cli_utilities_1.log.debug(`Verifying ${(taxonomyFieldData === null || taxonomyFieldData === void 0 ? void 0 : taxonomyFieldData.length) || 0} taxonomy references`);
40
46
  let isTaxonomyFieldRemoved = false;
41
47
  for (let index = 0; index < (taxonomyFieldData === null || taxonomyFieldData === void 0 ? void 0 : taxonomyFieldData.length); index++) {
42
48
  const taxonomyData = taxonomyFieldData[index];
43
49
  if (taxonomies === undefined || !taxonomies.hasOwnProperty(taxonomyData === null || taxonomyData === void 0 ? void 0 : taxonomyData.taxonomy_uid)) {
44
50
  // remove taxonomy from taxonomies field data with warning if respective taxonomy doesn't exists
45
- (0, _1.log)(importConfig, `Taxonomy '${taxonomyData === null || taxonomyData === void 0 ? void 0 : taxonomyData.taxonomy_uid}' does not exist. Removing the data from the taxonomies field`, 'warn');
51
+ cli_utilities_1.log.warn(`Taxonomy '${taxonomyData === null || taxonomyData === void 0 ? void 0 : taxonomyData.taxonomy_uid}' does not exist, removing from field`);
46
52
  taxonomyFieldData.splice(index, 1);
47
53
  --index;
48
54
  }
55
+ else {
56
+ cli_utilities_1.log.debug(`Taxonomy '${taxonomyData === null || taxonomyData === void 0 ? void 0 : taxonomyData.taxonomy_uid}' exists and is valid`);
57
+ }
49
58
  }
50
59
  if (!(taxonomyFieldData === null || taxonomyFieldData === void 0 ? void 0 : taxonomyFieldData.length)) {
51
- (0, _1.log)(importConfig, 'Taxonomy does not exist. Removing the field from content type', 'warn');
60
+ cli_utilities_1.log.warn('No valid taxonomies remain, removing entire taxonomy field');
52
61
  isTaxonomyFieldRemoved = true;
53
62
  }
63
+ cli_utilities_1.log.debug(`Taxonomy verification completed, removed: ${isTaxonomyFieldRemoved}`);
54
64
  return {
55
65
  updatedTaxonomyData: taxonomyFieldData,
56
66
  isTaxonomyFieldRemoved,
@@ -64,19 +74,24 @@ const verifyAndRemoveTaxonomy = function (taxonomyFieldData, taxonomies, importC
64
74
  * @param {ImportConfig} importConfig
65
75
  */
66
76
  const lookUpTerms = function (ctSchema, entry, taxonomiesAndTermData, importConfig) {
77
+ cli_utilities_1.log.debug(`Starting term lookup for entry: ${entry.uid}`);
67
78
  for (let index = 0; index < (ctSchema === null || ctSchema === void 0 ? void 0 : ctSchema.length); index++) {
68
79
  if (ctSchema[index].data_type === 'taxonomy') {
80
+ cli_utilities_1.log.debug(`Processing taxonomy field: ${ctSchema[index].uid}`);
69
81
  const taxonomyFieldData = entry[ctSchema[index].uid];
70
82
  const updatedTaxonomyData = verifyAndRemoveTerms(taxonomyFieldData, taxonomiesAndTermData, importConfig);
71
83
  if (updatedTaxonomyData === null || updatedTaxonomyData === void 0 ? void 0 : updatedTaxonomyData.length) {
84
+ cli_utilities_1.log.debug(`Updated taxonomy data for field: ${ctSchema[index].uid}`);
72
85
  entry[ctSchema[index].uid] = updatedTaxonomyData;
73
86
  }
74
87
  else {
75
88
  //Delete taxonomy from entry if taxonomy field removed from CT
89
+ cli_utilities_1.log.debug(`Removing taxonomy field from entry: ${ctSchema[index].uid}`);
76
90
  delete entry[ctSchema[index].uid];
77
91
  }
78
92
  }
79
93
  }
94
+ cli_utilities_1.log.debug('Term lookup completed');
80
95
  };
81
96
  exports.lookUpTerms = lookUpTerms;
82
97
  /**
@@ -96,10 +111,13 @@ const verifyAndRemoveTerms = function (taxonomyFieldData, taxonomiesAndTermData,
96
111
  (taxonomiesAndTermData.hasOwnProperty(taxUID) &&
97
112
  !(0, find_1.default)(taxonomiesAndTermData[taxUID], (term) => (term === null || term === void 0 ? void 0 : term.uid) === termUID))) {
98
113
  // remove term from taxonomies field data with warning if respective term doesn't exists
99
- (0, _1.log)(importConfig, `Term '${termUID}' does not exist. Removing it from taxonomy - '${taxUID}'`, 'warn');
114
+ cli_utilities_1.log.warn(`Term '${termUID}' does not exist in taxonomy '${taxUID}', removing from entry`);
100
115
  taxonomyFieldData.splice(index, 1);
101
116
  --index;
102
117
  }
118
+ else {
119
+ cli_utilities_1.log.debug(`Term '${termUID}' exists in taxonomy '${taxUID}'`);
120
+ }
103
121
  }
104
122
  return taxonomyFieldData;
105
123
  };
@@ -84,7 +84,7 @@
84
84
  },
85
85
  "module": {
86
86
  "char": "m",
87
- "description": "[optional] Specify the module to import into the target stack. If not specified, the import command will import all the modules into the stack. The available modules are assets, content-types, entries, environments, extensions, marketplace-apps, global-fields, labels, locales, webhooks, workflows, custom-roles, and taxonomies.",
87
+ "description": "[optional] Specify the module to import into the target stack. If not specified, the import command will import all the modules into the stack. The available modules are assets, content-types, entries, environments, extensions, marketplace-apps, global-fields, labels, locales, webhooks, workflows, custom-roles, personalize projects, and taxonomies.",
88
88
  "name": "module",
89
89
  "required": false,
90
90
  "hasDynamicHelp": false,
@@ -199,5 +199,5 @@
199
199
  ]
200
200
  }
201
201
  },
202
- "version": "1.25.0"
202
+ "version": "1.26.0"
203
203
  }
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@contentstack/cli-cm-import",
3
3
  "description": "Contentstack CLI plugin to import content into stack",
4
- "version": "1.25.0",
4
+ "version": "1.26.0",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {
8
- "@contentstack/cli-audit": "~1.13.0",
9
- "@contentstack/cli-command": "~1.5.0",
10
- "@contentstack/cli-utilities": "~1.12.0",
8
+ "@contentstack/cli-audit": "~1.14.0",
9
+ "@contentstack/cli-command": "~1.6.0",
10
+ "@contentstack/cli-utilities": "~1.13.0",
11
11
  "@contentstack/management": "~1.22.0",
12
- "@contentstack/cli-variants": "~1.2.1",
12
+ "@contentstack/cli-variants": "~1.3.0",
13
13
  "@oclif/core": "^4.3.0",
14
14
  "big-json": "^3.2.0",
15
15
  "bluebird": "^3.7.2",