forked from coast-guard/coasts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev_setup.sh
More file actions
executable file
·98 lines (84 loc) · 3.02 KB
/
dev_setup.sh
File metadata and controls
executable file
·98 lines (84 loc) · 3.02 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env bash
# dev_setup.sh — set up coast-dev and coastd-dev for local development.
#
# Builds the workspace in debug mode and creates symlinks in ~/.local/bin
# so you can run `coast-dev` and `coastd-dev` directly from any terminal.
#
# Usage:
# ./dev_setup.sh # build debug + symlink
# ./dev_setup.sh --release # build release + symlink
#
# After running this, add ~/.local/bin to your PATH if it isn't already:
# export PATH="$HOME/.local/bin:$PATH"
set -euo pipefail
PROFILE="debug"
CARGO_FLAGS=""
if [[ "${1:-}" == "--release" ]]; then
PROFILE="release"
CARGO_FLAGS="--release"
fi
REPO_ROOT="$(cd "$(dirname "$0")" && pwd)"
BIN_DIR="$HOME/.local/bin"
TARGET_DIR="$REPO_ROOT/target/$PROFILE"
# Build the web UI (embedded into the daemon at compile time via rust-embed)
echo "Building coast-guard UI..."
(cd "$REPO_ROOT/coast-guard" && npm install --silent)
# Regenerate TypeScript types from Rust structs + build the barrel file.
# The .ts files are generated by `cargo test -p coast-core export_bindings`;
# the barrel index.ts is needed for the build to succeed.
echo "Generating TypeScript types..."
(cd "$REPO_ROOT" && cargo test -p coast-core export_bindings -- --quiet 2>/dev/null || true)
(cd "$REPO_ROOT/coast-guard/src/types/generated" \
&& ls *.ts 2>/dev/null | sort | grep -v index.ts | sed 's/\.ts$//' \
| awk '{print "export type { " $0 " } from \"./" $0 "\";"}' > index.ts)
(cd "$REPO_ROOT/coast-guard" && npm run build)
echo "Building workspace ($PROFILE)..."
cargo build --workspace $CARGO_FLAGS
mkdir -p "$BIN_DIR"
# Symlink the dev binaries
for bin in coast-dev coastd-dev; do
src="$TARGET_DIR/$bin"
dest="$BIN_DIR/$bin"
if [[ ! -f "$src" ]]; then
echo "error: $src not found — build may have failed" >&2
exit 1
fi
ln -sf "$src" "$dest"
echo " $dest -> $src"
done
# Ensure ~/.local/bin is in PATH — append to shell profile if needed
if ! echo "$PATH" | tr ':' '\n' | grep -qx "$BIN_DIR"; then
LINE='export PATH="$HOME/.local/bin:$PATH"'
# Pick the right shell profile
SHELL_NAME="$(basename "$SHELL")"
case "$SHELL_NAME" in
zsh) RC="$HOME/.zshrc" ;;
bash)
if [[ -f "$HOME/.bash_profile" ]]; then
RC="$HOME/.bash_profile"
else
RC="$HOME/.bashrc"
fi
;;
*) RC="$HOME/.profile" ;;
esac
if ! grep -qF '.local/bin' "$RC" 2>/dev/null; then
echo "" >> "$RC"
echo "# Added by coasts dev_setup.sh" >> "$RC"
echo "$LINE" >> "$RC"
echo "Added ~/.local/bin to PATH in $RC"
fi
echo ""
echo "Restart your shell or run:"
echo ""
echo " source $RC"
echo ""
else
echo ""
echo "Done. You can now run:"
echo " coastd-dev --foreground # start the dev daemon"
echo " coast-dev daemon start # or start it in the background"
echo " coast-dev ls # use the dev CLI"
fi
echo ""
echo "Dev mode uses ~/.coast-dev/ and port 31416 — no conflicts with a global coast install."