@contentstack/cli-cm-import 1.26.0 → 1.26.2
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/commands/cm/stacks/import.js +8 -2
- package/lib/import/module-importer.js +19 -2
- package/lib/import/modules/stack.js +12 -12
- package/oclif.manifest.json +1 -1
- package/package.json +3 -3
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.2 linux-x64 node-v22.18.0
|
|
51
51
|
$ csdx --help [COMMAND]
|
|
52
52
|
USAGE
|
|
53
53
|
$ csdx COMMAND
|
|
@@ -10,9 +10,10 @@ class ImportCommand extends cli_command_1.Command {
|
|
|
10
10
|
// initialize the importer
|
|
11
11
|
// start import
|
|
12
12
|
let backupDir;
|
|
13
|
+
let importConfig;
|
|
13
14
|
try {
|
|
14
15
|
const { flags } = await this.parse(ImportCommand);
|
|
15
|
-
|
|
16
|
+
importConfig = await (0, utils_1.setupImportConfig)(flags);
|
|
16
17
|
// Prepare the context object
|
|
17
18
|
const context = this.createImportContext(importConfig.apiKey, importConfig.authenticationMethod);
|
|
18
19
|
importConfig.context = Object.assign({}, context);
|
|
@@ -60,7 +61,12 @@ class ImportCommand extends cli_command_1.Command {
|
|
|
60
61
|
catch (error) {
|
|
61
62
|
(0, cli_utilities_1.handleAndLogError)(error);
|
|
62
63
|
cli_utilities_1.log.info(`The log has been stored at '${(0, cli_utilities_1.getLogPath)()}'`);
|
|
63
|
-
|
|
64
|
+
if (importConfig === null || importConfig === void 0 ? void 0 : importConfig.backupDir) {
|
|
65
|
+
cli_utilities_1.log.info(`The backup content has been stored at '${importConfig === null || importConfig === void 0 ? void 0 : importConfig.backupDir}'`);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
cli_utilities_1.log.info('No backup directory was created due to early termination');
|
|
69
|
+
}
|
|
64
70
|
}
|
|
65
71
|
}
|
|
66
72
|
// Create export context object
|
|
@@ -40,7 +40,15 @@ class ModuleImporter {
|
|
|
40
40
|
// NOTE audit and fix the import content.
|
|
41
41
|
if (!this.importConfig.skipAudit &&
|
|
42
42
|
(!this.importConfig.moduleName ||
|
|
43
|
-
[
|
|
43
|
+
[
|
|
44
|
+
'content-types',
|
|
45
|
+
'global-fields',
|
|
46
|
+
'entries',
|
|
47
|
+
'extensions',
|
|
48
|
+
'workflows',
|
|
49
|
+
'custom-roles',
|
|
50
|
+
'assets'
|
|
51
|
+
].includes(this.importConfig.moduleName))) {
|
|
44
52
|
if (!(await this.auditImportData(logger))) {
|
|
45
53
|
return { noSuccessMsg: true };
|
|
46
54
|
}
|
|
@@ -119,11 +127,20 @@ class ModuleImporter {
|
|
|
119
127
|
}
|
|
120
128
|
else if (this.importConfig.modules.types.length) {
|
|
121
129
|
this.importConfig.modules.types
|
|
122
|
-
.filter((val) => [
|
|
130
|
+
.filter((val) => [
|
|
131
|
+
'content-types',
|
|
132
|
+
'global-fields',
|
|
133
|
+
'entries',
|
|
134
|
+
'extensions',
|
|
135
|
+
'workflows',
|
|
136
|
+
'custom-roles',
|
|
137
|
+
'assets'
|
|
138
|
+
].includes(val))
|
|
123
139
|
.forEach((val) => {
|
|
124
140
|
args.push('--modules', val);
|
|
125
141
|
});
|
|
126
142
|
}
|
|
143
|
+
args.push('--modules', 'field-rules');
|
|
127
144
|
(0, utils_1.log)(this.importConfig, 'Starting audit process', 'info');
|
|
128
145
|
const result = await cli_audit_1.AuditFix.run(args);
|
|
129
146
|
(0, utils_1.log)(this.importConfig, 'Audit process completed', 'info');
|
|
@@ -4,6 +4,7 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const node_path_1 = require("node:path");
|
|
5
5
|
const utils_1 = require("../../utils");
|
|
6
6
|
const base_class_1 = tslib_1.__importDefault(require("./base-class"));
|
|
7
|
+
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
7
8
|
class ImportStack extends base_class_1.default {
|
|
8
9
|
constructor({ importConfig, stackAPIClient }) {
|
|
9
10
|
super({ importConfig, stackAPIClient });
|
|
@@ -14,23 +15,22 @@ class ImportStack extends base_class_1.default {
|
|
|
14
15
|
}
|
|
15
16
|
async start() {
|
|
16
17
|
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
18
|
if (this.importConfig.management_token) {
|
|
25
|
-
|
|
26
|
-
(0, utils_1.log)(this.importConfig, 'Successfully imported stack', 'success');
|
|
19
|
+
cli_utilities_1.log.info('Skipping stack settings import: Operation is not supported when using a management token.', this.importConfig.context);
|
|
27
20
|
return;
|
|
28
21
|
}
|
|
29
22
|
if (utils_1.fileHelper.fileExistsSync(this.stackSettingsPath)) {
|
|
30
23
|
this.stackSettings = utils_1.fsUtil.readFile(this.stackSettingsPath, true);
|
|
31
24
|
}
|
|
32
25
|
else {
|
|
33
|
-
|
|
26
|
+
cli_utilities_1.log.info('No stack setting found!', this.importConfig.context);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (utils_1.fileHelper.fileExistsSync(this.envUidMapperPath)) {
|
|
30
|
+
this.envUidMapper = utils_1.fsUtil.readFile(this.envUidMapperPath, true);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
cli_utilities_1.log.warn('Skipping stack settings import. Please run the environments migration first.', this.importConfig.context);
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
36
|
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'])) {
|
|
@@ -40,10 +40,10 @@ class ImportStack extends base_class_1.default {
|
|
|
40
40
|
}
|
|
41
41
|
try {
|
|
42
42
|
await this.stack.addSettings(this.stackSettings);
|
|
43
|
-
|
|
43
|
+
cli_utilities_1.log.success('Successfully imported stack', this.importConfig.context);
|
|
44
44
|
}
|
|
45
45
|
catch (error) {
|
|
46
|
-
(0,
|
|
46
|
+
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.importConfig.context));
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
}
|
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.2",
|
|
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.1",
|
|
11
11
|
"@contentstack/management": "~1.22.0",
|
|
12
12
|
"@contentstack/cli-variants": "~1.3.0",
|
|
13
13
|
"@oclif/core": "^4.3.0",
|
|
@@ -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",
|