seed 0.3.3

A Rust framework for creating web apps, using WebAssembly
# ---- 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"]



# ---- TEST ----



[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_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"]



# ---- 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", "no-modules", "--out-name", "package", "--dev"]



[tasks.default_build_release]

extend = "default_build"

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

args = ["build", "--target", "no-modules", "--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"]



# ---- 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.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];



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

            if let Ok(path) = entry {

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

                run_task_in_example_root(example_root, task);

            }

        }

    }



    fn run_task_in_example_root(example_root: &str, task: &str) {

        Command::new("cargo")

            .stdout(Stdio::inherit())

            .stderr(Stdio::inherit())

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

            .output()

            .unwrap();

    }

    '''

]