@contentstack/cli-cm-import 1.26.1 → 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 +5 -5
- package/lib/import/modules/stack.js +12 -12
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
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);
|
|
@@ -45,10 +46,9 @@ class ImportCommand extends cli_command_1.Command {
|
|
|
45
46
|
// Branch not enabled, just the let flow continue
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
|
-
// Set backupDir early so it's available in error handling
|
|
49
|
-
backupDir = importConfig.backupDir;
|
|
50
49
|
const moduleImporter = new import_1.ModuleImporter(managementAPIClient, importConfig);
|
|
51
50
|
const result = await moduleImporter.start();
|
|
51
|
+
backupDir = importConfig.backupDir;
|
|
52
52
|
if (!(result === null || result === void 0 ? void 0 : result.noSuccessMsg)) {
|
|
53
53
|
const successMessage = importConfig.stackName
|
|
54
54
|
? `Successfully imported the content to the stack named ${importConfig.stackName} with the API key ${importConfig.apiKey} .`
|
|
@@ -61,8 +61,8 @@ class ImportCommand extends cli_command_1.Command {
|
|
|
61
61
|
catch (error) {
|
|
62
62
|
(0, cli_utilities_1.handleAndLogError)(error);
|
|
63
63
|
cli_utilities_1.log.info(`The log has been stored at '${(0, cli_utilities_1.getLogPath)()}'`);
|
|
64
|
-
if (backupDir) {
|
|
65
|
-
cli_utilities_1.log.info(`The backup content has been stored at '${backupDir}'`);
|
|
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
66
|
}
|
|
67
67
|
else {
|
|
68
68
|
cli_utilities_1.log.info('No backup directory was created due to early termination');
|
|
@@ -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