feat(cli): dsh CLI with personal config overlays from ~/.config/dsh

This commit is contained in:
Turtle
2026-07-22 10:55:17 +08:00
parent a2f17d71ed
commit 6baa030594
17 changed files with 450 additions and 6 deletions

22
bin/dsh Executable file
View File

@@ -0,0 +1,22 @@
#!/bin/sh
# dsh launcher: runs the apps/cli `dsh` bin FROM SOURCE with this checkout's
# tsx, so a symlink from anywhere (e.g. ~/.local/bin/dsh) always executes the
# current working tree — code changes apply on the next launch, no build step.
# --expose-internals: the shipped config mounts HMR, which needs Loader internals.
set -eu
# Resolve symlink chains without readlink -f (not on every macOS).
script=$0
while [ -L "$script" ]; do
target=$(readlink "$script")
case $target in
/*) script=$target ;;
*) script=$(dirname "$script")/$target ;;
esac
done
root=$(CDPATH='' cd -- "$(dirname -- "$script")/.." && pwd)
# tsx is imported by absolute path because bare `--import tsx` resolves from
# the invoking cwd, which is usually outside this repository.
export TSX_TSCONFIG_PATH="$root/tsconfig.json"
exec node --expose-internals --import "$root/node_modules/tsx/dist/loader.mjs" "$root/apps/cli/src/bin.ts" "$@"