7a7b2490c2
- justfile: add build-linux, build-windows, build-all (output to dist/) - .gitignore: cover ctask, ctask-*, dist/ - scripts/install.sh + scripts/uninstall.sh: POSIX equivalents of .ps1 - remove WorkspacePath metadata field (no production readers; legacy task.yaml files continue to parse silently) Linux smoke-test on WSL/container pending. See audit-report.md and v0.5.1-spec.md.
96 lines
2.9 KiB
Bash
96 lines
2.9 KiB
Bash
#!/bin/sh
|
|
# Install ctask to ~/.local/bin on Linux (or pass an alternative directory as $1).
|
|
# Builds ctask from the local repo, copies the binary and bash status-line helper
|
|
# to the install directory, and warns if the directory is not on $PATH.
|
|
# Does not modify workspace data. Does not modify shell config.
|
|
|
|
set -eu
|
|
|
|
INSTALL_DIR="${1:-$HOME/.local/bin}"
|
|
|
|
# Find repo root (script lives in scripts/)
|
|
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
REPO_ROOT=$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd)
|
|
|
|
if [ ! -f "$REPO_ROOT/go.mod" ]; then
|
|
printf 'Error: cannot find go.mod at %s. Run this script from the ctask repo.\n' "$REPO_ROOT" >&2
|
|
exit 1
|
|
fi
|
|
|
|
printf 'ctask install\n'
|
|
printf ' Source: %s\n' "$REPO_ROOT"
|
|
printf ' Target: %s\n' "$INSTALL_DIR"
|
|
printf '\n'
|
|
|
|
# Step 1: find go
|
|
if ! command -v go >/dev/null 2>&1; then
|
|
printf 'Error: Go not found on PATH. Install Go 1.26+ and ensure it is on PATH.\n' >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Step 2: build (host platform; on WSL/Linux this produces a Linux binary named "ctask")
|
|
printf 'Building ctask... '
|
|
if ! ( cd "$REPO_ROOT" && go build -o ctask ./ ); then
|
|
printf 'FAILED\n'
|
|
exit 1
|
|
fi
|
|
printf 'OK\n'
|
|
|
|
# Step 3: ensure install dir exists
|
|
if [ ! -d "$INSTALL_DIR" ]; then
|
|
mkdir -p "$INSTALL_DIR"
|
|
printf ' Created %s\n' "$INSTALL_DIR"
|
|
fi
|
|
|
|
# Step 4: copy binary and statusline helper
|
|
install_file() {
|
|
src=$1
|
|
dst=$2
|
|
if [ -f "$src" ]; then
|
|
cp -f "$src" "$dst"
|
|
chmod 0755 "$dst"
|
|
printf ' Installed %s\n' "$(basename "$dst")"
|
|
else
|
|
printf ' Warning: source not found: %s\n' "$src" >&2
|
|
fi
|
|
}
|
|
|
|
install_file "$REPO_ROOT/ctask" "$INSTALL_DIR/ctask"
|
|
install_file "$REPO_ROOT/scripts/ctask-statusline.sh" "$INSTALL_DIR/ctask-statusline.sh"
|
|
|
|
# Step 5: PATH check (do not modify shell config; warn with the right snippet)
|
|
case ":${PATH:-}:" in
|
|
*":$INSTALL_DIR:"*)
|
|
printf '\n PATH: already contains %s\n' "$INSTALL_DIR"
|
|
;;
|
|
*)
|
|
printf '\n PATH: %s is not on $PATH\n' "$INSTALL_DIR"
|
|
shell_name=$(basename "${SHELL:-/bin/sh}")
|
|
case "$shell_name" in
|
|
zsh)
|
|
printf ' Add this to ~/.zshrc:\n export PATH="%s:$PATH"\n' "$INSTALL_DIR"
|
|
;;
|
|
bash)
|
|
printf ' Add this to ~/.bashrc (or ~/.bash_profile on macOS):\n export PATH="%s:$PATH"\n' "$INSTALL_DIR"
|
|
;;
|
|
*)
|
|
printf ' Add the following to your shell config:\n export PATH="%s:$PATH"\n' "$INSTALL_DIR"
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|
|
|
|
# Step 6: verify
|
|
if [ -x "$INSTALL_DIR/ctask" ]; then
|
|
ver=$("$INSTALL_DIR/ctask" --version 2>/dev/null || echo unknown)
|
|
printf '\nInstalled: %s\n' "$ver"
|
|
else
|
|
printf 'Warning: binary not found at %s/ctask\n' "$INSTALL_DIR" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Step 7: clean up build artifact in repo root
|
|
rm -f "$REPO_ROOT/ctask"
|
|
|
|
printf "\nRun 'ctask doctor' in a new terminal to verify setup.\n"
|