@contentstack/cli-cm-import 1.7.0 → 1.8.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.
@@ -62,7 +62,7 @@ module.exports = class ImportMarketplaceApps {
62
62
  .catch((error) => {
63
63
  console.log(error);
64
64
  });
65
- if (tempStackData && tempStackData.org_uid) {
65
+ if (tempStackData === null || tempStackData === void 0 ? void 0 : tempStackData.org_uid) {
66
66
  this.config.org_uid = tempStackData.org_uid;
67
67
  }
68
68
  }
@@ -131,23 +131,26 @@ module.exports = class ImportMarketplaceApps {
131
131
  });
132
132
  }
133
133
  async generateUidMapper() {
134
+ var _a, _b;
134
135
  const listOfNewMeta = [];
135
136
  const listOfOldMeta = [];
136
- const extensionUidMapp = {};
137
- const allInstalledApps = await getAllStackSpecificApps(this.developerHubBaseUrl, this.httpClient, this.config);
137
+ const extensionUidMap = {};
138
+ const allInstalledApps = (await getAllStackSpecificApps(this.developerHubBaseUrl, this.httpClient, this.config)) || [];
138
139
  for (const app of this.marketplaceApps) {
139
- listOfOldMeta.push(..._.map(app.ui_location && app.ui_location.locations, 'meta').flat());
140
+ listOfOldMeta.push(..._.map((_a = app === null || app === void 0 ? void 0 : app.ui_location) === null || _a === void 0 ? void 0 : _a.locations, 'meta').flat());
140
141
  }
141
142
  for (const app of allInstalledApps) {
142
- listOfNewMeta.push(..._.map(app.ui_location && app.ui_location.locations, 'meta').flat());
143
+ listOfNewMeta.push(..._.map((_b = app === null || app === void 0 ? void 0 : app.ui_location) === null || _b === void 0 ? void 0 : _b.locations, 'meta').flat());
143
144
  }
144
145
  for (const { extension_uid, name, path, uid, data_type } of _.filter(listOfOldMeta, 'name')) {
145
- const meta = _.find(listOfNewMeta, { name, path }) || _.find(listOfNewMeta, { name: this.appNameMapping[name], path }) || _.find(listOfNewMeta, { name, uid, data_type });
146
+ const meta = _.find(listOfNewMeta, { name, path }) ||
147
+ _.find(listOfNewMeta, { name: this.appNameMapping[name], path }) ||
148
+ _.find(listOfNewMeta, { name, uid, data_type });
146
149
  if (meta) {
147
- extensionUidMapp[extension_uid] = meta.extension_uid;
150
+ extensionUidMap[extension_uid] = meta.extension_uid;
148
151
  }
149
152
  }
150
- return extensionUidMapp;
153
+ return extensionUidMap;
151
154
  }
152
155
  /**
153
156
  * @method handleAllPrivateAppsCreationProcess
@@ -164,10 +167,10 @@ module.exports = class ImportMarketplaceApps {
164
167
  for (let app of privateApps) {
165
168
  // NOTE keys can be passed to install new app in the developer hub
166
169
  app.manifest = _.pick(app.manifest, ['uid', 'name', 'description', 'icon', 'target_type', 'webhook', 'oauth']);
167
- this.appOrginalName = app.manifest.name;
170
+ this.appOriginalName = app.manifest.name;
168
171
  await this.createPrivateApps(Object.assign({ oauth: app.oauth, webhook: app.webhook, ui_location: app.ui_location }, app.manifest));
169
172
  }
170
- this.appOrginalName = undefined;
173
+ this.appOriginalName = undefined;
171
174
  }
172
175
  async getConfirmationToCreateApps(privateApps) {
173
176
  if (!this.config.forceStopMarketplaceAppsPrompt) {
@@ -182,7 +185,8 @@ module.exports = class ImportMarketplaceApps {
182
185
  }
183
186
  }
184
187
  async createPrivateApps(app, uidCleaned = false, appSuffix = 1) {
185
- let locations = app.ui_location && app.ui_location.locations;
188
+ var _a;
189
+ let locations = (_a = app === null || app === void 0 ? void 0 : app.ui_location) === null || _a === void 0 ? void 0 : _a.locations;
186
190
  if (!uidCleaned && !_.isEmpty(locations)) {
187
191
  app.ui_location.locations = this.updateManifestUILocations(locations, 'uid');
188
192
  }
@@ -221,7 +225,7 @@ module.exports = class ImportMarketplaceApps {
221
225
  // NOTE new app installation
222
226
  log(this.config, `${response.name} app created successfully.!`, 'success');
223
227
  this.appUidMapping[app.uid] = response.uid;
224
- this.appNameMapping[this.appOrginalName] = response.name;
228
+ this.appNameMapping[this.appOriginalName] = response.name;
225
229
  }
226
230
  }
227
231
  async handleNameConflict(app, appSuffix) {
@@ -252,8 +256,8 @@ module.exports = class ImportMarketplaceApps {
252
256
  location.meta = _.map(location.meta, (meta) => {
253
257
  if (meta.name) {
254
258
  const name = `${_.first(_.split(meta.name, '◈'))}◈${appSuffix}`;
255
- if (!this.appNameMapping[this.appOrginalName]) {
256
- this.appNameMapping[this.appOrginalName] = name;
259
+ if (!this.appNameMapping[this.appOriginalName]) {
260
+ this.appNameMapping[this.appOriginalName] = name;
257
261
  }
258
262
  meta.name = name;
259
263
  }
@@ -272,8 +276,10 @@ module.exports = class ImportMarketplaceApps {
272
276
  }
273
277
  /**
274
278
  * @method installApps
275
- * @param {Object} options
276
- * @returns {Void}
279
+ *
280
+ * @param {Record<string, any>} app
281
+ * @param {Record<string, any>[]} installedApps
282
+ * @returns {Promise<void>}
277
283
  */
278
284
  async installApps(app, installedApps) {
279
285
  let updateParam;
@@ -386,15 +392,13 @@ module.exports = class ImportMarketplaceApps {
386
392
  if (_.isEmpty(app) || _.isEmpty(payload) || !uid) {
387
393
  return Promise.resolve();
388
394
  }
389
- let installation = this.client
390
- .organization(this.config.org_uid)
391
- .app(app.manifest.uid)
392
- .installation(uid);
393
- installation = Object.assign(installation, payload);
394
- return installation
395
- .update()
396
- .then(async (data) => {
397
- if (data) {
395
+ return this.httpClient
396
+ .put(`${this.developerHubBaseUrl}/installations/${uid}`, payload)
397
+ .then(({ data }) => {
398
+ if (data.message) {
399
+ log(this.config, formatError(data.message), 'success');
400
+ }
401
+ else {
398
402
  log(this.config, `${app.manifest.name} app config updated successfully.!`, 'success');
399
403
  }
400
404
  })
@@ -101,13 +101,13 @@ module.exports = class importWorkflows {
101
101
  .catch(function (error) {
102
102
  self.fails.push(workflow);
103
103
  if (error.errors.name) {
104
- log(self.config, `workflow ${workflow.name} already exist`, 'error');
104
+ log(self.config, `workflow '${workflow.name}' already exist`, 'error');
105
105
  }
106
106
  else if (error.errors['workflow_stages.0.users']) {
107
107
  log(self.config, "Failed to import Workflows as you've specified certain roles in the Stage transition and access rules section. We currently don't import roles to the stack.", 'error');
108
108
  }
109
109
  else {
110
- log(self.config, `workflow ${workflow.name} failed.`, 'error');
110
+ log(self.config, `Workflow '${workflow.name}' failed.`, 'error');
111
111
  }
112
112
  });
113
113
  }
@@ -140,4 +140,5 @@ export default interface DefaultConfig {
140
140
  marketplaceAppEncryptionKey: string;
141
141
  getEncryptionKeyMaxRetry: number;
142
142
  useNewModuleStructure: boolean;
143
+ createBackupDir?: string;
143
144
  }
@@ -1,4 +1,4 @@
1
1
  import Bluebird from 'bluebird';
2
2
  import { ImportConfig } from 'src/types';
3
3
  export declare const uploadAssetHelper: (config: ImportConfig, req: any, fsPath: string, RETRY?: number) => Bluebird<unknown>;
4
- export declare const lookupAssets: (data: any, mappedAssetUids: string[], mappedAssetUrls: string[], assetUidMapperPath: string[], installedExtensions: string[]) => any;
4
+ export declare const lookupAssets: (data: Record<string, any>, mappedAssetUids: Record<string, any>, mappedAssetUrls: Record<string, any>, assetUidMapperPath: string, installedExtensions: Record<string, any>[]) => any;
@@ -3,12 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const path = tslib_1.__importStar(require("path"));
5
5
  const ncp_1 = tslib_1.__importDefault(require("ncp"));
6
+ const index_1 = require("./index");
6
7
  function setupBackupDir(importConfig) {
7
8
  return new Promise(async (resolve, reject) => {
8
9
  if (importConfig.hasOwnProperty('useBackedupDir')) {
9
10
  return resolve(importConfig.useBackedupDir);
10
11
  }
11
- const backupDirPath = path.join(process.cwd(), '_backup_' + Math.floor(Math.random() * 1000));
12
+ //NOTE: If the backup folder's directory is provided, create it at that location; otherwise, the default path (working directory).
13
+ let backupDirPath = path.join(process.cwd(), '_backup_' + Math.floor(Math.random() * 1000));
14
+ if (importConfig.createBackupDir) {
15
+ if (index_1.fileHelper.fileExistsSync(importConfig.createBackupDir)) {
16
+ index_1.fileHelper.removeDirSync(importConfig.createBackupDir);
17
+ }
18
+ index_1.fileHelper.makeDirectory(importConfig.createBackupDir);
19
+ backupDirPath = importConfig.createBackupDir;
20
+ }
12
21
  const limit = importConfig.backupConcurrency || 16;
13
22
  if (path.isAbsolute(importConfig.contentDir)) {
14
23
  return (0, ncp_1.default)(importConfig.contentDir, backupDirPath, { limit }, (error) => {
@@ -1,4 +1,7 @@
1
1
  /**
2
2
  * Entries lookup
3
3
  */
4
- export declare const lookupEntries: (data: any, mappedUids: string[], uidMapperPath: string) => any;
4
+ export declare const lookupEntries: (data: any, mappedUids: Record<string, any>, uidMapperPath: string) => any;
5
+ export declare const removeUidsFromJsonRteFields: (entry: Record<string, any>, ctSchema: Record<string, any>[]) => Record<string, any>;
6
+ export declare const removeEntryRefsFromJSONRTE: (entry: Record<string, any>, ctSchema: Record<string, any>[]) => Record<string, any>;
7
+ export declare const restoreJsonRteEntryRefs: (entry: Record<string, any>, sourceStackEntry: any, ctSchema: any, { mappedAssetUids, mappedAssetUrls }: any) => Record<string, any>;
@@ -3,7 +3,7 @@
3
3
  * Entries lookup
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.lookupEntries = void 0;
6
+ exports.restoreJsonRteEntryRefs = exports.removeEntryRefsFromJSONRTE = exports.removeUidsFromJsonRteFields = exports.lookupEntries = void 0;
7
7
  const tslib_1 = require("tslib");
8
8
  const path = tslib_1.__importStar(require("path"));
9
9
  const _ = tslib_1.__importStar(require("lodash"));
@@ -94,7 +94,7 @@ const lookupEntries = function (data, mappedUids, uidMapperPath) {
94
94
  }
95
95
  }
96
96
  };
97
- const find = function (schema, _entry) {
97
+ const find = function (schema = [], _entry) {
98
98
  for (let i = 0, _i = schema.length; i < _i; i++) {
99
99
  switch (schema[i].data_type) {
100
100
  case 'reference':
@@ -250,3 +250,323 @@ function findUidsInNewRefFields(entry, uids) {
250
250
  }
251
251
  }
252
252
  }
253
+ const removeUidsFromJsonRteFields = (entry, ctSchema) => {
254
+ for (const element of ctSchema) {
255
+ switch (element.data_type) {
256
+ case 'blocks': {
257
+ if (entry[element.uid]) {
258
+ if (element.multiple) {
259
+ entry[element.uid] = entry[element.uid].map((e) => {
260
+ let key = Object.keys(e).pop();
261
+ let subBlock = element.blocks.filter((block) => block.uid === key).pop();
262
+ e[key] = (0, exports.removeUidsFromJsonRteFields)(e[key], subBlock.schema);
263
+ return e;
264
+ });
265
+ }
266
+ }
267
+ break;
268
+ }
269
+ case 'global_field':
270
+ case 'group': {
271
+ if (entry[element.uid]) {
272
+ if (element.multiple) {
273
+ entry[element.uid] = entry[element.uid].map((e) => {
274
+ e = (0, exports.removeUidsFromJsonRteFields)(e, element.schema);
275
+ return e;
276
+ });
277
+ }
278
+ else {
279
+ entry[element.uid] = (0, exports.removeUidsFromJsonRteFields)(entry[element.uid], element.schema);
280
+ }
281
+ }
282
+ break;
283
+ }
284
+ case 'json': {
285
+ if (entry[element.uid] && element.field_metadata.rich_text_type) {
286
+ if (element.multiple) {
287
+ entry[element.uid] = entry[element.uid].map((jsonRteData) => {
288
+ delete jsonRteData.uid; // remove uid
289
+ if (_.isObject(jsonRteData.attrs)) {
290
+ jsonRteData.attrs.dirty = true;
291
+ }
292
+ if (!_.isEmpty(jsonRteData.children)) {
293
+ jsonRteData.children = _.map(jsonRteData.children, (child) => removeUidsFromChildren(child));
294
+ }
295
+ return jsonRteData;
296
+ });
297
+ }
298
+ else {
299
+ delete entry[element.uid].uid; // remove uid
300
+ if (entry[element.uid] && _.isObject(entry[element.uid].attrs)) {
301
+ entry[element.uid].attrs.dirty = true;
302
+ }
303
+ if (entry[element.uid] && !_.isEmpty(entry[element.uid].children)) {
304
+ entry[element.uid].children = _.map(entry[element.uid].children, (child) => removeUidsFromChildren(child));
305
+ }
306
+ }
307
+ }
308
+ break;
309
+ }
310
+ }
311
+ }
312
+ return entry;
313
+ };
314
+ exports.removeUidsFromJsonRteFields = removeUidsFromJsonRteFields;
315
+ function removeUidsFromChildren(children) {
316
+ if (children.length && children.length > 0) {
317
+ return children.map((child) => {
318
+ if (child.type && child.type.length > 0) {
319
+ delete child.uid; // remove uid
320
+ if (_.isObject(child.attrs)) {
321
+ child.attrs.dirty = true;
322
+ }
323
+ }
324
+ if (child.children && child.children.length > 0) {
325
+ child.children = removeUidsFromChildren(child.children);
326
+ }
327
+ return child;
328
+ });
329
+ }
330
+ else {
331
+ if (children.type && children.type.length > 0) {
332
+ delete children.uid; // remove uid
333
+ if (_.isObject(children.attrs)) {
334
+ children.attrs.dirty = true;
335
+ }
336
+ }
337
+ if (children.children && children.children.length > 0) {
338
+ children.children = removeUidsFromChildren(children.children);
339
+ }
340
+ return children;
341
+ }
342
+ }
343
+ const removeEntryRefsFromJSONRTE = (entry, ctSchema) => {
344
+ for (const element of ctSchema) {
345
+ switch (element.data_type) {
346
+ case 'blocks': {
347
+ if (entry[element.uid]) {
348
+ if (element.multiple) {
349
+ entry[element.uid] = entry[element.uid].map((e) => {
350
+ let key = Object.keys(e).pop();
351
+ let subBlock = element.blocks.filter((block) => block.uid === key).pop();
352
+ e[key] = (0, exports.removeEntryRefsFromJSONRTE)(e[key], subBlock.schema);
353
+ return e;
354
+ });
355
+ }
356
+ }
357
+ break;
358
+ }
359
+ case 'global_field':
360
+ case 'group': {
361
+ if (entry[element.uid]) {
362
+ if (element.multiple) {
363
+ entry[element.uid] = entry[element.uid].map((e) => {
364
+ e = (0, exports.removeEntryRefsFromJSONRTE)(e, element.schema);
365
+ return e;
366
+ });
367
+ }
368
+ else {
369
+ entry[element.uid] = (0, exports.removeEntryRefsFromJSONRTE)(entry[element.uid], element.schema);
370
+ }
371
+ }
372
+ break;
373
+ }
374
+ case 'json': {
375
+ if (entry[element.uid] && element.field_metadata.rich_text_type) {
376
+ if (element.multiple) {
377
+ entry[element.uid] = entry[element.uid].map((jsonRteData) => {
378
+ // repeated code from else block, will abstract later
379
+ let entryReferences = jsonRteData.children.filter((e) => doEntryReferencesExist(e));
380
+ if (entryReferences.length > 0) {
381
+ jsonRteData.children = jsonRteData.children.filter((e) => !doEntryReferencesExist(e));
382
+ return jsonRteData; // return jsonRteData without entry references
383
+ }
384
+ else {
385
+ return jsonRteData; // return jsonRteData as it is, because there are no entry references
386
+ }
387
+ });
388
+ }
389
+ else {
390
+ let entryReferences = entry[element.uid].children.filter((e) => doEntryReferencesExist(e));
391
+ if (entryReferences.length > 0) {
392
+ entry[element.uid].children = entry[element.uid].children.filter((e) => !doEntryReferencesExist(e));
393
+ }
394
+ }
395
+ }
396
+ break;
397
+ }
398
+ }
399
+ }
400
+ return entry;
401
+ };
402
+ exports.removeEntryRefsFromJSONRTE = removeEntryRefsFromJSONRTE;
403
+ function doEntryReferencesExist(element) {
404
+ // checks if the children of p element contain any references
405
+ // only checking one level deep, not recursive
406
+ if (element.length) {
407
+ for (const item of element) {
408
+ if ((item.type === 'p' || item.type === 'a') && item.children && item.children.length > 0) {
409
+ return doEntryReferencesExist(item.children);
410
+ }
411
+ else if (isEntryRef(item)) {
412
+ return true;
413
+ }
414
+ }
415
+ }
416
+ else {
417
+ if (isEntryRef(element)) {
418
+ return true;
419
+ }
420
+ if ((element.type === 'p' || element.type === 'a') && element.children && element.children.length > 0) {
421
+ return doEntryReferencesExist(element.children);
422
+ }
423
+ }
424
+ return false;
425
+ }
426
+ function isEntryRef(element) {
427
+ return element.type === 'reference' && element.attrs.type === 'entry';
428
+ }
429
+ const restoreJsonRteEntryRefs = (entry, sourceStackEntry, ctSchema, { mappedAssetUids, mappedAssetUrls }) => {
430
+ // let mappedAssetUids = fileHelper.readFileSync(this.mappedAssetUidPath) || {};
431
+ // let mappedAssetUrls = fileHelper.readFileSync(this.mappedAssetUrlPath) || {};
432
+ for (const element of ctSchema) {
433
+ switch (element.data_type) {
434
+ case 'blocks': {
435
+ if (entry[element.uid]) {
436
+ if (element.multiple) {
437
+ entry[element.uid] = entry[element.uid].map((e, eIndex) => {
438
+ let key = Object.keys(e).pop();
439
+ let subBlock = element.blocks.filter((block) => block.uid === key).pop();
440
+ let sourceStackElement = sourceStackEntry[element.uid][eIndex][key];
441
+ e[key] = (0, exports.restoreJsonRteEntryRefs)(e[key], sourceStackElement, subBlock.schema, {
442
+ mappedAssetUids,
443
+ mappedAssetUrls,
444
+ });
445
+ return e;
446
+ });
447
+ }
448
+ }
449
+ break;
450
+ }
451
+ case 'global_field':
452
+ case 'group': {
453
+ if (entry[element.uid]) {
454
+ if (element.multiple) {
455
+ entry[element.uid] = entry[element.uid].map((e, eIndex) => {
456
+ let sourceStackElement = sourceStackEntry[element.uid][eIndex];
457
+ e = (0, exports.restoreJsonRteEntryRefs)(e, sourceStackElement, element.schema, { mappedAssetUids, mappedAssetUrls });
458
+ return e;
459
+ });
460
+ }
461
+ else {
462
+ let sourceStackElement = sourceStackEntry[element.uid];
463
+ entry[element.uid] = (0, exports.restoreJsonRteEntryRefs)(entry[element.uid], sourceStackElement, element.schema, {
464
+ mappedAssetUids,
465
+ mappedAssetUrls,
466
+ });
467
+ }
468
+ }
469
+ break;
470
+ }
471
+ case 'json': {
472
+ if (entry[element.uid] && element.field_metadata.rich_text_type) {
473
+ if (element.multiple) {
474
+ entry[element.uid] = entry[element.uid].map((field, index) => {
475
+ // i am facing a Maximum call stack exceeded issue,
476
+ // probably because of this loop operation
477
+ let entryRefs = sourceStackEntry[element.uid][index].children
478
+ .map((e, i) => {
479
+ return { index: i, value: e };
480
+ })
481
+ .filter((e) => doEntryReferencesExist(e.value))
482
+ .map((e) => {
483
+ // commenting the line below resolved the maximum call stack exceeded issue
484
+ // e.value = this.setDirtyTrue(e.value)
485
+ setDirtyTrue(e.value);
486
+ return e;
487
+ })
488
+ .map((e) => {
489
+ // commenting the line below resolved the maximum call stack exceeded issue
490
+ // e.value = this.resolveAssetRefsInEntryRefsForJsonRte(e, mappedAssetUids, mappedAssetUrls)
491
+ resolveAssetRefsInEntryRefsForJsonRte(e.value, mappedAssetUids, mappedAssetUrls);
492
+ return e;
493
+ });
494
+ if (entryRefs.length > 0) {
495
+ entryRefs.forEach((entryRef) => {
496
+ field.children.splice(entryRef.index, 0, entryRef.value);
497
+ });
498
+ }
499
+ return field;
500
+ });
501
+ }
502
+ else {
503
+ let entryRefs = sourceStackEntry[element.uid].children
504
+ .map((e, index) => {
505
+ return { index: index, value: e };
506
+ })
507
+ .filter((e) => doEntryReferencesExist(e.value))
508
+ .map((e) => {
509
+ setDirtyTrue(e.value);
510
+ return e;
511
+ })
512
+ .map((e) => {
513
+ resolveAssetRefsInEntryRefsForJsonRte(e.value, mappedAssetUids, mappedAssetUrls);
514
+ return e;
515
+ });
516
+ if (entryRefs.length > 0) {
517
+ entryRefs.forEach((entryRef) => {
518
+ if (!_.isEmpty(entry[element.uid]) && entry[element.uid].children) {
519
+ entry[element.uid].children.splice(entryRef.index, 0, entryRef.value);
520
+ }
521
+ });
522
+ }
523
+ }
524
+ }
525
+ break;
526
+ }
527
+ }
528
+ }
529
+ return entry;
530
+ };
531
+ exports.restoreJsonRteEntryRefs = restoreJsonRteEntryRefs;
532
+ function setDirtyTrue(jsonRteChild) {
533
+ // also removing uids in this function
534
+ if (jsonRteChild.type) {
535
+ if (_.isObject(jsonRteChild.attrs)) {
536
+ jsonRteChild.attrs['dirty'] = true;
537
+ }
538
+ delete jsonRteChild.uid;
539
+ if (jsonRteChild.children && jsonRteChild.children.length > 0) {
540
+ jsonRteChild.children = jsonRteChild.children.map((subElement) => this.setDirtyTrue(subElement));
541
+ }
542
+ }
543
+ return jsonRteChild;
544
+ }
545
+ function resolveAssetRefsInEntryRefsForJsonRte(jsonRteChild, mappedAssetUids, mappedAssetUrls) {
546
+ if (jsonRteChild.type) {
547
+ if (jsonRteChild.attrs.type === 'asset') {
548
+ let assetUrl;
549
+ if (mappedAssetUids[jsonRteChild.attrs['asset-uid']]) {
550
+ jsonRteChild.attrs['asset-uid'] = mappedAssetUids[jsonRteChild.attrs['asset-uid']];
551
+ }
552
+ if (jsonRteChild.attrs['display-type'] !== 'link') {
553
+ assetUrl = jsonRteChild.attrs['asset-link'];
554
+ }
555
+ else {
556
+ assetUrl = jsonRteChild.attrs['href'];
557
+ }
558
+ if (mappedAssetUrls[assetUrl]) {
559
+ if (jsonRteChild.attrs['display-type'] !== 'link') {
560
+ jsonRteChild.attrs['asset-link'] = mappedAssetUrls[assetUrl];
561
+ }
562
+ else {
563
+ jsonRteChild.attrs['href'] = mappedAssetUrls[assetUrl];
564
+ }
565
+ }
566
+ }
567
+ if (jsonRteChild.children && jsonRteChild.children.length > 0) {
568
+ jsonRteChild.children = jsonRteChild.children.map((subElement) => resolveAssetRefsInEntryRefsForJsonRte(subElement, mappedAssetUids, mappedAssetUrls));
569
+ }
570
+ }
571
+ return jsonRteChild;
572
+ }
@@ -11,4 +11,5 @@ export declare const makeDirectory: (dir: string) => void;
11
11
  export declare const readdirSync: (dirPath: string) => any;
12
12
  export declare const isFolderExist: (folderPath: string) => Promise<any>;
13
13
  export declare const fileExistsSync: (path: string) => boolean;
14
+ export declare const removeDirSync: (path: string) => void;
14
15
  export declare const fsUtil: FsUtility;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fsUtil = exports.fileExistsSync = exports.isFolderExist = exports.readdirSync = exports.makeDirectory = exports.writeLargeFile = exports.writeFile = exports.writeFileSync = exports.readLargeFile = exports.readFile = exports.readFileSync = void 0;
3
+ exports.fsUtil = exports.removeDirSync = exports.fileExistsSync = exports.isFolderExist = exports.readdirSync = exports.makeDirectory = exports.writeLargeFile = exports.writeFile = exports.writeFileSync = exports.readLargeFile = exports.readFile = exports.readFileSync = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const fs = tslib_1.__importStar(require("fs"));
6
6
  const path = tslib_1.__importStar(require("path"));
@@ -137,4 +137,8 @@ const fileExistsSync = function (path) {
137
137
  return fs.existsSync(path);
138
138
  };
139
139
  exports.fileExistsSync = fileExistsSync;
140
+ const removeDirSync = function (path) {
141
+ fs.rmdirSync(path, { recursive: true });
142
+ };
143
+ exports.removeDirSync = removeDirSync;
140
144
  exports.fsUtil = new cli_utilities_1.FsUtility();
@@ -53,7 +53,7 @@ const setupConfig = async (importCmdFlags) => {
53
53
  config.isAuthenticated = (0, cli_utilities_1.isAuthenticated)();
54
54
  //Note to support the old key
55
55
  config.source_stack = config.apiKey;
56
- config.importWebhookStatus = importCmdFlags.importWebhookStatus;
56
+ config.importWebhookStatus = importCmdFlags['import-webhook-status'];
57
57
  config.forceStopMarketplaceAppsPrompt = importCmdFlags.yes;
58
58
  if (importCmdFlags['branch']) {
59
59
  config.branchName = importCmdFlags['branch'];
@@ -5,8 +5,8 @@ export { fsUtil } from './file-helper';
5
5
  export { default as backupHandler } from './backup-handler';
6
6
  export { log, unlinkFileLogger } from './logger';
7
7
  export { uploadAssetHelper, lookupAssets } from './asset-helper';
8
- export { getDeveloperHubUrl, getOrgUid, getConfirmationToCreateApps, createPrivateApp, handleNameConflict, installApp, makeRedirectUrlCall, confirmToCloseProcess, getAllStackSpecificApps, ifAppAlreadyExist, updateAppConfig } from './marketplace-app-helper';
8
+ export { getDeveloperHubUrl, getOrgUid, getConfirmationToCreateApps, createPrivateApp, handleNameConflict, installApp, makeRedirectUrlCall, confirmToCloseProcess, getAllStackSpecificApps, ifAppAlreadyExist, updateAppConfig, } from './marketplace-app-helper';
9
9
  export { schemaTemplate, suppressSchemaReference, removeReferenceFields } from './content-type-helper';
10
10
  export { lookupExtension } from './extension-helper';
11
- export { lookupEntries } from './entries-helper';
11
+ export { lookupEntries, removeUidsFromJsonRteFields, removeEntryRefsFromJSONRTE, restoreJsonRteEntryRefs, } from './entries-helper';
12
12
  export * from './common-helper';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.lookupEntries = exports.lookupExtension = exports.removeReferenceFields = exports.suppressSchemaReference = exports.schemaTemplate = exports.updateAppConfig = exports.ifAppAlreadyExist = exports.getAllStackSpecificApps = exports.confirmToCloseProcess = exports.makeRedirectUrlCall = exports.installApp = exports.handleNameConflict = exports.createPrivateApp = exports.getConfirmationToCreateApps = exports.getOrgUid = exports.getDeveloperHubUrl = exports.lookupAssets = exports.uploadAssetHelper = exports.unlinkFileLogger = exports.log = exports.backupHandler = exports.fsUtil = exports.fileHelper = exports.setupImportConfig = exports.interactive = void 0;
3
+ exports.restoreJsonRteEntryRefs = exports.removeEntryRefsFromJSONRTE = exports.removeUidsFromJsonRteFields = exports.lookupEntries = exports.lookupExtension = exports.removeReferenceFields = exports.suppressSchemaReference = exports.schemaTemplate = exports.updateAppConfig = exports.ifAppAlreadyExist = exports.getAllStackSpecificApps = exports.confirmToCloseProcess = exports.makeRedirectUrlCall = exports.installApp = exports.handleNameConflict = exports.createPrivateApp = exports.getConfirmationToCreateApps = exports.getOrgUid = exports.getDeveloperHubUrl = exports.lookupAssets = exports.uploadAssetHelper = exports.unlinkFileLogger = exports.log = exports.backupHandler = exports.fsUtil = exports.fileHelper = exports.setupImportConfig = exports.interactive = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  exports.interactive = tslib_1.__importStar(require("./interactive"));
6
6
  var import_config_handler_1 = require("./import-config-handler");
@@ -36,4 +36,7 @@ var extension_helper_1 = require("./extension-helper");
36
36
  Object.defineProperty(exports, "lookupExtension", { enumerable: true, get: function () { return extension_helper_1.lookupExtension; } });
37
37
  var entries_helper_1 = require("./entries-helper");
38
38
  Object.defineProperty(exports, "lookupEntries", { enumerable: true, get: function () { return entries_helper_1.lookupEntries; } });
39
+ Object.defineProperty(exports, "removeUidsFromJsonRteFields", { enumerable: true, get: function () { return entries_helper_1.removeUidsFromJsonRteFields; } });
40
+ Object.defineProperty(exports, "removeEntryRefsFromJSONRTE", { enumerable: true, get: function () { return entries_helper_1.removeEntryRefsFromJSONRTE; } });
41
+ Object.defineProperty(exports, "restoreJsonRteEntryRefs", { enumerable: true, get: function () { return entries_helper_1.restoreJsonRteEntryRefs; } });
39
42
  tslib_1.__exportStar(require("./common-helper"), exports);
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.7.0",
2
+ "version": "1.8.0",
3
3
  "commands": {
4
4
  "cm:stacks:import": {
5
5
  "id": "cm:stacks:import",
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.7.0",
4
+ "version": "1.8.0",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {
8
- "@contentstack/cli-command": "^1.2.11",
9
- "@contentstack/cli-utilities": "^1.5.1",
10
- "@contentstack/management": "~1.10.0",
8
+ "@contentstack/cli-command": "~1.2.11",
9
+ "@contentstack/cli-utilities": "~1.5.1",
10
+ "@contentstack/management": "~1.10.0",
11
11
  "@oclif/config": "^1.18.3",
12
12
  "@oclif/core": "^2.9.3",
13
13
  "big-json": "^3.2.0",
@@ -96,4 +96,4 @@
96
96
  }
97
97
  },
98
98
  "repository": "https://github.com/contentstack/cli"
99
- }
99
+ }