From 7331fbd2fb6e1c89a1f63dd2491ba397375f1e47 Mon Sep 17 00:00:00 2001 From: Daphne Yang Date: Fri, 31 Jan 2025 11:16:51 -0500 Subject: [PATCH 1/2] feat: call Mulesoft ACD extension with command "mule-dx-api.open-api-project" and OAS document vscode URI when new OAS doc created --- .../src/commands/apexActionController.ts | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/packages/salesforcedx-vscode-apex/src/commands/apexActionController.ts b/packages/salesforcedx-vscode-apex/src/commands/apexActionController.ts index 1b8287f30a..444e822ce4 100644 --- a/packages/salesforcedx-vscode-apex/src/commands/apexActionController.ts +++ b/packages/salesforcedx-vscode-apex/src/commands/apexActionController.ts @@ -107,6 +107,23 @@ export class ApexActionController { ); } } + + // Step 8: Call Mulesoft extension if installed + if (await this.isCommandAvailable('mule-dx-api.open-api-project')) { + try { + const yamlUri = vscode.Uri.file(this.replaceXmlToYaml(fullPath[1])); + await vscode.commands.executeCommand('mule-dx-api.open-api-project', yamlUri); + console.log('mule-dx-api.open-api-project command executed successfully'); + } catch (error) { + telemetryService.sendEventData('mule-dx-api.open-api-project command could not be executed', { + error: error.message + }); + console.error('mule-dx-api.open-api-project command could not be executed', error); + } + } else { + telemetryService.sendEventData('mule-dx-api.open-api-project command not found'); + console.log('mule-dx-api.open-api-project command not found'); + } } ); @@ -503,4 +520,14 @@ export class ApexActionController { diffWindowName ); }; + + /** + * Checks if a VSCode command is available. + * @param commandId Command ID of the VSCode command to check + * @returns boolean - true if the command is available, false otherwise + */ + private isCommandAvailable = async (commandId: string): Promise => { + const commands = await vscode.commands.getCommands(true); + return commands.includes(commandId); + }; } From 5bb896878d0861ea3afa0fd850eff42998060952 Mon Sep 17 00:00:00 2001 From: Daphne Yang Date: Fri, 31 Jan 2025 13:35:05 -0500 Subject: [PATCH 2/2] fix: address code review comments --- .../src/commands/apexActionController.ts | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/packages/salesforcedx-vscode-apex/src/commands/apexActionController.ts b/packages/salesforcedx-vscode-apex/src/commands/apexActionController.ts index 444e822ce4..263f866972 100644 --- a/packages/salesforcedx-vscode-apex/src/commands/apexActionController.ts +++ b/packages/salesforcedx-vscode-apex/src/commands/apexActionController.ts @@ -109,21 +109,22 @@ export class ApexActionController { } // Step 8: Call Mulesoft extension if installed - if (await this.isCommandAvailable('mule-dx-api.open-api-project')) { - try { - const yamlUri = vscode.Uri.file(this.replaceXmlToYaml(fullPath[1])); - await vscode.commands.executeCommand('mule-dx-api.open-api-project', yamlUri); - console.log('mule-dx-api.open-api-project command executed successfully'); - } catch (error) { - telemetryService.sendEventData('mule-dx-api.open-api-project command could not be executed', { - error: error.message - }); - console.error('mule-dx-api.open-api-project command could not be executed', error); + const callMulesoftExtension = async () => { + if (await this.isCommandAvailable('mule-dx-api.open-api-project')) { + try { + const yamlUri = vscode.Uri.file(this.replaceXmlToYaml(fullPath[1])); + await vscode.commands.executeCommand('mule-dx-api.open-api-project', yamlUri); + } catch (error) { + telemetryService.sendEventData('mule-dx-api.open-api-project command could not be executed', { + error: error.message + }); + console.error('mule-dx-api.open-api-project command could not be executed', error); + } + } else { + telemetryService.sendEventData('mule-dx-api.open-api-project command not found'); } - } else { - telemetryService.sendEventData('mule-dx-api.open-api-project command not found'); - console.log('mule-dx-api.open-api-project command not found'); - } + }; + await callMulesoftExtension(); } );