seed 0.9.1

A Rust framework for creating web apps, using WebAssembly
Documentation


[config]

default_to_workspace = false

min_version = "0.32.1"



[config.modify_core_tasks]

private = true

namespace = "default"



[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."

dependencies = ["populate_styles"]



[tasks.populate_styles]

description = "Populate styles"

env = { STYLES_ENDPOINT = "https://seed-rs.github.io/html-css-db/css_properties.json", STYLE_NAMES_FILE = "./src/dom_entity_names/styles/style_names.rs" }

script = [

'''

#!@duckscript

# fetch styles

styles_txt = http_client ${STYLES_ENDPOINT}

styles = json_parse ${styles_txt}



# generate content for style names

arr_range = range 0 ${styles.length}

style_pairs = set ""

for index in ${arr_range}

    original = get_by_name styles[${index}].name.original

    pascal_case = get_by_name styles[${index}].name.pascal_case



    if not is_empty ${pascal_case}

        style_pairs = concat ${style_pairs} "    ${pascal_case} => \"${original}\",\n"

    end

end

style_pairs = trim ${style_pairs}

trim_end_comma = ends_with ${style_pairs} ,

if ${trim_end_comma}

    style_pairs = substring ${style_pairs} -1

end

content_for_style_names_file = set "//! This file is generated automatically by `cargo make ${CARGO_MAKE_CURRENT_TASK_NAME}`.\n"

content_for_style_names_file = concat ${content_for_style_names_file} "//! It's not meant to be edited directly.\n\n"

content_for_style_names_file = concat ${content_for_style_names_file} "make_styles! {\n"

content_for_style_names_file = concat ${content_for_style_names_file} "    ${style_pairs}\n"

content_for_style_names_file = concat ${content_for_style_names_file} "}\n"



# write rust file

writefile ${STYLE_NAMES_FILE} ${content_for_style_names_file}

'''

]



# ---- GENERAL ----



[tasks.verify]

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

dependencies = ["fmt_all", "clippy_all", "test_h_firefox", "test_examples_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."

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



# ---- BUILD ----



[tasks.build]

description = "Build only Seed"

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"

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'"

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"

dependencies = ["fmt", "fmt_examples"]



[tasks.fmt_all_check]

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

dependencies = ["fmt_check", "fmt_examples_check"]



[tasks.clippy]

description = "Lint only Seed with Clippy"

command = "cargo"

args = ["clippy", "--all-features", "--", 

    "--deny", "warnings", 

    "--deny", "clippy::pedantic", 

    "--deny", "clippy::nursery",

    "--allow", "clippy::vec_init_then_push", # Vec::new() + push are used in macros in shortcuts.rs

]

dependencies = ["default::install-clippy"]



[tasks.clippy_one]

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

command = "cargo"

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

dependencies = ["clippy"]



[tasks.clippy_all]

description = "Lint Seed and all examples with Clippy"

dependencies = ["clippy", "clippy_examples"]



[tasks.publish_dry_run]

description = "Check the crate can be published"

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

command = "wasm-pack"

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

dependencies = ["default::install-wasm-pack"]



[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'"

command = "wasm-pack"

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

dependencies = ["default::install-wasm-pack"]



[tasks.test_one_h]

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

command = "wasm-pack"

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

dependencies = ["default::install-wasm-pack"]



[tasks.test_examples_firefox]

description = "Run tests in all examples in headless Firefox. Ex 'cargo make test_examples_firefox'"

command = "cargo"

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



# ---- START ----



[tasks.start]

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

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'"

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"

command = "wasm-pack"

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

dependencies = ["default::install-wasm-pack"]



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

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_test_firefox]

description = "Test with wasm-pack in Firefox"

command = "wasm-pack"

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

dependencies = ["default::install-wasm-pack"]



[tasks.default_clippy]

description = "Lint with Clippy"

command = "cargo"

args = ["clippy", "--all-features", "--",

    "--deny", "warnings",

    "--deny", "clippy::pedantic",

    "--deny", "clippy::nursery",

    "--allow", "clippy::wildcard_imports", # for `use seed::{prelude::*, *};`

    "--allow", "clippy::future_not_send", # JS/WASM is single threaded

    "--allow", "clippy::used_underscore_binding", # some libraries break this rule

    "--allow", "clippy::eval_order_dependence", # false positives

    "--allow", "clippy::vec_init_then_push", # Vec::new() + push are used in macros in shortcuts.rs

]

dependencies = ["default::install-clippy"]



# ---- HELPERS -----



[tasks.build_examples]

description = "Build examples"

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"

command = "cargo"

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

dependencies = [ "default::install-rustfmt" ]



[tasks.fmt_check]

extend = "fmt"

description = "Check format with rustfmt"

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



[tasks.fmt_examples]

description = "Format all examples with rustfmt"

command = "cargo"

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



[tasks.fmt_examples_check]

description = "Check format of all examples with rustfmt"

command = "cargo"

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



[tasks.clippy_examples]

description = "Lint examples with Clippy"

command = "cargo"

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



# ---- CLEAN----



[tasks.clean]

description = "Clean only Seed"

command = "cargo"

args = ["clean"]



[tasks.clean_pkg]

description = "Generic Clean command"

command = "cargo"

args = ["clean","--target-dir" ,"pkg"]



[tasks.clean_examples]

description = "Clean all examples pkg"

command = "cargo"

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



[tasks.clean_all]

description = "Clean all artifact in seed and examples"

dependencies = ["clean", "clean_examples"]





[tasks.for_each]

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

script = [

'''

#!@duckscript

defined = is_defined 1

assert ${defined} "Wrong number of arguments! Correct example: 'cargo make for_each build'"



task = set ${1}



handle = glob_array examples/*/Makefile.toml



for path in ${handle}

    example_root = dirname ${path}

    echo Example root: ${example_root}

    exec --fail-on-error cargo make --cwd ${example_root} ${task}

end

'''

]

[tasks.for_each_pkg]

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

script = [

    '''

    #!@duckscript

    defined = is_defined 1

    assert ${defined} "Wrong number of arguments! Correct example: 'cargo make for_each build'"



    task = set ${1}



    handle = glob_array examples/*/Makefile.toml



    for path in ${handle}

        example_root = dirname ${path}

        echo Example root: ${example_root}

        exec --fail-on-error cargo make --cwd ${example_root} ${task}

    end

    '''

]