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
3 changes: 1 addition & 2 deletions api/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ dist/
# Mono auto generated files
mono_crash.*

#MAC DS_Store File
/api/.DS_Store

# Build results
[Dd]ebug/
Expand Down Expand Up @@ -361,6 +359,7 @@ combine.log


!example.env
!production.env

database/
/sitecoreMigrationData
Expand Down
3 changes: 3 additions & 0 deletions api/production.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
APP_TOKEN_KEY=MIGRATION_V2
PORT=5001

6 changes: 3 additions & 3 deletions api/src/services/migration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,9 @@ export const createSourceLocales = async (req: Request) => {
* @throws Exception if the project ID is invalid or the when the path to project.json is incorrect
*/
export const updateLocaleMapper = async (req:Request) =>{
const mapperObject = req.body.mapper;
const mapperObject = req.body;
const projectFilePath = path.join(process.cwd(), 'database', 'project.json'); // Adjusted path to project.json
const projectId = req.params.projectId;
const projectId = req.params.projectId;

try {
// Check if the project.json file exists
Expand All @@ -496,7 +496,7 @@ export const updateLocaleMapper = async (req:Request) =>{
})
}
} catch (err: any) {
console.error("🚀 ~ createSourceLocales ~ err:", err?.response?.data ?? err, err)
console.error("🚀 ~ updateLocaleMapper ~ err:", err?.response?.data ?? err, err)
logger.warn('Bad Request', {
status: HTTP_CODES?.BAD_REQUEST,
message: HTTP_TEXTS?.INTERNAL_ERROR,
Expand Down
6 changes: 6 additions & 0 deletions ui/.env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
REACT_APP_WEBSITE_BASE_URL="http://localhost:3000/"
REACT_APP_BASE_API_URL="http://localhost:5001/"
REACT_APP_API_VERSION=v2
REACT_APP_HOST="http://localhost:3000"
REACT_APP_UPLOAD_SERVER="http://localhost:4002/"
REACT_APP_OFFLINE_CMS=true
4 changes: 3 additions & 1 deletion ui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ yarn-error.log*


# .npmrc
.npmrc
.npmrc

!.env.local
4 changes: 3 additions & 1 deletion upload-api/migration-contentful/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

const extractContentTypes = require('./libs/extractContentTypes');
const createInitialMapper = require('./libs/createInitialMapper');
const extractLocale = require('./libs/extractLocale')

module.exports = {
extractContentTypes,
createInitialMapper
createInitialMapper,
extractLocale
};

36 changes: 36 additions & 0 deletions upload-api/migration-contentful/libs/extractLocale.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"use strict";
/* eslint-disable @typescript-eslint/no-var-requires */
/**
* External module dependencies.
*/
const fs = require("fs");

/**
* @description
* Function to retrieve the unique source locales from the legacy CMS
* @param {*} jsonFilePath - Local file path of the exported data
* @returns {Array} - Array of unique locales used in the exported data
*/
const extractLocale = async (jsonFilePath) => {
try {
const rawData = fs.readFileSync(jsonFilePath, "utf8");
const jsonData = JSON.parse(rawData);

// Extract unique language codes from locales array
const uniqueLanguages = new Set();
if (Array.isArray(jsonData.locales)) {
jsonData.locales.forEach(locale => {
if (locale.code) {
uniqueLanguages.add(locale.code.toLowerCase()); // Normalize to lowercase
}
});
}

return [...uniqueLanguages]; // Convert Set to array for output
} catch (error) {
console.error(`Error reading JSON file:`, error.message);
return [];
}
};

module.exports = extractLocale
17 changes: 9 additions & 8 deletions upload-api/migration-sitecore/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
/* eslint-disable @typescript-eslint/no-var-requires */

const contentTypes = require("./libs/contenttypes.js")
// eslint-disable-next-line @typescript-eslint/no-var-requires
import contentTypes from "./libs/contenttypes.js";
const ExtractConfiguration = require("./libs/configuration.js")
// eslint-disable-next-line @typescript-eslint/no-var-requires
import ExtractConfiguration from "./libs/configuration.js"
const reference = require("./libs/reference.js")
// eslint-disable-next-line @typescript-eslint/no-var-requires
import reference from "./libs/reference.js";
const ExtractFiles = require("./libs/convert.js")
// eslint-disable-next-line @typescript-eslint/no-var-requires
import ExtractFiles from "./libs/convert.js"

import {findAndExtractLanguages} from './libs/extractLocales.js'
const extractLocales = require("./libs/extractLocales.js")

export {
module.exports = {
contentTypes,
ExtractConfiguration,
reference,
ExtractFiles,
findAndExtractLanguages
extractLocales
}
12 changes: 8 additions & 4 deletions upload-api/migration-sitecore/libs/extractLocales.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import fs from 'fs'
import path from 'path'
/* eslint-disable @typescript-eslint/no-var-requires */
const fs = require("fs");
const path = require("path");


const uniqueLanguages = new Set(); // Define uniqueLanguages globally or pass it as a parameter

export const findAndExtractLanguages = (dir) => {
const extractLocales = (dir) => {
const items = fs.readdirSync(dir, { withFileTypes: true });

for (const item of items) {
const fullPath = path.join(dir, item.name);

if (item.isDirectory()) {
findAndExtractLanguages(fullPath); // Proper recursion
extractLocales(fullPath); // Proper recursion
} else if (item.isFile() && item.name === "data.json.json") {
try {
const rawData = fs.readFileSync(fullPath, "utf8");
Expand All @@ -27,3 +29,5 @@ export const findAndExtractLanguages = (dir) => {
}
return uniqueLanguages;
};

module.exports = extractLocales;
Loading