From 4b701bcb9ba7a18fcc552078b164fc85e43af6f4 Mon Sep 17 00:00:00 2001 From: Fahmi Akbar Wildana Date: Wed, 4 Mar 2020 00:55:17 +0700 Subject: [PATCH 1/4] 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 --- .gitignore | 3 +++ Cargo.toml | 5 +++- maskfile.md | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 maskfile.md diff --git a/.gitignore b/.gitignore index 388af6ae95b4..190247aac6e5 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 1b13792befb1..16fbba486918 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 000000000000..1b9d45e86900 --- /dev/null +++ b/maskfile.md @@ -0,0 +1,69 @@ +# 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; cd .. # always prepare up-to-date examples in case it's already available +source .scripts/init_env.sh + +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 + +### 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 && 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 +``` From a82a072161391737f4f35bd60236eaa8b1020761 Mon Sep 17 00:00:00 2001 From: Fahmi Akbar Wildana Date: Wed, 4 Mar 2020 01:23:17 +0700 Subject: [PATCH 2/4] fix(task-runner): error when basename != dirname with assumption it only happen on examples/rust --- maskfile.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/maskfile.md b/maskfile.md index 1b9d45e86900..a10519d62374 100644 --- a/maskfile.md +++ b/maskfile.md @@ -33,7 +33,9 @@ case "$PWD" in yarn && yarn tauri:source dev ;; */rust/*) - cargo web deploy && cd .. + cargo web deploy + [ $example = `basename $(dirname $PWD)` ] && cd .. + yarn add tauri@link:../../../cli/tauri.js yarn && yarn tauri dev ;; From 3b8503d931922373f795cdac5e33034829e9fc62 Mon Sep 17 00:00:00 2001 From: Fahmi Akbar Wildana Date: Wed, 4 Mar 2020 16:48:12 +0700 Subject: [PATCH 3/4] chore(task-runner): add .gif from pr #486 --- maskfile.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/maskfile.md b/maskfile.md index a10519d62374..3a77789bf4b4 100644 --- a/maskfile.md +++ b/maskfile.md @@ -18,6 +18,8 @@ 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 From 2a21317696b4a05363ef85d820ae44fb46899964 Mon Sep 17 00:00:00 2001 From: Fahmi Akbar Wildana Date: Mon, 16 Mar 2020 11:46:44 +0700 Subject: [PATCH 4/4] fix(task-runner): point $TAURI_* to fixture/* --- maskfile.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/maskfile.md b/maskfile.md index 3a77789bf4b4..24b737c0cc8c 100644 --- a/maskfile.md +++ b/maskfile.md @@ -5,8 +5,10 @@ ```sh git clone --recursive git@github.com:tauri-apps/examples.git \ -|| cd examples && git pull; cd .. # always prepare up-to-date examples in case it's already available -source .scripts/init_env.sh +|| (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 @@ -28,7 +30,7 @@ source .scripts/init_env.sh shopt -s globstar cd examples/**/$example 2>/dev/null \ -|| cd examples/**/$example/$example # workaround for rust/yew/todomvc/todomvc +|| cd examples/**/$example/$example # workaround for rust/yew/todomvc/todomvc case "$PWD" in */node/*) @@ -40,10 +42,10 @@ case "$PWD" in yarn add tauri@link:../../../cli/tauri.js yarn && yarn tauri dev -;; +;; *) - echo unknown project $(dirname $example)/$example -;; + echo unknown project $(dirname $example)/$example +;; esac ```