From dae2441bc638a14692914d09a1c22947265d263f Mon Sep 17 00:00:00 2001 From: raj pandey Date: Fri, 16 Feb 2024 18:49:38 +0530 Subject: [PATCH] re-formatted --- .../src/import/modules/content-types.ts | 12 +++++------ .../src/import/modules/extensions.ts | 20 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/packages/contentstack-import/src/import/modules/content-types.ts b/packages/contentstack-import/src/import/modules/content-types.ts index 85dab431a1..fd65ba5acd 100644 --- a/packages/contentstack-import/src/import/modules/content-types.ts +++ b/packages/contentstack-import/src/import/modules/content-types.ts @@ -79,7 +79,7 @@ export default class ContentTypesImport extends BaseClass { this.createdGFs = []; this.pendingGFs = []; this.taxonomiesPath = path.join(importConfig.data, 'mapper/taxonomies', 'success.json'); - this.extPendingPath = path.join(importConfig.data,'mapper','extensions','pending_extensions.js'); + this.extPendingPath = path.join(importConfig.data, 'mapper', 'extensions', 'pending_extensions.js'); } async start(): Promise { @@ -109,7 +109,7 @@ export default class ContentTypesImport extends BaseClass { await fsUtil.writeFile(path.join(this.cTsFolderPath, 'field_rules_uid.json'), this.fieldRules); } log(this.importConfig, 'Updating the Extensions', 'success'); - await this.createPendingExtensions(); + await this.updatePendingExtensions(); log(this.importConfig, 'Extensions Updated', 'success'); await this.updatePendingGFs().catch((error) => { log(this.importConfig, `Error while updating pending global field ${formatError(error)}`, 'error'); @@ -256,13 +256,13 @@ export default class ContentTypesImport extends BaseClass { return apiOptions; } - async createPendingExtensions(): Promise{ + async updatePendingExtensions(): Promise { let apiContent = fsUtil.readFile(this.extPendingPath) as Record[]; - if(apiContent.length===0) { + if (apiContent.length === 0) { log(this.importConfig, `No Extension are present to be updated`, 'success'); return; } - + const onSuccess = ({ response, apiData: { uid, title } = { uid: null, title: '' } }: any) => { log(this.importConfig, `Extension '${response.title}' updated successfully`, 'success'); }; @@ -295,4 +295,4 @@ export default class ContentTypesImport extends BaseClass { false, ); } -} \ No newline at end of file +} diff --git a/packages/contentstack-import/src/import/modules/extensions.ts b/packages/contentstack-import/src/import/modules/extensions.ts index 04340aeba0..c8228aa85c 100644 --- a/packages/contentstack-import/src/import/modules/extensions.ts +++ b/packages/contentstack-import/src/import/modules/extensions.ts @@ -20,7 +20,7 @@ export default class ImportExtensions extends BaseClass { private extFailed: Record[]; private existingExtensions: Record[]; private extPendingPath: string; - private extensionObject:Record[]; + private extensionObject: Record[]; constructor({ importConfig, stackAPIClient }: ModuleClassParams) { super({ importConfig, stackAPIClient }); @@ -30,7 +30,7 @@ export default class ImportExtensions extends BaseClass { this.extUidMapperPath = join(this.mapperDirPath, 'uid-mapping.json'); this.extSuccessPath = join(this.mapperDirPath, 'success.json'); this.extFailsPath = join(this.mapperDirPath, 'fails.json'); - this.extPendingPath = join(this.mapperDirPath,'pending_extensions.js'); + this.extPendingPath = join(this.mapperDirPath, 'pending_extensions.js'); this.extFailed = []; this.extSuccess = []; this.existingExtensions = []; @@ -49,7 +49,7 @@ export default class ImportExtensions extends BaseClass { if (fileHelper.fileExistsSync(this.extensionsFolderPath)) { this.extensions = fsUtil.readFile(join(this.extensionsFolderPath, 'extensions.json'), true) as Record< string, - Record + Record >; } else { log(this.importConfig, `No such file or directory - '${this.extensionsFolderPath}'`, 'error'); @@ -220,14 +220,14 @@ export default class ImportExtensions extends BaseClass { }); } - getContentTypesInScope(){ + getContentTypesInScope() { const extension = values(this.extensions); - extension.forEach((ext:extensionType)=>{ - let ct:any = ext?.scope?.content_types || []; - if((ct.length===1 && (ct[0]!=='$all')) || (ct?.length>1)){ + extension.forEach((ext: extensionType) => { + let ct: any = ext?.scope?.content_types || []; + if ((ct.length === 1 && ct[0] !== '$all') || ct?.length > 1) { log(this.importConfig, `Removing the Content-types ${ct.join(',')} from Extension ${ext.title}`, 'success'); - const {uid, scope} = ext; - this.extensionObject.push({uid,scope}); + const { uid, scope } = ext; + this.extensionObject.push({ uid, scope }); delete ext.scope; this.extensions[ext.uid] = ext; } @@ -235,7 +235,7 @@ export default class ImportExtensions extends BaseClass { } updateUidExtension() { - for(let i in this.extensionObject) { + for (let i in this.extensionObject) { this.extensionObject[i].uid = this.extUidMapper[this.extensionObject[i].uid as string]; } fsUtil.writeFile(this.extPendingPath, this.extensionObject);