@contentstack/cli-cm-import 1.23.0 → 1.25.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.
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.
|
|
50
|
+
@contentstack/cli-cm-import/1.25.0 linux-x64 node-v22.17.0
|
|
51
51
|
$ csdx --help [COMMAND]
|
|
52
52
|
USAGE
|
|
53
53
|
$ csdx COMMAND
|
package/lib/config/index.js
CHANGED
|
@@ -30,6 +30,7 @@ const config = {
|
|
|
30
30
|
types: [
|
|
31
31
|
'locales',
|
|
32
32
|
'environments',
|
|
33
|
+
'stack',
|
|
33
34
|
'assets',
|
|
34
35
|
'taxonomies',
|
|
35
36
|
'extensions',
|
|
@@ -155,7 +156,13 @@ const config = {
|
|
|
155
156
|
},
|
|
156
157
|
personalize: {
|
|
157
158
|
baseURL: {
|
|
158
|
-
NA: 'https://personalize-api.contentstack.com',
|
|
159
|
+
'AWS-NA': 'https://personalize-api.contentstack.com',
|
|
160
|
+
'AWS-EU': 'https://eu-personalize-api.contentstack.com',
|
|
161
|
+
'AWS-AU': 'https://au-personalize-api.contentstack.com',
|
|
162
|
+
'AZURE-NA': 'https://azure-na-personalize-api.contentstack.com',
|
|
163
|
+
'AZURE-EU': 'https://azure-eu-personalize-api.contentstack.com',
|
|
164
|
+
'GCP-NA': 'https://gcp-na-personalize-api.contentstack.com',
|
|
165
|
+
'GCP-EU': 'https://gcp-eu-personalize-api.contentstack.com',
|
|
159
166
|
},
|
|
160
167
|
importData: true,
|
|
161
168
|
dirName: 'personalize',
|
|
@@ -33,11 +33,11 @@ export default class EntriesImport extends BaseClass {
|
|
|
33
33
|
taxonomies: Record<string, unknown>;
|
|
34
34
|
rteCTs: any;
|
|
35
35
|
rteCTsWithRef: any;
|
|
36
|
-
entriesForVariant: {
|
|
36
|
+
entriesForVariant: Array<{
|
|
37
37
|
content_type: string;
|
|
38
38
|
locale: string;
|
|
39
39
|
entry_uid: string;
|
|
40
|
-
}
|
|
40
|
+
}>;
|
|
41
41
|
constructor({ importConfig, stackAPIClient }: ModuleClassParams);
|
|
42
42
|
start(): Promise<any>;
|
|
43
43
|
/**
|
|
@@ -281,7 +281,7 @@ class EntriesImport extends base_class_1.default {
|
|
|
281
281
|
var _a, _b;
|
|
282
282
|
const { title, uid } = entry;
|
|
283
283
|
// NOTE Remove from list if any entry import failed
|
|
284
|
-
|
|
284
|
+
this.entriesForVariant = this.entriesForVariant.filter((item) => !(item.locale === locale && item.entry_uid === uid));
|
|
285
285
|
// NOTE: write existing entries into files to handler later
|
|
286
286
|
if (error.errorCode === 119) {
|
|
287
287
|
if (((_a = error === null || error === void 0 ? void 0 : error.errors) === null || _a === void 0 ? void 0 : _a.title) || ((_b = error === null || error === void 0 ? void 0 : error.errors) === null || _b === void 0 ? void 0 : _b.uid)) {
|
|
@@ -410,7 +410,7 @@ class EntriesImport extends base_class_1.default {
|
|
|
410
410
|
};
|
|
411
411
|
const onReject = ({ error, apiData: { uid, title } }) => {
|
|
412
412
|
// NOTE Remove from list if any entry import failed
|
|
413
|
-
|
|
413
|
+
this.entriesForVariant = this.entriesForVariant.filter((item) => !(item.locale === locale && item.entry_uid === uid));
|
|
414
414
|
(0, utils_1.log)(this.importConfig, `${title} entry of content type ${cTUid} in locale ${locale} failed to replace`, 'error');
|
|
415
415
|
(0, utils_1.log)(this.importConfig, (0, utils_1.formatError)(error), 'error');
|
|
416
416
|
this.failedEntries.push({
|
|
@@ -524,7 +524,7 @@ class EntriesImport extends base_class_1.default {
|
|
|
524
524
|
};
|
|
525
525
|
const onReject = ({ error, apiData: { uid, title } }) => {
|
|
526
526
|
// NOTE Remove from list if any entry import failed
|
|
527
|
-
|
|
527
|
+
this.entriesForVariant = this.entriesForVariant.filter((item) => !(item.locale === locale && item.entry_uid === uid));
|
|
528
528
|
(0, utils_1.log)(this.importConfig, `${title} entry of content type ${cTUid} in locale ${locale} failed to update`, 'error');
|
|
529
529
|
(0, utils_1.log)(this.importConfig, (0, utils_1.formatError)(error), 'error');
|
|
530
530
|
this.failedEntries.push({
|
|
@@ -643,21 +643,13 @@ class EntriesImport extends base_class_1.default {
|
|
|
643
643
|
async removeAutoCreatedEntries() {
|
|
644
644
|
var _a, _b;
|
|
645
645
|
const onSuccess = ({ response, apiData: { entryUid } }) => {
|
|
646
|
-
var _a, _b;
|
|
647
646
|
// NOTE Remove entry from list
|
|
648
|
-
(
|
|
649
|
-
entry_uid: entryUid,
|
|
650
|
-
locale: (_b = (_a = this.importConfig) === null || _a === void 0 ? void 0 : _a.master_locale) === null || _b === void 0 ? void 0 : _b.code,
|
|
651
|
-
});
|
|
647
|
+
this.entriesForVariant = this.entriesForVariant.filter((item) => { var _a, _b; return !(item.entry_uid === entryUid && item.locale === ((_b = (_a = this.importConfig) === null || _a === void 0 ? void 0 : _a.master_locale) === null || _b === void 0 ? void 0 : _b.code)); });
|
|
652
648
|
(0, utils_1.log)(this.importConfig, `Auto created entry in master locale removed - entry uid ${entryUid} `, 'success');
|
|
653
649
|
};
|
|
654
650
|
const onReject = ({ error, apiData: { entryUid } }) => {
|
|
655
|
-
var _a, _b;
|
|
656
651
|
// NOTE Remove entry from list
|
|
657
|
-
(
|
|
658
|
-
entry_uid: entryUid,
|
|
659
|
-
locale: (_b = (_a = this.importConfig) === null || _a === void 0 ? void 0 : _a.master_locale) === null || _b === void 0 ? void 0 : _b.code,
|
|
660
|
-
});
|
|
652
|
+
this.entriesForVariant = this.entriesForVariant.filter((item) => { var _a, _b; return !(item.entry_uid === entryUid && item.locale === ((_b = (_a = this.importConfig) === null || _a === void 0 ? void 0 : _a.master_locale) === null || _b === void 0 ? void 0 : _b.code)); });
|
|
661
653
|
(0, utils_1.log)(this.importConfig, `Failed to remove auto created entry in master locale - entry uid ${entryUid} \n ${(0, utils_1.formatError)(error)}`, 'error');
|
|
662
654
|
};
|
|
663
655
|
return await this.makeConcurrentCall({
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import BaseClass from './base-class';
|
|
2
|
+
import { ModuleClassParams } from '../../types';
|
|
3
|
+
export default class ImportStack extends BaseClass {
|
|
4
|
+
private stackSettingsPath;
|
|
5
|
+
private envUidMapperPath;
|
|
6
|
+
private stackSettings;
|
|
7
|
+
private envUidMapper;
|
|
8
|
+
constructor({ importConfig, stackAPIClient }: ModuleClassParams);
|
|
9
|
+
start(): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
const base_class_1 = tslib_1.__importDefault(require("./base-class"));
|
|
7
|
+
class ImportStack extends base_class_1.default {
|
|
8
|
+
constructor({ importConfig, stackAPIClient }) {
|
|
9
|
+
super({ importConfig, stackAPIClient });
|
|
10
|
+
this.stackSettings = null;
|
|
11
|
+
this.envUidMapper = {};
|
|
12
|
+
this.stackSettingsPath = (0, node_path_1.join)(this.importConfig.backupDir, 'stack', 'settings.json');
|
|
13
|
+
this.envUidMapperPath = (0, node_path_1.join)(this.importConfig.backupDir, 'mapper', 'environments', 'uid-mapping.json');
|
|
14
|
+
}
|
|
15
|
+
async start() {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
(0, utils_1.log)(this.importConfig, 'Migrating stack...', 'info');
|
|
18
|
+
if (utils_1.fileHelper.fileExistsSync(this.envUidMapperPath)) {
|
|
19
|
+
this.envUidMapper = utils_1.fsUtil.readFile(this.envUidMapperPath, true);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
throw new Error('Please run the environments migration first.');
|
|
23
|
+
}
|
|
24
|
+
if (utils_1.fileHelper.fileExistsSync(this.stackSettingsPath)) {
|
|
25
|
+
this.stackSettings = utils_1.fsUtil.readFile(this.stackSettingsPath, true);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
(0, utils_1.log)(this.importConfig, 'No stack Found!', 'info');
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (((_a = this.stackSettings) === null || _a === void 0 ? void 0 : _a.live_preview) && ((_b = this.stackSettings) === null || _b === void 0 ? void 0 : _b.live_preview['default-env'])) {
|
|
32
|
+
const oldEnvUid = this.stackSettings.live_preview['default-env'];
|
|
33
|
+
const mappedEnvUid = this.envUidMapper[oldEnvUid];
|
|
34
|
+
this.stackSettings.live_preview['default-env'] = mappedEnvUid;
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
await this.stack.addSettings(this.stackSettings);
|
|
38
|
+
(0, utils_1.log)(this.importConfig, 'Successfully imported stack', 'success');
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
(0, utils_1.log)(this.importConfig, `Stack failed to be imported! ${(0, utils_1.formatError)(error)}`, 'error');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.default = ImportStack;
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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.25.0",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@contentstack/cli-audit": "~1.13.0",
|
|
9
9
|
"@contentstack/cli-command": "~1.5.0",
|
|
10
10
|
"@contentstack/cli-utilities": "~1.12.0",
|
|
11
|
-
"@contentstack/management": "~1.
|
|
11
|
+
"@contentstack/management": "~1.22.0",
|
|
12
12
|
"@contentstack/cli-variants": "~1.2.1",
|
|
13
13
|
"@oclif/core": "^4.3.0",
|
|
14
14
|
"big-json": "^3.2.0",
|