@contentstack/cli-cm-import 1.25.0 → 1.25.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
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.25.
|
|
50
|
+
@contentstack/cli-cm-import/1.25.1 linux-x64 node-v22.17.0
|
|
51
51
|
$ csdx --help [COMMAND]
|
|
52
52
|
USAGE
|
|
53
53
|
$ csdx COMMAND
|
|
@@ -9,6 +9,7 @@ const entries_1 = tslib_1.__importDefault(require("lodash/entries"));
|
|
|
9
9
|
const isEqual_1 = tslib_1.__importDefault(require("lodash/isEqual"));
|
|
10
10
|
const omit_1 = tslib_1.__importDefault(require("lodash/omit"));
|
|
11
11
|
const utils_1 = require("../../utils");
|
|
12
|
+
const cloneDeep_1 = tslib_1.__importDefault(require("lodash/cloneDeep"));
|
|
12
13
|
class BaseClass {
|
|
13
14
|
constructor({ importConfig, stackAPIClient }) {
|
|
14
15
|
this.client = stackAPIClient;
|
|
@@ -197,9 +198,16 @@ class BaseClass {
|
|
|
197
198
|
return this.stack
|
|
198
199
|
.globalField(globalFieldUid, { api_version: '3.2' })
|
|
199
200
|
.fetch()
|
|
200
|
-
.then(async (
|
|
201
|
-
|
|
202
|
-
|
|
201
|
+
.then(async (gf) => {
|
|
202
|
+
const _a = (0, cloneDeep_1.default)(apiData), { uid } = _a, updatePayload = tslib_1.__rest(_a, ["uid"]);
|
|
203
|
+
Object.assign(gf, updatePayload);
|
|
204
|
+
try {
|
|
205
|
+
const response = await gf.update();
|
|
206
|
+
return onSuccess(response);
|
|
207
|
+
}
|
|
208
|
+
catch (error) {
|
|
209
|
+
return onReject(error);
|
|
210
|
+
}
|
|
203
211
|
})
|
|
204
212
|
.catch(onReject);
|
|
205
213
|
case 'create-environments':
|
|
@@ -74,6 +74,11 @@ class ContentTypesImport extends base_class_1.default {
|
|
|
74
74
|
if (this.isExtensionsUpdate) {
|
|
75
75
|
(0, utils_1.log)(this.importConfig, 'Successfully updated the extensions.', 'success');
|
|
76
76
|
}
|
|
77
|
+
this.pendingGFs = utils_1.fsUtil.readFile(this.gFsPendingPath);
|
|
78
|
+
if (!this.pendingGFs || (0, lodash_1.isEmpty)(this.pendingGFs)) {
|
|
79
|
+
(0, utils_1.log)(this.importConfig, 'No pending global fields found to update', 'info');
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
77
82
|
await this.updatePendingGFs().catch((error) => {
|
|
78
83
|
(0, utils_1.log)(this.importConfig, `Error while updating pending global field ${(0, utils_1.formatError)(error)}`, 'error');
|
|
79
84
|
});
|
|
@@ -165,8 +170,9 @@ class ContentTypesImport extends base_class_1.default {
|
|
|
165
170
|
}
|
|
166
171
|
async updatePendingGFs() {
|
|
167
172
|
this.pendingGFs = utils_1.fsUtil.readFile(this.gFsPendingPath);
|
|
173
|
+
(0, utils_1.log)(this.importConfig, `Found ${this.pendingGFs.length} pending global fields to update`, 'info');
|
|
168
174
|
this.gFs = utils_1.fsUtil.readFile(path.resolve(this.gFsFolderPath, this.gFsConfig.fileName));
|
|
169
|
-
const onSuccess = ({ response
|
|
175
|
+
const onSuccess = ({ response, apiData: { uid } = undefined }) => {
|
|
170
176
|
(0, utils_1.log)(this.importConfig, `Updated the global field ${uid} with content type references`, 'info');
|
|
171
177
|
};
|
|
172
178
|
const onReject = ({ error, apiData: { uid } = undefined }) => {
|
|
@@ -46,10 +46,10 @@ class ImportGlobalFields extends base_class_1.default {
|
|
|
46
46
|
}
|
|
47
47
|
this.installedExtensions = ((await utils_1.fsUtil.readFile(this.marketplaceAppMapperPath)) || { extension_uid: {} }).extension_uid;
|
|
48
48
|
await this.seedGFs();
|
|
49
|
-
if ((_a = this.seedGFs) === null || _a === void 0 ? void 0 : _a.length)
|
|
50
|
-
utils_1.fsUtil.writeFile(this.gFsPendingPath, this.pendingGFs);
|
|
51
49
|
(0, utils_1.log)(this.importConfig, 'Created Global Fields', 'success');
|
|
52
50
|
await this.updateGFs();
|
|
51
|
+
if ((_a = this.pendingGFs) === null || _a === void 0 ? void 0 : _a.length)
|
|
52
|
+
utils_1.fsUtil.writeFile(this.gFsPendingPath, this.pendingGFs);
|
|
53
53
|
(0, utils_1.log)(this.importConfig, 'Updated Global Fields', 'success');
|
|
54
54
|
if (this.importConfig.replaceExisting && this.existingGFs.length > 0) {
|
|
55
55
|
await this.replaceGFs().catch((error) => {
|
|
@@ -133,6 +133,8 @@ class ImportGlobalFields extends base_class_1.default {
|
|
|
133
133
|
await (0, utils_1.removeReferenceFields)(globalField.schema, flag, this.stack);
|
|
134
134
|
if (flag.supressed) {
|
|
135
135
|
this.pendingGFs.push(globalField.uid);
|
|
136
|
+
(0, utils_1.log)(this.importConfig, `Global field '${globalField.uid}' will be updated later`, 'info');
|
|
137
|
+
return resolve(true);
|
|
136
138
|
}
|
|
137
139
|
return this.stack
|
|
138
140
|
.globalField(globalField.uid, { api_version: '3.2' })
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED