Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Export - Cannot read properties of undefined (reading 'encrypt') #1098

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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;
}
}
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,13 @@ export default class ExportMarketplaceApps extends BaseClass {
async getAllStackSpecificApps(skip = 0): Promise<any> {
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);
}

Expand Down
6 changes: 3 additions & 3 deletions packages/contentstack-export/src/utils/file-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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);
});
}
};
Expand Down Expand Up @@ -81,7 +81,7 @@ export const writeLargeFile = function (filePath: string, data: any): Promise<an
const stringifyStream = bigJSON.createStringifyStream({
body: data,
});
var writeStream = fs.createWriteStream(filePath, 'utf-8');
let writeStream = fs.createWriteStream(filePath, 'utf-8');
stringifyStream.pipe(writeStream);
writeStream.on('finish', () => {
resolve('');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export async function createNodeCryptoInstance(config: ExportConfig): Promise<No
type: 'input',
name: 'name',
default: config.marketplaceAppEncryptionKey,
validate: (url) => {
validate: (url: any) => {
if (!url) return "Encryption key can't be empty.";

return true;
Expand All @@ -50,13 +50,12 @@ export async function createNodeCryptoInstance(config: ExportConfig): Promise<No

export const getStackSpecificApps = async (params: {
developerHubBaseUrl: string;
httpClient: HttpClient;
config: ExportConfig;
skip: number;
}) => {
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}`, {
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading