CLI: Improve interactive setup
See original GitHub issueUse case description
Ensure simple and straightforward onboarding experience into Serverless Framework and accompanying Dashboard
Proposed solution
- Work out single “new project setup” path, and for that focus on interactive
serverless
(deprecateserverless create
) - In interactive CLI support options through which answers to questions can be prefilled (it’ll allow providing ready project recipes in documentation)
- Settle on single source of official Serverless Framework templates, and let https://github.com/serverless/examples/ serve that purpose
- Improve interactive CLI steps that concern dashboard setup, so they do not involve
app
choice and deployment profile (which was refactored in favor of providers) - Propose to deploy newly setup project after new project is setup
How to implement it?
Each point should be addressed as individual PR
- Seclude interactive CLI setup from internals (specified in detail at https://github.com/serverless/serverless/issues/9354)
- Introduce
aws-node
andaws-python
examples into https://github.com/serverless/examples/. They should reflect more-less same named templates we host internally in a service - In
service
step, supporttemplate-path
(installs template pointed at provided local path) andname
(name of the project) options. They should override related questions - Refactor
service
step, so it downloads templates from https://github.com/serverless/examples/, update proposed projects list, so it lists following templates:aws-node
aws-node-rest-api
aws-node-express-api
aws-node-scheduled-cron
aws-node-sqs-worker
aws-python
aws-python-rest-api
aws-python-scheduled-cron
aws-python-sqs-worker
Ensure to runnpm install
in service folder, ifpackage.json
with provideddependencies
is found in a template
- In
service
step, supporttemplate-url
(any GitHub or Bitbucket url to template) andtemplate
(name of a template in examples repo) options. They should override related questions - In
service
step:- Provide a default value for project name (
<template-name>-project
) - Refactor Y/n prompt into (1) Yes (2) No select
- Provide a default value for project name (
- (In
@serverless/dashboard-plugin
):- Refactor
dashboard-login
so login/register works only via website (followssls login
logic). Presented question should be Do you want to login/register to the Serverless Dashboard? with (1) Yes (2) No select. - Remove preliminary question: You can monitor, troubleshoot, and test your new service with a free Serverless account."
- Refactor
- (In
@serverless/dashboard-plugin
) Refactordashboard-set-org
so if user has no apps setup yet, use app name same as service (do not prompt for app name) - (In
@serverless/dashboard-plugin
) Refactordashboard-set-org
so it doesn’t create and assign any deployment profiles (Addresses https://github.com/serverless/enterprise-plugin/issues/561 partially) - (In
@serverless/dashboard-plugin
) Refactordashboard-set-org
so:- If login/register step was not presented, there’s an option “Skip” at the end of the list that allows to opt-out.
- if login/register step was presented, and user is assigned with just one
org
, automatically add this org to YAML without raising a question
- (In
@serverless/utils
) RemoveServerless:
prefix frominquirer
prompt - (In
@serverless/dashboard-plugin
) Improve messaging after settingorg
to print messageYour project has been setup with org: "<org-name>" and app: "<app-name>"
- (In
@serverless/utils
/@serverless/dashboard-plugin
) RemoveServerless:
prefix and fix colors for log output during login - Refactor all
1. Yes
,2. No
prompts into confirm(Y/n)
prompts - Remove preliminary question “No project detected. Do you want to create a new one?”
- Remove
tab-completion
step from the flow - Change
auto-update
step to always enable auto updates (TO BE DISCUSSED) - Improve documentation around tab autocompletion and autoupdate settings
- (In
@serverless/dashboard-plugin
) SupportSERVERLESS_ACCESS_KEY
and prefillorg
based on the org that the key belongs to - Refactor
aws-credentials
step. So:- No AWS credentials were found… message is removed
- 'Do you want to set them up now? and 'Do you have an AWS account? prompts are removed in favor of: Do you have an AWS account?, which presents a select with following choices:
- (if service is setup for dashboard) AWS Access Role (most secure) - When that is chosen, we should open a browser with page that configures a provider for given app, and in CLI we should show prompt Press Enter to continue after configuring service provider credentials (Addresses serverless/enterprise-plugin#561 partially)
- Local AWS Access Keys, when that is chosen we should follow with same flow we have now for storing local credentials, (user should have browser opened that leads to AWS console, and after that should be asked to input key id and value)
- Skip
- Introduce
deploy
step, which is applied only ifservice
was successfully applied, and (in case of AWS service) if user has credentials setup locally or have set them up viaaws-credentials
setup… It should be Do you want to deploy now? Y/n prompt. Additionally, replace standard, verbose deploy output with simpler progress steps - If
service
step was presented and user created a new service, after all interactive setup steps finalize show- If
deploy
was performed: Your project is live and available in ./{name}. (in green). Additionally, below show information on how to useinfo
,deploy
anddashboard
commands - If
deploy
was not performed: Your project is available in ./{name}. (in green)
- If
- Report all interactive CLI steps choices with telemetry (report only internal questions
id
, preconfigured answers, and for user free form input, just indicate that input was provided, but do not report the actual input). Also measure steps duration as a part of telemetry. - Report with telemetry handlable exit signals (list of them can be found here: https://thomashunter.name/posts/2021-03-08-the-death-of-a-nodejs-process) I believe we should make it generic, so for every command. We should probably just store the event and do not send it (even if it’s deploy command). We probably should report it with
outcome: "cancel"
, to be discussed) - Implement support for
framework.onboarding
event based on proposal (from external Google Doc) - Validate telemetry payload with JSON schema (to be implemented in internal private package)
- Move internal templates to
legacy
folder in https://github.com/serverless/examples/ repo, and updatesls create
to install templates from that location. - Support non TTY invocation of
sls
command (to fully provide asls create
replacement). In such case all choices should be read from command line options, and in case of required option being missing, show messages like Cannot setup a service due to missing “template” option. If any of such situations were recorded, after command finalizes present message: Some steps could not be fulfilled. For interactive experience please use a TTY terminal - Soft deprecate
create
command (soft in sense of not making a real deprecation, at least at this point we’re not ready to remove it with next major release):- Mark
create
command ashidden
in schema (hidden: true
I believe does that), so it’s not exposed in commands help. - Whenever user runs
sls create
show message: “serverless create” is in consideration to be deprecated. Next time runsls
to setup a new service. - Scrub all documentation and resources we have access to, and replace
sls create
usage withsls
- Mark
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (8 by maintainers)
Top Results From Across the Web
Build Interactive CLI Tools in Python | by Dinesh Kumar K B
Bored of traditional CLIs? Develop interactive command lines with PyInquirer · Introduction: · Motivation: · A quick introduction to Click: · Why not...
Read more >how to build interactive command line tools (quick and easy ...
Usually CLI tools have really poor interactivity.In this tutorial we will use the equivalent of radio-buttons and check-boxes in a simple ...
Read more >How To Develop An Interactive Command Line Application ...
How To Develop An Interactive Command Line Application Using Node.js ... This will install the Commander module in your Node.js project.
Read more >Command Line Interface Guidelines
An open-source guide to help you write better command-line programs, taking traditional UNIX principles and updating them for the modern day.
Read more >Azure CLI interactive mode | Microsoft Learn
Interactive mode optionally displays command descriptions, parameter descriptions, and command examples. Turn descriptions and examples on or ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
They should follow the documentation. In all the usage examples CLI params follow the command
What about new users, coming straight to v3?