From c649ef47b67f014e6d650a7d638b9e61dcd5de10 Mon Sep 17 00:00:00 2001 From: Fahmi Akbar Wildana Date: Sun, 12 Apr 2020 20:57:52 +0700 Subject: [PATCH] build(task-runner): add self-documented task runner (#486) * feat(task-runner): add maskfile.md `mask` can also act as self-documented task runner https://github.com/jakedeichert/mask TODO: add demo.gif on opening this PR * fix(task-runner): error when basename != dirname with assumption it only happen on examples/rust * chore(task-runner): add .gif from pr #486 * fix(task-runner): point $TAURI_* to fixture/* --- .gitignore | 3 +++ Cargo.toml | 5 +++- maskfile.md | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 maskfile.md diff --git a/.gitignore b/.gitignore index 388af6ae9..190247aac 100644 --- a/.gitignore +++ b/.gitignore @@ -83,3 +83,6 @@ Cargo.lock # doing this because of how our tests currently (naively) drop the tauri.conf.js in that folder # todo: needs a proper fic /cli/tauri.js/tauri.conf.js + +# doing this because the task-runner (`mask prepare`) will clone gh:tauri-apps/examples +/examples diff --git a/Cargo.toml b/Cargo.toml index 1b13792be..16fbba486 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,5 +3,8 @@ members = [ "tauri", "tauri-api", "tauri-updater", - "tauri-utils" + "tauri-utils", +] +exclude = [ + "examples", ] diff --git a/maskfile.md b/maskfile.md new file mode 100644 index 000000000..24b737c0c --- /dev/null +++ b/maskfile.md @@ -0,0 +1,75 @@ +# Shorthand Commands + +## prepare +> Setup all stuffs needed for runing the examples + +```sh +git clone --recursive git@github.com:tauri-apps/examples.git \ +|| (cd examples && git pull origin master; cd ..) # always prepare up-to-date examples in case it's already available + +export TAURI_DIST_DIR=$PWD/tauri/test/fixture/dist +export TAURI_DIR=$PWD/tauri/test/fixture/src-tauri + +cargo build +cargo install --path cli/tauri-bundler --force +cargo install cargo-web # used by example rust/yew + +cd cli/tauri.js +yarn && yarn build +``` + +## run + +![tauri-mask-run-example](https://user-images.githubusercontent.com/4953069/75866011-00ed8600-5e37-11ea-9106-3cb104a05f80.gif) + +### run example (example) +> Run specific example in dev mode + +```sh +source .scripts/init_env.sh +shopt -s globstar + +cd examples/**/$example 2>/dev/null \ +|| cd examples/**/$example/$example # workaround for rust/yew/todomvc/todomvc + +case "$PWD" in +*/node/*) + yarn && yarn tauri:source dev +;; +*/rust/*) + cargo web deploy + [ $example = `basename $(dirname $PWD)` ] && cd .. + + yarn add tauri@link:../../../cli/tauri.js + yarn && yarn tauri dev +;; +*) + echo unknown project $(dirname $example)/$example +;; +esac +``` + +## list + +### list examples +> List all available examples + +```sh +find examples/*/*/* -maxdepth 0 -type d -not -path '*.git*' \ +-exec sh -c 'echo $(basename $(dirname {}))/$(basename {})' \; +``` + +## clean +> Remove installed dependencies and reset examples in case something gone wrong + +```sh +cargo uninstall tauri-bundler +cargo clean + +shopt -s globstar +rm -r **/node_modules + +cd examples +git checkout -- . # discard all unstaged changes +git clean -dfX # remove all untracked files & directories +```