Skip to content

Commit dd0cd30

Browse files
committed
fix: addressed comments
1 parent 2a5479f commit dd0cd30

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

src/commands/omnistudio/migration/migrate.ts

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import { Constants } from '../../../utils/constants/stringContants';
2626
import { OrgPreferences } from '../../../utils/orgPreferences';
2727
import { AnonymousApexRunner } from '../../../utils/apex/executor/AnonymousApexRunner';
2828
import { ProjectPathUtil } from '../../../utils/projectPathUtil';
29+
import { PromptUtil } from '../../../utils/promptUtil';
30+
import { YES_SHORT, YES_LONG, NO_SHORT, NO_LONG } from '../../../utils/projectPathUtil';
2931

3032
// Initialize Messages with the current plugin directory
3133
Messages.importMessagesDirectory(__dirname);
@@ -204,31 +206,27 @@ export default class Migrate extends OmniStudioBaseCommand {
204206
}
205207

206208
private async getMigrationConsent(): Promise<boolean> {
207-
const TIMEOUT_MS = 5 * 60 * 1000; // 5 minutes timeout
209+
const askWithTimeOut = PromptUtil.askWithTimeOut(messages);
210+
let validResponse = false;
211+
let consent = false;
208212

209-
let consent: boolean | null = null;
210-
let timeoutHandle: NodeJS.Timeout;
211-
212-
const timeoutPromise = new Promise<boolean>((_, reject) => {
213-
timeoutHandle = setTimeout(() => {
214-
reject(new Error(messages.getMessage('requestTimedOut')));
215-
}, TIMEOUT_MS);
216-
});
217-
218-
while (consent === null) {
213+
while (!validResponse) {
219214
try {
220-
// Race between the confirmation prompt and the timeout
221-
consent = await Promise.race([Logger.confirm(messages.getMessage('migrationConsentMessage')), timeoutPromise]);
222-
clearTimeout(timeoutHandle);
223-
} catch (error) {
224-
clearTimeout(timeoutHandle);
225-
if (error instanceof Error && error.message === messages.getMessage('requestTimedOut')) {
226-
Logger.log(messages.getMessage('requestTimedOut'));
227-
return false; // Return false on timeout
215+
const resp = await askWithTimeOut(Logger.prompt.bind(Logger), messages.getMessage('migrationConsentMessage'));
216+
const response = typeof resp === 'string' ? resp.trim().toLowerCase() : '';
217+
218+
if (response === YES_SHORT || response === YES_LONG) {
219+
consent = true;
220+
validResponse = true;
221+
} else if (response === NO_SHORT || response === NO_LONG) {
222+
consent = false;
223+
validResponse = true;
228224
} else {
229-
Logger.log(messages.getMessage('invalidYesNoResponse'));
230-
consent = null;
225+
Logger.error(messages.getMessage('invalidYesNoResponse'));
231226
}
227+
} catch (err) {
228+
Logger.error(messages.getMessage('requestTimedOut'));
229+
process.exit(1);
232230
}
233231
}
234232

@@ -415,7 +413,7 @@ export default class Migrate extends OmniStudioBaseCommand {
415413
let errors: any[] = obj.errors || [];
416414
errors = errors.concat(recordResults.errors || []);
417415

418-
obj.status = recordResults.skipped
416+
obj.status = recordResults?.skipped
419417
? messages.getMessage('labelStatusSkipped')
420418
: !recordResults || recordResults.hasErrors
421419
? messages.getMessage('labelStatusFailed')

src/migration/omniscript.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,12 +534,12 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
534534
if (omniProcessType === 'OmniScript') {
535535
const type = omniscript[this.namespacePrefix + 'IsLwcEnabled__c'] ? 'LWC' : 'Angular';
536536
if (type === 'Angular') {
537-
// Skip Angular OmniScripts and add a warning record this
537+
// Skip Angular OmniScripts and add a warning record
538538

539539
const skippedResponse: UploadRecordResult = {
540540
referenceId: recordId,
541541
id: '',
542-
success: true,
542+
success: false,
543543
hasErrors: false,
544544
errors: [],
545545
warnings: [angularWarningMessage],

0 commit comments

Comments
 (0)