@contentstack/cli-cm-import 1.15.0 → 1.15.1

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.15.0 linux-x64 node-v18.19.1
50
+ @contentstack/cli-cm-import/1.15.1 linux-x64 node-v18.20.1
51
51
  $ csdx --help [COMMAND]
52
52
  USAGE
53
53
  $ csdx COMMAND
@@ -65,7 +65,7 @@ export default class EntriesImport extends BaseClass {
65
65
  cTUid: string;
66
66
  locale: string;
67
67
  }): Promise<void>;
68
- replaceEntriesHandler({ apiParams, element: entry }: {
68
+ replaceEntriesHandler({ apiParams, element: entry, }: {
69
69
  apiParams: ApiOptions;
70
70
  element: Record<string, string>;
71
71
  isLastRequest: boolean;
@@ -429,7 +429,7 @@ class EntriesImport extends base_class_1.default {
429
429
  }
430
430
  }
431
431
  }
432
- async replaceEntriesHandler({ apiParams, element: entry }) {
432
+ async replaceEntriesHandler({ apiParams, element: entry, }) {
433
433
  const { additionalInfo: { cTUid, locale } = {} } = apiParams;
434
434
  return new Promise(async (resolve, reject) => {
435
435
  const { items: [entryInStack] = [] } = (await this.stack
@@ -710,11 +710,11 @@ class EntriesImport extends base_class_1.default {
710
710
  return Promise.resolve();
711
711
  }
712
712
  // log(this.importConfig, `Starting publish entries for ${cTUid} in locale ${locale}`, 'info');
713
- const onSuccess = ({ response, apiData: { environments, entryUid }, additionalInfo }) => {
714
- (0, utils_1.log)(this.importConfig, `Published entry: '${entryUid}' of content type ${cTUid} and locale ${locale} in ${environments === null || environments === void 0 ? void 0 : environments.join(',')} environments`, 'info');
713
+ const onSuccess = ({ response, apiData: { environments, entryUid, locales }, additionalInfo }) => {
714
+ (0, utils_1.log)(this.importConfig, `Published the entry: '${entryUid}' of Content Type '${cTUid}' and Locale '${locale}' in Environments '${environments === null || environments === void 0 ? void 0 : environments.join(',')}' and Locales '${locales === null || locales === void 0 ? void 0 : locales.join(',')}'`, 'info');
715
715
  };
716
- const onReject = ({ error, apiData, additionalInfo }) => {
717
- (0, utils_1.log)(this.importConfig, `${apiData.entryUid} entry of content type ${cTUid} in locale ${locale} failed to publish`, 'error');
716
+ const onReject = ({ error, apiData: { environments, entryUid, locales }, additionalInfo }) => {
717
+ (0, utils_1.log)(this.importConfig, `Failed to publish: '${entryUid}' entry of Content Type '${cTUid}' and Locale '${locale}' in Environments '${environments === null || environments === void 0 ? void 0 : environments.join(',')}' and Locales '${locales === null || locales === void 0 ? void 0 : locales.join(',')}'`, 'error');
718
718
  (0, utils_1.log)(this.importConfig, (0, utils_1.formatError)(error), 'error');
719
719
  };
720
720
  for (const index in indexer) {
@@ -163,31 +163,37 @@ class ImportMarketplaceApps {
163
163
  if ((0, isEmpty_1.default)(privateApps)) {
164
164
  return Promise.resolve();
165
165
  }
166
- await (0, utils_1.getConfirmationToCreateApps)(privateApps, this.importConfig);
167
- (0, utils_1.log)(this.importConfig, 'Starting developer hub private apps re-creation', 'success');
168
- for (let app of privateApps) {
169
- if (this.importConfig.skipPrivateAppRecreationIfExist && (await this.isPrivateAppExistInDeveloperHub(app))) {
170
- // NOTE Found app already exist in the same org
171
- this.appUidMapping[app.uid] = app.uid;
172
- cli_utilities_1.cliux.print(`App '${app.manifest.name}' already exist. skipping app recreation.!`, { color: 'yellow' });
173
- continue;
166
+ let canCreatePrivateApp = await (0, utils_1.getConfirmationToCreateApps)(privateApps, this.importConfig);
167
+ this.importConfig.canCreatePrivateApp = canCreatePrivateApp;
168
+ if (canCreatePrivateApp) {
169
+ (0, utils_1.log)(this.importConfig, 'Starting developer hub private apps re-creation', 'success');
170
+ for (let app of privateApps) {
171
+ if (this.importConfig.skipPrivateAppRecreationIfExist && (await this.isPrivateAppExistInDeveloperHub(app))) {
172
+ // NOTE Found app already exist in the same org
173
+ this.appUidMapping[app.uid] = app.uid;
174
+ cli_utilities_1.cliux.print(`App '${app.manifest.name}' already exist. skipping app recreation.!`, { color: 'yellow' });
175
+ continue;
176
+ }
177
+ // NOTE keys can be passed to install new app in the developer hub
178
+ const validKeys = [
179
+ 'uid',
180
+ 'name',
181
+ 'icon',
182
+ 'oauth',
183
+ 'webhook',
184
+ 'visibility',
185
+ 'target_type',
186
+ 'description',
187
+ 'ui_location',
188
+ 'framework_version',
189
+ ];
190
+ const manifest = (0, pick_1.default)(app.manifest, validKeys);
191
+ this.appOriginalName = manifest.name;
192
+ await this.createPrivateApp(manifest);
174
193
  }
175
- // NOTE keys can be passed to install new app in the developer hub
176
- const validKeys = [
177
- 'uid',
178
- 'name',
179
- 'icon',
180
- 'oauth',
181
- 'webhook',
182
- 'visibility',
183
- 'target_type',
184
- 'description',
185
- 'ui_location',
186
- 'framework_version',
187
- ];
188
- const manifest = (0, pick_1.default)(app.manifest, validKeys);
189
- this.appOriginalName = manifest.name;
190
- await this.createPrivateApp(manifest);
194
+ }
195
+ else {
196
+ (0, utils_1.log)(this.importConfig, 'Skipping private apps creation on Developer Hub...', 'success');
191
197
  }
192
198
  this.appOriginalName = undefined;
193
199
  }
@@ -332,6 +338,10 @@ class ImportMarketplaceApps {
332
338
  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 } });
333
339
  if (!currentStackApp) {
334
340
  // NOTE install new app
341
+ if (app.manifest.visibility === 'private' && !this.importConfig.canCreatePrivateApp) {
342
+ (0, utils_1.log)(this.importConfig, `Skipping the installation of the private app ${app.manifest.name}...`, 'info');
343
+ return Promise.resolve();
344
+ }
335
345
  const installation = await this.installApp(this.importConfig,
336
346
  // NOTE if it's private app it should get uid from mapper else will use manifest uid
337
347
  this.appUidMapping[app.manifest.uid] || app.manifest.uid);
@@ -85,7 +85,7 @@ module.exports = class ImportMarketplaceApps {
85
85
  return "Encryption key can't be empty.";
86
86
  return true;
87
87
  },
88
- message: 'Enter marketplace app configurations encryption key',
88
+ message: 'Enter Marketplace app configurations encryption key',
89
89
  });
90
90
  try {
91
91
  appConfig = !_.isEmpty(appConfig.configuration) ? appConfig.configuration : appConfig.server_configuration;
@@ -9,6 +9,7 @@ export interface ExternalConfig {
9
9
  password?: string;
10
10
  }
11
11
  export default interface ImportConfig extends DefaultConfig, ExternalConfig {
12
+ canCreatePrivateApp: boolean;
12
13
  contentDir: string;
13
14
  data: string;
14
15
  management_token?: string;
@@ -235,9 +235,11 @@ const lookupAssets = function (data, mappedAssetUids, mappedAssetUrls, assetUidM
235
235
  assetUrls.forEach(function (assetUrl) {
236
236
  let mappedAssetUrl = mappedAssetUrls[assetUrl];
237
237
  if (typeof mappedAssetUrl !== 'undefined') {
238
- const sanitizedUrl = escapeRegExp(assetUrl).replace(/\.\./g, '\\$&');
239
- const escapedMappedUrl = escapeRegExp(mappedAssetUrl).replace(/\.\./g, '\\$&');
240
- entry = entry.replace(new RegExp(sanitizedUrl, 'img'), escapedMappedUrl);
238
+ //NOTE - This code was added to resolve the SRE issue but once the code was merged Assets URLs in JSON RTE started breaking
239
+ // const sanitizedUrl = escapeRegExp(assetUrl).replace(/\.\./g, '\\$&');
240
+ // const escapedMappedUrl = escapeRegExp(mappedAssetUrl).replace(/\.\./g, '\\$&');
241
+ // entry = entry.replace(new RegExp(sanitizedUrl, 'img'), escapedMappedUrl);
242
+ entry = entry.replace(new RegExp(assetUrl, 'img'), mappedAssetUrl);
241
243
  matchedUrls.push(mappedAssetUrl);
242
244
  }
243
245
  else {
@@ -35,7 +35,7 @@ const askEncryptionKey = async (defaultValue) => {
35
35
  return "Encryption key can't be empty.";
36
36
  return true;
37
37
  },
38
- message: 'Enter marketplace app configurations encryption key',
38
+ message: 'Enter Marketplace app configurations encryption key',
39
39
  });
40
40
  };
41
41
  exports.askEncryptionKey = askEncryptionKey;
@@ -60,10 +60,15 @@ const getConfirmationToCreateApps = async (privateApps, config) => {
60
60
  if (!config.forceStopMarketplaceAppsPrompt) {
61
61
  if (!(await cli_utilities_1.cliux.confirm(chalk_1.default.yellow(`WARNING!!! The listed apps are private apps that are not available in the destination stack: \n\n${(0, map_1.default)(privateApps, ({ manifest: { name } }, index) => `${String(index + 1)}) ${name}`).join('\n')}\n\nWould you like to re-create the private app and then proceed with the installation? (y/n)`)))) {
62
62
  if (await cli_utilities_1.cliux.confirm(chalk_1.default.yellow(`\nWARNING!!! Canceling the app re-creation may break the content type and entry import. Would you like to proceed without re-create the private app? (y/n)`))) {
63
- return Promise.resolve(true);
63
+ return Promise.resolve(false);
64
64
  }
65
- if (!(await cli_utilities_1.cliux.confirm(chalk_1.default.yellow('\nWould you like to re-create the private app and then proceed with the installation? (y/n)')))) {
66
- process.exit();
65
+ else {
66
+ if (await cli_utilities_1.cliux.confirm(chalk_1.default.yellow('\nWould you like to re-create the private app and then proceed with the installation? (y/n)'))) {
67
+ return Promise.resolve(true);
68
+ }
69
+ else {
70
+ return Promise.resolve(false);
71
+ }
67
72
  }
68
73
  }
69
74
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.15.0",
2
+ "version": "1.15.1",
3
3
  "commands": {
4
4
  "cm:stacks:import": {
5
5
  "id": "cm:stacks:import",
@@ -12,6 +12,7 @@
12
12
  "aliases": [
13
13
  "cm:import"
14
14
  ],
15
+ "hiddenAliases": [],
15
16
  "examples": [
16
17
  "csdx cm:stacks:import --stack-api-key <stack_api_key> --data-dir <path/of/export/destination/dir>",
17
18
  "csdx cm:stacks:import --config <path/of/config/dir>",
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@contentstack/cli-cm-import",
3
3
  "description": "Contentstack CLI plugin to import content into stack",
4
- "version": "1.15.0",
4
+ "version": "1.15.1",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {
8
- "@contentstack/cli-audit": "~1.5.1",
8
+ "@contentstack/cli-audit": "~1.5.3",
9
9
  "@contentstack/cli-command": "~1.2.16",
10
10
  "@contentstack/cli-utilities": "~1.6.0",
11
11
  "@contentstack/management": "~1.15.3",