From cb1a2f8e1d5057d1daab789a5eab40fc69ee1ebf Mon Sep 17 00:00:00 2001 From: Luccas Castro <64063580+DevPio@users.noreply.github.com> Date: Fri, 4 Oct 2024 18:03:30 -0300 Subject: [PATCH] Include m365 prefix and log passed CLI command options. Closes: #283 (#313) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎯 Aim Adding the m365 prefix: The m365 prefix is now included before every CLI command, ensuring that the logged commands accurately reflect what is run in the terminal. Logging CLI command options: The PR also includes the functionality to log the options passed with each command, providing better transparency and guidance for developers who want to understand the equivalent terminal commands for SPFx Toolkit features. However, the functionality to set json as the default output for all commands was not implemented, as there are parts of the code that use other output formats, such as md (Markdown). Changing the default output to json globally could break those functionalities. ![image](https://github.com/user-attachments/assets/61a93e6a-712f-4122-82fb-f00ae3ce18b7) ## 📷 Result ![Captura de tela 2024-09-30 124116](https://github.com/user-attachments/assets/0dce5b35-2022-4e54-980a-4c318441282f) ![Captura de tela 2024-09-30 124152](https://github.com/user-attachments/assets/eb01d647-8580-4677-912a-ea6af1ae10d2) ## 🔗 Related issue Closes: #283 --- src/services/executeWrappers/CliCommandExecuter.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/services/executeWrappers/CliCommandExecuter.ts b/src/services/executeWrappers/CliCommandExecuter.ts index b34b013..de7341a 100644 --- a/src/services/executeWrappers/CliCommandExecuter.ts +++ b/src/services/executeWrappers/CliCommandExecuter.ts @@ -28,8 +28,20 @@ export class CliExecuter { let cmdOutput: string = ''; let cmdOutputIncludingStderr: string = ''; const outputChannel = Logger.channel; + let cliCommandOptions = ''; + if (args) { + cliCommandOptions = `${Object.keys(args).map(key => { + let option = `--${key}`; + const value = args[key]; + if (value) { + option = `${option} ${value}`; + } + + return option; + }).join(' ')}`; + } - Logger.info(`Running CLI command: ${command}`); + Logger.info(`Running CLI command: m365 ${command} --output ${output} ${cliCommandOptions}`); executeCommand(command, { output, ...args }, { stdout: (message: string) => { message = message.toString();