serverless/serverless

Refactor: Seclude non-service specific commands out of internals

Open

#9,738 opened on Jul 13, 2021

View on GitHub
 (0 comments) (0 reactions) (0 assignees)JavaScript (46,915 stars) (5,734 forks)batch import
cat/clicat/designhelp wantedrefactor

Description

Use case description

Currently lifecycle engine implemented into Serverless powers most of our commands. Whole point of lifecycle engine is to make our commands hack-able by plugins. Still that's not a use case for commands which are not designed to work in service context (e.g. config, dashboard, login), and actually implementing them through lifecycle engine makes it more complicated then it should.

We've already reconfigured interactive CLI setup, so it doesn't run through Serveless instance and best if same is done with other commands.

It's an important shift especially in light of moving into multi providers engine (https://github.com/serverless/serverless/issues/9583), where we will deprecate old single provider engine, but those non-service specific commands should not be affected

Proposed solution

Refactor following commands out of Serverless instance:

Let's propose each command as public module in commands/<command-name>.js. If there'll be a need to seclude some common utils, let's put them into lib/commands/... (let's agree that lib is considered a private scope, not be used publicly)

Each item should be addressed with separate PR

  • config (to be implemented in commands/config.js)
  • config credentials (to be implemented in commands/config-credentials.js)
  • config tabcompletion install & config tabcompletion uninstall (to be implemented in commands/tabcompletion-install.js and commands/tabcompletion-uninstall.js)
  • dashboard (to be implemented in commands/dashboard.js)
  • generate-event (to be implemented in commands/generate-event.js)
  • login & logout (to be implemented in commands/login.js & commands/logout.js)
  • slsstats (to be implemented in commands/slsstats.js)
  • upgrade & uninstall (to be implemented in commands/upgrade.js & commands/uninstall.js)

Unless proven needed, let's not attempt to migratecreate and install commands, as they're soft deprecated, and no longer advertised to be used.

Contributor guide