From 94369c33bd3aadb1b359f3950af64ac8cb4ad810 Mon Sep 17 00:00:00 2001 From: Antony Date: Tue, 10 Oct 2023 19:41:50 +0530 Subject: [PATCH] Fix: Export - Cannot read properties of undefined (reading 'encrypt') --- package-lock.json | 8 ++++---- .../src/export/modules-js/marketplace-apps.js | 9 +++------ .../src/export/modules/marketplace-apps.ts | 3 +-- packages/contentstack-export/src/utils/file-helper.ts | 6 +++--- .../src/utils/marketplace-app-helper.ts | 7 +++---- pnpm-lock.yaml | 2 +- 6 files changed, 15 insertions(+), 20 deletions(-) diff --git a/package-lock.json b/package-lock.json index 071561e287..f2bf30e239 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22741,7 +22741,7 @@ }, "packages/contentstack": { "name": "@contentstack/cli", - "version": "1.9.1", + "version": "1.9.2", "license": "MIT", "dependencies": { "@contentstack/cli-audit": "~1.0.0", @@ -22752,7 +22752,7 @@ "@contentstack/cli-cm-clone": "~1.5.1", "@contentstack/cli-cm-export": "~1.9.1", "@contentstack/cli-cm-export-to-csv": "~1.4.3", - "@contentstack/cli-cm-import": "~1.9.1", + "@contentstack/cli-cm-import": "~1.9.2", "@contentstack/cli-cm-migrate-rte": "~1.4.12", "@contentstack/cli-cm-seed": "~1.5.1", "@contentstack/cli-command": "~1.2.13", @@ -24423,7 +24423,7 @@ }, "packages/contentstack-import": { "name": "@contentstack/cli-cm-import", - "version": "1.9.1", + "version": "1.9.2", "license": "MIT", "dependencies": { "@contentstack/cli-command": "~1.2.13", @@ -26832,7 +26832,7 @@ "@contentstack/cli-cm-clone": "~1.5.1", "@contentstack/cli-cm-export": "~1.9.1", "@contentstack/cli-cm-export-to-csv": "~1.4.3", - "@contentstack/cli-cm-import": "~1.9.1", + "@contentstack/cli-cm-import": "~1.9.2", "@contentstack/cli-cm-migrate-rte": "~1.4.12", "@contentstack/cli-cm-seed": "~1.5.1", "@contentstack/cli-command": "~1.2.13", diff --git a/packages/contentstack-export/src/export/modules-js/marketplace-apps.js b/packages/contentstack-export/src/export/modules-js/marketplace-apps.js index d4b6c0cb42..88c051b651 100644 --- a/packages/contentstack-export/src/export/modules-js/marketplace-apps.js +++ b/packages/contentstack-export/src/export/modules-js/marketplace-apps.js @@ -45,7 +45,7 @@ module.exports = class ExportMarketplaceApps { this.developerHubBaseUrl = this.config.developerHubBaseUrl || (await getDeveloperHubUrl(this.config)); this.appSdkAxiosInstance = await managementSDKClient({ - host: this.developerHubBaseUrl.split('://').pop() + endpoint: this.developerHubBaseUrl, }); await this.getOrgUid(); @@ -82,7 +82,7 @@ module.exports = class ExportMarketplaceApps { console.log(error); }); - if (tempStackData && tempStackData.org_uid) { + if (tempStackData?.org_uid) { this.config.org_uid = tempStackData.org_uid; } } @@ -96,10 +96,7 @@ module.exports = class ExportMarketplaceApps { await this.getAppConfigurations(client, installedApps, [+index, app]); } - await fileHelper.writeFileSync( - path.join(this.marketplaceAppPath, this.marketplaceAppConfig.fileName), - installedApps, - ); + fileHelper.writeFileSync(path.join(this.marketplaceAppPath, this.marketplaceAppConfig.fileName), installedApps); log(this.config, chalk.green('All the marketplace apps have been exported successfully'), 'success'); } else { diff --git a/packages/contentstack-export/src/export/modules/marketplace-apps.ts b/packages/contentstack-export/src/export/modules/marketplace-apps.ts index 1102992e63..7ae7da9be2 100644 --- a/packages/contentstack-export/src/export/modules/marketplace-apps.ts +++ b/packages/contentstack-export/src/export/modules/marketplace-apps.ts @@ -84,14 +84,13 @@ export default class ExportMarketplaceApps extends BaseClass { async getAllStackSpecificApps(skip = 0): Promise { const data = await getStackSpecificApps({ developerHubBaseUrl: this.developerHubBaseUrl, - httpClient: this.httpClient as HttpClient, config: this.exportConfig, skip, }); const { data: apps, count } = data; - if (!this.nodeCrypto && find(apps, (app) => isEmpty(app.configuration))) { + if (!this.nodeCrypto && find(apps, (app) => !isEmpty(app.configuration))) { this.nodeCrypto = await createNodeCryptoInstance(this.exportConfig); } diff --git a/packages/contentstack-export/src/utils/file-helper.ts b/packages/contentstack-export/src/utils/file-helper.ts index ce7c7f326e..a329787094 100644 --- a/packages/contentstack-export/src/utils/file-helper.ts +++ b/packages/contentstack-export/src/utils/file-helper.ts @@ -39,7 +39,7 @@ export const readLargeFile = function (filePath: string, options: { type?: strin if (fs.existsSync(filePath)) { return new Promise((resolve, reject) => { const readStream = fs.createReadStream(filePath, { encoding: 'utf-8' }); - const parseStream = bigJSON.createParseStream(); + const parseStream: any = bigJSON.createParseStream(); parseStream.on('data', function (data: unknown) { if (options.type === 'array') { return resolve(Object.values(data)); @@ -50,7 +50,7 @@ export const readLargeFile = function (filePath: string, options: { type?: strin console.log('error', error); reject(error); }); - readStream.pipe(parseStream as any); + readStream.pipe(parseStream); }); } }; @@ -81,7 +81,7 @@ export const writeLargeFile = function (filePath: string, data: any): Promise { resolve(''); diff --git a/packages/contentstack-export/src/utils/marketplace-app-helper.ts b/packages/contentstack-export/src/utils/marketplace-app-helper.ts index 35752d4820..22d9fc8480 100644 --- a/packages/contentstack-export/src/utils/marketplace-app-helper.ts +++ b/packages/contentstack-export/src/utils/marketplace-app-helper.ts @@ -36,7 +36,7 @@ export async function createNodeCryptoInstance(config: ExportConfig): Promise { + validate: (url: any) => { if (!url) return "Encryption key can't be empty."; return true; @@ -50,13 +50,12 @@ export async function createNodeCryptoInstance(config: ExportConfig): Promise { - const { developerHubBaseUrl, httpClient, config, skip } = params; + const { developerHubBaseUrl, config, skip } = params; const appSdkAxiosInstance = await managementSDKClient({ - host: developerHubBaseUrl.split('://').pop() + endpoint: developerHubBaseUrl, }); return appSdkAxiosInstance.axiosInstance .get(`${developerHubBaseUrl}/installations?target_uids=${config.source_stack}&skip=${skip}`, { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8bb2c1460a..638ea7df43 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -18,7 +18,7 @@ importers: '@contentstack/cli-cm-clone': ~1.5.1 '@contentstack/cli-cm-export': ~1.9.1 '@contentstack/cli-cm-export-to-csv': ~1.4.3 - '@contentstack/cli-cm-import': ~1.9.1 + '@contentstack/cli-cm-import': ~1.9.2 '@contentstack/cli-cm-migrate-rte': ~1.4.12 '@contentstack/cli-cm-seed': ~1.5.1 '@contentstack/cli-command': ~1.2.13