Skip to content

Commit 9899a50

Browse files
Logging Enhancement Changes (#291)
1 parent 3876e84 commit 9899a50

File tree

24 files changed

+558
-177
lines changed

24 files changed

+558
-177
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ package-lock.json
99
# debug logs
1010
npm-error.log
1111
yarn-error.log
12-
12+
logs/
1313

1414
# compile source
1515
lib

messages/assess.json

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,57 @@
3232
"apexLwc": "Please select the type of components to assess: 'apex' for Apex classes, 'lwc' for Lightning Web Components, or 'apex,lwc' if you want to include both types.",
3333
"invalidNamespace": "The namespace you have passed is not valid namespace, the valid namespace of your org is ",
3434
"noPackageInstalled": "No package installed on given org.",
35-
"alreadyStandardModel": "The org is already on standard data model."
36-
}
35+
"alreadyStandardModel": "The org is already on standard data model.",
36+
"invalidRelatedObjectsOption": "Invalid option provided for -r: %s. Valid options are apex, lwc.",
37+
"formulaSyntaxError": "There was some problem while updating the formula syntax, please check the all the formula's syntax once : %s",
38+
"errorDuringFlexCardAssessment": "Error during FlexCard assessment",
39+
"errorDuringOmniScriptAssessment": "Error during OmniScript assessment",
40+
"processingFlexCard": "Processing FlexCard: %s",
41+
"processingDataRaptor": "Processing DataRaptor: %s",
42+
"processingOmniScript": "Processing OmniScript: %s",
43+
"foundDataRaptorsToAssess": "Found %s DataRaptors to assess",
44+
"foundOmniScriptsToAssess": "Found %s OmniScripts and Integration Procedures to assess",
45+
"startingDataRaptorAssessment": "Starting DataRaptor assessment",
46+
"startingOmniScriptAssessment": "Starting OmniScript assessment",
47+
"allVersionsInfo": "allVersions : %s",
48+
"assessmentInitialization": "Assessment Initialization: Using namespace: %s",
49+
"apiVersionInfo": "API Version: %s",
50+
"assessmentTargets": "Assessment targets: %s",
51+
"relatedObjectsInfo": "Related objects: %s",
52+
"allVersionsFlagInfo": "All versions: %s",
53+
"assessedDataRaptorsCount": "Assessed %s DataRaptors",
54+
"dataRaptorAssessmentCompleted": "DataRaptor assessment completed",
55+
"flexCardAssessment": "FlexCard Assessment",
56+
"assessedFlexCardsCount": "Assessed %s FlexCards",
57+
"flexCardAssessmentCompleted": "FlexCard assessment completed",
58+
"omniScriptAssessment": "OmniScript and Integration Procedure Assessment",
59+
"assessedOmniScriptsCount": "Assessed %s OmniScripts",
60+
"assessedIntegrationProceduresCount": "Assessed %s Integration Procedures",
61+
"omniScriptAssessmentCompleted": "OmniScript and Integration Procedure assessment completed",
62+
"startingFlexCardAssessment": "Starting FlexCard assessment",
63+
"foundFlexCardsToAssess": "Found %s FlexCards to assess",
64+
"startingApexAssessment": "Starting Apex assessment in project path: %s",
65+
"processingApexFilesForAssessment": "Processing Apex files for assessment",
66+
"successfullyProcessedApexFilesForAssessment": "Successfully processed %s Apex files for assessment",
67+
"apexAssessmentResults": "Apex assessment results: %s",
68+
"foundApexFilesInDirectory": "Found %s Apex files in directory: %s",
69+
"skippingNonApexFile": "Skipping non-Apex file: %s",
70+
"processingApexFile": "Processing Apex file: %s",
71+
"skippingApexFileFewChanges": "Skipping Apex file: %s as it has less than 3 changes",
72+
"successfullyProcessedApexFile": "Successfully processed Apex file: %s",
73+
"fileNoOmnistudioCalls": "File %s does not have any omnistudio calls or remote calls. No changes will be applied.",
74+
"fileAlreadyImplementsCallable": "file %s already implements callable no changes will be applied",
75+
"inApexDrNameWillBeUpdated": "In Apex %s DR name %s will be updated to %s",
76+
"startingLwcAssessment": "Starting LWC assessment in project path: %s",
77+
"processingLwcsForAssessment": "Processing LWCs for assessment",
78+
"successfullyProcessedLwcsForAssessment": "Successfully processed %s LWCs for assessment",
79+
"lwcAssessmentResults": "LWC assessment results: %s",
80+
"errorReadingFiles": "Error in reading files: %s",
81+
"errorProcessingFiles": "Error in processing files: %s",
82+
"startingProcessRelatedObjects": "Starting processRelatedObjects for %s in project path: %s",
83+
"errorProcessingApexFile": "Error processing Apex file: %s",
84+
"fileUpdatedToAllowRemoteCalls": "File updated to allow remote calls",
85+
"fileUpdatedToAllowCalls": "File updated to allow calls",
86+
"fileImplementsVlocityOpenInterface": "file %s implements VlocityOpenInterface no changes will be applied",
87+
"methodCallBundleNameUpdated": "Method call bundle name will be updated in %s for class %s method %s"
88+
}

messages/info.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,9 @@
88
"sfdx omnistudio:migration:info --name myname --targetusername [email protected]"
99
],
1010
"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."
12-
}
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.",
12+
"greetingOrgInfo": "Hello %s! This is org: %s",
13+
"greetingOrgInfoWithDate": "Hello %s! This is org: %s and I will be around until %s!",
14+
"hubOrgId": "My hub org id is: %s",
15+
"allVersionsAppended": " and all versions will be migrated"
16+
}

messages/migrate.json

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,45 @@
3232
"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.",
3333
"invalidNamespace": "The namespace you have passed is not valid namespace, the valid namespace of your org is ",
3434
"noPackageInstalled": "No package installed on given org.",
35-
"alreadyStandardModel": "The org is already on standard data model."
36-
}
35+
"alreadyStandardModel": "The org is already on standard data model.",
36+
"invalidRelatedObjectsOption": "Invalid option provided for -r: %s. Valid options are apex, lwc.",
37+
"userConsentMessage": "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? [y/n]",
38+
"userDeclinedConsent": "User declined consent, will not process %s .",
39+
"userConsentedToProceed": "User consented to proceed",
40+
"projectPathConfirmation": "Do you have a sfdc project where %s files are already retrieved from org - y\nor you want tool to create a project omnistudio_migration in current directory for processing - n ? [y/n]",
41+
"enterProjectPath": "Enter the project path for processing %s :",
42+
"projectJsonNotFound": "Could not find any %s in %s.",
43+
"usingProjectPath": "Using project path: %s",
44+
"enterTargetNamespace": "Enter the target namespace to be used for calling package Apex classes",
45+
"usingTargetNamespace": "Using target namespace: %s for calling package Apex classes",
46+
"cleaningComponent": "Cleaning: %s",
47+
"cleaningDone": "Cleaning Done: %s",
48+
"migratingComponent": "Migrating: %s",
49+
"migrationCompleted": "Migration completed: %s",
50+
"formulaSyntaxError": "There was some problem while updating the formula syntax, please check the all the formula's syntax once : %s",
51+
"foundDataRaptorsToMigrate": "Found %s DataRaptors to migrate",
52+
"foundFlexCardsToMigrate": "Found %s FlexCards to migrate",
53+
"foundOmniScriptsToMigrate": "Found %s OmniScripts and Integration Procedures to migrate",
54+
"allVersionsInfo": "allVersions : %s",
55+
"migrationInitialization": "Migration Initialization: Using namespace: %s",
56+
"apiVersionInfo": "API Version: %s",
57+
"migrationTargets": "Migration targets: %s",
58+
"relatedObjectsInfo": "Related objects: %s",
59+
"allVersionsFlagInfo": "All versions: %s",
60+
"startingApexMigration": "Starting Apex migration in project path: %s",
61+
"processingApexFilesForMigration": "Processing Apex files for migration",
62+
"successfullyProcessedApexFilesForMigration": "Successfully processed %s Apex files for migration",
63+
"apexMigrationResults": "Apex migration results: %s",
64+
"startingLwcMigration": "Starting LWC migration in project path: %s",
65+
"processingLwcsForMigration": "Processing LWCs for migration",
66+
"successfullyProcessedLwcsForMigration": "Successfully processed %s LWCs for migration",
67+
"lwcMigrationResults": "LWC migration results: %s",
68+
"inApexDrNameWillBeUpdatedMigration": "In Apex %s DR name %s will be updated to %s",
69+
"retrievingMetadata": "Retrieving metadata for %s in project path: %s",
70+
"creatingProject": "Creating project %s",
71+
"projectCreated": "Project %s created",
72+
"metadataRetrieved": "Metadata %s retrieved from %s",
73+
"deployingMetadata": "Deploying metadata %s to %s",
74+
"metadataDeployed": "Metadata %s deployed to %s",
75+
"sfProjectCommandError": "Error executing command: %s"
76+
}

src/commands/omnistudio/migration/assess.ts

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,35 +42,43 @@ export default class Assess extends OmniStudioBaseCommand {
4242
char: 'r',
4343
description: messages.getMessage('apexLwc'),
4444
}),
45+
verbose: flags.builtin({
46+
type: 'builtin',
47+
description: 'Enable verbose output',
48+
}),
4549
};
4650

4751
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4852
public async run(): Promise<any> {
4953
DebugTimer.getInstance().start();
50-
const apiVersion = (this.flags.apiversion || '55.0') as string;
54+
let apiVersion = this.flags.apiversion as string;
5155
const allVersions = (this.flags.allversions || false) as boolean;
5256
const assessOnly = (this.flags.only || '') as string;
5357
const relatedObjects = (this.flags.relatedobjects || '') as string;
5458
const conn = this.org.getConnection();
59+
Logger.initialiseLogger(this.ux, this.logger, 'assess', this.flags.verbose);
60+
61+
if (apiVersion) {
62+
conn.setApiVersion(apiVersion);
63+
} else {
64+
apiVersion = conn.getApiVersion();
65+
}
5566
const orgs: OmnistudioOrgDetails = await OrgUtils.getOrgDetails(conn, this.flags.namespace);
5667

5768
if (!orgs.hasValidNamespace) {
58-
this.ux.warn(messages.getMessage('invalidNamespace') + orgs.packageDetails.namespace);
69+
Logger.warn(messages.getMessage('invalidNamespace') + orgs.packageDetails.namespace);
5970
}
6071

6172
if (!orgs.packageDetails) {
62-
this.ux.error(messages.getMessage('noPackageInstalled'));
73+
Logger.error(messages.getMessage('noPackageInstalled'));
6374
return;
6475
}
65-
6676
if (orgs.omniStudioOrgPermissionEnabled) {
67-
this.ux.error(messages.getMessage('alreadyStandardModel'));
77+
Logger.error(messages.getMessage('alreadyStandardModel'));
6878
return;
6979
}
7080

7181
const namespace = orgs.packageDetails.namespace;
72-
Logger.initialiseLogger(this.ux, this.logger);
73-
conn.setApiVersion(apiVersion);
7482

7583
const assesmentInfo: AssessmentInfo = {
7684
lwcAssessmentInfos: [],
@@ -83,6 +91,11 @@ export default class Assess extends OmniStudioBaseCommand {
8391
},
8492
};
8593

94+
Logger.log(messages.getMessage('assessmentInitialization', [String(namespace)]));
95+
Logger.logVerbose(messages.getMessage('apiVersionInfo', [String(apiVersion)]));
96+
Logger.logVerbose(messages.getMessage('assessmentTargets', [String(this.flags.only || 'all')]));
97+
Logger.logVerbose(messages.getMessage('relatedObjectsInfo', [relatedObjects || 'none']));
98+
Logger.logVerbose(messages.getMessage('allVersionsFlagInfo', [String(allVersions)]));
8699
// Assess OmniStudio components
87100
await this.assessOmniStudioComponents(assesmentInfo, assessOnly, namespace, conn, allVersions);
88101

@@ -95,7 +108,7 @@ export default class Assess extends OmniStudioBaseCommand {
95108
// Validate input
96109
for (const obj of objectsToProcess) {
97110
if (!validOptions.includes(obj)) {
98-
Logger.logger.warn(`Invalid option provided for -r: ${obj}. Valid options are apex, lwc.`);
111+
Logger.warn(messages.getMessage('invalidRelatedObjectsOption', [String(obj)]));
99112
}
100113
}
101114

@@ -125,8 +138,6 @@ export default class Assess extends OmniStudioBaseCommand {
125138
conn: Connection,
126139
allVersions: boolean
127140
): Promise<void> {
128-
this.logger.info(namespace);
129-
this.ux.log(`Using Namespace: ${namespace}`);
130141
if (!assessOnly) {
131142
// If no specific component is specified, assess all components
132143
await this.assessDataRaptors(assesmentInfo, namespace, conn);
@@ -154,12 +165,12 @@ export default class Assess extends OmniStudioBaseCommand {
154165
}
155166

156167
private async assessDataRaptors(assesmentInfo: AssessmentInfo, namespace: string, conn: Connection): Promise<void> {
157-
const drMigrator = new DataRaptorMigrationTool(namespace, conn, this.logger, messages, this.ux);
168+
const drMigrator = new DataRaptorMigrationTool(namespace, conn, Logger, messages, this.ux);
158169
assesmentInfo.dataRaptorAssessmentInfos = await drMigrator.assess();
159-
if (assesmentInfo.dataRaptorAssessmentInfos) {
160-
this.ux.log('dataRaptorAssessmentInfos');
161-
this.ux.log(assesmentInfo.dataRaptorAssessmentInfos.toString());
162-
}
170+
Logger.logVerbose(
171+
messages.getMessage('assessedDataRaptorsCount', [assesmentInfo.dataRaptorAssessmentInfos.length])
172+
);
173+
Logger.log(messages.getMessage('dataRaptorAssessmentCompleted'));
163174
}
164175

165176
private async assessFlexCards(
@@ -168,8 +179,11 @@ export default class Assess extends OmniStudioBaseCommand {
168179
conn: Connection,
169180
allVersions: boolean
170181
): Promise<void> {
171-
const flexMigrator = new CardMigrationTool(namespace, conn, this.logger, messages, this.ux, allVersions);
182+
const flexMigrator = new CardMigrationTool(namespace, conn, Logger, messages, this.ux, allVersions);
183+
Logger.logVerbose(messages.getMessage('flexCardAssessment'));
172184
assesmentInfo.flexCardAssessmentInfos = await flexMigrator.assess();
185+
Logger.logVerbose(messages.getMessage('assessedFlexCardsCount', [assesmentInfo.flexCardAssessmentInfos.length]));
186+
Logger.log(messages.getMessage('flexCardAssessmentCompleted'));
173187
}
174188

175189
private async assessOmniScripts(
@@ -179,18 +193,20 @@ export default class Assess extends OmniStudioBaseCommand {
179193
allVersions: boolean,
180194
exportType: OmniScriptExportType
181195
): Promise<void> {
182-
const osMigrator = new OmniScriptMigrationTool(
183-
exportType,
184-
namespace,
185-
conn,
186-
this.logger,
187-
messages,
188-
this.ux,
189-
allVersions
190-
);
196+
Logger.logVerbose(messages.getMessage('omniScriptAssessment'));
197+
const osMigrator = new OmniScriptMigrationTool(exportType, namespace, conn, Logger, messages, this.ux, allVersions);
191198
assesmentInfo.omniAssessmentInfo = await osMigrator.assess(
192199
assesmentInfo.dataRaptorAssessmentInfos,
193200
assesmentInfo.flexCardAssessmentInfos
194201
);
202+
Logger.logVerbose(
203+
messages.getMessage('assessedOmniScriptsCount', [assesmentInfo.omniAssessmentInfo.osAssessmentInfos.length])
204+
);
205+
Logger.logVerbose(
206+
messages.getMessage('assessedIntegrationProceduresCount', [
207+
assesmentInfo.omniAssessmentInfo.ipAssessmentInfos.length,
208+
])
209+
);
210+
Logger.log(messages.getMessage('omniScriptAssessmentCompleted'));
195211
}
196212
}

src/commands/omnistudio/migration/info.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as os from 'os';
88
import { flags, SfdxCommand } from '@salesforce/command';
99
import { Messages, SfdxError } from '@salesforce/core';
1010
import { AnyJson } from '@salesforce/ts-types';
11+
import { Logger } from '../../../utils/logger';
1112

1213
// Initialize Messages with the current plugin directory
1314
Messages.importMessagesDirectory(__dirname);
@@ -34,6 +35,10 @@ export default class Org extends SfdxCommand {
3435
description: messages.getMessage('allVersionsDescription'),
3536
required: false,
3637
}),
38+
verbose: flags.builtin({
39+
type: 'builtin',
40+
description: 'Enable verbose output',
41+
}),
3742
};
3843

3944
// Comment this out if your command does not require an org username
@@ -73,21 +78,23 @@ export default class Org extends SfdxCommand {
7378
const orgName = result.records[0].Name;
7479
const trialExpirationDate = result.records[0].TrialExpirationDate;
7580

76-
let outputString = `Hello ${name}! This is org: ${orgName}`;
81+
let outputString = '';
7782
if (trialExpirationDate) {
7883
const date = new Date(trialExpirationDate).toDateString();
79-
outputString = `${outputString} and I will be around until ${date}!`;
84+
outputString = messages.getMessage('greetingOrgInfoWithDate', [name, orgName, date]);
85+
} else {
86+
outputString = messages.getMessage('greetingOrgInfo', [name, orgName]);
8087
}
81-
this.ux.log(outputString);
88+
Logger.log(outputString);
8289

8390
// this.hubOrg is NOT guaranteed because supportsHubOrgUsername=true, as opposed to requiresHubOrgUsername.
8491
if (this.hubOrg) {
8592
const hubOrgId = this.hubOrg.getOrgId();
86-
this.ux.log(`My hub org id is: ${hubOrgId}`);
93+
Logger.log(messages.getMessage('hubOrgId', [hubOrgId]));
8794
}
8895

8996
if (allVersions) {
90-
outputString = `${outputString} and all versions will be migrated`;
97+
outputString = outputString + messages.getMessage('allVersionsAppended');
9198
}
9299

93100
// Return an object to be displayed with --json

0 commit comments

Comments
 (0)