@contentstack/cli-cm-import 1.17.1 → 1.19.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.17.1 linux-x64 node-v18.20.4
50
+ @contentstack/cli-cm-import/1.19.0 linux-x64 node-v18.20.4
51
51
  $ csdx --help [COMMAND]
52
52
  USAGE
53
53
  $ csdx COMMAND
@@ -19,6 +19,8 @@ class ImportCommand extends cli_command_1.Command {
19
19
  importConfig.host = this.cmaHost;
20
20
  importConfig.region = this.region;
21
21
  importConfig.developerHubBaseUrl = this.developerHubUrl;
22
+ if (this.personalizeUrl)
23
+ importConfig.modules.personalize.baseURL[importConfig.region.name] = this.personalizeUrl;
22
24
  backupDir = importConfig.cliLogsPath || importConfig.backupDir;
23
25
  const managementAPIClient = await (0, cli_utilities_1.managementSDKClient)(importConfig);
24
26
  const moduleImporter = new import_1.ModuleImporter(managementAPIClient, importConfig);
@@ -33,7 +33,7 @@ const config = {
33
33
  'marketplace-apps',
34
34
  'global-fields',
35
35
  'content-types',
36
- 'personalization',
36
+ 'personalize',
37
37
  'custom-roles',
38
38
  'workflows',
39
39
  'entries',
@@ -151,12 +151,12 @@ const config = {
151
151
  dirName: 'taxonomies',
152
152
  fileName: 'taxonomies.json',
153
153
  },
154
- personalization: {
154
+ personalize: {
155
155
  baseURL: {
156
- NA: 'https://personalization-api.contentstack.com',
156
+ NA: 'https://personalize-api.contentstack.com',
157
157
  },
158
158
  importData: true,
159
- dirName: 'personalization',
159
+ dirName: 'personalize',
160
160
  importOrder: ['attributes', 'audiences', 'events', 'experiences'],
161
161
  project_id: '',
162
162
  projects: {
@@ -333,7 +333,7 @@ class ImportMarketplaceApps {
333
333
  * @returns {Promise<void>}
334
334
  */
335
335
  async installApps(app) {
336
- var _a, _b;
336
+ var _a;
337
337
  let updateParam;
338
338
  const { configuration, server_configuration } = app;
339
339
  const currentStackApp = (0, find_1.default)(this.installedApps, { manifest: { uid: (_a = app === null || app === void 0 ? void 0 : app.manifest) === null || _a === void 0 ? void 0 : _a.uid } });
@@ -347,7 +347,7 @@ class ImportMarketplaceApps {
347
347
  // NOTE if it's private app it should get uid from mapper else will use manifest uid
348
348
  this.appUidMapping[app.manifest.uid] || app.manifest.uid);
349
349
  if (installation.installation_uid) {
350
- const appName = (_b = this.appNameMapping[app.manifest.name]) !== null && _b !== void 0 ? _b : app.manifest.name;
350
+ const appName = this.appNameMapping[app.manifest.name] || app.manifest.name || app.manifest.uid;
351
351
  (0, utils_1.log)(this.importConfig, `${appName} app installed successfully.!`, 'success');
352
352
  await (0, utils_1.makeRedirectUrlCall)(installation, appName, this.importConfig);
353
353
  this.installationUidMapping[app.uid] = installation.installation_uid;
@@ -359,7 +359,8 @@ class ImportMarketplaceApps {
359
359
  }
360
360
  }
361
361
  else if (!(0, isEmpty_1.default)(configuration) || !(0, isEmpty_1.default)(server_configuration)) {
362
- (0, utils_1.log)(this.importConfig, `${app.manifest.name} is already installed`, 'success');
362
+ const appName = app.manifest.name || app.manifest.uid;
363
+ (0, utils_1.log)(this.importConfig, `${appName} is already installed`, 'success');
363
364
  updateParam = await (0, utils_1.ifAppAlreadyExist)(app, currentStackApp, this.importConfig);
364
365
  }
365
366
  if (!this.appUidMapping[app.manifest.uid]) {
@@ -389,7 +390,8 @@ class ImportMarketplaceApps {
389
390
  (0, utils_1.log)(this.importConfig, (0, utils_1.formatError)(data.message), 'success');
390
391
  }
391
392
  else {
392
- (0, utils_1.log)(this.importConfig, `${app.manifest.name} app config updated successfully.!`, 'success');
393
+ const appName = app.manifest.name || app.manifest.uid;
394
+ (0, utils_1.log)(this.importConfig, `${appName} app config updated successfully.!`, 'success');
393
395
  }
394
396
  })
395
397
  .catch((error) => {
@@ -1,7 +1,7 @@
1
1
  import { ImportConfig, ModuleClassParams } from '../../types';
2
- export default class ImportPersonalization {
2
+ export default class ImportPersonalize {
3
3
  private config;
4
- personalizeConfig: ImportConfig['modules']['personalization'];
4
+ personalizeConfig: ImportConfig['modules']['personalize'];
5
5
  constructor({ importConfig }: ModuleClassParams);
6
6
  /**
7
7
  * The `start` function in TypeScript asynchronously imports data based on a specified order using a
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const cli_variants_1 = require("@contentstack/cli-variants");
4
4
  const utils_1 = require("../../utils");
5
- class ImportPersonalization {
5
+ class ImportPersonalize {
6
6
  constructor({ importConfig }) {
7
7
  this.config = importConfig;
8
- this.personalizeConfig = importConfig.modules.personalization;
8
+ this.personalizeConfig = importConfig.modules.personalize;
9
9
  }
10
10
  /**
11
11
  * The `start` function in TypeScript asynchronously imports data based on a specified order using a
@@ -39,12 +39,12 @@ class ImportPersonalization {
39
39
  }
40
40
  }
41
41
  catch (error) {
42
- this.personalizeConfig.importData = false; // Stop personalization import if project creation fails
42
+ this.personalizeConfig.importData = false; // Stop personalize import if project creation fails
43
43
  (0, utils_1.log)(this.config, error, 'error');
44
44
  if (!this.personalizeConfig.importData) {
45
- (0, utils_1.log)(this.config, 'Skipping personalization migration...', 'warn');
45
+ (0, utils_1.log)(this.config, 'Skipping personalize migration...', 'warn');
46
46
  }
47
47
  }
48
48
  }
49
49
  }
50
- exports.default = ImportPersonalization;
50
+ exports.default = ImportPersonalize;
@@ -1,7 +1,7 @@
1
1
  import { ImportConfig, ModuleClassParams } from '../../types';
2
2
  export default class ImportVarientEntries {
3
3
  private config;
4
- personalization: ImportConfig['modules']['personalization'];
4
+ personalize: ImportConfig['modules']['personalize'];
5
5
  private projectMapperFilePath;
6
6
  constructor({ importConfig }: ModuleClassParams);
7
7
  /**
@@ -8,8 +8,8 @@ const utils_1 = require("../../utils");
8
8
  class ImportVarientEntries {
9
9
  constructor({ importConfig }) {
10
10
  this.config = importConfig;
11
- this.personalization = importConfig.modules.personalization;
12
- this.projectMapperFilePath = path_1.default.resolve((0, cli_utilities_1.sanitizePath)(this.config.data), 'mapper', (0, cli_utilities_1.sanitizePath)(this.personalization.dirName), 'projects', 'projects.json');
11
+ this.personalize = importConfig.modules.personalize;
12
+ this.projectMapperFilePath = path_1.default.resolve((0, cli_utilities_1.sanitizePath)(this.config.data), 'mapper', (0, cli_utilities_1.sanitizePath)(this.personalize.dirName), 'projects', 'projects.json');
13
13
  }
14
14
  /**
15
15
  * The `start` function in TypeScript is an asynchronous method that conditionally imports data using
@@ -18,8 +18,8 @@ class ImportVarientEntries {
18
18
  async start() {
19
19
  try {
20
20
  const project = utils_1.fsUtil.readFile(this.projectMapperFilePath);
21
- if (project && project.uid && this.personalization.importData) {
22
- this.config.modules.personalization.project_id = project.uid;
21
+ if (project && project.uid) {
22
+ this.config.modules.personalize.project_id = project.uid;
23
23
  const helpers = {
24
24
  lookUpTerms: utils_1.lookUpTerms,
25
25
  lookupAssets: utils_1.lookupAssets,
@@ -120,7 +120,7 @@ export default interface DefaultConfig {
120
120
  fileName: string;
121
121
  dependencies?: Modules[];
122
122
  };
123
- personalization: {
123
+ personalize: {
124
124
  baseURL: Record<string, string>;
125
125
  dirName: string;
126
126
  importData: boolean;
@@ -26,7 +26,7 @@ export interface User {
26
26
  email: string;
27
27
  authtoken: string;
28
28
  }
29
- export type Modules = 'stack' | 'assets' | 'locales' | 'environments' | 'extensions' | 'webhooks' | 'global-fields' | 'entries' | 'content-types' | 'custom-roles' | 'workflows' | 'labels' | 'marketplace-apps' | 'taxonomies' | 'personalization' | 'variant-entries';
29
+ export type Modules = 'stack' | 'assets' | 'locales' | 'environments' | 'extensions' | 'webhooks' | 'global-fields' | 'entries' | 'content-types' | 'custom-roles' | 'workflows' | 'labels' | 'marketplace-apps' | 'taxonomies' | 'personalize' | 'variant-entries';
30
30
  export type ModuleClassParams = {
31
31
  stackAPIClient: ReturnType<ContentstackClient['stack']>;
32
32
  importConfig: ImportConfig;
@@ -542,11 +542,18 @@ const restoreJsonRteEntryRefs = (entry, sourceStackEntry, ctSchema = [], { uidMa
542
542
  }
543
543
  else {
544
544
  entry[element.uid] = restoreReferenceInJsonRTE(sourceStackEntry[element.uid], uidMapper);
545
- entry[element.uid].children = entry[element.uid].children.map((child) => {
546
- child = setDirtyTrue(child);
547
- child = resolveAssetRefsInEntryRefsForJsonRte(child, mappedAssetUids, mappedAssetUrls);
548
- return child;
549
- });
545
+ if (entry[element.uid].children && entry[element.uid].children.length > 0) {
546
+ entry[element.uid].children = entry[element.uid].children.map((child) => {
547
+ child = setDirtyTrue(child);
548
+ child = resolveAssetRefsInEntryRefsForJsonRte(child, mappedAssetUids, mappedAssetUrls);
549
+ return child;
550
+ });
551
+ }
552
+ else {
553
+ entry[element.uid].children = [
554
+ { type: 'p', attrs: { style: {}, 'redactor-attributes': {}, dir: 'ltr' } },
555
+ ];
556
+ }
550
557
  }
551
558
  }
552
559
  break;
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.17.1",
2
+ "version": "1.19.0",
3
3
  "commands": {
4
4
  "cm:stacks:import": {
5
5
  "id": "cm:stacks:import",
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@contentstack/cli-cm-import",
3
3
  "description": "Contentstack CLI plugin to import content into stack",
4
- "version": "1.17.1",
4
+ "version": "1.19.0",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {
8
- "@contentstack/cli-audit": "~1.7.0",
9
- "@contentstack/cli-command": "~1.3.0",
10
- "@contentstack/cli-utilities": "~1.7.2",
8
+ "@contentstack/cli-audit": "~1.7.2",
9
+ "@contentstack/cli-command": "~1.3.2",
10
+ "@contentstack/cli-utilities": "~1.8.0",
11
11
  "@contentstack/management": "~1.17.0",
12
- "@contentstack/cli-variants": "0.0.1-alpha",
12
+ "@contentstack/cli-variants": "~1.1.0",
13
13
  "@oclif/core": "^3.26.5",
14
14
  "big-json": "^3.2.0",
15
15
  "bluebird": "^3.7.2",