Skip to content

Commit 9665703

Browse files
authored
Merge pull request #450 from contentstack/feature/bug-test-mig
bug fixes
2 parents 84248fe + 49a857e commit 9665703

File tree

5 files changed

+65
-42
lines changed

5 files changed

+65
-42
lines changed

api/package-lock.json

Lines changed: 37 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/src/services/migration.service.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -224,25 +224,25 @@ const startTestMigration = async (req: Request): Promise<any> => {
224224
case CMS.SITECORE_V8:
225225
case CMS.SITECORE_V9:
226226
case CMS.SITECORE_V10: {
227-
if (packagePath) {
228-
await siteCoreService?.createEntry({ packagePath, contentTypes, destinationStackId: project?.current_test_stack_id, projectId,keyMapper: project?.mapperKeys });
229-
await siteCoreService?.createLocale(req, project?.current_test_stack_id, projectId);
230-
await siteCoreService?.createVersionFile(project?.current_test_stack_id);
231-
}
232-
break;
227+
if (packagePath) {
228+
await siteCoreService?.createEntry({ packagePath, contentTypes, master_locale: project?.stackDetails?.master_locale, destinationStackId: project?.current_test_stack_id, projectId, keyMapper: project?.mapperKeys });
229+
await siteCoreService?.createLocale(req, project?.current_test_stack_id, projectId);
230+
await siteCoreService?.createVersionFile(project?.current_test_stack_id);
231+
}
232+
break;
233233
}
234234
case CMS.WORDPRESS: {
235235
if (packagePath) {
236236
await wordpressService?.getAllAssets(file_path, packagePath, project?.current_test_stack_id, projectId)
237237
await wordpressService?.createAssetFolderFile(file_path, project?.current_test_stack_id, projectId)
238238
await wordpressService?.getAllreference(file_path, packagePath, project?.current_test_stack_id, projectId)
239239
await wordpressService?.extractChunks(file_path, packagePath, project?.current_test_stack_id, projectId)
240-
await wordpressService?.getAllAuthors(file_path, packagePath,project?.current_test_stack_id, projectId,contentTypes, project?.mapperKeys)
240+
await wordpressService?.getAllAuthors(file_path, packagePath, project?.current_test_stack_id, projectId, contentTypes, project?.mapperKeys)
241241
//await wordpressService?.extractContentTypes(projectId, project?.current_test_stack_id, contentTypes)
242-
await wordpressService?.getAllTerms(file_path, packagePath,project?.current_test_stack_id, projectId,contentTypes, project?.mapperKeys)
243-
await wordpressService?.getAllTags(file_path, packagePath,project?.current_test_stack_id, projectId,contentTypes, project?.mapperKeys)
244-
await wordpressService?.getAllCategories(file_path, packagePath,project?.current_test_stack_id, projectId,contentTypes, project?.mapperKeys)
245-
await wordpressService?.extractPosts( packagePath,project?.current_test_stack_id, projectId,contentTypes, project?.mapperKeys)
242+
await wordpressService?.getAllTerms(file_path, packagePath, project?.current_test_stack_id, projectId, contentTypes, project?.mapperKeys)
243+
await wordpressService?.getAllTags(file_path, packagePath, project?.current_test_stack_id, projectId, contentTypes, project?.mapperKeys)
244+
await wordpressService?.getAllCategories(file_path, packagePath, project?.current_test_stack_id, projectId, contentTypes, project?.mapperKeys)
245+
await wordpressService?.extractPosts(packagePath, project?.current_test_stack_id, projectId, contentTypes, project?.mapperKeys)
246246
await wordpressService?.extractGlobalFields(project?.current_test_stack_id, projectId)
247247
await wordpressService?.createVersionFile(project?.current_test_stack_id, projectId);
248248
}
@@ -312,12 +312,12 @@ const startMigration = async (req: Request): Promise<any> => {
312312
await wordpressService?.createAssetFolderFile(file_path, project?.destination_stack_id, projectId)
313313
await wordpressService?.getAllreference(file_path, packagePath, project?.destination_stack_id, projectId)
314314
await wordpressService?.extractChunks(file_path, packagePath, project?.destination_stack_id, projectId)
315-
await wordpressService?.getAllAuthors(file_path, packagePath,project?.destination_stack_id, projectId,contentTypes, project?.mapperKeys)
315+
await wordpressService?.getAllAuthors(file_path, packagePath, project?.destination_stack_id, projectId, contentTypes, project?.mapperKeys)
316316
//await wordpressService?.extractContentTypes(projectId, project?.destination_stack_id)
317-
await wordpressService?.getAllTerms(file_path, packagePath,project?.destination_stack_id, projectId,contentTypes, project?.mapperKeys)
318-
await wordpressService?.getAllTags(file_path, packagePath,project?.destination_stack_id, projectId,contentTypes, project?.mapperKeys)
319-
await wordpressService?.getAllCategories(file_path, packagePath,project?.destination_stack_id, projectId,contentTypes, project?.mapperKeys)
320-
await wordpressService?.extractPosts( packagePath,project?.destination_stack_id, projectId,contentTypes, project?.mapperKeys)
317+
await wordpressService?.getAllTerms(file_path, packagePath, project?.destination_stack_id, projectId, contentTypes, project?.mapperKeys)
318+
await wordpressService?.getAllTags(file_path, packagePath, project?.destination_stack_id, projectId, contentTypes, project?.mapperKeys)
319+
await wordpressService?.getAllCategories(file_path, packagePath, project?.destination_stack_id, projectId, contentTypes, project?.mapperKeys)
320+
await wordpressService?.extractPosts(packagePath, project?.destination_stack_id, projectId, contentTypes, project?.mapperKeys)
321321
await wordpressService?.extractGlobalFields(project?.destination_stack_id, projectId)
322322
await wordpressService?.createVersionFile(project?.destination_stack_id, projectId);
323323

api/src/utils/content-type-creator.utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ export const contenTypeMaker = async ({ contentType, destinationStackId, project
630630
title: extractValue(element?.contentstackField, item?.contentstackField, ' >')?.trim(),
631631
}
632632
const schema: any = convertToSchemaFormate({ field });
633-
if (typeof schema === 'object' && Array.isArray(group?.schema)) {
633+
if (typeof schema === 'object' && Array.isArray(group?.schema) && element?.isDeleted === false) {
634634
group.schema.push(schema);
635635
}
636636
})
@@ -643,7 +643,7 @@ export const contenTypeMaker = async ({ contentType, destinationStackId, project
643643
uid: item?.contentstackFieldUid
644644
}
645645
});
646-
if (dt) {
646+
if (dt && item?.isDeleted === false) {
647647
ct?.schema?.push(dt);
648648
}
649649
}

api/src/utils/test-folder-creator.utils.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,15 +224,15 @@ const writeGlobalField = async (schema: any, globalSave: string, filePath: strin
224224
const sortGlobalField = async (baseDir: string, finalData: any) => {
225225
const globalSave = path.join(process.cwd(), baseDir, GLOBAL_FIELDS_DIR_NAME);
226226
const globalPath = path.join(globalSave, GLOBAL_FIELDS_FILE_NAME);
227-
if(fs.existsSync(globalPath)){
227+
if (fs.existsSync(globalPath)) {
228228
const globalData = await JSON.parse(await fs.promises.readFile(globalPath, 'utf8'));
229-
const globalResult = [];
230-
for await (const ct of globalData) {
231-
await lookForReference(ct, finalData);
232-
globalResult?.push(ct);
229+
const globalResult = [];
230+
for await (const ct of globalData) {
231+
await lookForReference(ct, finalData);
232+
globalResult?.push(ct);
233+
}
234+
await writeGlobalField(globalResult, globalPath, globalPath);
233235
}
234-
await writeGlobalField(globalResult, globalPath, globalPath);
235-
}
236236
}
237237

238238
const sortContentType = async (baseDir: string, finalData: any) => {
@@ -271,12 +271,12 @@ export const testFolderCreator = async ({ destinationStackId }: any) => {
271271
}
272272
}
273273
}
274-
const sortData = allData.sort((a, b) => b?.count - a?.count).slice?.(1, 4);
274+
const sortData = allData?.length > 3 ? allData.sort((a, b) => b?.count - a?.count).slice?.(1, 4) : allData;
275275
const finalData: any = [];
276276
sortData.forEach((et: any) => {
277277
const entryObj: any = {};
278-
const ctData = Object?.values?.(et?.entryData)?.splice?.(0, 5);
279-
ctData?.forEach((entItem: any) => {
278+
const ctData = et?.count > 4 ? Object?.values?.(et?.entryData)?.splice?.(0, 5) : et?.entryData;
279+
ctData?.forEach?.((entItem: any) => {
280280
entryObj[entItem?.uid] = entItem;
281281
})
282282
finalData?.push({ contentType: et?.contentType, entryObj, locale: et?.locale });

upload-api/package-lock.json

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)