Skip to content

Commit 60a2875

Browse files
committed
Conflict resolved
2 parents eb583b8 + 607f0e5 commit 60a2875

File tree

7 files changed

+137
-121
lines changed

7 files changed

+137
-121
lines changed

.github/workflows/repo-sync.yml

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -101,33 +101,34 @@ jobs:
101101
npm install --save-dev eslint @eslint/js globals
102102
103103
104-
# if [ ! -f "eslint.config.cjs" ]; then
105-
# echo "Creating default ESLint config..."
106-
# cat <<EOL > eslint.config.cjs
107-
# const js = require("@eslint/js");
108-
# const globals = require("globals");
109-
110-
# module.exports = [
111-
# js.configs.recommended,
112-
# {
113-
# languageOptions: {
114-
# ecmaVersion: "latest",
115-
# sourceType: "module",
116-
# globals: globals.node,
117-
# },
118-
# rules: {
119-
# "no-unused-vars": "warn",
120-
# "no-console": "off"
121-
# }
122-
# }
123-
# ];
124-
# EOL
125-
# fi
104+
if [ ! -f "eslint.config.cjs" ]; then
105+
echo "Creating default ESLint config..."
106+
cat <<EOL > eslint.config.cjs
107+
const js = require("@eslint/js");
108+
const globals = require("globals");
109+
110+
module.exports = [
111+
js.configs.recommended,
112+
{
113+
languageOptions: {
114+
ecmaVersion: "latest",
115+
sourceType: "module",
116+
globals: globals.node,
117+
},
118+
rules: {
119+
"no-unused-vars": "warn",
120+
"no-console": "off"
121+
"@typescript-eslint/no-var-requires": 'off'
122+
}
123+
}
124+
];
125+
EOL
126+
fi
126127
127128
# # Remove unused imports and missing file references
128-
# echo "Running ESLint to remove unused imports..."
129-
# npm install eslint -g
130-
# eslint . --fix
129+
echo "Running ESLint to remove unused imports..."
130+
npm install eslint -g
131+
eslint . --fix --ignore-pattern "cli/**"
131132
132133
# echo "Running autoflake to remove unused imports..."
133134
# pip install autoflake

api/src/controllers/migration.controller.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { migrationService } from "../services/migration.service.js"
1010
*/
1111
const createTestStack = async (req: Request, res: Response): Promise<void> => {
1212
const resp = await migrationService.createTestStack(req);
13-
res.status(200).json(resp);
13+
res.status(resp?.status).json(resp);
1414
};
1515

1616
/**
@@ -55,12 +55,12 @@ const getLogs = async (req: Request, res: Response): Promise<void> => {
5555
res.status(200).json(resp);
5656
};
5757

58-
const saveLocales = async (req:Request, res: Response):Promise<void> =>{
58+
const saveLocales = async (req: Request, res: Response): Promise<void> => {
5959
const resp = await migrationService.createSourceLocales(req)
6060
res.status(200).json(resp);
6161
}
6262

63-
const saveMappedLocales = async (req:Request, res:Response):Promise<void> =>{
63+
const saveMappedLocales = async (req: Request, res: Response): Promise<void> => {
6464
const resp = await migrationService.updateLocaleMapper(req);
6565
res.status(200).json(resp);
6666
}

api/src/services/contentful.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ const createEntry = async (packagePath: any, destination_stack_id: string, proje
755755
const environmentsId = await readFile(environmentSave, ENVIRONMENTS_FILE_NAME) ?? {};
756756
const displayField: { [key: string]: any } = {}
757757
content.map((item: any) => {
758-
displayField[item.name.toLowerCase().replace(/[^a-z0-9]+/g, "_")] =
758+
displayField[item?.sys?.id] =
759759
{
760760
displayField: item.displayField || "untitled",
761761
};

upload-api/migration-contentful/libs/contentTypeMapper.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,13 +299,13 @@ const contentTypeMapper = (data) => {
299299
};
300300

301301
// Process validations and content names when data.items is not defined
302-
if (!item.items) {
303-
if (item.validations?.length > 0) {
302+
if (!item?.items) {
303+
if (item?.validations?.length > 0) {
304304
item.validations.forEach((entries) => {
305-
if (entries.linkContentType?.length) {
306-
commonRef = processLinkContentType(entries.linkContentType);
305+
if (entries?.linkContentType?.length) {
306+
commonRef = processLinkContentType(entries?.linkContentType);
307307
referenceFields =
308-
commonRef.length > 0 ? commonRef : item.contentNames?.slice(0, 9);
308+
commonRef?.length > 0 ? commonRef : item?.contentNames?.slice(0, 9);
309309
}
310310
});
311311
} else {
@@ -331,7 +331,9 @@ const contentTypeMapper = (data) => {
331331
: item?.contentNames?.slice(0, 9);
332332
}
333333
}
334-
acc.push(createFieldObject(item, 'reference', 'reference', referenceFields));
334+
const refFieldData = createFieldObject(item, 'reference', 'reference', referenceFields)
335+
refFieldData.refrenceTo = referenceFields;
336+
acc.push(refFieldData);
335337
break;
336338
}
337339
case 'checkbox':

upload-api/migration-sitecore/constants/index.js

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,49 @@
11
const MIGRATION_DATA_CONFIG = {
2-
DATA: 'cmsMigrationData',
3-
DATA_MAPPER_DIR: 'MapperData',
4-
DATA_MAPPER_CONFIG: 'configuration',
5-
DATA_MAPPER_CONFIG_TREE: 'configurationTree',
6-
DATA_MAPPER_CONFIG_FILE: 'configuration.json',
7-
DATA_MAPPER_CONFIG_TREE_FILE: 'configurationTree.json',
2+
DATA :"cmsMigrationData",
3+
DATA_MAPPER_DIR :"MapperData",
4+
DATA_MAPPER_CONFIG :"configuration",
5+
DATA_MAPPER_CONFIG_TREE :"configurationTree",
6+
DATA_MAPPER_CONFIG_FILE :"configuration.json",
7+
DATA_MAPPER_CONFIG_TREE_FILE :"configurationTree.json",
8+
9+
BACKUP_DATA: "migration-data",
10+
BACKUP_LOG_DIR: "logs",
11+
BACKUP_FOLDER_NAME: "import",
12+
BACKUP_FILE_NAME: "success.log",
13+
14+
LOCALE_DIR_NAME : "locale",
15+
LOCALE_FILE_NAME : "locales.json",
16+
LOCALE_MASTER_LOCALE : "master-locale.json",
17+
LOCALE_CF_LANGUAGE : "language.json",
18+
19+
CONTENT_TYPES_DIR_NAME : "content_types",
20+
CONTENT_TYPES_FILE_NAME : "contenttype.json",
21+
CONTENT_TYPES_MASTER_FILE : "contenttypes.json",
22+
CONTENT_TYPES_SCHEMA_FILE : "schema.json",
23+
24+
REFERENCES_DIR_NAME : "reference",
25+
REFERENCES_FILE_NAME : "reference.json",
26+
27+
RTE_REFERENCES_DIR_NAME : "rteReference",
28+
RTE_REFERENCES_FILE_NAME : "rteReference.json",
29+
30+
ASSETS_DIR_NAME : "assets",
31+
ASSETS_FILE_NAME : "assets.json",
32+
ASSETS_SCHEMA_FILE : "index.json",
33+
ASSETS_FAILED_FILE : "cs_failed.json",
34+
ASSETS_METADATA_FILE :"metadata.json",
35+
36+
ENTRIES_DIR_NAME : "entries",
37+
ENTRIES_MASTER_FILE : "index.json",
38+
39+
40+
GLOBAL_FIELDS_DIR_NAME : "global_fields",
41+
GLOBAL_FIELDS_FILE: "globalfields",
42+
GLOBAL_FIELDS_FILE_NAME : "globalfields.json",
43+
EXPORT_INFO_FILE: "export-info.json"
44+
}
845

9-
BACKUP_DATA: 'migration-data',
10-
BACKUP_LOG_DIR: 'logs',
11-
BACKUP_FOLDER_NAME: 'import',
12-
BACKUP_FILE_NAME: 'success.log',
1346

14-
LOCALE_DIR_NAME: 'locale',
15-
LOCALE_FILE_NAME: 'locales.json',
16-
LOCALE_MASTER_LOCALE: 'master-locale.json',
17-
LOCALE_CF_LANGUAGE: 'language.json',
18-
19-
CONTENT_TYPES_DIR_NAME: 'content_types',
20-
CONTENT_TYPES_FILE_NAME: 'contenttype.json',
21-
CONTENT_TYPES_MASTER_FILE: 'contenttypes.json',
22-
CONTENT_TYPES_SCHEMA_FILE: 'schema.json',
23-
24-
REFERENCES_DIR_NAME: 'reference',
25-
REFERENCES_FILE_NAME: 'reference.json',
26-
27-
RTE_REFERENCES_DIR_NAME: 'rteReference',
28-
RTE_REFERENCES_FILE_NAME: 'rteReference.json',
29-
30-
ASSETS_DIR_NAME: 'assets',
31-
ASSETS_FILE_NAME: 'assets.json',
32-
ASSETS_SCHEMA_FILE: 'index.json',
33-
ASSETS_FAILED_FILE: 'cs_failed.json',
34-
ASSETS_METADATA_FILE: 'metadata.json',
35-
36-
ENTRIES_DIR_NAME: 'entries',
37-
ENTRIES_MASTER_FILE: 'index.json',
38-
39-
GLOBAL_FIELDS_DIR_NAME: 'global_fields',
40-
GLOBAL_FIELDS_FILE: 'globalfields',
41-
GLOBAL_FIELDS_FILE_NAME: 'globalfields.json',
42-
EXPORT_INFO_FILE: 'export-info.json'
43-
};
4447

4548
module.exports = {
4649
MIGRATION_DATA_CONFIG

upload-api/src/constants/index.ts

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export const HTTP_TEXTS = {
2323
ZIP_FILE_SAVE: 'Issue While Saving Zip File.',
2424
XML_FILE_SAVE: 'Issue While Saving XML File.',
2525
MAPPER_SAVED: 'Mapping process completed successfull.',
26-
LOCALE_SAVED: 'Source locales stored successfully'
26+
LOCALE_SAVED: 'Source locales stored successfully',
27+
LOCALE_FAILED: 'Unable to create source.',
2728
};
2829

2930
export const HTTP_RESPONSE_HEADERS = {
@@ -33,46 +34,46 @@ export const HTTP_RESPONSE_HEADERS = {
3334
};
3435

3536
export const MIGRATION_DATA_CONFIG = {
36-
DATA: 'cmsMigrationData',
37+
DATA: "cmsMigrationData",
3738

3839
BACKUP_DATA: 'migration-data',
3940
BACKUP_LOG_DIR: 'logs',
4041
BACKUP_FOLDER_NAME: 'import',
4142
BACKUP_FILE_NAME: 'success.log',
4243

43-
LOCALE_DIR_NAME: 'locale',
44-
LOCALE_FILE_NAME: 'locales.json',
45-
LOCALE_MASTER_LOCALE: 'master-locale.json',
46-
LOCALE_CF_LANGUAGE: 'language.json',
44+
LOCALE_DIR_NAME: "locale",
45+
LOCALE_FILE_NAME: "locales.json",
46+
LOCALE_MASTER_LOCALE: "master-locale.json",
47+
LOCALE_CF_LANGUAGE: "language.json",
4748

48-
WEBHOOKS_DIR_NAME: 'webhooks',
49-
WEBHOOKS_FILE_NAME: 'webhooks.json',
49+
WEBHOOKS_DIR_NAME: "webhooks",
50+
WEBHOOKS_FILE_NAME: "webhooks.json",
5051

51-
ENVIRONMENTS_DIR_NAME: 'environments',
52-
ENVIRONMENTS_FILE_NAME: 'environments.json',
52+
ENVIRONMENTS_DIR_NAME: "environments",
53+
ENVIRONMENTS_FILE_NAME: "environments.json",
5354

54-
CONTENT_TYPES_DIR_NAME: 'content_types',
55-
CONTENT_TYPES_FILE_NAME: 'contenttype.json',
56-
CONTENT_TYPES_MASTER_FILE: 'contenttypes.json',
57-
CONTENT_TYPES_SCHEMA_FILE: 'schema.json',
55+
CONTENT_TYPES_DIR_NAME: "content_types",
56+
CONTENT_TYPES_FILE_NAME: "contenttype.json",
57+
CONTENT_TYPES_MASTER_FILE: "contenttypes.json",
58+
CONTENT_TYPES_SCHEMA_FILE: "schema.json",
5859

59-
REFERENCES_DIR_NAME: 'reference',
60-
REFERENCES_FILE_NAME: 'reference.json',
60+
REFERENCES_DIR_NAME: "reference",
61+
REFERENCES_FILE_NAME: "reference.json",
6162

62-
RTE_REFERENCES_DIR_NAME: 'rteReference',
63-
RTE_REFERENCES_FILE_NAME: 'rteReference.json',
63+
RTE_REFERENCES_DIR_NAME: "rteReference",
64+
RTE_REFERENCES_FILE_NAME: "rteReference.json",
6465

65-
ASSETS_DIR_NAME: 'assets',
66-
ASSETS_FILE_NAME: 'assets.json',
67-
ASSETS_SCHEMA_FILE: 'index.json',
68-
ASSETS_FAILED_FILE: 'cs_failed.json',
69-
ASSETS_METADATA_FILE: 'metadata.json',
66+
ASSETS_DIR_NAME: "assets",
67+
ASSETS_FILE_NAME: "assets.json",
68+
ASSETS_SCHEMA_FILE: "index.json",
69+
ASSETS_FAILED_FILE: "cs_failed.json",
70+
ASSETS_METADATA_FILE: "metadata.json",
7071

71-
ENTRIES_DIR_NAME: 'entries',
72-
ENTRIES_MASTER_FILE: 'index.json',
72+
ENTRIES_DIR_NAME: "entries",
73+
ENTRIES_MASTER_FILE: "index.json",
7374

74-
GLOBAL_FIELDS_DIR_NAME: 'global_fields',
75-
GLOBAL_FIELDS_FILE_NAME: 'globalfields.json',
75+
GLOBAL_FIELDS_DIR_NAME: "global_fields",
76+
GLOBAL_FIELDS_FILE_NAME: "globalfields.json",
7677

7778
EXPORT_INFO_FILE: 'export-info.json'
7879
};

upload-api/src/controllers/sitecore/index.ts

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,39 @@ const {
1414
GLOBAL_FIELDS_FILE_NAME
1515
} = MIGRATION_DATA_CONFIG;
1616

17+
const createLocaleSource = async ({ app_token, localeData, projectId }: { app_token: string | string[], localeData: any, projectId: string | string[] }) => {
18+
const mapperConfig = {
19+
method: 'post',
20+
maxBodyLength: Infinity,
21+
url: `${process.env.NODE_BACKEND_API}/v2/migration/localeMapper/${projectId}`,
22+
headers: {
23+
app_token,
24+
'Content-Type': 'application/json'
25+
},
26+
data: {
27+
locale: Array?.from?.(localeData) ?? []
28+
},
29+
};
30+
const mapRes = await axios?.request?.(mapperConfig);
31+
if (mapRes?.status == 200) {
32+
logger.info('Legacy CMS', {
33+
status: HTTP_CODES?.OK,
34+
message: HTTP_TEXTS?.LOCALE_SAVED,
35+
});
36+
} else {
37+
logger.warn('Legacy CMS error:', {
38+
status: HTTP_CODES?.UNAUTHORIZED,
39+
message: HTTP_TEXTS?.LOCALE_FAILED,
40+
});
41+
}
42+
}
43+
1744
const createSitecoreMapper = async (filePath: string = "", projectId: string | string[], app_token: string | string[], affix: string | string[], config: object) => {
1845
try {
1946
const newPath = path.join(filePath, 'items');
2047
await ExtractFiles(newPath);
2148
const localeData = await extractLocales(path.join(filePath, 'items', 'master', 'sitecore', 'content'));
49+
await createLocaleSource?.({ app_token, localeData, projectId });
2250
await ExtractConfiguration(newPath);
2351
await contentTypes(newPath, affix, config);
2452
const infoMap = await reference();
@@ -56,25 +84,6 @@ const createSitecoreMapper = async (filePath: string = "", projectId: string | s
5684
status: HTTP_CODES?.OK,
5785
message: HTTP_TEXTS?.MAPPER_SAVED,
5886
});
59-
const mapperConfig = {
60-
method: 'post',
61-
maxBodyLength: Infinity,
62-
url: `${process.env.NODE_BACKEND_API}/v2/migration/localeMapper/${projectId}`,
63-
headers: {
64-
app_token,
65-
'Content-Type': 'application/json'
66-
},
67-
data: {
68-
locale: Array?.from?.(localeData) ?? []
69-
},
70-
};
71-
const mapRes = await axios.request(mapperConfig);
72-
if (mapRes?.status == 200) {
73-
logger.info('Legacy CMS', {
74-
status: HTTP_CODES?.OK,
75-
message: HTTP_TEXTS?.LOCALE_SAVED,
76-
});
77-
}
7887
}
7988
}
8089
} catch (err: any) {

0 commit comments

Comments
 (0)