Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
20e633a
updated code
umeshmore45 May 16, 2024
36285b6
updated code
umeshmore45 May 16, 2024
39ef821
updated code
umeshmore45 May 16, 2024
52d8866
updated code
umeshmore45 May 16, 2024
cb17fa0
updated code
umeshmore45 May 16, 2024
75b0287
create project delete api and also comment status update in current-s…
shristi-sinha May 23, 2024
5fc5ab9
Merge pull request #121 from contentstack/feature/project-delete
shreyasBhoyar May 23, 2024
763f1f4
card Ui
snehalsankhe May 24, 2024
5806219
Mapping corrections on the fields
sayalijoshi27 May 24, 2024
f046622
create Project restore api and add isDeleted filter in get all projec…
shristi-sinha May 27, 2024
db34863
apply validation
shristi-sinha May 28, 2024
1a0cbe9
Merge pull request #123 from contentstack/feature/project-restore
sayalijoshi27 May 28, 2024
53ac6b3
[CMG-130] - Project dashboard | Project delete is not working
sayalijoshi27 May 28, 2024
d04ccfd
Merge branch 'dev' of https://github.com/contentstack/migration-v2-no…
sayalijoshi27 May 28, 2024
5f251f3
Merge pull request #124 from contentstack/feature/project-delete
AishDani May 28, 2024
dde0d35
Merge branch 'dev' of https://github.com/contentstack/migration-v2-no…
sayalijoshi27 May 28, 2024
6d90a06
Advanced Properties changes as per the field type
sayalijoshi27 May 28, 2024
8201804
Merge pull request #125 from contentstack/feature/CMG-103
AishDani May 28, 2024
45a801e
changes in layout
snehalsankhe May 29, 2024
81cce41
Merge pull request #122 from contentstack/new-project-dashboard
sayalijoshi27 May 29, 2024
e10da74
dev pull
snehalsankhe May 29, 2024
1ebba64
feat:created redux setup
AishDani Jun 3, 2024
57b3054
feat:latest package-lock.json file
AishDani Jun 3, 2024
b59305f
[CMG-107] - UI for Populate advance properties for the content type i…
sayalijoshi27 Jun 3, 2024
bf3bb9a
refactor:resolved empty org value in dropdown
AishDani Jun 3, 2024
5b93f1c
refactor:added optional chaining
AishDani Jun 3, 2024
e9f1d90
refactor:resolved PR comments
AishDani Jun 3, 2024
df899db
Merge pull request #126 from contentstack/feature/redux-setup
sreeneshkini Jun 3, 2024
b3c6360
added layout changes
snehalsankhe Jun 3, 2024
e8be3f0
resolved conflicts
snehalsankhe Jun 3, 2024
4798cfe
changes in card status
snehalsankhe Jun 4, 2024
bd9c525
removed commented
snehalsankhe Jun 4, 2024
89a546d
Merge pull request #127 from contentstack/layout-changes
sreeneshkini Jun 4, 2024
e52397f
Embed Objects added for RTE advanced properties
sayalijoshi27 Jun 4, 2024
4d0a9ef
Merge branch 'dev' of https://github.com/contentstack/migration-v2-no…
sayalijoshi27 Jun 4, 2024
da11d85
added mapper
umeshmore45 Jun 4, 2024
6da67f8
Removed contentstack/utils package
sayalijoshi27 Jun 4, 2024
c0c3fb1
Removed commented code
sayalijoshi27 Jun 4, 2024
0b4f990
Removed commented code
sayalijoshi27 Jun 5, 2024
9171e77
Merge pull request #128 from contentstack/feature/CMG-103
sreeneshkini Jun 5, 2024
cf64f71
feat:created horizontal stepper component
AishDani Jun 5, 2024
f4fe3e2
Merge branch 'dev' of github.com:contentstack/migration-v2-node-serve…
AishDani Jun 5, 2024
79dd79d
added layout changes
snehalsankhe Jun 5, 2024
d4cea28
merged data from dev
snehalsankhe Jun 5, 2024
b7ad519
refactor:removed commented code
AishDani Jun 5, 2024
23556b2
Merge pull request #129 from contentstack/layout-changes
sreeneshkini Jun 5, 2024
c2d09d4
Merge pull request #130 from contentstack/feature/horizontal-stepper
sreeneshkini Jun 5, 2024
676285b
added mapper
umeshmore45 Jun 6, 2024
19e26a2
resloved conflicts
umeshmore45 Jun 6, 2024
fe46948
resloved conflict
umeshmore45 Jun 6, 2024
68c9012
Merge pull request #131 from contentstack/feature/resloved-conflicts
sreeneshkini Jun 6, 2024
4c060b7
refactor:changed stepper as per new design
AishDani Jun 6, 2024
fa70d6a
Migration flow header UI and Stepper changes
sayalijoshi27 Jun 6, 2024
d0b147d
Merge pull request #132 from contentstack/feature/horizontal-stepper
sreeneshkini Jun 6, 2024
3159149
Merge branch 'dev' of https://github.com/contentstack/migration-v2-no…
sayalijoshi27 Jun 6, 2024
fc2c43c
Merge pull request #133 from contentstack/feature/CMG-57
sreeneshkini Jun 6, 2024
4116a39
Update code as per new design update
snehalsankhe Jun 7, 2024
cd7e23b
Merge pull request #134 from contentstack/layout-changes
v1shalpatel Jun 7, 2024
24e2a99
Main header, login image and logo changes
sayalijoshi27 Jun 7, 2024
41d6d5d
Merge branch 'dev' of https://github.com/contentstack/migration-v2-no…
sayalijoshi27 Jun 7, 2024
f7975d2
Merge pull request #135 from contentstack/feature/CMG-57
sreeneshkini Jun 7, 2024
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
Prev Previous commit
Next Next commit
added mapper
  • Loading branch information
umeshmore45 committed Jun 4, 2024
commit da11d858ae951e46fa132ec9394bad03ea2fcefa
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,5 @@ uploade-api/node_modules
uploade-api/build
package-lock.json
ui/.env
uplaode-api/sitecoreMigrationData
uplaode-api/sitecoreMigrationData
uplaode-api/extracted_files
7 changes: 3 additions & 4 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 Expand Up @@ -256,8 +256,7 @@ const updateContentType = async (req: Request) => {
NEW_PROJECT_STATUS[4],
].includes(project.status) ||
project.current_step < STEPPER_STEPS.CONTENT_MAPPING
)
{
) {
logger.error(
getLogMessage(
srcFun,
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
6 changes: 5 additions & 1 deletion uplaode-api/migration-sitecore/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ const contentTypes = require("./libs/contenttypes.js");
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
reference,
ExtractFiles
}
59 changes: 12 additions & 47 deletions uplaode-api/migration-sitecore/libs/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
* External module Dependencies.
*/
/* eslint-disable @typescript-eslint/no-var-requires */
const mkdirp = require("mkdirp");
const path = require("path");
const fs = require("fs"),
const parseString = require("xml2js").parseString,
const fs = require("fs");
const parseString = require("xml2js").parseString;
const read = require("fs-readdir-recursive");
/**
* Internal module Dependencies.
Expand All @@ -25,54 +24,20 @@ const config = {
* Create folders and files if they are not created
*/



function ExtractFiles(sitecore_folder) {
const xml_folder = read(sitecore_folder)
if (!fs.existsSync(path.join(process.cwd(), config.data))) {
mkdirp.sync(path.join(process.cwd(), config.data));
for (let i = 0; i < xml_folder.length; i++) {
const xml_data = `${sitecore_folder}/`.concat(xml_folder[i])
const json_data = xml_data.replace('/xml', '')
if (!fs.existsSync(path.resolve(json_data, config.json_filename))) {
parseString(helper.readXMLFile(xml_data), { explicitArray: false }, function (err, result) {
if (err) {
console.error("failed to parse xml: ", err);
} else {
const filePath = path.join(json_data, config?.json_filename)
fs.writeFileSync(`${filePath}.json`, JSON.stringify(result, null, 4), "utf-8");
}
})
} else {
fs.unlink(path.resolve(json_data, config.json_filename), (err) => {
if (err) throw err;
});
}
}
} else {
for (let i = 0; i < xml_folder.length; i++) {
if (xml_folder?.[i]?.includes?.("/xml")) {
const xml_data = `${sitecore_folder}/${xml_folder?.[i]}`
const json_data = xml_data.replace('/xml', '')
if (!fs.existsSync(path.resolve(json_data, config.json_filename))) {
parseString(helper.readXMLFile(xml_data), { explicitArray: false }, function (err, result) {
if (err) {
console.error("failed to parse xml: ", err);
} else {
const filePath = path.join(json_data, config?.json_filename)
fs.writeFileSync(filePath, JSON.stringify(result, null, 4), "utf-8");
}
})
for (let i = 0; i < xml_folder.length; i++) {
if (xml_folder?.[i]?.includes?.("/xml")) {
const xml_data = `${sitecore_folder}/${xml_folder?.[i]}`;
const json_data = xml_data.replace('/xml', '');
parseString(helper.readXMLFile(xml_data), { explicitArray: false }, function (err, result) {
if (err) {
console.error("failed to parse xml: ", err);
} else {
fs.unlink(path.resolve(json_data, config.json_filename), (err) => {
if (err) {
console.log(err)
throw err
}
console.log('File was deleted');
});
const filePath = path.join(json_data, config?.json_filename);
fs.writeFileSync(filePath, JSON.stringify(result, null, 4), "utf8");
}
}
})
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions uplaode-api/migration-sitecore/utils/helper.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-var-requires */
/**
* External module Dependencies.
*/
Expand All @@ -11,9 +12,8 @@ var mkdirp = require("mkdirp");

// for checking XML file
exports.readXMLFile = function (filePath) {
var data;
if (fs.existsSync(filePath)) data = fs.readFileSync(filePath, "utf-8");
console.log("🚀 ~ file: helper.js:16 ~ data:", data)
let data;
if (fs.existsSync(filePath)) data = fs.readFileSync(filePath, "utf8");
return data;
};

Expand Down
34 changes: 27 additions & 7 deletions uplaode-api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion uplaode-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@types/inquirer": "^9.0.7",
"@types/lodash.isempty": "^4.4.9",
"@types/multer": "^1.4.11",
"@types/node": "^20.11.0",
"@types/node": "^20.12.12",
"@typescript-eslint/eslint-plugin": "^7.7.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
Expand All @@ -42,6 +42,7 @@
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"express": "^4.18.2",
"express-rate-limit": "^7.2.0",
"inquirer": "^9.2.15",
"jszip": "^3.10.1",
"lodash.isempty": "^4.4.0",
Expand Down
4 changes: 3 additions & 1 deletion uplaode-api/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export const HTTP_TEXTS = {
SOMETHING_WENT_WRONG: 'Something went wrong while processing your request, please try again.',
ROUTE_ERROR: 'Sorry, the requested resource is not available.',
VALIDATION_ERROR: 'File validation failed.',
VALIDATION_SUCCESSFULL: ' File validated successfully.'
VALIDATION_SUCCESSFULL: ' File validated successfully.',
ZIP_FILE_SAVE: 'Issue While Saving Zip File.',
MAPPER_SAVED: 'Mapping process completed successfull.'
};

export const HTTP_RESPONSE_HEADERS = {
Expand Down
27 changes: 20 additions & 7 deletions uplaode-api/src/controllers/sitecore/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import axios from "axios";
import { readFileSync } from "fs";
import { deleteFolderSync } from "../../helper";
import logger from "../../utils/logger";
import { HTTP_CODES, HTTP_TEXTS } from "../../constants";

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { contentTypes, ExtractConfiguration, reference } = require('migration-sitecore');
const { contentTypes, ExtractConfiguration, reference, ExtractFiles } = require('migration-sitecore');

const createSitecoreMapper = async () => {
const createSitecoreMapper = async (filePath: string = "", projectId: string | string[], app_token: string | string[]) => {
try {
const path = "/Users/umesh.more/Downloads/package 45/items";
const path = `${filePath}/items`;
await ExtractFiles(path);
await ExtractConfiguration(path);
await contentTypes(path);
const infoMap = await reference();
Expand All @@ -17,22 +21,31 @@ const createSitecoreMapper = async () => {
JSON.parse(readFileSync(`${infoMap?.path}/content_types/${contentType}`, 'utf8'))
);
}
console.log("🚀 ~ createSitecoreMapper ~ fieldMapping:", fieldMapping)
const config = {
method: 'post',
maxBodyLength: Infinity,
url: `http://localhost:5000/v2/mapper/createDummyData/98ee1edc-f297-419d-a394-8ab71e2e546c`,
url: `${process.env.NODE_BACKEND_API}/v2/mapper/createDummyData/${projectId}`,
headers: {
'app_token': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyZWdpb24iOiJOQSIsInVzZXJfaWQiOiJibHQzNWNlZTkxZThmZDI4YWRiIiwiaWF0IjoxNzE1ODU1MzMwLCJleHAiOjE3MTU5NDE3MzB9.4-aVhDCWjvCPNXeWK8RaNnH97quOM7j8rMF_pSKh7rM',
app_token,
'Content-Type': 'application/json'
},
data: JSON.stringify(fieldMapping),
};
const response = await axios.request(config)
console.log("🚀 ~ forawait ~ response:", response?.data)
if (response?.data?.content_mapper?.length) {
deleteFolderSync(infoMap?.path);
logger.info('Validation success:', {
status: HTTP_CODES?.OK,
message: HTTP_TEXTS?.MAPPER_SAVED,
});
}
}
} catch (err: any) {
console.error("🚀 ~ createSitecoreMapper ~ err:", err?.response?.data ?? err)
logger.warn('Validation error:', {
status: HTTP_CODES?.UNAUTHORIZED,
message: HTTP_TEXTS?.VALIDATION_ERROR,
});
}
}

Expand Down
64 changes: 63 additions & 1 deletion uplaode-api/src/helper/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import rateLimit from "express-rate-limit";
import fs from "fs";
import path from "path";
import { HTTP_TEXTS, HTTP_CODES } from '../constants';
import logger from "../utils/logger";

const getFileName = (params: { Key: string }) => {
const obj: { fileName?: string; fileExt?: string } = {};
//fine Name
Expand All @@ -7,4 +13,60 @@ const getFileName = (params: { Key: string }) => {
return obj;
};

export { getFileName };
const saveZip = async (zip: any) => {
try {
const keys = Object?.keys(zip.files);
for await (const filename of keys) {
const file = zip?.files?.[filename];
if (!file?.dir) { // Ignore directories
const filePath = path.join(__dirname, '../../extracted_files', filename);
// Ignore __MACOSX folder asynchronously
if (!(filePath.includes("__MACOSX"))) {
// Ensure the directory exists asynchronously
await fs.promises.mkdir(path.dirname(filePath), { recursive: true });
// Write the file asynchronously
const content = await file.async('nodebuffer');
await fs.promises.writeFile(filePath, content);
}
}
}
return true;
} catch (err: any) {
console.error(err);
logger.info('Zipfile error:', {
status: HTTP_CODES?.SERVER_ERROR,
message: HTTP_TEXTS?.ZIP_FILE_SAVE,
});
return false;
}
};

const fileOperationLimiter = rateLimit({
windowMs: 2 * 60 * 1000, // 2 minutes
max: 2, // Limit each IP to 2 requests per windowMs for this endpoint
message: {
status: "rate limit",
message: "Rate limit exceeded. Only 2 calls allowed every 2 minutes.",
}
});


function deleteFolderSync(folderPath: string): void {
if (fs.existsSync(folderPath)) {
fs.readdirSync(folderPath).forEach((file: string) => {
const currentPath: string = path.join(folderPath, file);
if (fs.lstatSync(currentPath).isDirectory()) {
// Recurse
deleteFolderSync(currentPath);
} else {
// Delete file
fs.unlinkSync(currentPath);
}
});
// Delete now-empty folder
fs.rmdirSync(folderPath);
}
}


export { getFileName, saveZip, fileOperationLimiter, deleteFolderSync };
Loading