Skip to content

Commit e57c0e3

Browse files
author
kumar-ankita
committed
feat: tnc changes
1 parent f273251 commit e57c0e3

File tree

5 files changed

+48
-6
lines changed

5 files changed

+48
-6
lines changed

messages/assess.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@
2828
"errorWhileCreatingElements": "An error ocurred while saving OmniScript elements: ",
2929
"allVersionsDescription": "Migrate all versions of a component",
3030
"changeMessage": " %s will be changed from %s to %s",
31-
"angularOSWarning": " Angular OmniScript will not be migrated, please convert this to LWC based Omniscript"
31+
"angularOSWarning": " Angular OmniScript will not be migrated, please convert this to LWC based Omniscript",
32+
"apexLwc": "Specify Apex/LWC migration"
3233
}

messages/info.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
"sfdx omnistudio:migration:info --targetusername [email protected] --targetdevhubusername [email protected]",
88
"sfdx omnistudio:migration:info --name myname --targetusername [email protected]"
99
],
10-
"allVersionsDescription": "Migrate all versions of a component"
10+
"allVersionsDescription": "Migrate all versions of a component",
11+
"apexLwc": "Specify Apex/LWC migration"
1112
}

messages/migrate.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@
2525
"errorWhileActivatingCard": "Could not activate Card: ",
2626
"errorWhileUploadingCard": "An error ocurred while uploading Card: ",
2727
"errorWhileCreatingElements": "An error ocurred while saving OmniScript elements: ",
28-
"allVersionsDescription": "Migrate all versions of a component"
28+
"allVersionsDescription": "Migrate all versions of a component",
29+
"apexLwc": "Specify Apex/LWC migration"
2930
}

src/commands/omnistudio/migration/migrate.ts

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ export default class Migrate extends OmniStudioBaseCommand {
5050
description: messages.getMessage('allVersionsDescription'),
5151
required: false,
5252
}),
53+
relatedObjects: flags.boolean({
54+
char: 'r',
55+
description: messages.getMessage('apexLwc'),
56+
}),
57+
// lwc: flags.boolean({
58+
// char: 'l',
59+
// description: 'Include LWC migration in the process. User consent is required.',
60+
// }),
5361
};
5462

5563
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -58,6 +66,7 @@ export default class Migrate extends OmniStudioBaseCommand {
5866
const apiVersion = (this.flags.apiversion || '55.0') as string;
5967
const migrateOnly = (this.flags.only || '') as string;
6068
const allVersions = this.flags.allversions || false;
69+
const relatedObjects = (this.flags.relatedobjects || '') as string;
6170

6271
Logger.initialiseLogger(this.ux, this.logger);
6372
this.logger = Logger.logger;
@@ -67,7 +76,33 @@ export default class Migrate extends OmniStudioBaseCommand {
6776

6877
// Let's time every step
6978
DebugTimer.getInstance().start();
79+
// const includeApex = this.flags.apex
80+
// ? await this.ux.confirm('Do you want to include Apex migration? (yes/no)')
81+
// : false;
7082

83+
if (relatedObjects) {
84+
const validOptions = ['apex', 'lwc'];
85+
const objectsToProcess = relatedObjects.split(',').map((obj) => obj.trim());
86+
// Validate input
87+
for (const obj of objectsToProcess) {
88+
if (!validOptions.includes(obj)) {
89+
throw new Error(`Invalid option provided for -r: ${obj}. Valid options are apex, lwc.`);
90+
}
91+
}
92+
// Ask for user consent
93+
const consent = await this.ux.confirm(
94+
'By proceeding further, you hereby consent to the use, accept changes to your custom code, and the accompanying terms and conditions associated with the use of the OmniStudio Migration Tool. Do you want to proceed?'
95+
);
96+
if (!consent) {
97+
this.ux.log('User declined consent. Aborting the process.');
98+
return;
99+
}
100+
const projectPath = await this.ux.prompt('Enter the project path for processing:');
101+
this.ux.log(`Using project path: ${projectPath}`);
102+
OmnistudioRelatedObjectMigrationFacade.intializeProject(projectPath);
103+
}
104+
105+
// const includeLwc = this.flags.lwc ? await this.ux.confirm('Do you want to include LWC migration? (yes/no)') : false;
71106
// Register the migration objects
72107
let migrationObjects: MigrationTool[] = [];
73108
if (!migrateOnly) {
@@ -122,7 +157,6 @@ export default class Migrate extends OmniStudioBaseCommand {
122157
throw new Error(messages.getMessage('invalidOnlyFlag'));
123158
}
124159
}
125-
126160
// Migrate individual objects
127161
const debugTimer = DebugTimer.getInstance();
128162
let objectMigrationResults: MigratedObject[] = [];

src/migration/related/OmnistudioRelatedObjectMigrationFacade.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,17 @@ export default class OmnistudioRelatedObjectMigrationFacade {
4949
return process.cwd() + '/' + defaultProjectName;
5050
}
5151
}
52-
public migrateAll(migrationResult: MigratedObject[], relatedObjects: string[]): RelatedObjectAssesmentInfo {
52+
53+
public migrateAll(
54+
migrationResult: MigratedObject[],
55+
relatedObjects: string[],
56+
projectPath?: string
57+
): RelatedObjectAssesmentInfo {
5358
// Start the debug timer
5459
DebugTimer.getInstance().start();
5560

5661
// Declare an array of MigrationTool
57-
const projectDirectory: string = OmnistudioRelatedObjectMigrationFacade.intializeProject();
62+
const projectDirectory: string = OmnistudioRelatedObjectMigrationFacade.intializeProject(projectPath);
5863
const debugTimer = DebugTimer.getInstance();
5964
debugTimer.start();
6065
// Initialize migration tools based on the relatedObjects parameter

0 commit comments

Comments
 (0)