serverless / compose

Orchestrate Serverless Framework in monorepos
https://serverless.com/framework/docs/guides/compose
MIT License
110 stars 15 forks source link

unrecognized CLI options: "--stage" when running "sls myService:doctor" #151

Open timo92 opened 2 years ago

timo92 commented 2 years ago

Are you certain it's a bug?

Are you using the latest version?

Is there an existing issue for this?

Issue description

When executing sls myService:doctor the comand fails with

Error: Detected unrecognized CLI options: "--stage".

Currently one has to manually change the working directory and execute the command locally. Serverless compose seems to add "--stage dev" to all commands per default.

Service configuration (serverless-compose.yml) content

module.exports = {
  services: {
    myService: {
      path: "some/path",
    },
  },
};

Command name and used flags

serverless myService:doctor

Command output

serverless > Invoking "doctor" on service "myService"
myService > Running "serverless doctor --stage dev"
Error:
pgrzesik commented 2 years ago

Hey @timo92 - thanks for reporting and sorry you've run into trouble. That's true this is the case, but the thing is, serverless doctor command will never really work in context of a specific service - it only captures the deprecations of last serverless command, so you can just run sls doctor and it will print out the deprecations from last command, running it against a service wouldn't really change anything.

timo92 commented 2 years ago

Hey @pgrzesik, thank you for getting back to me and clearing up the functionallity of sls doctor. The reason why I attempted to run the command on the service level (besides not finding any documentation on it on the serverless website) was the error message I received when executing it at the root of my monorepo from where I deployed the service. I.e. running sls myService:deploy yields

myService > 1 deprecation found: run 'serverless doctor' for more details

and then running serverless doctor errors with

Command "doctor" doesn't exist. Available commands: deploy, remove, info, logs, outputs, refresh-outputs. If this is a service-specific command, run it using the component name: "serverless \:doctor"

Not sure whether you want to support it or mention it in the documentation. Either could be helpful when being faced with the suggestion to run serverless doctor.

pgrzesik commented 2 years ago

I see, I think I have a solution for it and it will be applied on Framework level (it does triaging how the commands should be handled), it should always assume "non-compose" context for doctor command