Skip to content

Commit 8c250b5

Browse files
author
Shailesh M. Pachbhai
committed
feat: fix html qoute issue
1 parent 055ba08 commit 8c250b5

File tree

5 files changed

+45
-19
lines changed

5 files changed

+45
-19
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"@types/jsdom": "^21.1.7",
1616
"@types/lodash.chunk": "^4.2.9",
1717
"@types/shelljs": "^0.8.15",
18-
"cheerio": "^1.0.0",
1918
"jsdom": "^25.0.0",
2019
"lodash.chunk": "^4.2.0",
2120
"open": "^8.4.2",

src/migration/related/LwcMigration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class LwcMigration extends BaseRelatedObjectMigration implements RelatedO
6363
const jsonData: LWCAssessmentInfo[] = [];
6464
fileMap.forEach((fileList, dir) => {
6565
const changeInfos: FileChangeInfo[] = [];
66-
if (dir !== 'lwc' && !dir.endsWith('English') && !dir.includes('_') && !dir.includes('cf')) {
66+
if (dir !== 'lwc' && !dir.endsWith('English') && !dir.includes('_') && !dir.startsWith('cf')) {
6767
for (const file of fileList) {
6868
if (this.isValideFile(file.name)) {
6969
const processor = FileProcessorFactory.getFileProcessor(file.ext);

src/utils/lwcparser/htmlParser/HTMLParser.ts

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,48 @@ export class HTMLParser {
4040
public replaceTags(namespaceTag: string): Map<string, string> {
4141
const htmlContentMap = new Map<string, string>();
4242
// Load the HTML into cheerio
43-
const $ = this.parser;
43+
//const $ = this.parser;
4444
htmlContentMap.set(FileConstant.BASE_CONTENT, this.html);
4545
// Find all tags that contain the substring "omnistudio" in their tag name
46-
$('*').each((i, element) => {
47-
if (element.type === TAG && element.name && element.name.includes(namespaceTag + '-')) {
48-
// Create a new tag with the same content and attributes as the old tag
49-
const newTag = DEFAULT_NAMESPACE + element.name.substring(element.name.indexOf('-'));
50-
const newElement = $(`<${newTag}>`).html($(element).html());
46+
// $('*').each((i, element) => {
47+
// if (element.type === TAG && element.name && element.name.includes(namespaceTag + '-')) {
48+
// // Create a new tag with the same content and attributes as the old tag
49+
// const newTag = DEFAULT_NAMESPACE + element.name.substring(element.name.indexOf('-'));
50+
// const newElement = $(`<${newTag}>`).html($(element).html());
5151

52-
// Copy all attributes from the old element to the new one
53-
Object.keys(element.attribs).forEach((attr) => {
54-
newElement.attr(attr, $(element).attr(attr));
55-
});
52+
// // Copy all attributes from the old element to the new one
53+
// Object.entries(element.attribs).forEach(([key, value]) => {
54+
// newElement.attr(key, value);
55+
// });
5656

57-
// Replace the old element with the new one
58-
$(element).replaceWith(newElement);
59-
}
60-
});
61-
$.html().replace(/\n\s*/g, '');
62-
htmlContentMap.set(FileConstant.MODIFIED_CONTENT, $.html());
57+
// // Replace the old element with the new one
58+
// $(element).replaceWith(newElement);
59+
// }
60+
// });
61+
// // $.html().replace(/\n\s*/g, '');
62+
63+
// let html = `
64+
// <html lang="en">
65+
// <head>
66+
// <meta charset="UTF-8" />
67+
// <meta name="viewport" content="width=device-width, initial-scale=1.0" />
68+
// <title>Replace Tags Example</title>
69+
// </head>
70+
// <span dir={_dir}>test</span>
71+
// <body>
72+
// <template>
73+
// <vlocity_ins-input vertical-align=stretch>Hello Shailesh</vlocity_ins-input>
74+
// <vlocity_ins-input vertical-align=stretch>Another Input</vlocity_ins-input>
75+
// </template>
76+
// </body>
77+
// </html>`;
78+
79+
// Use a regular expression to match <omnistudio-input ...>...</omnistudio-input>
80+
this.html = this.html.replace('/<'+namespaceTag+'-/g', '<c-').replace('/<'+namespaceTag+'-/g', '</c-');
81+
82+
console.log(this.html);
83+
// htmlContentMap.set(FileConstant.MODIFIED_CONTENT, $.html());
84+
htmlContentMap.set(FileConstant.MODIFIED_CONTENT, this.html);
6385
return htmlContentMap;
6486
}
6587

src/utils/lwcparser/xmlParser/XmlParser.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,9 @@ export class XmlParser {
5656
throw error;
5757
}
5858
}
59+
60+
// public isAutogenratedFile(filePath: string) {
61+
// this.fileContent = fs.readFileSync(filePath, 'utf-8');
62+
// return this.fileContent.includes('OmniScript Auto-generated');
63+
// }
5964
}

test/utils/lwc/parser/htmlparser.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ describe('HTMLParser test class', () => {
1212
// eslint-disable-next-line no-console
1313
console.log(new FileDiffUtil().getFileDiff('file.txt', html.get('original'), html.get('modified')));
1414
htmlParser.saveToFile('test/utils/lwc/parser/output/test.html', html.get('modified'));
15-
expect(htmlParser.getModifiedHTML()).contains('c-input');
15+
expect(htmlParser.getModifiedHTML()).contains('c-omniscript-step-chart');
1616
});
1717
});

0 commit comments

Comments
 (0)