@contentstack/cli-cm-import 1.25.1 → 1.26.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.
- package/README.md +3 -3
- package/lib/commands/cm/stacks/import.d.ts +1 -0
- package/lib/commands/cm/stacks/import.js +39 -12
- package/lib/import/module-importer.js +20 -3
- package/lib/import/modules/assets.d.ts +1 -1
- package/lib/import/modules/assets.js +93 -39
- package/lib/import/modules/content-types.js +76 -31
- package/lib/import/modules/custom-roles.js +95 -19
- package/lib/import/modules/entries.js +128 -57
- package/lib/import/modules/environments.js +48 -14
- package/lib/import/modules/extensions.js +78 -16
- package/lib/import/modules/global-fields.js +85 -20
- package/lib/import/modules/labels.d.ts +4 -4
- package/lib/import/modules/labels.js +60 -18
- package/lib/import/modules/locales.js +63 -20
- package/lib/import/modules/marketplace-apps.js +160 -31
- package/lib/import/modules/personalize.js +33 -7
- package/lib/import/modules/stack.js +5 -0
- package/lib/import/modules/taxonomies.js +52 -13
- package/lib/import/modules/variant-entries.js +21 -3
- package/lib/import/modules/webhooks.js +44 -12
- package/lib/import/modules/workflows.js +65 -21
- package/lib/types/import-config.d.ts +3 -1
- package/lib/types/index.d.ts +22 -0
- package/lib/utils/asset-helper.js +24 -1
- package/lib/utils/backup-handler.js +15 -1
- package/lib/utils/common-helper.js +41 -16
- package/lib/utils/content-type-helper.js +35 -2
- package/lib/utils/entries-helper.js +24 -2
- package/lib/utils/extension-helper.js +35 -1
- package/lib/utils/import-config-handler.js +21 -0
- package/lib/utils/login-handler.js +8 -4
- package/lib/utils/marketplace-app-helper.js +50 -11
- package/lib/utils/taxonomies-helper.js +22 -4
- package/oclif.manifest.json +2 -2
- package/package.json +6 -6
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
};
|
package/oclif.manifest.json
CHANGED
|
@@ -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.
|
|
202
|
+
"version": "1.26.1"
|
|
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.
|
|
4
|
+
"version": "1.26.1",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@contentstack/cli-audit": "~1.
|
|
9
|
-
"@contentstack/cli-command": "~1.
|
|
10
|
-
"@contentstack/cli-utilities": "~1.
|
|
8
|
+
"@contentstack/cli-audit": "~1.14.0",
|
|
9
|
+
"@contentstack/cli-command": "~1.6.0",
|
|
10
|
+
"@contentstack/cli-utilities": "~1.13.1",
|
|
11
11
|
"@contentstack/management": "~1.22.0",
|
|
12
|
-
"@contentstack/cli-variants": "~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",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@types/uuid": "^9.0.8",
|
|
37
37
|
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
|
38
38
|
"eslint": "^8.57.1",
|
|
39
|
-
"eslint-config-oclif": "^6.0.
|
|
39
|
+
"eslint-config-oclif": "^6.0.89",
|
|
40
40
|
"mocha": "^10.8.2",
|
|
41
41
|
"nyc": "^15.1.0",
|
|
42
42
|
"oclif": "^4.17.46",
|