Skip to content

Commit 07e8f38

Browse files
Merge pull request #264 from salesforcecli/t/kumar-ankita/W-17258174/tncChanges
W-17258174 - feat: tnc changes
2 parents f273251 + b99f72a commit 07e8f38

File tree

9 files changed

+93
-82
lines changed

9 files changed

+93
-82
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,11 @@ OPTIONS
5959
-a, --allversions migrate all versions and not
6060
and not just the active ones.
6161
62+
--relatedobjects=relatedobjects Please select the type of components to
63+
migrate: 'apex' for Apex classes, 'lwc' for Lightning Web Components, or 'apex,lwc' if you want to include both types.
64+
6265
```
66+
67+
Terms:
68+
Notwithstanding anything stated in the terms and conditions agreed between Salesforce (‘SFDC’) and you (‘Customer’), the use of the OmniStudio Migration Tool (‘Tool’) is designed to facilitate the migration and it’s going to modify your custom code and by deploying and using the Tool you hereby provide your consent to automate the migration process and enable a smooth transition. Customer shall access and use the Tool only as permitted to the Customer and shall not compromise, break or circumvent any technical processes or security measures associated with the services provided by SFDC.
69+
The Customer agrees to hold harmless, indemnify, and defend SFDC, and its officers, directors, agents, employees, licensees, successors and assigns (collectively, the “Indemnified Parties”) against any and all damages, penalties, losses, liabilities, judgments, settlements, awards, costs, and expenses (including reasonable attorneys’ fees and expenses) to the extent arising out of or in connection with any claims related to the Customers use of the Tool or any willful misconduct, fraud or grossly negligent acts or omissions by the Customer.

command-snapshot.json

Lines changed: 25 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,26 @@
11
[
2-
{
3-
"command": "basecommand",
4-
"plugin": "@salesforce/plugin-omnistudio-migration-tool",
5-
"flags": [
6-
"apiversion",
7-
"json",
8-
"loglevel",
9-
"targetusername"
10-
],
11-
"alias": []
12-
},
13-
{
14-
"command": "omnistudio:migration:assess",
15-
"plugin": "@salesforce/plugin-omnistudio-migration-tool",
16-
"flags": [
17-
"allversions",
18-
"apiversion",
19-
"json",
20-
"loglevel",
21-
"namespace",
22-
"only",
23-
"targetusername"
24-
],
25-
"alias": []
26-
},
27-
{
28-
"command": "omnistudio:migration:info",
29-
"plugin": "@salesforce/plugin-omnistudio-migration-tool",
30-
"flags": [
31-
"allversions",
32-
"apiversion",
33-
"json",
34-
"loglevel",
35-
"name",
36-
"targetdevhubusername",
37-
"targetusername"
38-
],
39-
"alias": []
40-
},
41-
{
42-
"command": "omnistudio:migration:migrate",
43-
"plugin": "@salesforce/plugin-omnistudio-migration-tool",
44-
"flags": [
45-
"allversions",
46-
"apiversion",
47-
"json",
48-
"loglevel",
49-
"namespace",
50-
"only",
51-
"targetusername"
52-
],
53-
"alias": []
54-
}
55-
]
2+
{
3+
"command": "basecommand",
4+
"plugin": "@salesforce/plugin-omnistudio-migration-tool",
5+
"flags": ["apiversion", "json", "loglevel", "targetusername"],
6+
"alias": []
7+
},
8+
{
9+
"command": "omnistudio:migration:assess",
10+
"plugin": "@salesforce/plugin-omnistudio-migration-tool",
11+
"flags": ["allversions", "apiversion", "json", "loglevel", "namespace", "only", "targetusername"],
12+
"alias": []
13+
},
14+
{
15+
"command": "omnistudio:migration:info",
16+
"plugin": "@salesforce/plugin-omnistudio-migration-tool",
17+
"flags": ["allversions", "apiversion", "json", "loglevel", "name", "targetdevhubusername", "targetusername"],
18+
"alias": []
19+
},
20+
{
21+
"command": "omnistudio:migration:migrate",
22+
"plugin": "@salesforce/plugin-omnistudio-migration-tool",
23+
"flags": ["allversions", "apiversion", "json", "loglevel", "namespace", "only", "relatedobjects", "targetusername"],
24+
"alias": []
25+
}
26+
]

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": "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."
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": "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."
1112
}

messages/migrate.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
"omnistudio:migration:migrate -u [email protected] --namespace=YOUR_PACKAGE_NAMESPACE --only=dr",
55
"omnistudio:migration:migrate -u [email protected] --namespace=YOUR_PACKAGE_NAMESPACE --only=ip",
66
"omnistudio:migration:migrate -u [email protected] --namespace=YOUR_PACKAGE_NAMESPACE --only=os",
7-
"omnistudio:migration:migrate -u [email protected] --namespace=YOUR_PACKAGE_NAMESPACE --only=fc"
7+
"omnistudio:migration:migrate -u [email protected] --namespace=YOUR_PACKAGE_NAMESPACE --only=fc",
8+
"omnistudio:migration:migrate -u [email protected] --namespace=YOUR_PACKAGE_NAMESPACE -r apex,lwc",
9+
"omnistudio:migration:migrate -u [email protected] --namespace=YOUR_PACKAGE_NAMESPACE -r apex",
10+
"omnistudio:migration:migrate -u [email protected] --namespace=YOUR_PACKAGE_NAMESPACE -r lwc"
811
],
912
"commandDescription": "print a greeting and your org IDs",
1013
"namespaceFlagDescription": "The namespaced of the package",
@@ -25,5 +28,6 @@
2528
"errorWhileActivatingCard": "Could not activate Card: ",
2629
"errorWhileUploadingCard": "An error ocurred while uploading Card: ",
2730
"errorWhileCreatingElements": "An error ocurred while saving OmniScript elements: ",
28-
"allVersionsDescription": "Migrate all versions of a component"
31+
"allVersionsDescription": "Migrate all versions of a component",
32+
"apexLwc": "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."
2933
}

src/commands/omnistudio/migration/migrate.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ export default class Migrate extends OmniStudioBaseCommand {
5050
description: messages.getMessage('allVersionsDescription'),
5151
required: false,
5252
}),
53+
relatedobjects: flags.string({
54+
char: 'r',
55+
description: messages.getMessage('apexLwc'),
56+
}),
5357
};
5458

5559
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -58,6 +62,7 @@ export default class Migrate extends OmniStudioBaseCommand {
5862
const apiVersion = (this.flags.apiversion || '55.0') as string;
5963
const migrateOnly = (this.flags.only || '') as string;
6064
const allVersions = this.flags.allversions || false;
65+
const relatedObjects = (this.flags.relatedobjects || '') as string;
6166

6267
Logger.initialiseLogger(this.ux, this.logger);
6368
this.logger = Logger.logger;
@@ -67,7 +72,33 @@ export default class Migrate extends OmniStudioBaseCommand {
6772

6873
// Let's time every step
6974
DebugTimer.getInstance().start();
75+
// const includeApex = this.flags.apex
76+
// ? await this.ux.confirm('Do you want to include Apex migration? (yes/no)')
77+
// : false;
7078

79+
if (relatedObjects) {
80+
const validOptions = ['apex', 'lwc'];
81+
const objectsToProcess = relatedObjects.split(',').map((obj) => obj.trim());
82+
// Validate input
83+
for (const obj of objectsToProcess) {
84+
if (!validOptions.includes(obj)) {
85+
Logger.logger.warn(`Invalid option provided for -r: ${obj}. Valid options are apex, lwc.`);
86+
}
87+
}
88+
// Ask for user consent
89+
const consent = await this.ux.confirm(
90+
'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?'
91+
);
92+
if (!consent) {
93+
this.ux.log('User declined consent. Aborting the process.');
94+
} else {
95+
const projectPath = await this.ux.prompt('Enter the project path for processing:');
96+
this.ux.log(`Using project path: ${projectPath}`);
97+
OmnistudioRelatedObjectMigrationFacade.intializeProject(projectPath);
98+
}
99+
}
100+
101+
// const includeLwc = this.flags.lwc ? await this.ux.confirm('Do you want to include LWC migration? (yes/no)') : false;
71102
// Register the migration objects
72103
let migrationObjects: MigrationTool[] = [];
73104
if (!migrateOnly) {
@@ -122,7 +153,6 @@ export default class Migrate extends OmniStudioBaseCommand {
122153
throw new Error(messages.getMessage('invalidOnlyFlag'));
123154
}
124155
}
125-
126156
// Migrate individual objects
127157
const debugTimer = DebugTimer.getInstance();
128158
let objectMigrationResults: MigratedObject[] = [];

src/migration/related/ApexMigration.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
SingleTokenUpdate,
1313
TokenUpdater,
1414
} from '../../utils/apex/parser/apexparser';
15-
import { MigrationResult } from '../interfaces';
1615
import { sfProject } from '../../utils/sfcli/project/sfProject';
1716
import { fileutil, File } from '../../utils/file/fileutil';
1817
import { Logger } from '../../utils/logger';
@@ -41,12 +40,12 @@ export class ApexMigration extends BaseRelatedObjectMigration {
4140
public processObjectType(): string {
4241
return 'apex';
4342
}
44-
public identifyObjects(migrationResults: MigrationResult[]): Promise<JSON[]> {
45-
throw new Error('Method not implemented.');
46-
}
47-
public migrateRelatedObjects(migrationResults: MigrationResult[], migrationCandidates: JSON[]): ApexAssessmentInfo[] {
48-
return this.migrate();
49-
}
43+
// public identifyObjects(migrationResults: MigrationResult[]): Promise<JSON[]> {
44+
// throw new Error('Method not implemented.');
45+
// }
46+
// public migrateRelatedObjects(migrationResults: MigrationResult[], migrationCandidates: JSON[]): ApexAssessmentInfo[] {
47+
// return this.migrate();
48+
// }
5049
public migrate(): ApexAssessmentInfo[] {
5150
const pwd = shell.pwd();
5251
shell.cd(this.projectPath);

src/migration/related/LwcMigration.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import * as shell from 'shelljs';
33
import { Org } from '@salesforce/core';
44
import { fileutil, File } from '../../utils/file/fileutil';
5-
import { MigrationResult } from '../interfaces';
65
import { sfProject } from '../../utils/sfcli/project/sfProject';
76
import { Logger } from '../../utils/logger';
87
import { FileProcessorFactory } from '../../utils/lwcparser/fileutils/FileProcessorFactory';
@@ -16,13 +15,13 @@ export class LwcMigration extends BaseRelatedObjectMigration {
1615
public processObjectType(): string {
1716
return 'lwc';
1817
}
19-
public identifyObjects(migrationResults: MigrationResult[]): Promise<JSON[]> {
20-
this.assessment();
21-
throw new Error('Method not implemented.');
22-
}
23-
public migrateRelatedObjects(migrationResults: MigrationResult[], migrationCandidates: JSON[]): string[] {
24-
return this.mapToName(this.migrate());
25-
}
18+
// public identifyObjects(migrationResults: MigrationResult[]): Promise<JSON[]> {
19+
// this.assessment();
20+
// throw new Error('Method not implemented.');
21+
// }
22+
// public migrateRelatedObjects(migrationResults: MigrationResult[], migrationCandidates: JSON[]): string[] {
23+
// return this.mapToName(this.migrate());
24+
// }
2625
public assessment(): LWCAssessmentInfo[] {
2726
const type = 'assessment';
2827
const pwd = shell.pwd();
@@ -104,10 +103,4 @@ export class LwcMigration extends BaseRelatedObjectMigration {
104103
private isValideFile(filename: string): boolean {
105104
return !filename.includes('_def') && !filename.includes('styleDefinition') && !filename.includes('definition');
106105
}
107-
108-
private mapToName(lwcAssessmentInfos: LWCAssessmentInfo[]): string[] {
109-
return lwcAssessmentInfos.map((lwcAssessmentInfo) => {
110-
return lwcAssessmentInfo.name;
111-
});
112-
}
113106
}

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)