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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -351,4 +351,7 @@ MigrationBackup/

uploade-api/node_modules
uploade-api/build
package-lock.json
package-lock.json
ui/.env
uplaode-api/sitecoreMigrationData
uplaode-api/extracted_files
5 changes: 0 additions & 5 deletions api/example.env

This file was deleted.

1 change: 1 addition & 0 deletions api/src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import fs from "fs";

const connectToDatabase = async () => {
try {
//check if the database folder exists
if (!fs.existsSync("./database")) {
fs.mkdirSync("./database");
}
Expand Down
4 changes: 2 additions & 2 deletions api/src/services/contentMapper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const putTestData = async (req: Request) => {
return { id, isDeleted: true, ...field };
});
FieldMapperModel.update((data: any) => {
data.field_mapper = [...data?.field_mapper, ...fields];
data.field_mapper = [...data?.field_mapper ?? [], ...fields];
});
contentTypes[index].fieldMapping = fieldIds;
});
Expand All @@ -44,7 +44,7 @@ const putTestData = async (req: Request) => {
const contentType = contentTypes.map((item: any) => {
const id = uuidv4();
contentIds.push(id);
return { id, ...item };
return { ...item, id };
});

await ContentTypesMapperModelLowdb.update((data: any) => {
Expand Down
3 changes: 2 additions & 1 deletion uplaode-api/.env
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
PORT=4002
PORT=4002
NODE_BACKEND_API =http://localhost:5000
3 changes: 2 additions & 1 deletion uplaode-api/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
"root": true,
"env": {
"browser": true,
"node": true,
"es2021": true
},
"extends": ["prettier", "eslint:recommended", "plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2022,
"project": ["./tsconfig.json"],
"project": [],
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "prettier"],
Expand Down
7 changes: 7 additions & 0 deletions uplaode-api/migration-sitecore/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
csMigrationData
node_modules
logs
sitecoreMigrationData
Alaska
data
_
4 changes: 4 additions & 0 deletions uplaode-api/migration-sitecore/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
import contentTypes from "./libs/contenttypes.js";

export default contentTypes;
15 changes: 15 additions & 0 deletions uplaode-api/migration-sitecore/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const contentTypes = require("./libs/contenttypes.js");
// eslint-disable-next-line @typescript-eslint/no-var-requires
const ExtractConfiguration = require("./libs/configuration.js")
// eslint-disable-next-line @typescript-eslint/no-var-requires
const reference = require("./libs/reference.js");
// eslint-disable-next-line @typescript-eslint/no-var-requires
const ExtractFiles = require("./libs/convert.js")

module.exports = {
contentTypes,
ExtractConfiguration,
reference,
ExtractFiles
}
72 changes: 72 additions & 0 deletions uplaode-api/migration-sitecore/libs/configuration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require("path");
const read = require("fs-readdir-recursive");
const helper = require("../utils/helper");


const assignFolderName = ({ path }) => {
const spliter = "/sitecore";
const newPath = path.split(spliter)?.[1];
return `${spliter}${newPath}`;
}




function ExtractConfiguration(sitecore_folder) {
const xml_folder = read(sitecore_folder);
const obj = {};
const treeObj = {};
for (let i = 0; i < xml_folder?.length; i++) {
if ((xml_folder?.[i]?.includes("data.json") || xml_folder?.[i]?.includes("data.json.json")) && !xml_folder?.[i]?.includes("undefined.json")) {
const path = xml_folder?.[i]
const data = helper?.readFile(`${sitecore_folder}/${xml_folder?.[i]}`)
if (data?.item?.$?.template === "configuration group") {
let newPath = path?.split("/{")?.[0];
const groupPath = read(`${sitecore_folder}/${newPath}`)
let arrayValue = [];
let multiValueArrayTree = [];
groupPath?.forEach((item) => {
if ((item?.includes("data.json") || item?.includes("data.json.json")) && !item?.includes("undefined.json")) {
const conf = helper?.readFile(`${sitecore_folder}/${newPath}/${item}`)
const value = conf?.item?.fields?.field?.find((item) => item?.$?.key === "value")
if (value) {
arrayValue.push({ key: conf?.item?.$?.name, value: value?.content !== "" ? value?.content : conf?.item?.$?.name })
} else {
arrayValue.push({ value: conf?.item?.$?.name })
}
multiValueArrayTree.push({ key: conf?.item?.$?.name, value: conf?.item?.$?.id })
}
})
obj[assignFolderName({ path: `${sitecore_folder}/${newPath}` })] = arrayValue;
treeObj[assignFolderName({ path: `${sitecore_folder}/${newPath}` })] = multiValueArrayTree;
}
}
}
helper.writeFile(
path.join(
process.cwd(),
"sitecoreMigrationData/MapperData",
),
JSON.stringify(obj, null, 4),
"configuration",
(err) => {
if (err) throw err;
}
);
helper.writeFile(
path.join(
process.cwd(),
"sitecoreMigrationData/MapperData",
),
JSON.stringify(treeObj, null, 4),
"configurationTree",
(err) => {
if (err) throw err;
}
);
}



module.exports = ExtractConfiguration;
Loading