File tree Expand file tree Collapse file tree 13 files changed +1838
-110
lines changed
Expand file tree Collapse file tree 13 files changed +1838
-110
lines changed Original file line number Diff line number Diff line change 1717# Mono auto generated files
1818mono_crash. *
1919
20- # MAC DS_Store File
21- /api /.DS_Store
2220
2321# Build results
2422[Dd ]ebug /
@@ -361,6 +359,7 @@ combine.log
361359
362360
363361! example.env
362+ ! production.env
364363
365364database /
366365/sitecoreMigrationData
Original file line number Diff line number Diff line change 1+ APP_TOKEN_KEY = MIGRATION_V2
2+ PORT = 5001
3+
Original file line number Diff line number Diff line change @@ -468,9 +468,9 @@ export const createSourceLocales = async (req: Request) => {
468468 * @throws Exception if the project ID is invalid or the when the path to project.json is incorrect
469469 */
470470export const updateLocaleMapper = async ( req :Request ) => {
471- const mapperObject = req . body . mapper ;
471+ const mapperObject = req . body ;
472472 const projectFilePath = path . join ( process . cwd ( ) , 'database' , 'project.json' ) ; // Adjusted path to project.json
473- const projectId = req . params . projectId ;
473+ const projectId = req . params . projectId ;
474474
475475 try {
476476 // Check if the project.json file exists
@@ -496,7 +496,7 @@ export const updateLocaleMapper = async (req:Request) =>{
496496 } )
497497 }
498498 } catch ( err : any ) {
499- console . error ( "🚀 ~ createSourceLocales ~ err:" , err ?. response ?. data ?? err , err )
499+ console . error ( "🚀 ~ updateLocaleMapper ~ err:" , err ?. response ?. data ?? err , err )
500500 logger . warn ( 'Bad Request' , {
501501 status : HTTP_CODES ?. BAD_REQUEST ,
502502 message : HTTP_TEXTS ?. INTERNAL_ERROR ,
Original file line number Diff line number Diff line change 1+ REACT_APP_WEBSITE_BASE_URL = " http://localhost:3000/"
2+ REACT_APP_BASE_API_URL = " http://localhost:5001/"
3+ REACT_APP_API_VERSION = v2
4+ REACT_APP_HOST = " http://localhost:3000"
5+ REACT_APP_UPLOAD_SERVER = " http://localhost:4002/"
6+ REACT_APP_OFFLINE_CMS = true
Original file line number Diff line number Diff line change @@ -24,4 +24,6 @@ yarn-error.log*
2424
2525
2626# .npmrc
27- .npmrc
27+ .npmrc
28+
29+ ! .env.local
Original file line number Diff line number Diff line change 22
33const extractContentTypes = require ( './libs/extractContentTypes' ) ;
44const createInitialMapper = require ( './libs/createInitialMapper' ) ;
5+ const extractLocale = require ( './libs/extractLocale' )
56
67module . exports = {
78 extractContentTypes,
8- createInitialMapper
9+ createInitialMapper,
10+ extractLocale
911} ;
1012
Original file line number Diff line number Diff line change 1+ "use strict" ;
2+ /* eslint-disable @typescript-eslint/no-var-requires */
3+ /**
4+ * External module dependencies.
5+ */
6+ const fs = require ( "fs" ) ;
7+
8+ /**
9+ * @description
10+ * Function to retrieve the unique source locales from the legacy CMS
11+ * @param {* } jsonFilePath - Local file path of the exported data
12+ * @returns {Array } - Array of unique locales used in the exported data
13+ */
14+ const extractLocale = async ( jsonFilePath ) => {
15+ try {
16+ const rawData = fs . readFileSync ( jsonFilePath , "utf8" ) ;
17+ const jsonData = JSON . parse ( rawData ) ;
18+
19+ // Extract unique language codes from locales array
20+ const uniqueLanguages = new Set ( ) ;
21+ if ( Array . isArray ( jsonData . locales ) ) {
22+ jsonData . locales . forEach ( locale => {
23+ if ( locale . code ) {
24+ uniqueLanguages . add ( locale . code . toLowerCase ( ) ) ; // Normalize to lowercase
25+ }
26+ } ) ;
27+ }
28+
29+ return [ ...uniqueLanguages ] ; // Convert Set to array for output
30+ } catch ( error ) {
31+ console . error ( `Error reading JSON file:` , error . message ) ;
32+ return [ ] ;
33+ }
34+ } ;
35+
36+ module . exports = extractLocale
Original file line number Diff line number Diff line change 1+ /* eslint-disable @typescript-eslint/no-var-requires */
2+
3+ const contentTypes = require ( "./libs/contenttypes.js" )
14// eslint-disable-next-line @typescript-eslint/no-var-requires
2- import contentTypes from "./libs/contenttypes .js" ;
5+ const ExtractConfiguration = require ( "./libs/configuration .js" )
36// eslint-disable-next-line @typescript-eslint/no-var-requires
4- import ExtractConfiguration from "./libs/configuration .js"
7+ const reference = require ( "./libs/reference .js" )
58// eslint-disable-next-line @typescript-eslint/no-var-requires
6- import reference from "./libs/reference .js" ;
9+ const ExtractFiles = require ( "./libs/convert .js" )
710// eslint-disable-next-line @typescript-eslint/no-var-requires
8- import ExtractFiles from "./libs/convert.js"
9-
10- import { findAndExtractLanguages } from './libs/extractLocales.js'
11+ const extractLocales = require ( "./libs/extractLocales.js" )
1112
12- export {
13+ module . exports = {
1314 contentTypes,
1415 ExtractConfiguration,
1516 reference,
1617 ExtractFiles,
17- findAndExtractLanguages
18+ extractLocales
1819}
Original file line number Diff line number Diff line change 1- import fs from 'fs'
2- import path from 'path'
1+ /* eslint-disable @typescript-eslint/no-var-requires */
2+ const fs = require ( "fs" ) ;
3+ const path = require ( "path" ) ;
4+
35
46const uniqueLanguages = new Set ( ) ; // Define uniqueLanguages globally or pass it as a parameter
57
6- export const findAndExtractLanguages = ( dir ) => {
8+ const extractLocales = ( dir ) => {
79 const items = fs . readdirSync ( dir , { withFileTypes : true } ) ;
810
911 for ( const item of items ) {
1012 const fullPath = path . join ( dir , item . name ) ;
1113
1214 if ( item . isDirectory ( ) ) {
13- findAndExtractLanguages ( fullPath ) ; // Proper recursion
15+ extractLocales ( fullPath ) ; // Proper recursion
1416 } else if ( item . isFile ( ) && item . name === "data.json.json" ) {
1517 try {
1618 const rawData = fs . readFileSync ( fullPath , "utf8" ) ;
@@ -27,3 +29,5 @@ export const findAndExtractLanguages = (dir) => {
2729 }
2830 return uniqueLanguages ;
2931} ;
32+
33+ module . exports = extractLocales ;
You can’t perform that action at this time.
0 commit comments