serverless / components

The Serverless Framework's new infrastructure provisioning technology — Build, compose, & deploy serverless apps in seconds...
https://www.serverless.com
Apache License 2.0
2.31k stars 182 forks source link

templates & serverless init command #588

Closed eahefnawy closed 4 years ago

eahefnawy commented 4 years ago

We have two onboarding issues:

Because of this, I'd like to introduce a new serverless init command that integrates with a new templating implementation

the serverless init command

Just like the framework's create command. This command downloads a template into the cwd, but with a much better experience. Because the framework does not have an init command, we could reserve it to components. Here's how it'd work:

In an empty directory, you'd run:

$ serverless init

Because init would be a reserved command for components, the runtime would be routed to the components project. This command would list the available components, and asks the user to choose one to initialize

$ serverless init

Please choose a component:

- website
- express

when a user makes their choice, the CLI fetches the component metadata from the platform, and use the repo property to check for templates directory in that components repo. It'll then list the available templates in realtime in another list for the user to choose from:

$ serverless init

Please choose a "website" template to get started with:

- basic
- react
- vue.js

When the user makes their choice, the CLI would download the relevant directory from the components repo into the cwd.

With this in place, we can keep adding templates to each component without having to make a new CLI release, and the interactive experience would make it a lot easier to get started with components

hkbarton commented 4 years ago

@eahefnawy I like this idea. One quick question, since @medikoo has already added new user onboarding flow for CN commands when user type sls in a non-serverless folder, it will onboard users using interactive CLI asking user choose a template and create the project from the template. It's kind of similar to serverless init. Should we consider merging those two together?

tinafangkunding commented 4 years ago

https://github.com/serverless/roadmap-tencent/issues/291 FYI

medikoo commented 4 years ago

@eahefnawy to me it looks that serverless init is components version of onboarding we do with serverless for v1.

So I take severless init is simply a hack to enforce Components onboarding instead of v1 ?

Note that (as @hkbarton mentioned) for users in China we already enforce (tencent) components onboarding for serverless command.

eahefnawy commented 4 years ago

@hkbarton @medikoo @tinafangkunding that's correct. I'd love to integrate it to the root serverless command though if the user won't be distracted by v1 stuff.

medikoo commented 4 years ago

@hkbarton @medikoo @tinafangkunding that's correct. I'd love to integrate it to the root serverless command though if the user won't be distracted by v1 stuff.

We may integrate like that (and that'll be cleanest I think), but for that we need to add a question, to confirm if user wants to create a component or v1 project. Having an answer we will follow with chosen flow

astuyve commented 4 years ago

This issue was closed in: https://github.com/serverless/components/pull/678