Skip to content

Commit 99ccfca

Browse files
authored
Merge pull request #361 from sf-kishore-kurri/u/kkurri/W-18994070
feat: @W-18994070 : Naming convention and clean of flags on assess an…
2 parents 00c7f8d + 7c24671 commit 99ccfca

File tree

9 files changed

+34
-109
lines changed

9 files changed

+34
-109
lines changed

DEV.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This repository contains the code required to enable the OmniStudio Migration As
1111
5. In a new command line assistant, run the following command:
1212

1313
```
14-
bin/run omnistudio:migration:migrate -u [email protected] --namespace=agarciana46_238 --json
14+
bin/run omnistudio:migration:migrate -u [email protected]
1515
```
1616

1717
### Usage & parameters
@@ -22,19 +22,12 @@ USAGE
2222
trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
2323
2424
OPTIONS
25-
-n, --namespace=namespace the namespace of the vertical package
26-
2725
-u, --targetusername=targetusername username or alias for the target
2826
org; overrides default target org
2927
3028
-v, --targetdevhubusername=targetdevhubusername username or alias for the dev hub
3129
org; overrides default dev hub org
3230
33-
--apiversion=apiversion override the api version used for
34-
api requests made by this command
35-
36-
--json format output as json
37-
3831
--loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for
3932
this command invocation
4033

README.md

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ You can also authenticate using a consumer key (client ID) and secret key throug
2828
3. In a new terminal session, Install the Omnistudio Migration Assistant by running the `sf plugins install` command. For example
2929

3030
```
31-
sf plugins install @salesforce/[email protected].13
31+
sf plugins install @salesforce/[email protected].25
3232
```
3333

3434
4. Run the Omnistudio Migration Assistant from the Salesforce CLI:
@@ -42,7 +42,7 @@ sfdx omnistudio:migration:migrate -u [email protected]
4242
4343
4444
// To migrate/assess specific components: FlexCards, DataMappers, Integration Procedures, or OmniScripts, add the following parameters:
45-
--only=dr
45+
--only=dm
4646
--only=ip
4747
--only=os
4848
--only=fc
@@ -53,8 +53,6 @@ sfdx omnistudio:migration:migrate -u [email protected]
5353
// To assess specific related objects:
5454
--relatedobjects=apex // for Apex classes only
5555
56-
// To specify the Velocity Namespace (Optional)
57-
--namespace=VLOCITY_PACKAGE_NAMESPACE
5856
```
5957

6058
5. An HTML page will be open in your default browser with the results of your migration/assessment reports.
@@ -63,23 +61,16 @@ sfdx omnistudio:migration:migrate -u [email protected]
6361

6462
```
6563
USAGE
66-
$ sf omnistudio:migration:assess [-n <string>] [-f] [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel
64+
$ sf omnistudio:migration:assess [-f] [-v <string>] [-u <string>] [--loglevel
6765
trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
6866
6967
OPTIONS
70-
-n, --namespace=namespace the namespace of the vertical package
71-
7268
-u, --targetusername=targetusername username or alias for the target
7369
org; overrides default target org
7470
7571
-v, --targetdevhubusername=targetdevhubusername username or alias for the dev hub
7672
org; overrides default dev hub org
7773
78-
--apiversion=apiversion override the api version used for
79-
api requests made by this command
80-
81-
--json format output as json
82-
8374
--loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for
8475
this command invocation
8576
@@ -98,31 +89,24 @@ OPTIONS
9889

9990
```
10091
USAGE
101-
$ sf omnistudio:migration:migrate [-n <string>] [-f] [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel
92+
$ sf omnistudio:migration:migrate [-f] [-v <string>] [-u <string>] [--loglevel
10293
trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
10394
10495
OPTIONS
105-
-n, --namespace=namespace the namespace of the vertical package
106-
10796
-u, --targetusername=targetusername username or alias for the target
10897
org; overrides default target org
10998
11099
-v, --targetdevhubusername=targetdevhubusername username or alias for the dev hub
111100
org; overrides default dev hub org
112101
113-
--apiversion=apiversion override the api version used for
114-
api requests made by this command
115-
116-
--json format output as json
117-
118102
--loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for
119103
this command invocation
120104
121105
-a, --allversions migrate all versions and not
122106
and not just the active ones.
123107
124108
--only=only specify components to migrate:
125-
dr (DataRaptors), ip (Integration Procedures),
109+
dm (DataMappers), ip (Integration Procedures),
126110
os (OmniScripts), fc (FlexCards)
127111
128112
--relatedobjects=relatedobjects specify related objects to assess:

command-snapshot.json

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,25 @@
22
{
33
"command": "basecommand",
44
"plugin": "@salesforce/plugin-omnistudio-migration-tool",
5-
"flags": ["apiversion", "json", "loglevel", "targetusername"],
5+
"flags": ["loglevel", "targetusername"],
66
"alias": []
77
},
88
{
99
"command": "omnistudio:migration:assess",
1010
"plugin": "@salesforce/plugin-omnistudio-migration-tool",
11-
"flags": [
12-
"allversions",
13-
"apiversion",
14-
"json",
15-
"loglevel",
16-
"namespace",
17-
"only",
18-
"targetusername",
19-
"relatedobjects",
20-
"verbose"
21-
],
11+
"flags": ["allversions", "loglevel", "only", "targetusername", "relatedobjects", "verbose"],
2212
"alias": []
2313
},
2414
{
2515
"command": "omnistudio:migration:info",
2616
"plugin": "@salesforce/plugin-omnistudio-migration-tool",
27-
"flags": [
28-
"allversions",
29-
"apiversion",
30-
"json",
31-
"loglevel",
32-
"name",
33-
"targetdevhubusername",
34-
"targetusername",
35-
"verbose"
36-
],
17+
"flags": ["allversions", "loglevel", "name", "targetdevhubusername", "targetusername", "verbose"],
3718
"alias": []
3819
},
3920
{
4021
"command": "omnistudio:migration:migrate",
4122
"plugin": "@salesforce/plugin-omnistudio-migration-tool",
42-
"flags": [
43-
"allversions",
44-
"apiversion",
45-
"json",
46-
"loglevel",
47-
"namespace",
48-
"only",
49-
"relatedobjects",
50-
"targetusername",
51-
"verbose"
52-
],
23+
"flags": ["allversions", "loglevel", "only", "relatedobjects", "targetusername", "verbose"],
5324
"alias": []
5425
}
5526
]

messages/assess.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"namespaceFlagDescription": "The namespaced of the package",
1111
"apiVersionFlagDescription": "The Salesforce API version to use",
1212
"errorNoOrgResults": "No results found for the org '%s'.",
13-
"onlyFlagDescription": "Migrate a single element: os | ip | fc | dr",
14-
"invalidOnlyFlag": "Invalid flag, valid options are: os | ip | fc | dr",
13+
"onlyFlagDescription": "Migrate a single element: os | ip | fc | dm ",
14+
"invalidOnlyFlag": "Invalid flag, valid options are: os | ip | fc | dm",
1515
"couldNotDeactivateOmniProcesses": "Could not deactivate current OmniProcesses",
1616
"couldNotTruncate": "Could not truncate %s",
1717
"couldNotTruncateOmnniProcess": "Could not truncate OmniProcess. Please make sure your OS/IP is not referenced in an OmniScrirpt or Flex Card.",
@@ -105,7 +105,7 @@
105105
"invalidYesNoResponse": "Invalid response. Please answer y or n.",
106106
"notSfdxProjectFolderPath": "Provided folder is not a valid Salesforce DX project. Please select a folder containing sfdx-project.json",
107107
"failedToGetValidProjectPath": "Failed to get valid project path",
108-
"errorRunningAssess": "Error running assess",
108+
"errorRunningAssess": "Assessment process failed reason : %s",
109109
"enableVerboseOutput": "Enable verbose output",
110110
"apexFileChangesIdentifiedNotApplied": "Changes identified for Apex class %s but not applied (assessment mode)",
111111
"apexFileHasMultipleInterfaces": "File %s has multiple interfaces including Callable, standardizing to System.Callable only",

messages/migrate.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"notSfdxProjectFolderPath": "Provided folder is not a valid Salesforce DX project. Please select a folder containing sfdx-project.json",
5151
"operationCancelled": "Operation cancelled.",
5252
"failedToGetValidProjectPath": "Failed to get valid project path",
53-
"errorRunningMigrate": "Error running migrate %s",
53+
"errorRunningMigrate": "Migration process failed reason : %s",
5454
"couldNotEnableOmniPreferences": "Could not enable Omni preferences: %s",
5555
"errorSettingDesignersToStandardDataModel": "Error occurred while setting designers to use the standard data model %s",
5656
"exceptionSettingDesignersToStandardDataModel": "Exception occurred while setting designers to use the standard data model %s",

src/commands/omnistudio/migration/assess.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ export default class Assess extends OmniStudioBaseCommand {
2727
public static args = [{ name: 'file' }];
2828

2929
protected static flagsConfig = {
30-
namespace: flags.string({
31-
char: 'n',
32-
description: messages.getMessage('namespaceFlagDescription'),
33-
}),
3430
only: flags.string({
3531
char: 'o',
3632
description: messages.getMessage('onlyFlagDescription'),
@@ -56,27 +52,23 @@ export default class Assess extends OmniStudioBaseCommand {
5652
try {
5753
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
5854
return await this.runAssess();
59-
} catch (error) {
60-
Logger.error(messages.getMessage('errorRunningAssess'), error);
55+
} catch (e) {
56+
const error = e as Error;
57+
Logger.error(messages.getMessage('errorRunningAssess', [error.message]), error);
6158
process.exit(1);
6259
}
6360
}
6461

6562
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6663
public async runAssess(): Promise<any> {
6764
DebugTimer.getInstance().start();
68-
let apiVersion = this.flags.apiversion as string;
6965
const allVersions = (this.flags.allversions || false) as boolean;
7066
const assessOnly = (this.flags.only || '') as string;
7167
const relatedObjects = (this.flags.relatedobjects || '') as string;
7268
const conn = this.org.getConnection();
7369

74-
if (apiVersion) {
75-
conn.setApiVersion(apiVersion);
76-
} else {
77-
apiVersion = conn.getApiVersion();
78-
}
79-
const orgs: OmnistudioOrgDetails = await OrgUtils.getOrgDetails(conn, this.flags.namespace);
70+
const apiVersion = conn.getApiVersion();
71+
const orgs: OmnistudioOrgDetails = await OrgUtils.getOrgDetails(conn);
8072

8173
if (!orgs.hasValidNamespace && this.flags.namespace) {
8274
Logger.warn(messages.getMessage('invalidNamespace') + orgs.packageDetails.namespace);
@@ -120,10 +112,14 @@ export default class Assess extends OmniStudioBaseCommand {
120112
// eslint-disable-next-line @typescript-eslint/no-explicit-any
121113
} catch (ex: any) {
122114
if (ex instanceof InvalidEntityTypeError) {
123-
Logger.error(`${messages.getMessage('invalidTypeAssessErrorMessage', [namespace])}`);
115+
Logger.error(messages.getMessage('invalidTypeAssessErrorMessage', [namespace]));
116+
process.exit(1);
117+
}
118+
119+
if (ex instanceof Error) {
120+
Logger.error(messages.getMessage('errorRunningAssess', [ex.message]));
124121
process.exit(1);
125122
}
126-
Logger.error('Error assessing object', ex);
127123
}
128124

129125
let objectsToProcess: string[];

src/commands/omnistudio/migration/migrate.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ export default class Migrate extends OmniStudioBaseCommand {
4444
public static args = [{ name: 'file' }];
4545

4646
protected static flagsConfig = {
47-
namespace: flags.string({
48-
char: 'n',
49-
description: messages.getMessage('namespaceFlagDescription'),
50-
}),
5147
only: flags.string({
5248
char: 'o',
5349
description: messages.getMessage('onlyFlagDescription'),
@@ -75,30 +71,25 @@ export default class Migrate extends OmniStudioBaseCommand {
7571
return await this.runMigration();
7672
} catch (e) {
7773
const error = e as Error;
78-
Logger.error(messages.getMessage('errorRunningMigrate'), error);
74+
Logger.error(messages.getMessage('errorRunningMigrate', [error.message]));
7975
process.exit(1);
8076
}
8177
}
8278

8379
// eslint-disable-next-line @typescript-eslint/no-explicit-any
8480
// eslint-disable-next-line complexity
8581
public async runMigration(): Promise<any> {
86-
let apiVersion = this.flags.apiversion as string;
8782
const migrateOnly = (this.flags.only || '') as string;
8883
const allVersions = this.flags.allversions || (false as boolean);
8984
const relatedObjects = (this.flags.relatedobjects || '') as string;
9085

9186
// this.org is guaranteed because requiresUsername=true, as opposed to supportsUsername
9287
const conn = this.org.getConnection();
93-
if (apiVersion) {
94-
conn.setApiVersion(apiVersion);
95-
} else {
96-
apiVersion = conn.getApiVersion();
97-
}
88+
const apiVersion = conn.getApiVersion();
9889

99-
const orgs: OmnistudioOrgDetails = await OrgUtils.getOrgDetails(conn, this.flags.namespace);
90+
const orgs: OmnistudioOrgDetails = await OrgUtils.getOrgDetails(conn);
10091

101-
if (!orgs.hasValidNamespace && this.flags.namespace) {
92+
if (!orgs.hasValidNamespace) {
10293
Logger.warn(messages.getMessage('invalidNamespace') + orgs.packageDetails.namespace);
10394
}
10495

src/utils/constants/stringContants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export const Constants = {
33
Omniscript: 'os',
44
Flexcard: 'fc',
55
IntegrationProcedure: 'ip',
6-
DataMapper: 'dr',
6+
DataMapper: 'dm',
77
LWC: 'lwc',
88
Apex: 'apex',
99

src/utils/orgUtils/index.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ export class OrgUtils {
287287
* @param connection - Salesforce connection object
288288
* @returns Promise resolving to an array of PackageDetail objects
289289
*/
290-
public static async getOrgDetails(connection: Connection, namespace: string): Promise<OmnistudioOrgDetails> {
290+
public static async getOrgDetails(connection: Connection): Promise<OmnistudioOrgDetails> {
291291
// Query all installed packages and cast the result to InstalledPackage[]
292292
const allInstalledPackages = (await QueryTools.queryAll(
293293
connection,
@@ -309,20 +309,10 @@ export class OrgUtils {
309309
namespace: '',
310310
};
311311

312-
for (const pkg of allInstalledPackages) {
313-
if (namespace && namespace === pkg.NamespacePrefix) {
314-
packageDetails.version = `${pkg.MajorVersion}.${pkg.MinorVersion}`;
315-
packageDetails.namespace = pkg.NamespacePrefix;
316-
break;
317-
}
318-
}
319312
const installedOmniPackages = [];
320-
if (packageDetails.namespace === '') {
321-
hasValidNamespace = false;
322-
for (const pkg of allInstalledPackages) {
323-
if ((namespace && namespace === pkg.NamespacePrefix) || this.namespaces.has(pkg.NamespacePrefix)) {
324-
installedOmniPackages.push(pkg);
325-
}
313+
for (const pkg of allInstalledPackages) {
314+
if (this.namespaces.has(pkg.NamespacePrefix)) {
315+
installedOmniPackages.push(pkg);
326316
}
327317
}
328318

0 commit comments

Comments
 (0)