serverless / compose

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

Handle first `serverless deploy` in non-interactive #87

Closed mnapoli closed 2 years ago

mnapoli commented 2 years ago

Since serverless deploy needs to install Compose, there can be scenarios where compose is not installed (e.g. in CI). In non-interactive mode (i.e. CI again) the CLI is just stuck:

image

We could imagine 2 solutions:

  1. throw an error inviting the user to install Compose via NPM first
  2. auto-install Compose (i.e. assume "Y" by default)

Since non-interactive will run in CI 90% of the time, I would go with option 2 because:

I would consider the surprise factor very low since, again, you are explicitly running Compose so there's little chance you actually don't want to install it? WDYT @pgrzesik

pgrzesik commented 2 years ago

Great point raising that @mnapoli - I missed that.

I'm not sure we should install it automatically for users and would prefer to throw an explicit error - if they're adopting compose for the first time, they will be aware that it needs to be installed separately and I don't think it will be a big problem for them to install compose. They most likely will have it in local package.json - I believe 99% users will already have a package.json and will be running npm i anyway because they either have a node project so they install dependencies or they use a different runtime that requires a plugin to properly bundle code (e.g. Python). So honestly I don't expect any annoyance because they're most likely running npm i anyway.

mnapoli commented 2 years ago

Discussion summary.

Scenarios:

  1. no package.json | compose not installed at all
  2. no package.json | they use yarn/something else
  3. package.json but no @serverless/compose dependency
  4. package.json with @serverless/compose dependency

In scenarios other than 4, let's trigger an error. In scenario 4 ideally let's install NPM dependencies automatically as this should have no negative side effect.

pgrzesik commented 2 years ago

Related PR: https://github.com/serverless/serverless/pull/10984