-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathrun_viewer.sh
More file actions
executable file
·67 lines (50 loc) · 2.12 KB
/
Copy pathrun_viewer.sh
File metadata and controls
executable file
·67 lines (50 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env bash
# Build the evtx-wasm crate for the browser target and start the viewer dev server.
#
# Usage:
# ./run_viewer.sh # builds in release mode (optimised) and starts Vite
# ./run_viewer.sh --debug # builds with debug symbols for easier tracing
#
# NOTE: Requires `wasm-pack`, `bun` (or npm/yarn) and Vite installed.
set -euo pipefail
# -------- settings ----------
CRATE_DIR="evtx-wasm" # Rust crate path (relative to repo root)
VIEWER_DIR="evtx-wasm/evtx-viewer" # React viewer path
VIEWER_WASM_DIR="$VIEWER_DIR/src/wasm" # Where the TS code expects the generated bindings
OUT_NAME="evtx_wasm" # Base filename for the generated JS/WASM artefacts
# ----------------------------
MODE="release"
if [[ ${1:-} == "--debug" || ${1:-} == "-d" ]]; then
MODE="debug"
shift
fi
echo "📦 Building WASM in $MODE mode..."
# Clean previous artefacts so we never serve stale code
rm -rf "$VIEWER_WASM_DIR"
rm -rf "$VIEWER_DIR/public/pkg" # remove old public/pkg if present
mkdir -p "$VIEWER_WASM_DIR"
# Convert to an absolute path so it stays valid after we cd into the crate dir
ABS_VIEWER_WASM_DIR="$(cd "$(dirname "$VIEWER_WASM_DIR")" && pwd)/$(basename "$VIEWER_WASM_DIR")"
pushd "$CRATE_DIR" >/dev/null
BUILD_FLAGS=(
--target web # generate browser-compatible bindings
--out-dir "$ABS_VIEWER_WASM_DIR" # place them where the viewer imports from
--out-name "$OUT_NAME" # keep filenames stable
)
if [[ "$MODE" == "debug" ]]; then
wasm-pack build "${BUILD_FLAGS[@]}" --debug
else
wasm-pack build "${BUILD_FLAGS[@]}" --release
fi
popd >/dev/null
echo "✅ WASM build complete – artefacts are in $ABS_VIEWER_WASM_DIR"
echo "🚀 Starting Vite dev server... (press Ctrl+C to stop)"
pushd "$VIEWER_DIR" >/dev/null
# Ensure JS/TS deps are installed (cheap if already up-to-date)
# Make sample available
mkdir -p "$VIEWER_DIR/public/samples"
ln -sf "$(pwd)/samples/security.evtx" "$VIEWER_DIR/public/samples/security.evtx"
bun install
# Forward any leftover CLI args to the dev server (e.g. --open, --host)
bun run dev "$@"
popd >/dev/null