@@ -244,10 +244,10 @@ const startTestMigration = async (req: Request): Promise<any> => {
244244 await wordpressService ?. extractChunks ( file_path , packagePath , project ?. current_test_stack_id , projectId )
245245 await wordpressService ?. getAllAuthors ( file_path , packagePath , project ?. current_test_stack_id , projectId , contentTypes , project ?. mapperKeys , project ?. stackDetails ?. master_locale )
246246 //await wordpressService?.extractContentTypes(projectId, project?.current_test_stack_id, contentTypes)
247- await wordpressService ?. getAllTerms ( file_path , packagePath , project ?. current_test_stack_id , projectId , contentTypes , project ?. mapperKeys , project ?. stackDetails ?. master_locale )
248- await wordpressService ?. getAllTags ( file_path , packagePath , project ?. current_test_stack_id , projectId , contentTypes , project ?. mapperKeys , project ?. stackDetails ?. master_locale )
249- await wordpressService ?. getAllCategories ( file_path , packagePath , project ?. current_test_stack_id , projectId , contentTypes , project ?. mapperKeys , project ?. stackDetails ?. master_locale )
250- await wordpressService ?. extractPosts ( packagePath , project ?. current_test_stack_id , projectId , contentTypes , project ?. mapperKeys , project ?. stackDetails ?. master_locale )
247+ await wordpressService ?. getAllTerms ( file_path , packagePath , project ?. current_test_stack_id , projectId , contentTypes , project ?. mapperKeys , project ?. stackDetails ?. master_locale )
248+ await wordpressService ?. getAllTags ( file_path , packagePath , project ?. current_test_stack_id , projectId , contentTypes , project ?. mapperKeys , project ?. stackDetails ?. master_locale )
249+ await wordpressService ?. getAllCategories ( file_path , packagePath , project ?. current_test_stack_id , projectId , contentTypes , project ?. mapperKeys , project ?. stackDetails ?. master_locale )
250+ await wordpressService ?. extractPosts ( packagePath , project ?. current_test_stack_id , projectId , contentTypes , project ?. mapperKeys , project ?. stackDetails ?. master_locale )
251251 await wordpressService ?. extractGlobalFields ( project ?. current_test_stack_id , projectId )
252252 await wordpressService ?. createVersionFile ( project ?. current_test_stack_id , projectId ) ;
253253 }
@@ -318,12 +318,12 @@ const startMigration = async (req: Request): Promise<any> => {
318318 await wordpressService ?. createAssetFolderFile ( file_path , project ?. destination_stack_id , projectId )
319319 await wordpressService ?. getAllreference ( file_path , packagePath , project ?. destination_stack_id , projectId )
320320 await wordpressService ?. extractChunks ( file_path , packagePath , project ?. destination_stack_id , projectId )
321- await wordpressService ?. getAllAuthors ( file_path , packagePath , project ?. destination_stack_id , projectId , contentTypes , project ?. mapperKeys , project ?. stackDetails ?. master_locale )
321+ await wordpressService ?. getAllAuthors ( file_path , packagePath , project ?. destination_stack_id , projectId , contentTypes , project ?. mapperKeys , project ?. stackDetails ?. master_locale )
322322 //await wordpressService?.extractContentTypes(projectId, project?.destination_stack_id)
323323 await wordpressService ?. getAllTerms ( file_path , packagePath , project ?. destination_stack_id , projectId , contentTypes , project ?. mapperKeys , project ?. stackDetails ?. master_locale )
324- await wordpressService ?. getAllTags ( file_path , packagePath , project ?. destination_stack_id , projectId , contentTypes , project ?. mapperKeys , project ?. stackDetails ?. master_locale )
325- await wordpressService ?. getAllCategories ( file_path , packagePath , project ?. destination_stack_id , projectId , contentTypes , project ?. mapperKeys , project ?. stackDetails ?. master_locale )
326- await wordpressService ?. extractPosts ( packagePath , project ?. destination_stack_id , projectId , contentTypes , project ?. mapperKeys , project ?. stackDetails ?. master_locale )
324+ await wordpressService ?. getAllTags ( file_path , packagePath , project ?. destination_stack_id , projectId , contentTypes , project ?. mapperKeys , project ?. stackDetails ?. master_locale )
325+ await wordpressService ?. getAllCategories ( file_path , packagePath , project ?. destination_stack_id , projectId , contentTypes , project ?. mapperKeys , project ?. stackDetails ?. master_locale )
326+ await wordpressService ?. extractPosts ( packagePath , project ?. destination_stack_id , projectId , contentTypes , project ?. mapperKeys , project ?. stackDetails ?. master_locale )
327327 await wordpressService ?. extractGlobalFields ( project ?. destination_stack_id , projectId )
328328 await wordpressService ?. createVersionFile ( project ?. destination_stack_id , projectId ) ;
329329
@@ -426,23 +426,23 @@ export const createSourceLocales = async (req: Request) => {
426426
427427 try {
428428 // Check if the project.json file exists
429- if ( ! fs . existsSync ( projectFilePath ) ) {
429+ if ( ! fs ? .existsSync ?. ( projectFilePath ) ) {
430430 console . error ( `project.json not found at ${ projectFilePath } ` ) ;
431431 throw new Error ( `project.json not found.` ) ;
432432 }
433-
433+
434434 // Find the project with the specified projectId
435- const project : any = ProjectModelLowdb . chain . get ( "projects" ) . find ( { id : projectId } ) . value ( ) ;
435+ const project : any = ProjectModelLowdb ? .chain ? .get ?. ( "projects" ) ? .find ?. ( { id : projectId } ) ? .value ?. ( ) ;
436436 if ( project ) {
437- const index = ProjectModelLowdb . chain . get ( "projects" ) . findIndex ( { id : projectId } ) . value ( ) ;
437+ const index = ProjectModelLowdb ? .chain ? .get ?. ( "projects" ) ? .findIndex ?. ( { id : projectId } ) ? .value ( ) ;
438438 if ( index > - 1 ) {
439-
440- ProjectModelLowdb . update ( ( data : any ) => {
439+
440+ ProjectModelLowdb ? .update ( ( data : any ) => {
441441 data . projects [ index ] . source_locales = locales ;
442442 } ) ;
443443 } // Write back the updated projects
444444 } else {
445- logger . error ( `Project with ID: ${ projectId } not found` , {
445+ logger . error ( `Project with ID: ${ projectId } not found` , {
446446 status : HTTP_CODES ?. NOT_FOUND ,
447447 message : HTTP_TEXTS ?. INVALID_ID
448448 } )
@@ -467,30 +467,30 @@ export const createSourceLocales = async (req: Request) => {
467467 * @return - void
468468 * @throws Exception if the project ID is invalid or the when the path to project.json is incorrect
469469 */
470- export const updateLocaleMapper = async ( req :Request ) => {
471- const mapperObject = req . body ;
472- const projectFilePath = path . join ( process . cwd ( ) , 'database' , 'project.json' ) ; // Adjusted path to project.json
473- const projectId = req . params . projectId ;
470+ export const updateLocaleMapper = async ( req : Request ) => {
471+ const mapperObject = req ? .body ;
472+ const projectFilePath = path ? .join ?. ( process ? .cwd ( ) , 'database' , 'project.json' ) ; // Adjusted path to project.json
473+ const projectId = req ? .params ? .projectId ;
474474
475475 try {
476476 // Check if the project.json file exists
477- if ( ! fs . existsSync ( projectFilePath ) ) {
477+ if ( ! fs ? .existsSync ?. ( projectFilePath ) ) {
478478 console . error ( `project.json not found at ${ projectFilePath } ` ) ;
479479 throw new Error ( `project.json not found.` ) ;
480480 }
481-
481+
482482 // Find the project with the specified projectId
483- const project : any = ProjectModelLowdb . chain . get ( "projects" ) . find ( { id : projectId } ) . value ( ) ;
483+ const project : any = ProjectModelLowdb ? .chain ? .get ?. ( "projects" ) ? .find ?. ( { id : projectId } ) ? .value ( ) ;
484484 if ( project ) {
485- const index = ProjectModelLowdb . chain . get ( "projects" ) . findIndex ( { id : projectId } ) . value ( ) ;
485+ const index = ProjectModelLowdb ? .chain ? .get ( "projects" ) ? .findIndex ?. ( { id : projectId } ) ? .value ( ) ;
486486 if ( index > - 1 ) {
487- ProjectModelLowdb . update ( ( data : any ) => {
487+ ProjectModelLowdb ? .update ( ( data : any ) => {
488488 data . projects [ index ] . master_locale = mapperObject ?. master_locale ;
489489 data . projects [ index ] . locales = mapperObject ?. locales ;
490490 } ) ;
491491 } // Write back the updated projects
492492 } else {
493- logger . error ( `Project with ID: ${ projectId } not found` , {
493+ logger . error ( `Project with ID: ${ projectId } not found` , {
494494 status : HTTP_CODES ?. NOT_FOUND ,
495495 message : HTTP_TEXTS ?. INVALID_ID
496496 } )
0 commit comments