Skip to content

Commit f9b09e5

Browse files
committed
chore: addressed comments
1 parent 05c063f commit f9b09e5

File tree

14 files changed

+733
-240
lines changed

14 files changed

+733
-240
lines changed

messages/assess.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"allVersionsDescription": "Migrate all versions of a component",
3030
"changeMessage": " %s will be changed from %s to %s",
3131
"angularOSWarning": " Angular OmniScript will not be migrated, please convert this to LWC based Omniscript",
32-
"apexLwcGA": "Please select the type of component to assess: 'apex' for Apex classes, 'lwc' for Lightning Web Components, or 'apex,lwc' if you want to include both types.",
32+
"relatedObjectGA": "Please select the type of component to assess: 'apex' for Apex classes, 'lwc' for Lightning Web Components, 'flexipage' for FlexiPages, or 'apex,lwc,flexipage' if you want to include all types.",
3333
"apexLwc": "Please select the type of component to assess: 'apex' for Apex classes.",
3434
"invalidNamespace": "The namespace you have passed is not valid namespace, the valid namespace of your org is ",
3535
"noPackageInstalled": "No package installed on given org.",
@@ -123,7 +123,8 @@
123123
"processingFlexiPage": "Processing flexipage file: %s",
124124
"startingFlexiPageProcessing": "Starting to process flexipage: %s",
125125
"readFlexiPageContent": "Read file content, size: %s characters",
126-
"updatedModifiedContent": "Wrote modified content to file: %s",
126+
"updatedModifiedContent": "updated content in file: %s",
127127
"generatedDiffForFile": "Generated diff for file: %s",
128-
"errorProcessingFlexiPage": "Error processing flexipage file: %s, %s"
128+
"errorProcessingFlexiPage": "Error processing flexipage file: %s, %s",
129+
"flexipagesWithChanges": "Found %s flexipage files with changes"
129130
}

messages/migrate.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"errorWhileUploadingCard": "An error ocurred while uploading Card: ",
3030
"errorWhileCreatingElements": "An error ocurred while saving OmniScript elements: ",
3131
"allVersionsDescription": "Migrate all versions of a component",
32-
"apexLwcGA": "Please select the type of components to migrate: 'apex' for Apex classes, 'lwc' for Lightning Web Components, or 'apex,lwc' if you want to include both types.",
32+
"relatedObjectGA": "Please select the type of components to migrate: 'apex' for Apex classes, 'lwc' for Lightning Web Components, 'flexipage' for FlexiPages, or 'apex,lwc,flexipage' if you want to include all types.",
3333
"apexLwc": "Please select the type of components to migrate: 'apex' for Apex classes.",
3434
"invalidNamespace": "The namespace you have passed is not valid namespace, the valid namespace of your org is ",
3535
"noPackageInstalled": "No package installed on given org.",
@@ -118,7 +118,8 @@
118118
"processingFlexiPage": "Processing flexipage file: %s",
119119
"startingFlexiPageProcessing": "Starting to process flexipage: %s",
120120
"readFlexiPageContent": "Read file content, size: %s characters",
121-
"updatedModifiedContent": "Wrote modified content to file: %s",
121+
"updatedModifiedContent": "updated content in file: %s",
122122
"generatedDiffForFile": "Generated diff for file: %s",
123-
"errorProcessingFlexiPage": "Error processing flexipage file: %s, %s"
123+
"errorProcessingFlexiPage": "Error processing flexipage file: %s, %s",
124+
"flexipagesWithChanges": "Found %s flexipage files with changes"
124125
}

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-
"fast-xml-parser": "^5.2.5",
1918
"jsdom": "^25.0.0",
2019
"lodash.chunk": "^4.2.0",
2120
"open": "^8.4.2",

src/commands/omnistudio/migration/migrate.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default class Migrate extends OmniStudioBaseCommand {
5757
}),
5858
relatedobjects: flags.string({
5959
char: 'r',
60-
description: messages.getMessage('apexLwc'),
60+
description: messages.getMessage('relatedObjectGA'),
6161
}),
6262
verbose: flags.builtin({
6363
type: 'builtin',
@@ -126,7 +126,7 @@ export default class Migrate extends OmniStudioBaseCommand {
126126
let targetApexNamespace: string;
127127
if (relatedObjects) {
128128
// To-Do: Add LWC to valid options when GA is released
129-
const validOptions = [Constants.Apex];
129+
const validOptions = [Constants.Apex, Constants.FlexiPage];
130130
objectsToProcess = relatedObjects.split(',').map((obj) => obj.trim());
131131
// Validate input
132132
for (const obj of objectsToProcess) {
@@ -178,7 +178,8 @@ export default class Migrate extends OmniStudioBaseCommand {
178178
const relatedObjectMigrationResult = omnistudioRelatedObjectsMigration.migrateAll(objectsToProcess);
179179
generatePackageXml.createChangeList(
180180
relatedObjectMigrationResult.apexAssessmentInfos,
181-
relatedObjectMigrationResult.lwcAssessmentInfos
181+
relatedObjectMigrationResult.lwcAssessmentInfos,
182+
relatedObjectMigrationResult.flexipageAssessmentInfos
182183
);
183184

184185
let actionItems = [];

src/migration/base.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@ import { Stringutil } from '../utils/StringValue/stringutil';
77
import { Logger } from '../utils/logger';
88
import { TransformData, UploadRecordResult } from './interfaces';
99

10-
export type ComponentType = 'Data Mapper' | 'Flexcard' | 'Omniscript and Integration Procedure' | 'Flexipage';
10+
export type ComponentType = 'Data Mapper' | 'Flexcard' | 'Omniscript and Integration Procedure';
11+
export type RelatedObjectType = 'Flexipage';
1112

1213
/**
1314
* Creates a progress bar for migration/assessment operations
1415
*
1516
* @param action - The action being performed (e.g., 'Migrating', 'Assessing')
16-
* @param componentType - The type of component being processed
17+
* @param type - The type of component being processed
1718
* @returns A configured cliProgress.SingleBar instance
1819
*/
19-
export const createProgressBar = (action: string, componentType: ComponentType): cliProgress.SingleBar => {
20+
export const createProgressBar = (action: string, type: ComponentType | RelatedObjectType): cliProgress.SingleBar => {
2021
return new cliProgress.SingleBar({
21-
format: `${action} ${componentType} |${
22-
componentType === 'Omniscript and Integration Procedure' ? '' : '\t\t\t\t'
22+
format: `${action} ${type} |${
23+
type === 'Omniscript and Integration Procedure' ? '' : '\t\t\t\t'
2324
} {bar} | {percentage}% || {value}/{total} Tasks`,
2425
barCompleteChar: '\u2588',
2526
barIncompleteChar: '\u2591',

src/migration/related/FlexipageMigration.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Logger } from '../../utils/logger';
1414
import { Constants } from '../../utils/constants/stringContants';
1515
import { FlexiPageAssessmentInfo } from '../../utils/interfaces';
1616
import { createProgressBar } from '../base';
17-
import { xmlUtil } from '../../utils/XMLUtil';
17+
import { XMLUtil } from '../../utils/XMLUtil';
1818
import { FileDiffUtil } from '../../utils/lwcparser/fileutils/FileDiffUtil';
1919
import { transformFlexipageBundle } from '../../utils/flexipage/flexiPageTransformer';
2020
import { Flexipage } from '../interfaces';
@@ -41,6 +41,7 @@ import { BaseRelatedObjectMigration } from './BaseRealtedObjectMigration';
4141
export class FlexipageMigration extends BaseRelatedObjectMigration {
4242
/** Messages instance for internationalization */
4343
private messages: Messages;
44+
private xmlUtil: XMLUtil;
4445

4546
/**
4647
* Creates a new FlexipageMigration instance.
@@ -53,6 +54,7 @@ export class FlexipageMigration extends BaseRelatedObjectMigration {
5354
public constructor(projectPath: string, namespace: string, org: Org, messages: Messages) {
5455
super(projectPath, namespace, org);
5556
this.messages = messages;
57+
this.xmlUtil = new XMLUtil(['flexiPageRegions', 'itemInstances', 'componentInstanceProperties']);
5658
}
5759

5860
/**
@@ -123,18 +125,21 @@ export class FlexipageMigration extends BaseRelatedObjectMigration {
123125
);
124126
} catch (error) {
125127
Logger.error(this.messages.getMessage('errorProcessingFlexiPage', [file, error]));
128+
Logger.error(error);
126129
flexPageAssessmentInfos.push({
127130
name: file,
128131
errors: [error instanceof Error ? error.message : JSON.stringify(error)],
129132
path: filePath,
130133
diff: '',
131-
status: 'Errors',
134+
status: mode === 'assess' ? 'Errors' : 'Failed',
132135
});
133136
}
134137
progressBar.increment();
135138
}
136139
progressBar.stop();
137140
Logger.info(this.messages.getMessage('completedProcessingAllFlexiPages', [flexPageAssessmentInfos.length]));
141+
flexPageAssessmentInfos.filter((flexPageAssessmentInfo) => flexPageAssessmentInfo.status !== 'No Changes');
142+
Logger.info(this.messages.getMessage('flexipagesWithChanges', [flexPageAssessmentInfos.length]));
138143
return flexPageAssessmentInfos;
139144
}
140145

@@ -159,8 +164,9 @@ export class FlexipageMigration extends BaseRelatedObjectMigration {
159164
const fileContent = fs.readFileSync(filePath, 'utf8');
160165
Logger.logVerbose(this.messages.getMessage('readFlexiPageContent', [fileContent.length]));
161166

162-
const parent: { FlexiPage: Flexipage } = xmlUtil.parse(fileContent) as { FlexiPage: Flexipage };
163-
const json = parent.FlexiPage;
167+
const json = this.xmlUtil.parse(fileContent) as Flexipage;
168+
const jsonPath = path.join(shell.pwd().toString(), 'json', fileName + '.json');
169+
fs.writeFileSync(jsonPath.toString(), JSON.stringify(json) || '');
164170
const transformedFlexiPage = transformFlexipageBundle(json, this.namespace);
165171
if (transformedFlexiPage === false) {
166172
return {
@@ -171,8 +177,10 @@ export class FlexipageMigration extends BaseRelatedObjectMigration {
171177
status: 'No Changes',
172178
};
173179
}
174-
parent.FlexiPage = transformedFlexiPage as Flexipage;
175-
const modifiedContent = xmlUtil.build(parent);
180+
const modifiedContent = this.xmlUtil.build(transformedFlexiPage, 'FlexiPage');
181+
182+
const xmlPath = path.join(shell.pwd().toString(), 'xml', fileName);
183+
fs.writeFileSync(xmlPath.toString(), modifiedContent);
176184

177185
if (mode === 'migrate') {
178186
fs.writeFileSync(filePath, modifiedContent);
@@ -187,7 +195,7 @@ export class FlexipageMigration extends BaseRelatedObjectMigration {
187195
name: fileName,
188196
diff: JSON.stringify(diff),
189197
errors: [],
190-
status: 'Can be Automated',
198+
status: mode === 'assess' ? 'Can be Automated' : 'Complete',
191199
};
192200
}
193201
}

0 commit comments

Comments
 (0)