Skip to content
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
9 changes: 4 additions & 5 deletions api/src/services/runCli.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ const addCustomMessageInCliLogs = async (loggerPath: string, level: string = 'in

export const runCli = async (rg: string, user_id: string, stack_uid: any, projectId: string, isTest = false, transformePath: string) => {
try {
const message: string = isTest ? 'Test Migration Process Completed' : 'Migration Process Completed'
const message: string = isTest ? 'Test Migration Process Completed' : 'Migration Process Completed'
const regionPresent = CS_REGIONS?.find((item: string) => item === rg) ?? 'NA';
await AuthenticationModel.read();
const userData = AuthenticationModel.chain
.get("users")
.find({ region: regionPresent, user_id })
.value();
if (userData?.authtoken && stack_uid) {
const { BACKUP_DATA, BACKUP_LOG_DIR, BACKUP_FOLDER_NAME, BACKUP_FILE_NAME} = MIGRATION_DATA_CONFIG;
const { BACKUP_DATA, BACKUP_LOG_DIR, BACKUP_FOLDER_NAME, BACKUP_FILE_NAME } = MIGRATION_DATA_CONFIG;
const sourcePath = path.join(process.cwd(), MIGRATION_DATA_CONFIG.DATA, stack_uid);
const backupPath = path.join(process.cwd(), BACKUP_DATA, `${stack_uid}_${v4().slice(0, 4)}`);
await copyDirectory(sourcePath, backupPath);
Expand All @@ -59,10 +59,9 @@ export const runCli = async (rg: string, user_id: string, stack_uid: any, projec
ProjectModelLowdb.write();
}
await addCustomMessageInCliLogs(loggerPath, 'info', message);
!isTest && ProjectModelLowdb.update((data:any)=>{
!isTest && ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].isMigrationCompleted = true;
data.projects[projectIndex].isMigrationStarted = false;

data.projects[projectIndex].isMigrationStarted = false;
})
}
});
Expand Down
5 changes: 4 additions & 1 deletion api/src/services/sitecore.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ const createEntry = async ({ packagePath, contentTypes, master_locale = 'en-us',
}
}
}
entryObj.publish_details = [];
if (Object.keys?.(entryObj)?.length > 1) {
entryLocale[uid] = unflatten(entryObj) ?? {};
const message = getLogMessage(
Expand All @@ -282,11 +283,13 @@ const createEntry = async ({ packagePath, contentTypes, master_locale = 'en-us',
}
});
}
const mapperCt: string = (keyMapper[ctType?.contentstackUid] !== "" && keyMapper[ctType?.contentstackUid] !== undefined) ? keyMapper[ctType?.contentstackUid]
: ctType?.contentstackUid;
const fileMeta = { "1": `${newLocale}.json` };
const entryPath = path.join(
process.cwd(),
entrySave,
keyMapper[ctType?.contentstackUid] ?? ctType?.contentstackUid,
mapperCt,
newLocale
);
await writeFiles(entryPath, fileMeta, entryLocale, newLocale)
Expand Down
4 changes: 3 additions & 1 deletion api/src/utils/content-type-creator.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,9 @@ export const contenTypeMaker = async ({ contentType, destinationStackId, project
schema: []
}
let currentCt: any = {};
if (Object?.keys?.(keyMapper)?.length && keyMapper?.[contentType?.contentstackUid]) {
if (Object?.keys?.(keyMapper)?.length &&
keyMapper?.[contentType?.contentstackUid] !== "" &&
keyMapper?.[contentType?.contentstackUid] !== undefined) {
currentCt = await existingCtMapper({ keyMapper, contentTypeUid: contentType?.contentstackUid, projectId, region, user_id });
}
const ctData: any = arrangGroups({ schema: contentType?.fieldMapping, newStack })
Expand Down
3 changes: 2 additions & 1 deletion cli/packages/contentstack/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ tsconfig.tsbuildinfo
/merge-summary.json
!bin
/sitecoreMigrationData
/migration-data
/migration-data
/cmsMigrationData