yewstack / yew

Rust / Wasm framework for creating reliable and efficient web applications
https://yew.rs
Apache License 2.0
30.71k stars 1.42k forks source link

Proposal: Replace bash scripts with a Rust CLI #1418

Closed siku2 closed 4 years ago

siku2 commented 4 years ago

Proposal

Currently Yew uses a number of bash scripts for various maintenance tasks. Examples include the run_stable_checks.sh and examples/build.sh scripts. This is problematic for Windows contributors who either don't have bash installed or don't know that they do (for example through git). The scripts might also depend on executables that aren't typically found in a Windows environment.

The solution proposed here is to create a command line tool for the Yew repository that takes care of running tests, building and running the examples, and other tasks.

We should use a generic name like tools to avoid confusion in case we create a yew cli for developers in the future. To run the CLI one would use cargo run -p tools -- <args>.

The following table shows the most relevant commands:

Command Description Replaced Script
example <name> Run the specified example examples/build.sh
check Lint and format the code run_stable_checks.sh
test <crate> Test the specified crate N/A
test --all Test all crates run_tests.sh

It should be much easier than with bash to make these commands user-friendly.

Rejected Alternatives

By using Rust we don't require contributors to install any dependencies and since they're familiar with the language it should be easier to maintain.

References

Related Issues:

Relevant Links:

philip-peterson commented 4 years ago

While we are tackling this with #1419, just for the sake of discussion I'd like to throw out the idea of using rhai for some of the simpler tasks. https://docs.rs/rhai/0.17.0/rhai/ Rhai is a rust-based scripting language that has a slightly different syntax but shares many of the same ideas and is more lightweight than Rust, plus installable via Cargo. It's not necessarily ready for prime time, but worth looking into (IMO) if someone has spare time.

guslen commented 4 years ago

Maybe I misunderstood the intention of the issue. But it sounds as if the build script for yew when you work on it should not depend on a certain scripting language hence the os specific scripting language but something like https://github.com/sagiegurari/cargo-make to automate ci and help with setup of new devs? This could be relevant as apparently frontend devs are interested in the framework as well and are used to the npm script tools with you can automate some tedious tasks. yew cli I would understand as a tool to get started quicker to work on a yew based project to utilize framework more easily. So one is a tool for users and the other a feature to make it easier for contributors to get started.

siku2 commented 4 years ago

I haven't had the chance to use cargo-make yet, is it mature enough to handle more complex tasks?

yew cli I would understand as a tool to get started quicker to work on a yew based project to utilize framework more easily. So one is a tool for users and the other a feature to make it easier for contributors to get started.

Yes, that's what I had in mind as well. Separate tools for different purposes.

If cargo-make is capable of handling the task it would make for a much better developer experience than having to compile an entire CLI first.

guslen commented 4 years ago

I haven't had the chance to use cargo-make yet, is it mature enough to handle more complex tasks?

@siku2 it seems pretty stable for whatever in Rust can be considered stable :) that's the official repository https://github.com/sagiegurari/cargo-make . I haven't had the chance to use cargo-make yet either. But judging by the number of features and length of documentation it seems pretty solid.

sagiegurari commented 4 years ago

just saw this issue and wanted to say that i would be more than happy to help out if needed. with cargo make you can break those scripts to tasks and sub tasks and create flows.

anything too complex to define declaratively as a task can be scripted with any scripting language you want (including bash) and have a different script implementation per OS (optional). however, cargo-make does come with an embedded bash like scripting language called duckscript which is really really simple and since its built in rust, it supports all major OS (including max, linux and windows). But in general, scripts should only be used if you can't really declare the tasks as simple commands and flows.

siku2 commented 4 years ago

@sagiegurari, really appreciate the offer! I'm pretty much convinced at this point that cargo-make would make a great fit for Yew. Usually, I prefer the simplicity of "Just" but cargo-make is much more cross-platform friendly and seems more ambitious in terms of scope. For the past week or so I've been reading into the documentation but I haven't had the chance to sit down and actually implement it.

sagiegurari commented 4 years ago

@siku2 i started a draft PR to show how to migrate, i'll probably continue it for more scripts. tell me if it makes sense or not? i started with run_stable_checks.sh