From 53d418d7532947f1caf0917344720dcbb0599b7e Mon Sep 17 00:00:00 2001 From: Sudo-Ivan Date: Tue, 30 Dec 2025 11:14:37 -0600 Subject: [PATCH] refactor: update Taskfile to change output paths for WASM build and add example tasks for various functionalities --- Taskfile.yml | 83 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 76 insertions(+), 7 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index 80d6154..e500714 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -186,19 +186,19 @@ tasks: env: CGO_ENABLED: '0' cmds: - - mkdir -p examples/wasm/static - - 'cd examples/wasm && GOOS=js GOARCH=wasm {{.GOCMD}} build -o static/reticulum-go.wasm .' + - mkdir -p examples/wasm/public/static + - 'cd examples/wasm && GOOS=js GOARCH=wasm {{.GOCMD}} build -o public/static/reticulum-go.wasm .' - | GOROOT=$({{.GOCMD}} env GOROOT) if [ -f "$GOROOT/lib/wasm/wasm_exec.js" ]; then - cp "$GOROOT/lib/wasm/wasm_exec.js" examples/wasm/ + cp "$GOROOT/lib/wasm/wasm_exec.js" examples/wasm/public/js/ echo "wasm_exec.js copied successfully from $GOROOT/lib/wasm/" elif [ -f "$GOROOT/misc/wasm/wasm_exec.js" ]; then - cp "$GOROOT/misc/wasm/wasm_exec.js" examples/wasm/ + cp "$GOROOT/misc/wasm/wasm_exec.js" examples/wasm/public/js/ echo "wasm_exec.js copied successfully from $GOROOT/misc/wasm/" else - echo "Warning: wasm_exec.js not found at $GOROOT/lib/wasm/wasm_exec.js or $GOROOT/misc/wasm/wasm_exec.js" - echo "Please copy it manually to examples/wasm/" + echo "Warning: wasm_exec.js not found" + exit 1 fi install: @@ -217,4 +217,73 @@ tasks: else echo "Error: Binary not found at $BINARY_PATH" exit 1 - fi \ No newline at end of file + fi + + example:announce: + desc: Run announce example + cmds: + - 'cd examples/announce && {{.GOCMD}} run .' + + example:minimal: + desc: Run minimal example + cmds: + - 'cd examples/minimal && {{.GOCMD}} run .' + + example:pageserver: + desc: Run pageserver example + cmds: + - 'cd examples/pageserver && {{.GOCMD}} run .' + + example:echo-listen: + desc: Run echo example (waits for incoming connections, P2P peer) + cmds: + - 'cd examples/echo && {{.GOCMD}} run . --server' + + example:echo-connect: + desc: Run echo example (initiates connection to peer, requires DESTINATION env var) + cmds: + - | + if [ -z "${DESTINATION}" ]; then + echo "Error: DESTINATION environment variable required (hexadecimal hash of peer)" + echo "Example: DESTINATION=abc123... task example:echo-connect" + exit 1 + fi + cd examples/echo && {{.GOCMD}} run . --destination="${DESTINATION}" + + example:link-listen: + desc: Run link example (waits for incoming link requests, P2P peer) + cmds: + - 'cd examples/link && {{.GOCMD}} run . --server' + + example:link-connect: + desc: Run link example (initiates link to peer, requires DESTINATION env var) + cmds: + - | + if [ -z "${DESTINATION}" ]; then + echo "Error: DESTINATION environment variable required (hexadecimal hash of peer)" + echo "Example: DESTINATION=abc123... task example:link-connect" + exit 1 + fi + cd examples/link && {{.GOCMD}} run . --destination="${DESTINATION}" + + example:filetransfer-share: + desc: Run filetransfer example (shares files from directory, P2P peer) + cmds: + - | + if [ -z "${SERVE_PATH}" ]; then + echo "Error: SERVE_PATH environment variable required (directory to share)" + echo "Example: SERVE_PATH=/path/to/files task example:filetransfer-share" + exit 1 + fi + cd examples/filetransfer && {{.GOCMD}} run . --server --serve="${SERVE_PATH}" + + example:filetransfer-fetch: + desc: Run filetransfer example (fetches files from peer, requires DESTINATION env var) + cmds: + - | + if [ -z "${DESTINATION}" ]; then + echo "Error: DESTINATION environment variable required (hexadecimal hash of peer)" + echo "Example: DESTINATION=abc123... task example:filetransfer-fetch" + exit 1 + fi + cd examples/filetransfer && {{.GOCMD}} run . --destination="${DESTINATION}"