Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template: Extend it to include more capabilities #368

Open
Mossaka opened this issue Mar 17, 2023 · 4 comments
Open

Template: Extend it to include more capabilities #368

Mossaka opened this issue Mar 17, 2023 · 4 comments
Labels
📐 proposal A concept/proposition, no design work has been done yet

Comments

@Mossaka
Copy link
Member

Mossaka commented Mar 17, 2023

Describe the solution you'd like

Currently when I do slight new -n spidey@v0.4.0 rust, it will create a rust bin program that has a main.rs and some code to use the keyvalue capability. This is great to get people start using slight right away, but also lack significantly for other use cases. For example, a common use case for slight is to set up a HTTP server and handles HTTP requests using http-server capability. In order to create one application like this, I need to manually edit Cargo.toml to include [lib] section and rename main.rs to lib.rs in order to use the WASI reactor model.

Solution

We want slight new to not only take a programming language name like C or Rust, but also a capability / service. This means we would maintain a 3D matrix of capability name, service name and language name to get people started with creating slight applications.

slight new -n spidey -l rust -c http-server -v 0.4.0 or
slight new -n spidey -l rust -c keyvalue -s redis -v 0.4.0

The above two command examples show how users can create different slight application with one simple command.

Alternatively

We could build a CLI that asks user questions on what kind of project they want to get started, and use all the answers to build a templated project for them .

slight new
> name: 
spidey
> langauge:
rust
> capabilities (seperated by comma)
http-server, keyvalue
> services (seperated by comma)
keyvalue.azblob, keyvalue. 
> version
0.4 <-
0.3
0.2
...

✔️ building a spidey...
✔️ finished... 

Additional context

@Mossaka Mossaka added the 📐 proposal A concept/proposition, no design work has been done yet label Mar 17, 2023
@danbugs
Copy link
Collaborator

danbugs commented Mar 17, 2023

I think slight new -n spidey -l rust -c keyvalue -s redis -v 0.4.0 is very messy and error prone.

The thing is: slight new -n spidey@v0.4.0 rust is not meant to be something that covers all use-cases. Instead, after running slight new, if people want to add other capabilities they can use slight add.

For example, while I was crafting my WasmIO demo, I did:

slight new -n wasmio-demo@v0.4.0 rust && cd wasmio-demo
cd wit && slight add messaging@0.4.0

@Mossaka
Copy link
Member Author

Mossaka commented Mar 20, 2023

I guess my main point is that the current new command creates a slight application that automatically adds the keyvalue interface in, which probably isn't what the user wants. In addition to that, the way we use slight http-server capability requires users to edit many files:

  • rename main.rs to lib.rs
  • add [lib] section to Cargo.toml
  • add http-server capability
  • add slight macro dependencies to Cargo.toml

This isn't a great experience imo.

@danbugs
Copy link
Collaborator

danbugs commented Mar 20, 2023

I guess my main point is that the current new command creates a slight application that automatically adds the keyvalue interface in, which probably isn't what the user wants. In addition to that, the way we use slight http-server capability requires users to edit many files:

  • rename main.rs to lib.rs
  • add [lib] section to Cargo.toml
  • add http-server capability
  • add slight macro dependencies to Cargo.toml

This isn't a great experience imo.

I agree that users might not always want keyvalue, but that template is just the most basic one we have w/ the most basic application possible. To fit other users needs, we need to create other templates – for your example, that would be smt like http-rust.

Also, I think our current template does have the slight macro dependency already added to the Cargo.toml, and all the other changes required that you mentioned are because of recent code changes.

@Mossaka
Copy link
Member Author

Mossaka commented Mar 21, 2023

this sounds good to me. I will be working on a http-server-rust template for http-server template.

Another concern of mine is how we can maintain the templates - each time we bump up the CLI version, we will have to bump up the version used in the templates. Any mistakes in this process would cause a re-deployment. Can we somehow make the dep versions in the templates aligned with CLI version automatically?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📐 proposal A concept/proposition, no design work has been done yet
Projects
Status: Backlog
Development

No branches or pull requests

2 participants