Skip to content

Commit

Permalink
fix: messages
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhinavKumar-sf committed Dec 23, 2024
1 parent e87fb60 commit ac5ea68
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ sfdx plugins:install @salesforce/plugin-omnistudio-migration-tool
// To migrate everything
sfdx omnistudio:migration:migrate -u [email protected] --namespace=VLOCITY_PACKAGE_NAMESPACE
//to migrate specific components: FlexCards, DataRaptors, Integration Procedures, or OmniScripts, add the following parameters:
//to migrate specific components: FlexCards, DataMappers, Integration Procedures, or OmniScripts, add the following parameters:
--only=dr
--only=ip
--only=os
Expand Down
8 changes: 4 additions & 4 deletions messages/assess.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
"omnistudio:migration:assess -u [email protected] --namespace=YOUR_PACKAGE_NAMESPACE --only=os",
"omnistudio:migration:assess -u [email protected] --namespace=YOUR_PACKAGE_NAMESPACE --only=fc"
],
"commandDescription": "print a greeting and your org IDs",
"commandDescription": "Assess migration of omnistudio components from custom objects to standard objects",
"namespaceFlagDescription": "The namespaced of the package",
"apiVersionFlagDescription": "The Salesforce API version to use",
"errorNoOrgResults": "No results found for the org '%s'.",
"onlyFlagDescription": "Migrate a single element: osip | fc | dr",
"invalidOnlyFlag": "Invalid flag, valid options are: osip | fc | dr",
"onlyFlagDescription": "Migrate a single element: os | ip | fc | dr",
"invalidOnlyFlag": "Invalid flag, valid options are: os | ip | fc | dr",
"couldNotDeactivateOmniProcesses": "Could not deactivate current OmniProcesses",
"couldNotTruncate": "Could not truncate {0}",
"couldNotTruncateOmnniProcess": "Could not truncate OmniProcess. Please make sure your OS/IP is not referenced in an OmniScrirpt or Flex Card.",
"invalidNameTypeSubtypeOrLanguage": "Not a valid Name, Type, SubType or Language",
"invalidOrRepeatingOmniscriptElementNames": "Invalid or Repeating Element Names for Same OmniScript",
"invalidDataRaptorName": "Invalid name, can not have special characters",
"duplicatedCardName": "Duplicated Flex Card name",
"duplicatedDrName": "Duplicated DataRaptor name",
"duplicatedDrName": "Duplicated DataMapper name",
"duplicatedOSName": "Duplicated OmniScript name",
"duplicatedName": "Duplicated name",
"errorWhileActivatingOs": "Could not activate OmniScript / Integration Procedure: ",
Expand Down
10 changes: 5 additions & 5 deletions messages/migrate.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
"omnistudio:migration:migrate -u [email protected] --namespace=YOUR_PACKAGE_NAMESPACE -r apex",
"omnistudio:migration:migrate -u [email protected] --namespace=YOUR_PACKAGE_NAMESPACE -r lwc"
],
"commandDescription": "print a greeting and your org IDs",
"namespaceFlagDescription": "The namespaced of the package",
"commandDescription": "Migrate omnistudio components from custom objects to standard objects",
"namespaceFlagDescription": "The namespace of the package",
"apiVersionFlagDescription": "The Salesforce API version to use",
"errorNoOrgResults": "No results found for the org '%s'.",
"onlyFlagDescription": "Migrate a single element: osip | fc | dr",
"invalidOnlyFlag": "Invalid flag, valid options are: osip | fc | dr",
"onlyFlagDescription": "Migrate a single element: os | ip | fc | dr",
"invalidOnlyFlag": "Invalid flag, valid options are: os | ip | fc | dr",
"couldNotDeactivateOmniProcesses": "Could not deactivate current OmniProcesses",
"couldNotTruncate": "Could not truncate {0}",
"couldNotTruncateOmnniProcess": "Could not truncate OmniProcess. Please make sure your OS/IP is not referenced in an OmniScrirpt or Flex Card.",
"invalidNameTypeSubtypeOrLanguage": "Not a valid Name, Type, SubType or Language",
"invalidOrRepeatingOmniscriptElementNames": "Invalid or Repeating Element Names for Same OmniScript",
"invalidDataRaptorName": "Invalid name, can not have special characters",
"duplicatedCardName": "Duplicated Flex Card name",
"duplicatedDrName": "Duplicated DataRaptor name",
"duplicatedDrName": "Duplicated DataMapper name",
"duplicatedOSName": "Duplicated OmniScript name",
"errorWhileActivatingOs": "Could not activate OmniScript / Integration Procedure: ",
"errorWhileActivatingCard": "Could not activate Card: ",
Expand Down
3 changes: 2 additions & 1 deletion src/commands/omnistudio/migration/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export default class Migrate extends OmniStudioBaseCommand {
Logger.ux.log('Cleaning: ' + cls.getName());
debugTimer.lap('Cleaning: ' + cls.getName());
await cls.truncate();
Logger.ux.log('Cleaning Done: ' + cls.getName());
} catch (ex: any) {
allTruncateComplete = false;
objectMigrationResults.push({
Expand All @@ -126,7 +127,7 @@ export default class Migrate extends OmniStudioBaseCommand {
this.ux.log('Migrating: ' + cls.getName());
debugTimer.lap('Migrating: ' + cls.getName());
const results = await cls.migrate();

this.ux.log('Migration completed: ' + cls.getName());
objectMigrationResults = objectMigrationResults.concat(
results.map((r) => {
return {
Expand Down
4 changes: 2 additions & 2 deletions src/migration/dataraptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class DataRaptorMigrationTool extends BaseMigrationTool implements Migrat
static readonly OMNIDATATRANSFORMITEM_NAME = 'OmniDataTransformItem';

getName(): string {
return 'DataRaptor';
return 'DataMappers';
}

getRecordName(record: string) {
Expand Down Expand Up @@ -183,7 +183,7 @@ export class DataRaptorMigrationTool extends BaseMigrationTool implements Migrat
}

return {
name: 'Data Raptor',
name: 'Data Mapper',
results: drUploadInfo,
records: originalDrRecords,
};
Expand Down
2 changes: 2 additions & 0 deletions src/migration/related/ApexMigration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ export class ApexMigration extends BaseRelatedObjectMigration {
shell.cd(this.projectPath);
// const targetOrg: Org = this.org;
// sfProject.retrieve(APEXCLASS, targetOrg.getUsername());
Logger.logger.info('Processing Apex ');
const apexAssessmentInfos = this.processApexFiles(this.projectPath);
Logger.logger.info('Apex processed for migration ');
// sfProject.deploy(APEXCLASS, targetOrg.getUsername());
shell.cd(pwd);
return apexAssessmentInfos;
Expand Down
2 changes: 2 additions & 0 deletions src/migration/related/LwcMigration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ export class LwcMigration extends BaseRelatedObjectMigration {
shell.cd(this.projectPath);
// const targetOrg: Org = this.org;
// sfProject.retrieve(LWCTYPE, targetOrg.getUsername());
Logger.logger.info('Processing LWCs for migration ');
const filesMap = this.processLwcFiles(this.projectPath);
const LWCAssessmentInfos = this.processFiles(filesMap, 'migration');
Logger.logger.info(' LWCs processed for migration ');
// sfProject.deploy(LWCTYPE, targetOrg.getUsername());
shell.cd(pwd);
return LWCAssessmentInfos;
Expand Down
9 changes: 5 additions & 4 deletions src/utils/file/fileutil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/* eslint-disable no-console */
import * as fs from 'fs';
import * as path from 'path';
import { Logger } from '../logger';

export class fileutil {
public static readFilesSync(dir: string): File[] {
Expand Down Expand Up @@ -67,7 +68,7 @@ export class fileutil {
public static saveToFile(outputFilePath: string, modifiedHtml: string): void {
try {
fs.writeFileSync(outputFilePath, modifiedHtml);
console.log(`Modified HTML saved to ${outputFilePath}`);
Logger.logger.info(`Modified HTML saved to ${outputFilePath}`);
} catch (error) {
console.error(`Error writing file to disk: ${error}`);
throw error;
Expand All @@ -85,14 +86,14 @@ export class fileutil {
});

for (const subDirectory of subDirectories) {
console.log(`Processing subdirectory: ${subDirectory}`);
Logger.logger.info(`Processing subdirectory: ${subDirectory}`);
const subDirPath = path.join(baseDir, subDirectory);

// Check the XML file for the substring
const xmlFilePath = path.join(subDirPath, `${subDirectory}.js-meta.xml`);
if (fs.existsSync(xmlFilePath)) {
if (this.doesSubstringExist(xmlFilePath, searchString)) {
console.log(`Substring found in ${xmlFilePath}. Skipping all files in ${subDirectory}.`);
Logger.logger.info(`Substring found in ${xmlFilePath}. Skipping all files in ${subDirectory}.`);
continue; // Move to the next subdirectory
}
}
Expand All @@ -104,7 +105,7 @@ export class fileutil {
.filter((file) => file.endsWith('.html') || file.endsWith('.js') || file.endsWith('.xml'));
files.forEach((file) => {
const filePath = path.join(subDirPath, file);
console.log(`Processing file: ${filePath}`);
Logger.logger.info(`Processing file: ${filePath}`);
const name = path.parse(file).name;
const ext = path.parse(file).ext;
const filepath = path.resolve(subDirPath, file);
Expand Down
5 changes: 3 additions & 2 deletions src/utils/lwcparser/htmlParser/HTMLParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
/* eslint-disable no-console */
import * as fs from 'fs';
import { FileConstant } from '../fileutils/FileConstant';
import { Logger } from '../../logger';

const DEFAULT_NAMESPACE = 'c';

Expand Down Expand Up @@ -46,9 +47,9 @@ export class HTMLParser {
public saveToFile(outputFilePath: string, modifiedHtml: string): void {
try {
fs.writeFileSync(outputFilePath, modifiedHtml);
console.log(`Modified HTML saved to ${outputFilePath}`);
Logger.logger.info(`Modified HTML saved to ${outputFilePath}`);
} catch (error) {
console.error(`Error writing file to disk: ${error}`);
Logger.logger.error(`Error writing file to disk: ${error}`);
throw error;
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/utils/lwcparser/jsParser/JavaScriptParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as fs from 'fs';
import { parse } from '@babel/parser';
import traverse from '@babel/traverse';
import { FileConstant } from '../fileutils/FileConstant';
import { Logger } from '../../logger';

const DEFAULT_NAMESPACE = 'c';

Expand Down Expand Up @@ -65,9 +66,9 @@ export class JavaScriptParser {
public saveToFile(filePath: string, output: string): void {
try {
fs.writeFileSync(filePath, output, 'utf-8');
console.log(`Replaced import in file: ${filePath}`);
Logger.logger.info(`Replaced import in file: ${filePath}`);
} catch (error) {
console.error(`Error writing file to disk: ${error}`);
Logger.logger.error(`Error writing file to disk: ${error}`);
throw error;
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/utils/lwcparser/xmlParser/XmlParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import * as fs from 'fs';
import { DOMParser, XMLSerializer } from 'xmldom';
import { FileConstant } from '../fileutils/FileConstant';
import { Logger } from '../../logger';

export class XmlParser {
private xmlDoc: Document | null = null;
Expand Down Expand Up @@ -55,9 +56,9 @@ export class XmlParser {
public saveToFile(outputFilePath: string, xmlString: string): void {
try {
fs.writeFileSync(outputFilePath, xmlString);
console.log(`Modified HTML saved to ${outputFilePath}`);
Logger.logger.info(`Modified HTML saved to ${outputFilePath}`);
} catch (error) {
console.error(`Error writing file to disk: ${error}`);
Logger.logger.error(`Error writing file to disk: ${error}`);
throw error;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/resultsbuilder/DRAssessmentReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class DRAssessmentReporter {
instanceUrl: string
): string {
let tableBody = '';
tableBody += '<div class="slds-text-heading_large">Data Raptor Components Assessment</div>';
tableBody += '<div class="slds-text-heading_large">Data Mapper Components Assessment</div>';
for (const dr of dataRaptorAssessmentInfos) {
const row = `
<tr class="slds-hint_parent">
Expand Down Expand Up @@ -38,7 +38,7 @@ export class DRAssessmentReporter {
private static getDRAssessmentReport(tableContent: string): string {
const tableBody = `
<div style="margin-block:15px">
<table style="width: 100%; table-layout: auto;" class="slds-table slds-table_cell-buffer slds-table_bordered slds-table_striped slds-table_col-bordered" aria-label="Results for Data Raptor updates">
<table style="width: 100%; table-layout: auto;" class="slds-table slds-table_cell-buffer slds-table_bordered slds-table_striped slds-table_col-bordered" aria-label="Results for Data Mapper updates">
<thead>
<tr class="slds-line-height_reset">
<th class="" scope="col" style="width: 20%; word-wrap: break-word; white-space: normal; text-align: left;">
Expand Down
2 changes: 1 addition & 1 deletion src/utils/resultsbuilder/IPAssessmentReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class IPAssessmentReporter {
<div title="Dependencies">Integration Procedures Dependencies</div>
</th>
<th class="" scope="col" style="width: 20%; word-wrap: break-word; white-space: normal; text-align: left;">
<div title="Dependencies">Data Raptor dependencies</div>
<div title="Dependencies">Data Mapper dependencies</div>
</th>
<th class="" scope="col" style="width: 20%; word-wrap: break-word; white-space: normal; text-align: left;">
<div title="Dependencies">Remote Action Dependencies</div>
Expand Down
2 changes: 1 addition & 1 deletion src/utils/resultsbuilder/OSAssessmentReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class OSAssesmentReporter {
<div title="Dependencies">Integration Procedures Dependencies</div>
</th>
<th class="" scope="col" style="width: 20%; word-wrap: break-word; white-space: normal; text-align: left;">
<div title="Dependencies">Data Raptor Dependencies</div>
<div title="Dependencies">Data Mapper Dependencies</div>
</th>
<th class="" scope="col" style="width: 20%; word-wrap: break-word; white-space: normal; text-align: left;">
<div title="Dependencies">Remote Action dependencies</div>
Expand Down
2 changes: 1 addition & 1 deletion src/utils/resultsbuilder/assessmentReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export class AssessmentReporter {
<div title="Dependencies">Integration Procedures Dependencies</div>
</th>
<th class="" scope="col" style="width: 20%; word-wrap: break-word; white-space: normal; text-align: left;">
<div title="Dependencies">Data Raptor Dependencies</div>
<div title="Dependencies">Data Mapper Dependencies</div>
</th>
</tr>
</thead>
Expand Down

0 comments on commit ac5ea68

Please sign in to comment.