Skip to content

Commit

Permalink
re-formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
cs-raj committed Feb 16, 2024
1 parent 9f12882 commit dae2441
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
12 changes: 6 additions & 6 deletions packages/contentstack-import/src/import/modules/content-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any> {
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -256,13 +256,13 @@ export default class ContentTypesImport extends BaseClass {
return apiOptions;
}

async createPendingExtensions(): Promise<any>{
async updatePendingExtensions(): Promise<any> {
let apiContent = fsUtil.readFile(this.extPendingPath) as Record<string, any>[];
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');
};
Expand Down Expand Up @@ -295,4 +295,4 @@ export default class ContentTypesImport extends BaseClass {
false,
);
}
}
}
20 changes: 10 additions & 10 deletions packages/contentstack-import/src/import/modules/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default class ImportExtensions extends BaseClass {
private extFailed: Record<string, unknown>[];
private existingExtensions: Record<string, unknown>[];
private extPendingPath: string;
private extensionObject:Record<string,unknown>[];
private extensionObject: Record<string, unknown>[];

constructor({ importConfig, stackAPIClient }: ModuleClassParams) {
super({ importConfig, stackAPIClient });
Expand All @@ -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 = [];
Expand All @@ -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<string,unknown>
Record<string, unknown>
>;
} else {
log(this.importConfig, `No such file or directory - '${this.extensionsFolderPath}'`, 'error');
Expand Down Expand Up @@ -220,22 +220,22 @@ 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;
}
});
}

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);
Expand Down

0 comments on commit dae2441

Please sign in to comment.