Skip to content

Commit 6219a0b

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

File tree

2 files changed

+13
-61
lines changed

2 files changed

+13
-61
lines changed

src/migration/related/LwcMigration.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class LwcMigration extends BaseRelatedObjectMigration implements RelatedO
2727
const type = 'assessment';
2828
const pwd = shell.pwd();
2929
shell.cd(this.projectPath);
30-
// sfProject.retrieve(LWCTYPE, this.org.getUsername());
30+
sfProject.retrieve(LWCTYPE, this.org.getUsername());
3131
const filesMap = this.processLwcFiles(this.projectPath);
3232
shell.cd(pwd);
3333
return this.processFiles(filesMap, type);
@@ -70,6 +70,11 @@ export class LwcMigration extends BaseRelatedObjectMigration implements RelatedO
7070
if (processor != null) {
7171
const path = file.location;
7272
const name = file.name + file.ext;
73+
if (file.ext === 'xml') {
74+
// if (fileutil.isAutogenratedFile(path)) {
75+
76+
// }
77+
}
7378
const diff = processor.process(file, type, this.namespace);
7479
if (diff != null) {
7580
const fileInfo: FileChangeInfo = {
Lines changed: 7 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,14 @@
1-
/* eslint-disable @typescript-eslint/no-unsafe-return */
2-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
3-
/* eslint-disable @typescript-eslint/no-unsafe-call */
4-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
5-
/* eslint-disable @typescript-eslint/explicit-member-accessibility */
6-
/* eslint-disable @typescript-eslint/restrict-template-expressions */
7-
/* eslint-disable @typescript-eslint/member-ordering */
8-
/* eslint-disable no-console */
91
import * as fs from 'fs';
10-
import * as cheerio from 'cheerio';
112
import { FileConstant } from '../fileutils/FileConstant';
123

134
const DEFAULT_NAMESPACE = 'c';
14-
const TAG = 'tag';
15-
16-
// const { window } = new JSDOM();
17-
// const { document } = window;
185

196
export class HTMLParser {
20-
private parser: cheerio.CheerioAPI;
217
html: string;
228
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
239
constructor(htmlFilePath: string) {
2410
// Load the HTML file and initialize cheerio
2511
this.html = this.loadHTMLFromFile(htmlFilePath);
26-
this.parser = cheerio.load(this.html, { xmlMode: true });
2712
}
2813

2914
// Method to load HTML from a file
@@ -38,50 +23,12 @@ export class HTMLParser {
3823

3924
// Method to replace custom tags
4025
public replaceTags(namespaceTag: string): Map<string, string> {
41-
const htmlContentMap = new Map<string, string>();
42-
// Load the HTML into cheerio
43-
//const $ = this.parser;
44-
htmlContentMap.set(FileConstant.BASE_CONTENT, this.html);
45-
// 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());
51-
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-
// });
56-
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);
26+
const htmlContentMap = new Map<string, string>();
27+
htmlContentMap.set(FileConstant.BASE_CONTENT, this.html);
28+
// Use a regular expression to match <omnistudio-input ...>...</omnistudio-input>
29+
this.html = this.html.replace('<'+namespaceTag, '<'+DEFAULT_NAMESPACE).replace('</'+namespaceTag, '</'+DEFAULT_NAMESPACE);
30+
htmlContentMap.set(FileConstant.MODIFIED_CONTENT, this.html);
31+
console.log(this.html);
8532
return htmlContentMap;
8633
}
8734

@@ -98,6 +45,6 @@ console.log(this.html);
9845

9946
// Optional: Method to get the modified HTML as a string
10047
public getModifiedHTML(): string {
101-
return this.parser.html();
48+
return this.html;
10249
}
10350
}

0 commit comments

Comments
 (0)