Skip to content

Commit fa17b29

Browse files
committed
Merge branch 'prerelease/develop-ga' into auto-deploy
2 parents 7def135 + 13fa275 commit fa17b29

File tree

19 files changed

+493
-292
lines changed

19 files changed

+493
-292
lines changed

messages/assess.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"foundApexFilesInDirectory": "Found %s Apex files in directory: %s",
7979
"skippingNonApexFile": "Skipping non-Apex file: %s",
8080
"processingApexFile": "Processing Apex file: %s",
81-
"skippingApexFileFewChanges": "Skipping Apex file: %s as it has less than 3 changes",
81+
"skippingApexFileNoChanges": "Skipping Apex file: %s as it has no changes",
8282
"successfullyProcessedApexFile": "Successfully processed Apex file: %s",
8383
"fileNoOmnistudioCalls": "File %s does not have any omnistudio calls or remote calls. No changes will be applied.",
8484
"fileAlreadyImplementsCallable": "file %s already implements callable no changes will be applied",
@@ -183,5 +183,6 @@
183183
"missingInfo": "Info is missing",
184184
"errorCheckingGlobalAutoNumber": "We couldn’t check whether the Global Auto Number setting is enabled: %s. Try again later.",
185185
"errorMigrationMessage": "Error migrating object: %s",
186-
"nameMappingUndefined": "Name Mapping is undefined"
186+
"nameMappingUndefined": "Name Mapping is undefined",
187+
"experienceSiteException": "Exception occurred while processing experience sites"
187188
}

messages/migrate.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@
195195
"flexcardStorageProcessingStarted": "Started preparing storage for flexcards",
196196
"errorWhileProcessingFlexcardStorage": "Error occurred while processing key for flexcard storage",
197197
"missingInfo": "Info is missing",
198-
"incompleteMigrationDetected": "We couldn’t complete the migration process",
199198
"errorCheckingGlobalAutoNumber": "We couldn’t check whether the Global Auto Number setting is enabled: %s. Try again later.",
200199
"errorMigrationMessage": "Error migrating object: %s",
201200
"nameMappingUndefined": "Name Mapping is undefined",
@@ -208,5 +207,6 @@
208207
"installingRequiredDependencies": "Installing required node dependencies",
209208
"creatingNPMConfigFile": "Creating npm config file",
210209
"npmConfigFileCreated": "Npm config file created",
211-
"authKeyEnvVarNotSet": "OMA_AUTH_KEY environment variable is not set, LWCs will not be deployed"
210+
"authKeyEnvVarNotSet": "OMA_AUTH_KEY environment variable is not set, LWCs will not be deployed",
211+
"experienceSiteException": "Exception occurred while processing experience sites"
212212
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@salesforce/plugin-omnistudio-migration-tool",
33
"description": "This SFDX plugin migrates FlexCard, OmniScript, DataRaptor, and Integration Procedure custom objects to standard objects.",
4-
"version": "2.0.0-rc.8",
4+
"version": "2.0.0-rc.10",
55
"author": "Salesforce",
66
"bugs": "https://github.com/forcedotcom/cli/issues",
77
"dependencies": {

src/commands/omnistudio/migration/assess.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export default class Assess extends OmniStudioBaseCommand {
7575
const conn = this.org.getConnection();
7676
let objectsToProcess: string[];
7777
// To-Do: Add LWC to valid options when GA is released
78-
const validOptions = [Constants.Apex, Constants.ExpSites, Constants.FlexiPage];
78+
const validOptions = [Constants.Apex, Constants.ExpSites, Constants.FlexiPage, Constants.LWC];
7979
if (apiVersion) {
8080
conn.setApiVersion(apiVersion);
8181
} else {
@@ -98,7 +98,7 @@ export default class Assess extends OmniStudioBaseCommand {
9898

9999
const namespace = orgs.packageDetails.namespace;
100100
let projectPath = '';
101-
const preMigrate: PreMigrate = new PreMigrate(this.org, namespace, conn, this.logger, messages, this.ux);
101+
const preMigrate: PreMigrate = new PreMigrate(namespace, conn, this.logger, messages, this.ux);
102102
if (relatedObjects) {
103103
objectsToProcess = relatedObjects.split(',').map((obj) => obj.trim());
104104
projectPath = await ProjectPathUtil.getProjectPath(messages, true);
@@ -140,6 +140,8 @@ export default class Assess extends OmniStudioBaseCommand {
140140

141141
// Assess related objects if specified
142142
if (relatedObjects) {
143+
objectsToProcess = relatedObjects.split(',').map((obj) => obj.trim());
144+
143145
// Validate input
144146
for (const obj of objectsToProcess) {
145147
if (!validOptions.includes(obj)) {

src/commands/omnistudio/migration/migrate.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export default class Migrate extends OmniStudioBaseCommand {
134134
let projectPath: string;
135135
let objectsToProcess: string[] = [];
136136
let targetApexNamespace: string;
137-
const preMigrate: PreMigrate = new PreMigrate(this.org, namespace, conn, this.logger, messages, this.ux);
137+
const preMigrate: PreMigrate = new PreMigrate(namespace, conn, this.logger, messages, this.ux);
138138
const isExperienceBundleMetadataAPIProgramaticallyEnabled: { value: boolean } = { value: false };
139139

140140
let deploymentConfig = { autoDeploy: false, authKey: undefined };
@@ -249,7 +249,7 @@ export default class Migrate extends OmniStudioBaseCommand {
249249
targetApexNamespace: string;
250250
deploymentConfig: { autoDeploy: boolean; authKey: string | undefined };
251251
}> {
252-
const validOptions = [Constants.Apex, Constants.ExpSites, Constants.FlexiPage];
252+
const validOptions = [Constants.Apex, Constants.ExpSites, Constants.FlexiPage, Constants.LWC];
253253
const objectsToProcess = relatedObjects.split(',').map((obj) => obj.trim());
254254
// Validate input
255255
for (const obj of objectsToProcess) {
@@ -532,11 +532,13 @@ export default class Migrate extends OmniStudioBaseCommand {
532532
let errors: any[] = obj.errors || [];
533533
errors = errors.concat(recordResults.errors || []);
534534

535-
obj.status = recordResults?.skipped
536-
? messages.getMessage('labelStatusSkipped')
537-
: !recordResults || recordResults.hasErrors
538-
? messages.getMessage('labelStatusFailed')
539-
: messages.getMessage('labelStatusComplete');
535+
if (recordResults?.skipped) {
536+
obj.status = messages.getMessage('labelStatusSkipped');
537+
} else if (!recordResults || recordResults.hasErrors) {
538+
obj.status = messages.getMessage('labelStatusFailed');
539+
} else {
540+
obj.status = messages.getMessage('labelStatusComplete');
541+
}
540542
obj.errors = errors;
541543
obj.migratedId = recordResults.id;
542544
obj.warnings = recordResults.warnings;

src/migration/base.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import { Logger } from '../utils/logger';
88
import { TransformData, UploadRecordResult } from './interfaces';
99

1010
export type ComponentType = 'Data Mapper' | 'Flexcard' | 'Omniscript and Integration Procedure' | 'GlobalAutoNumber';
11-
12-
export type RelatedObjectType = 'Flexipage' | 'ExperienceSites';
11+
export type RelatedObjectType = 'Flexipage' | 'ExperienceSites' | 'Lightning Web Components' | 'Apex Classes';
1312

1413
/**
1514
* Creates a progress bar for migration/assessment operations

src/migration/flexcard.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
113113
const flexCards = await this.getAllActiveCards();
114114
Logger.log(this.messages.getMessage('foundFlexCardsToAssess', [flexCards.length]));
115115

116-
const flexCardsAssessmentInfos = this.processCardComponents(flexCards);
116+
const flexCardsAssessmentInfos = await this.processCardComponents(flexCards);
117+
this.prepareAssessmentStorageForFlexcards(flexCardsAssessmentInfos);
117118
return flexCardsAssessmentInfos;
118119
} catch (err) {
119120
if (err instanceof InvalidEntityTypeError) {
@@ -135,9 +136,6 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
135136
try {
136137
const flexCardAssessmentInfo = await this.processFlexCard(flexCard, uniqueNames);
137138
flexCardAssessmentInfos.push(flexCardAssessmentInfo);
138-
139-
// Prepare assessment storage for flexcards
140-
this.prepareAssessmentStorageForFlexcards(flexCardAssessmentInfos);
141139
} catch (e) {
142140
flexCardAssessmentInfos.push({
143141
name: flexCard['Name'],
@@ -638,7 +636,7 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
638636
flexCardAssessmentInfo.nameMapping === undefined ||
639637
flexCardAssessmentInfo.nameMapping === null
640638
) {
641-
Logger.logVerbose(this.messages.getMessage('missingInfo'));
639+
Logger.error(this.messages.getMessage('missingInfo'));
642640
return;
643641
}
644642

@@ -647,8 +645,8 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
647645
isDuplicate: false,
648646
};
649647

650-
if (flexCardAssessmentInfo.warnings) {
651-
value.error = flexCardAssessmentInfo.warnings;
648+
if (flexCardAssessmentInfo.errors && flexCardAssessmentInfo.errors.length > 0) {
649+
value.error = flexCardAssessmentInfo.errors;
652650
value.migrationSuccess = false;
653651
} else {
654652
value.migrationSuccess = true;
@@ -668,9 +666,8 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
668666
Logger.logVerbose(this.messages.getMessage('errorWhileProcessingFlexcardStorage'));
669667
Logger.error(error);
670668
}
671-
672-
StorageUtil.printMigrationStorage();
673669
}
670+
StorageUtil.printAssessmentStorage();
674671
}
675672

676673
private prepareStorageForFlexcards(
@@ -692,13 +689,13 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
692689

693690
if (newrecord === undefined) {
694691
value.error = ['Migration Failed'];
695-
}
696-
697-
if (newrecord.hasErrors) {
698-
value.error = newrecord.errors;
699-
value.migrationSuccess = false;
700692
} else {
701-
value.migrationSuccess = true;
693+
if (newrecord.hasErrors) {
694+
value.error = newrecord.errors;
695+
value.migrationSuccess = false;
696+
} else {
697+
value.migrationSuccess = true;
698+
}
702699
}
703700

704701
let finalKey = `${oldrecord['Name']}`;

src/migration/omniscript.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
537537

538538
private updateStorageForOmniscriptAssessment(osAssessmentInfo: OSAssessmentInfo[]): void {
539539
if (osAssessmentInfo === undefined || osAssessmentInfo === null) {
540+
Logger.error(this.messages.getMessage('missingInfo'));
540541
return;
541542
}
542543

@@ -559,7 +560,7 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
559560
isDuplicate: false,
560561
};
561562

562-
if (Array.isArray(currentOsRecordInfo.errors) && currentOsRecordInfo.errors.length > 0) {
563+
if (currentOsRecordInfo.errors && currentOsRecordInfo.errors.length > 0) {
563564
value.error = currentOsRecordInfo.errors;
564565
value.migrationSuccess = false;
565566
} else {
@@ -579,7 +580,7 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
579580
storage.osStorage.set(finalKey, value);
580581
}
581582
} catch (error) {
582-
Logger.logVerbose(error);
583+
Logger.error(error);
583584
}
584585
}
585586

@@ -905,11 +906,16 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
905906
isDuplicate: false,
906907
};
907908

908-
if (newrecord.hasErrors) {
909-
value.error = newrecord.errors;
909+
// New record can be undefined
910+
if (newrecord === undefined) {
910911
value.migrationSuccess = false;
911912
} else {
912-
value.migrationSuccess = true;
913+
if (newrecord.hasErrors) {
914+
value.error = newrecord.errors;
915+
value.migrationSuccess = false;
916+
} else {
917+
value.migrationSuccess = true;
918+
}
913919
}
914920

915921
let finalKey = `${oldrecord[this.namespacePrefix + 'Type__c']}${

src/migration/premigrate.ts

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,16 @@
1-
/* eslint-disable */
2-
3-
import { Connection, Messages, Org } from '@salesforce/core';
1+
import { Connection, Messages } from '@salesforce/core';
42
import { UX } from '@salesforce/command';
53
import { Logger } from '../utils/logger';
64
import { Constants } from '../utils/constants/stringContants';
75
import { OrgPreferences } from '../utils/orgPreferences';
8-
import { BaseMigrationTool } from './base';
96
import { askStringWithTimeout } from '../utils/promptUtil';
7+
import { YES_SHORT, YES_LONG, NO_SHORT, NO_LONG } from '../utils/projectPathUtil';
8+
import { BaseMigrationTool } from './base';
109

1110
export class PreMigrate extends BaseMigrationTool {
12-
private readonly org: Org;
13-
1411
// Source Custom Object Names
15-
constructor(org: Org, namespace: string, connection: Connection, logger: Logger, messages: Messages, ux: UX) {
12+
public constructor(namespace: string, connection: Connection, logger: Logger, messages: Messages, ux: UX) {
1613
super(namespace, connection, logger, messages, ux);
17-
this.org = org;
18-
}
19-
20-
// Just to disable org is unused error coming
21-
public printOrgDetails(): void {
22-
try {
23-
Logger.log(JSON.stringify(this.org));
24-
} catch (e) {
25-
Logger.log(e);
26-
}
2714
}
2815

2916
public async handleExperienceSitePrerequisites(
@@ -67,8 +54,9 @@ export class PreMigrate extends BaseMigrationTool {
6754
// This needs to be behind timeout
6855
private async getExpSiteMetadataEnableConsent(): Promise<boolean> {
6956
const question = this.messages.getMessage('consentForExperienceSites');
57+
const validResponse = false;
7058

71-
while (true) {
59+
while (!validResponse) {
7260
try {
7361
// Get string input from user with timeout
7462
const userInput = await askStringWithTimeout(
@@ -80,19 +68,18 @@ export class PreMigrate extends BaseMigrationTool {
8068
// Validate and convert the input
8169
const normalizedInput = userInput.trim().toLowerCase();
8270

83-
if (normalizedInput === 'y' || normalizedInput === 'yes') {
71+
if (normalizedInput === YES_SHORT || normalizedInput === YES_LONG) {
8472
return true;
85-
} else if (normalizedInput === 'n' || normalizedInput === 'no') {
73+
} else if (normalizedInput === NO_SHORT || normalizedInput === NO_LONG) {
8674
return false;
8775
} else {
8876
// Invalid input - show error and continue loop to re-prompt
8977
Logger.error(this.messages.getMessage('invalidYesNoResponse'));
90-
Logger.log('Please enter "y" or "yes" to consent, "n" or "no" to decline.');
9178
}
9279
} catch (error) {
9380
// Handle timeout or other errors
94-
Logger.error(this.messages.getMessage('failedToGetConsentError', [error.message]));
95-
throw error; // Re-throw to let caller handle timeout
81+
Logger.error(this.messages.getMessage('requestTimedOut'));
82+
process.exit(1);
9683
}
9784
}
9885
}

0 commit comments

Comments
 (0)