Description
CLI no longer displays deprecation messages for command name
Steps to reproduce
execute the m365 spo site classic add command with valid arguments
Expected results
A message showing that the command is deprecated and you should use spo site add instead
Actual results
No deprecation message
Diagnostics
No response
CLI for Microsoft 365 version
latest from main
nodejs version
v16
Operating system (environment)
macOS
Shell
zsh
cli doctor
No response
Additional Info
This is caused by changes that we've done at some point to allow commands to call other commands here:
|
// store the current command name, if any and set the name to the name of |
|
// the command to execute |
|
const cli = Cli.getInstance(); |
|
const parentCommandName: string | undefined = cli.currentCommandName; |
|
cli.currentCommandName = command.getCommandName(); |
|
|
|
command.action(logger, args as any, (err: any): void => { |
|
// restore the original command name |
|
cli.currentCommandName = parentCommandName; |
cli.currentCommandName on line 234 contains the name that was used to invoke command. When one command calls another, it contains the name of the parent command. On line 235 we're replacing it with the name of the command to execute, losing information about the originally used name that could be deprecated and for which we should show a warning. We restore the original name after the command's execution completed, but at that point it's too late, because the deprecation check already happened.
Description
CLI no longer displays deprecation messages for command name
Steps to reproduce
execute the
m365 spo site classic addcommand with valid argumentsExpected results
A message showing that the command is deprecated and you should use
spo site addinsteadActual results
No deprecation message
Diagnostics
No response
CLI for Microsoft 365 version
latest from main
nodejs version
v16
Operating system (environment)
macOS
Shell
zsh
cli doctor
No response
Additional Info
This is caused by changes that we've done at some point to allow commands to call other commands here:
cli-microsoft365/src/cli/Cli.ts
Lines 231 to 239 in efdacec
cli.currentCommandNameon line 234 contains the name that was used to invoke command. When one command calls another, it contains the name of the parent command. On line 235 we're replacing it with the name of the command to execute, losing information about the originally used name that could be deprecated and for which we should show a warning. We restore the original name after the command's execution completed, but at that point it's too late, because the deprecation check already happened.