seed 0.5.1

A Rust framework for creating web apps, using WebAssembly
Documentation
[env]

# Reset rustup recursion limit because otherwise `cargo make clippy_all` fails.

# https://github.com/rust-lang/rustup.rs/blob/d35f94183601a81489bce025c2abc35cd395c909/src/toolchain.rs#L296

RUST_RECURSION_COUNT = "0"



# ---- SCRIPTS ----



[tasks.populate_all]

description = "Populate styles, tags, attributes, etc."

workspace = false

dependencies = ["populate_styles"]



[tasks.populate_styles]

description = "Populate styles"

workspace = false

command = "cargo"

args = ["script", "./scripts/populate_styles.rs"]



# ---- GENERAL ----



[tasks.verify]

description = "Format, lint with Clippy, build, run tests, simulate publish"

workspace = false

dependencies = ["fmt_all", "clippy_all", "all", "test_h_firefox", "publish_dry_run"]



[tasks.verify_for_ci]

description = "Like `verify`, but fails if the code isn't formatted and you should run tests with other commands."

workspace = false

dependencies = ["fmt_all_check", "clippy_all", "all", "publish_dry_run"]



# ---- BUILD ----



[tasks.build]

description = "Build only Seed"

clear = true

workspace = false

command = "cargo"

args = ["build"]



[tasks.build_release]

extend = "build"

description = "Build only Seed in relase mode"

args = ["build", "--release"]



[tasks.all]

description = "Build Seed and examples"

workspace = false

dependencies = ["build", "build_examples"]



[tasks.all_release]

extend = "all"

description = "Build Seed and examples in release mode"

dependencies = ["build_release", "build_examples_release"]



[tasks.one]

description = "Build Seed and chosen example. Ex: 'cargo make one counter'"

workspace = false

command = "cargo"

args = ["make", "--cwd", "./examples/${@}", "build"]

dependencies = ["build"]



[tasks.one_release]

extend = "one"

description = "Build Seed and chosen example in release mode. Ex: 'cargo make one counter'"

args = ["make", "--cwd", "./examples/${@}", "build_release"]

dependencies = ["build_release"]



# ---- LINT ----



[tasks.fmt_all]

description = "Format Seed and all examples with rustfmt"

workspace = false

dependencies = ["fmt", "fmt_examples"]



[tasks.fmt_all_check]

description = "Check format of Seed and all examples with rustfmt"

workspace = false

dependencies = ["fmt_check", "fmt_examples_check"]



[tasks.clippy]

description = "Lint only Seed with Clippy"

clear = true

workspace = false

install_crate = { rustup_component_name = "clippy", binary = "cargo-clippy", test_arg = "--help" }

command = "cargo"

args = ["clippy", "--all-features", "--", "--deny", "warnings", "--deny", "clippy::pedantic", "--deny", "clippy::nursery"]



[tasks.clippy_one]

description = "Lint Seed and chosen example with Clippy. Ex: 'cargo make clippy_one counter'"

workspace = false

command = "cargo"

args = ["make", "--cwd", "./examples/${@}", "clippy"]

dependencies = ["clippy"]



[tasks.clippy_all]

description = "Lint Seed and all examples with Clippy"

workspace = false

dependencies = ["clippy", "clippy_examples"]



[tasks.publish_dry_run]

description = "Check the crate can be published"

workspace = false

command = "cargo"

args = ["publish", "--dry-run", "--allow-dirty"]



# ---- TEST ----



# wasm-pack test docs:

# https://rustwasm.github.io/wasm-pack/book/commands/test.html



[tasks.test]

description = "Run Seed's tests. Ex: 'cargo make test firefox'. Test envs: [chrome, firefox, safari]"

clear = true

workspace = false

install_crate = { crate_name = "wasm-pack", binary = "wasm-pack", test_arg = "-V" }

command = "wasm-pack"

args = ["test", "--${@}"]



[tasks.test_release]

extend = "test"

description = "Run Seed's tests in release mode. Ex: 'cargo make test firefox'. Test envs: [chrome, firefox, safari]"

args = ["test", "--${@}", "--release"]



[tasks.test_h]

description = "Run headless Seed's tests. Ex: 'cargo make test_h firefox'. Test envs: [chrome, firefox, safari]"

extend = "test"

args = ["test", "--headless", "--${@}"]



[tasks.test_h_firefox]

description = "Run headless Seed's tests with Firefox."

extend = "test"

args = ["test", "--headless", "--firefox"]



[tasks.test_h_release]

extend = "test_h"

description = "Run headless Seed's tests in release mode. Ex: 'cargo make test_h firefox'. Test envs: [chrome, firefox, safari]"

args = ["test", "--headless", "--${@}", "--release"]



[tasks.test_one]

description = "Run a single test in Firefox. Ex 'cargo make test_one my_test'"

clear = true

workspace = false

install_crate = { crate_name = "wasm-pack", binary = "wasm-pack", test_arg = "-V" }

command = "wasm-pack"

args = ["test", "--firefox", "--", "--lib", "${@}"]



[tasks.test_one_h]

description = "Run a single test in headless Firefox. Ex 'cargo make test_one_h my_test'"

clear = true

workspace = false

install_crate = { crate_name = "wasm-pack", binary = "wasm-pack", test_arg = "-V" }

command = "wasm-pack"

args = ["test", "--firefox", "--headless", "--", "--lib", "${@}"]



# ---- START ----



[tasks.start]

description = "Start chosen example. Ex: 'cargo make start counter'"

workspace = false

command = "cargo"

args = ["make", "--cwd", "./examples/${@}", "start"]



[tasks.start_release]

extend = "start"

description = "Start chosen example in release mode. Ex: 'cargo make start counter'"

args = ["make", "--cwd", "./examples/${@}", "start_release"]



[tasks.start_server]

description = "Start server of chosen example (only a few have one). Ex: 'cargo make start_server websocket'"

workspace = false

command = "cargo"

args = ["make", "--cwd", "./examples/${@}", "start_server"]



[tasks.start_server_release]

extend = "start_server"

description = "Start server of chosen example (only a few have one) in release mode. Ex: 'cargo make start_server websocket'"

args = ["make", "--cwd", "./examples/${@}", "start_server_release"]



# ---- DEFAULT TASKS FOR EXAMPLES ----

# These tasks should be run only from the example root

# and example's Makefile.toml should override all tasks in dependencies.



[tasks.default_build]

description = "Build with wasm-pack"

workspace = false

install_crate = { crate_name = "wasm-pack", binary = "wasm-pack", test_arg = "-V" }

command = "wasm-pack"

args = ["build", "--target", "web", "--out-name", "package", "--dev"]



[tasks.default_build_release]

extend = "default_build"

description = "Build with wasm-pack in release mode"

args = ["build", "--target", "web", "--out-name", "package", "--release"]



[tasks.default_start]

description = "Build and start microserver"

workspace = false

install_crate = { crate_name = "microserver", binary = "microserver", test_arg = "-h" }

command = "microserver"

args = ["--port", "8000"]

dependencies = ["build"]



[tasks.default_start_release]

extend = "default_start"

description = "Build and start microserver in release mode"

dependencies = ["build_release"]



[tasks.default_clippy]

description = "Lint with Clippy"

workspace = false

install_crate = { rustup_component_name = "clippy", binary = "cargo-clippy", test_arg = "--help" }

command = "cargo"

args = ["clippy", "--all-features", "--", "--deny", "warnings", "--deny", "clippy::pedantic", "--deny", "clippy::nursery"]



# ---- HELPERS -----



[tasks.build_examples]

description = "Build examples"

workspace = false

command = "cargo"

args = ["make", "for_each", "build"]



[tasks.build_examples_release]

extend = "build_examples"

description = "Build examples in release mode"

args = ["make", "for_each", "build_release"]



[tasks.fmt]

description = "Format with rustfmt"

workspace = false

install_crate = { crate_name = "rustfmt-nightly", rustup_component_name = "rustfmt", binary = "rustfmt", test_arg = "--help" }

command = "cargo"

args = ["fmt", "--all"]



[tasks.fmt_check]

extend = "fmt"

description = "Check format with rustfmt"

args = ["fmt", "--all", "--", "--check"]



[tasks.fmt_examples]

description = "Format all examples with rustfmt"

workspace = false

command = "cargo"

args = ["make", "for_each", "fmt"]



[tasks.fmt_examples_check]

description = "Check format of all examples with rustfmt"

workspace = false

command = "cargo"

args = ["make", "for_each", "fmt_check"]



[tasks.clippy_examples]

description = "Lint examples with Clippy"

workspace = false

command = "cargo"

args = ["make", "for_each", "clippy"]



[tasks.for_each]

description = "Run chosen task for each example in its root. Ex: 'cargo make for_each build'"

workspace = false

script_runner = "@rust"

script = [

    '''

    //! ```cargo

    //! [dependencies]

    //! glob = "*"

    //! ```

    extern crate glob;



    use std::process::{Command, exit, Stdio};

    use std::env;

    use glob::glob;



    fn main() {

        let args: Vec<String> = env::args().collect();

        // args[0] is a script name, args[1] is the given task

        if args.len() != 2 {

            eprintln!("Wrong number of arguments! Correct example: 'cargo make for_each build'");

            exit(1);

        }



        let task = &args[1];

        let mut exit_code = 0;



        for entry in glob("examples/*/Makefile.toml").unwrap() {

            if let Ok(path) = entry {

                let example_root = path.parent().unwrap().to_str().unwrap();

                if !run_task_in_example_root(example_root, task) {

                    exit_code = 1;

                }

            }

        }

        exit(exit_code);

    }



    fn run_task_in_example_root(example_root: &str, task: &str) -> bool {

        println!("Example root: '{}'", example_root);

        Command::new("cargo")

            .stdout(Stdio::inherit())

            .stderr(Stdio::inherit())

            .args(&["make", "--cwd", example_root, task])

            .output()

            .unwrap()

            .status

            .success()

    }

    '''

]