@contentstack/cli-cm-import 1.24.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.24.0 linux-x64 node-v22.16.0
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
@@ -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',
@@ -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;
@@ -199,5 +199,5 @@
199
199
  ]
200
200
  }
201
201
  },
202
- "version": "1.24.0"
202
+ "version": "1.25.0"
203
203
  }
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.24.0",
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.21.4",
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",