Skip to content

Commit

Permalink
Merge branch 'development' into fix/CS-41944
Browse files Browse the repository at this point in the history
  • Loading branch information
cs-raj authored Oct 11, 2023
2 parents 3985bdc + a3b80b7 commit bf0762e
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 27 deletions.
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 packages/contentstack-import/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-cm-import",
"description": "Contentstack CLI plugin to import content into stack",
"version": "1.9.1",
"version": "1.9.2",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
Expand Down
14 changes: 10 additions & 4 deletions packages/contentstack-import/src/import/modules/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ export default class EntriesImport extends BaseClass {
* @returns {ApiOptions} ApiOptions
*/
serializeUpdateCTs(apiOptions: ApiOptions): ApiOptions {
const { apiData: contentType } = apiOptions;
const { apiData } = apiOptions;
const contentType = cloneDeep(apiData);
if (contentType.field_rules) {
delete contentType.field_rules;
}
Expand Down Expand Up @@ -286,7 +287,11 @@ export default class EntriesImport extends BaseClass {
const onSuccess = ({ response, apiData: entry, additionalInfo }: any) => {
if (additionalInfo[entry.uid]?.isLocalized) {
let oldUid = additionalInfo[entry.uid].entryOldUid;
log(this.importConfig, `Localized entry: '${entry.title}' of content type ${cTUid} in locale ${locale}`, 'info');
log(
this.importConfig,
`Localized entry: '${entry.title}' of content type ${cTUid} in locale ${locale}`,
'info',
);
entry.uid = oldUid;
entry.entryOldUid = oldUid;
entry.sourceEntryFilePath = path.join(basePath, additionalInfo.entryFileName); // stores source file path temporarily
Expand Down Expand Up @@ -379,7 +384,7 @@ export default class EntriesImport extends BaseClass {
apiOptions.apiData = entryResponse;
apiOptions.additionalInfo[entryResponse.uid] = {
isLocalized: true,
entryOldUid: entry.uid
entryOldUid: entry.uid,
};
return apiOptions;
}
Expand Down Expand Up @@ -544,7 +549,8 @@ export default class EntriesImport extends BaseClass {
* @returns {ApiOptions} ApiOptions
*/
serializeUpdateCTsWithRef(apiOptions: ApiOptions): ApiOptions {
const { apiData: contentType } = apiOptions;
const { apiData } = apiOptions;
const contentType = cloneDeep(apiData);
if (contentType.field_rules) {
delete contentType.field_rules;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli",
"description": "Command-line tool (CLI) to interact with Contentstack",
"version": "1.9.1",
"version": "1.9.2",
"author": "Contentstack",
"bin": {
"csdx": "./bin/run"
Expand Down Expand Up @@ -30,7 +30,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",
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.

0 comments on commit bf0762e

Please sign in to comment.