serverless / serverless/serverless

Refactor: Seclude non-service specific commands out of internals

Open
#9,738 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cat/cli cat/design help wanted refactor
Dominant language
JavaScript
Stars
46.9k
Forks
5.7k
Avg merge
10h 7m
Merged PRs (30d)
57

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by selecting one unchecked command and tracing its current implementation through the Serverless instance. Move that command to the specified public path under commands/, using lib/commands/ only for private shared utilities if needed. The work is done when the selected command no longer depends on the Serverless instance and its intended CLI behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
cli
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.