@contentstack/cli-cm-import 1.26.2 → 1.26.3
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/config/index.js +1 -1
- package/lib/import/modules/content-types.js +1 -1
- package/lib/import/modules/entries.js +18 -14
- package/lib/utils/asset-helper.js +2 -2
- package/lib/utils/content-type-helper.js +1 -2
- package/lib/utils/entries-helper.js +1 -1
- package/lib/utils/extension-helper.js +3 -3
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ $ npm install -g @contentstack/cli-cm-import
|
|
|
47
47
|
$ csdx COMMAND
|
|
48
48
|
running command...
|
|
49
49
|
$ csdx (--version)
|
|
50
|
-
@contentstack/cli-cm-import/1.26.
|
|
50
|
+
@contentstack/cli-cm-import/1.26.3 linux-x64 node-v22.18.0
|
|
51
51
|
$ csdx --help [COMMAND]
|
|
52
52
|
USAGE
|
|
53
53
|
$ csdx COMMAND
|
package/lib/config/index.js
CHANGED
|
@@ -436,7 +436,7 @@ const config = {
|
|
|
436
436
|
getEncryptionKeyMaxRetry: 3,
|
|
437
437
|
// useBackedupDir: '',
|
|
438
438
|
// backupConcurrency: 10,
|
|
439
|
-
onlyTSModules: ['taxonomies', 'personalize', 'variant-entries'],
|
|
439
|
+
onlyTSModules: ['taxonomies', 'personalize', 'variant-entries', 'stack'],
|
|
440
440
|
auditConfig: {
|
|
441
441
|
noLog: false,
|
|
442
442
|
skipConfirm: true,
|
|
@@ -61,7 +61,7 @@ class ContentTypesImport extends base_class_1.default {
|
|
|
61
61
|
cli_utilities_1.log.debug(`Found ${this.cTs.length} content types to import`, this.importConfig.context);
|
|
62
62
|
await utils_1.fsUtil.makeDirectory(this.cTsMapperPath);
|
|
63
63
|
cli_utilities_1.log.debug('Created content types mapper directory', this.importConfig.context);
|
|
64
|
-
this.installedExtensions = (
|
|
64
|
+
this.installedExtensions = (utils_1.fsUtil.readFile(this.marketplaceAppMapperPath) || { extension_uid: {} }).extension_uid;
|
|
65
65
|
cli_utilities_1.log.debug(`Loaded ${(_a = Object.keys(this.installedExtensions)) === null || _a === void 0 ? void 0 : _a.length} installed extensions`, this.importConfig.context);
|
|
66
66
|
this.taxonomies = utils_1.fsUtil.readFile(this.taxonomiesPath);
|
|
67
67
|
const taxonomyCount = Object.keys(this.taxonomies || {}).length;
|
|
@@ -46,24 +46,24 @@ class EntriesImport extends base_class_1.default {
|
|
|
46
46
|
async start() {
|
|
47
47
|
var _a;
|
|
48
48
|
try {
|
|
49
|
-
this.cTs = utils_1.fsUtil.readFile(path.join(this.cTsPath, 'schema.json'));
|
|
49
|
+
this.cTs = (utils_1.fsUtil.readFile(path.join(this.cTsPath, 'schema.json')) || []);
|
|
50
50
|
if (!this.cTs || (0, lodash_1.isEmpty)(this.cTs)) {
|
|
51
|
-
cli_utilities_1.log.
|
|
51
|
+
cli_utilities_1.log.warn(`No content types file found at ${path.join(this.cTsPath, 'schema.json')}. Skipping entries import.`, this.importConfig.context);
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
54
|
cli_utilities_1.log.debug(`Found ${this.cTs.length} content types for entry import`, this.importConfig.context);
|
|
55
|
-
this.installedExtensions = (
|
|
55
|
+
this.installedExtensions = (utils_1.fsUtil.readFile(this.marketplaceAppMapperPath) || { extension_uid: {} }).extension_uid;
|
|
56
56
|
cli_utilities_1.log.debug('Loaded installed extensions for entry processing', this.importConfig.context);
|
|
57
57
|
this.assetUidMapper = utils_1.fsUtil.readFile(this.assetUidMapperPath) || {};
|
|
58
58
|
this.assetUrlMapper = utils_1.fsUtil.readFile(this.assetUrlMapperPath) || {};
|
|
59
59
|
cli_utilities_1.log.debug(`Loaded asset mappings - UIDs: ${Object.keys(this.assetUidMapper).length}, URLs: ${Object.keys(this.assetUrlMapper).length}`, this.importConfig.context);
|
|
60
|
-
this.taxonomies = utils_1.fsUtil.readFile(this.taxonomiesPath);
|
|
60
|
+
this.taxonomies = (utils_1.fsUtil.readFile(this.taxonomiesPath) || {});
|
|
61
61
|
cli_utilities_1.log.debug('Loaded taxonomy data for entry processing', this.importConfig.context);
|
|
62
62
|
utils_1.fsUtil.makeDirectory(this.entriesMapperPath);
|
|
63
63
|
cli_utilities_1.log.debug('Created entries mapper directory', this.importConfig.context);
|
|
64
64
|
cli_utilities_1.log.info('Preparing content types for entry import', this.importConfig.context);
|
|
65
65
|
await this.disableMandatoryCTReferences();
|
|
66
|
-
this.locales = (0, lodash_1.values)(utils_1.fsUtil.readFile(this.localesPath));
|
|
66
|
+
this.locales = (0, lodash_1.values)((utils_1.fsUtil.readFile(this.localesPath) || []));
|
|
67
67
|
this.locales.unshift(this.importConfig.master_locale); // adds master locale to the list
|
|
68
68
|
cli_utilities_1.log.debug(`Processing entries for ${(0, lodash_1.values)(this.locales).length} locales`, this.importConfig.context);
|
|
69
69
|
//Create Entries
|
|
@@ -119,8 +119,14 @@ class EntriesImport extends base_class_1.default {
|
|
|
119
119
|
// Publishing entries
|
|
120
120
|
if (!this.importConfig.skipEntriesPublish) {
|
|
121
121
|
cli_utilities_1.log.info('Starting entry publishing process', this.importConfig.context);
|
|
122
|
-
this.envs = utils_1.fileHelper.readFileSync(this.envPath);
|
|
123
|
-
|
|
122
|
+
this.envs = utils_1.fileHelper.readFileSync(this.envPath) || {};
|
|
123
|
+
if (Object.keys(this.envs).length === 0) {
|
|
124
|
+
cli_utilities_1.log.warn(`No environments file found at ${this.envPath}. Entries will not be published.`, this.importConfig.context);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
cli_utilities_1.log.debug(`Loaded ${Object.keys(this.envs).length} environments for publishing`, this.importConfig.context);
|
|
129
|
+
}
|
|
124
130
|
for (let entryRequestOption of entryRequestOptions) {
|
|
125
131
|
await this.publishEntries(entryRequestOption).catch((error) => {
|
|
126
132
|
(0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.importConfig.context), { cTUid: entryRequestOption.cTUid, locale: entryRequestOption.locale }), `Error in publishing entries of ${entryRequestOption.cTUid} in locale ${entryRequestOption.locale}`);
|
|
@@ -137,7 +143,6 @@ class EntriesImport extends base_class_1.default {
|
|
|
137
143
|
catch (error) {
|
|
138
144
|
this.createEntryDataForVariantEntry();
|
|
139
145
|
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.importConfig.context));
|
|
140
|
-
throw new Error('Error while importing entries');
|
|
141
146
|
}
|
|
142
147
|
}
|
|
143
148
|
/**
|
|
@@ -157,8 +162,7 @@ class EntriesImport extends base_class_1.default {
|
|
|
157
162
|
cli_utilities_1.log.debug(`Successfully processed content type: ${uid}`, this.importConfig.context);
|
|
158
163
|
};
|
|
159
164
|
const onReject = ({ error, apiData: { uid } }) => {
|
|
160
|
-
(0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.importConfig.context), { uid }));
|
|
161
|
-
throw new Error(`${uid} content type references removal failed`);
|
|
165
|
+
(0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.importConfig.context), { uid }), `${uid} content type references removal failed`);
|
|
162
166
|
};
|
|
163
167
|
return await this.makeConcurrentCall({
|
|
164
168
|
processName: 'Update content types (removing mandatory references temporarily)',
|
|
@@ -587,7 +591,7 @@ class EntriesImport extends base_class_1.default {
|
|
|
587
591
|
for (const index in indexer) {
|
|
588
592
|
cli_utilities_1.log.debug(`Processing reference update chunk ${index} of ${indexerCount} for ${cTUid} in ${locale}`, this.importConfig.context);
|
|
589
593
|
const chunk = await fs.readChunkFiles.next().catch((error) => {
|
|
590
|
-
(0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.importConfig.context), { cTUid, locale }), '
|
|
594
|
+
(0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.importConfig.context), { cTUid, locale }), 'Failed to load data chunks due to a read error. Ensure the files are accessible and not corrupted.');
|
|
591
595
|
});
|
|
592
596
|
if (chunk) {
|
|
593
597
|
let apiContent = (0, lodash_1.values)(chunk);
|
|
@@ -664,7 +668,7 @@ class EntriesImport extends base_class_1.default {
|
|
|
664
668
|
cli_utilities_1.log.success(`${uid} content type references updated`, this.importConfig.context);
|
|
665
669
|
};
|
|
666
670
|
const onReject = ({ error, apiData: { uid } }) => {
|
|
667
|
-
(0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.importConfig.context), { uid }), '
|
|
671
|
+
(0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.importConfig.context), { uid }), `Failed to update references of content type '${uid}'`);
|
|
668
672
|
throw new Error(`Failed to update references of content type ${uid}`);
|
|
669
673
|
};
|
|
670
674
|
return await this.makeConcurrentCall({
|
|
@@ -724,7 +728,7 @@ class EntriesImport extends base_class_1.default {
|
|
|
724
728
|
}
|
|
725
729
|
async updateFieldRules() {
|
|
726
730
|
var _a, _b, _c;
|
|
727
|
-
let cTsWithFieldRules = utils_1.fsUtil.readFile(path.join(this.cTsPath + '/field_rules_uid.json'));
|
|
731
|
+
let cTsWithFieldRules = (utils_1.fsUtil.readFile(path.join(this.cTsPath + '/field_rules_uid.json')) || []);
|
|
728
732
|
if (!cTsWithFieldRules || (cTsWithFieldRules === null || cTsWithFieldRules === void 0 ? void 0 : cTsWithFieldRules.length) === 0) {
|
|
729
733
|
cli_utilities_1.log.debug('No content types with field rules found to update', this.importConfig.context);
|
|
730
734
|
return;
|
|
@@ -732,7 +736,7 @@ class EntriesImport extends base_class_1.default {
|
|
|
732
736
|
cli_utilities_1.log.debug(`Found ${cTsWithFieldRules.length} content types with field rules to update`, this.importConfig.context);
|
|
733
737
|
for (let cTUid of cTsWithFieldRules) {
|
|
734
738
|
cli_utilities_1.log.debug(`Processing field rules for content type: ${cTUid}`, this.importConfig.context);
|
|
735
|
-
const cTs = utils_1.fsUtil.readFile(path.join(this.cTsPath, 'schema.json'));
|
|
739
|
+
const cTs = (utils_1.fsUtil.readFile(path.join(this.cTsPath, 'schema.json')) || []);
|
|
736
740
|
const contentType = (0, lodash_1.find)(cTs, { uid: cTUid });
|
|
737
741
|
if (contentType.field_rules) {
|
|
738
742
|
cli_utilities_1.log.debug(`Found ${contentType.field_rules.length} field rules for content type: ${cTUid}`, this.importConfig.context);
|
|
@@ -290,7 +290,7 @@ const lookupAssets = function (data, mappedAssetUids, mappedAssetUrls, assetUidM
|
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
if (unmatchedUids.length) {
|
|
293
|
-
cli_utilities_1.log.
|
|
293
|
+
cli_utilities_1.log.debug(`Found ${unmatchedUids.length} unmatched asset UIDs`);
|
|
294
294
|
let unmatchedAssetUids = helper.readFileSync(path.join(assetUidMapperPath, 'unmatched-asset-uids.json'));
|
|
295
295
|
unmatchedAssetUids = unmatchedAssetUids || {};
|
|
296
296
|
if (unmatchedAssetUids.hasOwnProperty(data.content_type.uid)) {
|
|
@@ -304,7 +304,7 @@ const lookupAssets = function (data, mappedAssetUids, mappedAssetUrls, assetUidM
|
|
|
304
304
|
helper.writeFile(path.join(assetUidMapperPath, 'unmatched-asset-uids.json'));
|
|
305
305
|
}
|
|
306
306
|
if (unmatchedUrls.length) {
|
|
307
|
-
cli_utilities_1.log.
|
|
307
|
+
cli_utilities_1.log.debug(`Found ${unmatchedUrls.length} unmatched asset URLs`);
|
|
308
308
|
let unmatchedAssetUrls = helper.readFileSync(path.join(assetUidMapperPath, 'unmatched-asset-urls.json'));
|
|
309
309
|
unmatchedAssetUrls = unmatchedAssetUrls || {};
|
|
310
310
|
if (unmatchedAssetUrls.hasOwnProperty(data.content_type.uid)) {
|
|
@@ -128,8 +128,7 @@ const removeReferenceFields = async function (schema, flag = { supressed: false
|
|
|
128
128
|
catch (error) {
|
|
129
129
|
// Else warn and modify the schema object.
|
|
130
130
|
isContentTypeError = true;
|
|
131
|
-
cli_utilities_1.log.warn(`Content
|
|
132
|
-
console.warn(`Content-type ${schema[i].reference_to[j]} does not exist. Removing the field from schema`);
|
|
131
|
+
cli_utilities_1.log.warn(`Content-type ${schema[i].reference_to[j]} does not exist. Removing the field from schema`);
|
|
133
132
|
}
|
|
134
133
|
}
|
|
135
134
|
if (isContentTypeError) {
|
|
@@ -238,7 +238,7 @@ const lookupEntries = function (data, mappedUids, uidMapperPath) {
|
|
|
238
238
|
}
|
|
239
239
|
});
|
|
240
240
|
if (unmapped.length > 0) {
|
|
241
|
-
cli_utilities_1.log.
|
|
241
|
+
cli_utilities_1.log.debug(`Found ${unmapped.length} unmapped entry references`);
|
|
242
242
|
let unmappedUids = fileHelper.readFileSync(path.join(uidMapperPath, 'unmapped-uids.json'));
|
|
243
243
|
unmappedUids = unmappedUids || {};
|
|
244
244
|
if (unmappedUids.hasOwnProperty(data.content_type.uid)) {
|
|
@@ -69,7 +69,7 @@ const lookupExtension = function (config, schema, preserveStackVersion, installe
|
|
|
69
69
|
schema[i].reference_to = global_fields_data[global_fields_key_value];
|
|
70
70
|
}
|
|
71
71
|
else {
|
|
72
|
-
cli_utilities_1.log.
|
|
72
|
+
cli_utilities_1.log.debug(`No mapping found for global field: ${global_fields_key_value}`);
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
else if (schema[i].hasOwnProperty('extension_uid')) {
|
|
@@ -88,7 +88,7 @@ const lookupExtension = function (config, schema, preserveStackVersion, installe
|
|
|
88
88
|
schema[i].extension_uid = installedExtensions[schema[i].extension_uid];
|
|
89
89
|
}
|
|
90
90
|
else {
|
|
91
|
-
cli_utilities_1.log.
|
|
91
|
+
cli_utilities_1.log.debug(`No mapping found for extension: ${extension_key_value}`);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -111,7 +111,7 @@ const lookupExtension = function (config, schema, preserveStackVersion, installe
|
|
|
111
111
|
newPluginUidsArray.push(marketPlaceAppsData.extension_uid[extension_key_value]);
|
|
112
112
|
}
|
|
113
113
|
else {
|
|
114
|
-
cli_utilities_1.log.
|
|
114
|
+
cli_utilities_1.log.debug(`No mapping found for plugin extension: ${extension_key_value}`);
|
|
115
115
|
}
|
|
116
116
|
});
|
|
117
117
|
cli_utilities_1.log.debug(`Updated plugins array with ${newPluginUidsArray.length} mapped extensions`);
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-cm-import",
|
|
3
3
|
"description": "Contentstack CLI plugin to import content into stack",
|
|
4
|
-
"version": "1.26.
|
|
4
|
+
"version": "1.26.3",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@contentstack/cli-audit": "~1.14.0",
|
|
9
9
|
"@contentstack/cli-command": "~1.6.0",
|
|
10
|
-
"@contentstack/cli-utilities": "~1.13.
|
|
10
|
+
"@contentstack/cli-utilities": "~1.13.2",
|
|
11
11
|
"@contentstack/management": "~1.22.0",
|
|
12
12
|
"@contentstack/cli-variants": "~1.3.0",
|
|
13
13
|
"@oclif/core": "^4.3.0",
|