diff options
Diffstat (limited to 'Biz/Ide')
-rwxr-xr-x | Biz/Ide/ftags.sh (renamed from Biz/Ide/ftags.bash) | 0 | ||||
-rwxr-xr-x | Biz/Ide/hoog.sh (renamed from Biz/Ide/hoog.bash) | 0 | ||||
-rwxr-xr-x | Biz/Ide/hooks/commit-msg.sh (renamed from Biz/Ide/hooks/commit-msg.bash) | 0 | ||||
-rwxr-xr-x | Biz/Ide/hooks/post-applypatch.sh (renamed from Biz/Ide/hooks/post-applypatch.bash) | 0 | ||||
-rwxr-xr-x | Biz/Ide/hooks/post-checkout.sh (renamed from Biz/Ide/hooks/post-checkout.bash) | 6 | ||||
-rwxr-xr-x | Biz/Ide/hooks/post-commit.sh (renamed from Biz/Ide/hooks/post-commit.bash) | 0 | ||||
-rwxr-xr-x | Biz/Ide/hooks/post-merge.sh (renamed from Biz/Ide/hooks/post-merge.bash) | 2 | ||||
-rwxr-xr-x | Biz/Ide/hooks/post-rewrite.sh (renamed from Biz/Ide/hooks/post-rewrite.bash) | 0 | ||||
-rwxr-xr-x | Biz/Ide/hooks/pre-auto-gc.sh (renamed from Biz/Ide/hooks/pre-auto-gc.bash) | 0 | ||||
-rwxr-xr-x | Biz/Ide/hooks/pre-commit.sh (renamed from Biz/Ide/hooks/pre-commit.bash) | 6 | ||||
-rwxr-xr-x | Biz/Ide/hooks/pre-push.sh (renamed from Biz/Ide/hooks/pre-push.bash) | 7 | ||||
-rwxr-xr-x | Biz/Ide/hooks/reference-transaction.sh (renamed from Biz/Ide/hooks/reference-transaction.bash) | 0 | ||||
-rwxr-xr-x | Biz/Ide/mktags.sh (renamed from Biz/Ide/mktags.bash) | 22 | ||||
-rwxr-xr-x | Biz/Ide/ns.sh (renamed from Biz/Ide/ns.bash) | 2 | ||||
-rwxr-xr-x | Biz/Ide/push.sh (renamed from Biz/Ide/push.bash) | 10 | ||||
-rwxr-xr-x | Biz/Ide/repl.sh (renamed from Biz/Ide/repl.bash) | 36 | ||||
-rwxr-xr-x | Biz/Ide/run.sh (renamed from Biz/Ide/run.bash) | 2 | ||||
-rwxr-xr-x | Biz/Ide/ship.bash | 23 | ||||
-rwxr-xr-x | Biz/Ide/ship.sh | 25 | ||||
-rwxr-xr-x | Biz/Ide/tidy.bash | 2 | ||||
-rwxr-xr-x | Biz/Ide/tidy.sh | 2 | ||||
-rwxr-xr-x | Biz/Ide/tips.bash | 13 | ||||
-rwxr-xr-x | Biz/Ide/tips.sh | 13 | ||||
-rwxr-xr-x | Biz/Ide/version.sh (renamed from Biz/Ide/version.bash) | 4 |
24 files changed, 88 insertions, 87 deletions
diff --git a/Biz/Ide/ftags.bash b/Biz/Ide/ftags.sh index 02d78c5..02d78c5 100755 --- a/Biz/Ide/ftags.bash +++ b/Biz/Ide/ftags.sh diff --git a/Biz/Ide/hoog.bash b/Biz/Ide/hoog.sh index 976f0d4..976f0d4 100755 --- a/Biz/Ide/hoog.bash +++ b/Biz/Ide/hoog.sh diff --git a/Biz/Ide/hooks/commit-msg.bash b/Biz/Ide/hooks/commit-msg.sh index 64e400d..64e400d 100755 --- a/Biz/Ide/hooks/commit-msg.bash +++ b/Biz/Ide/hooks/commit-msg.sh diff --git a/Biz/Ide/hooks/post-applypatch.bash b/Biz/Ide/hooks/post-applypatch.sh index 5071dc5..5071dc5 100755 --- a/Biz/Ide/hooks/post-applypatch.bash +++ b/Biz/Ide/hooks/post-applypatch.sh diff --git a/Biz/Ide/hooks/post-checkout.bash b/Biz/Ide/hooks/post-checkout.sh index 982cb4b..e4a0d67 100755 --- a/Biz/Ide/hooks/post-checkout.bash +++ b/Biz/Ide/hooks/post-checkout.sh @@ -1,16 +1,16 @@ #!/usr/bin/env bash set -e -mktags=${CODEROOT:?}/Biz/Ide/mktags +mktags=${CODEROOT:?}/Biz/Ide/mktags.sh old=$1 new=$2 # filter out only the changed haskell files -changed=($(git diff --diff-filter=d --name-only $old $new -- '*.hs')) +mapfile -t changed < <(git diff --diff-filter=d --name-only "$old" "$new" -- '*.hs') if [[ ! -r tags ]] || [[ ! -r TAGS ]] then $mktags "$CODEROOT"/**/* elif [[ ${#changed[@]} -gt 0 ]] then - $mktags $changed + $mktags "${changed[@]}" fi direnv reload ## START BRANCHLESS CONFIG diff --git a/Biz/Ide/hooks/post-commit.bash b/Biz/Ide/hooks/post-commit.sh index cd1f195..cd1f195 100755 --- a/Biz/Ide/hooks/post-commit.bash +++ b/Biz/Ide/hooks/post-commit.sh diff --git a/Biz/Ide/hooks/post-merge.bash b/Biz/Ide/hooks/post-merge.sh index 94f0f60..d2cfa63 100755 --- a/Biz/Ide/hooks/post-merge.bash +++ b/Biz/Ide/hooks/post-merge.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -exec ${CODEROOT:?}/Biz/Ide/hooks/post-checkout 'HEAD@{1}' HEAD +"${CODEROOT:?}"/Biz/Ide/hooks/post-checkout 'HEAD@{1}' HEAD ## START BRANCHLESS CONFIG git branchless hook post-merge "$@" diff --git a/Biz/Ide/hooks/post-rewrite.bash b/Biz/Ide/hooks/post-rewrite.sh index 8b3237a..8b3237a 100755 --- a/Biz/Ide/hooks/post-rewrite.bash +++ b/Biz/Ide/hooks/post-rewrite.sh diff --git a/Biz/Ide/hooks/pre-auto-gc.bash b/Biz/Ide/hooks/pre-auto-gc.sh index c92a844..c92a844 100755 --- a/Biz/Ide/hooks/pre-auto-gc.bash +++ b/Biz/Ide/hooks/pre-auto-gc.sh diff --git a/Biz/Ide/hooks/pre-commit.bash b/Biz/Ide/hooks/pre-commit.sh index 560eee7..e7c34ab 100755 --- a/Biz/Ide/hooks/pre-commit.bash +++ b/Biz/Ide/hooks/pre-commit.sh @@ -4,10 +4,10 @@ # - guard against lint errors ## set -e - changed=($(git diff-index --cached --name-only HEAD)) - for ns in ${changed[@]} + mapfile -t changed < <(git diff-index --cached --name-only HEAD) + for ns in "${changed[@]}" do - version=$(${CODEROOT:?}/Biz/Ide/version $ns) + version=$("${CODEROOT:?}"/Biz/Ide/version "$ns") if [[ $version -eq -1 ]]; then echo "info: version: $ns: deleted" elif [[ $version -lt 1 ]]; then diff --git a/Biz/Ide/hooks/pre-push.bash b/Biz/Ide/hooks/pre-push.sh index 5abd3ee..16f11d1 100755 --- a/Biz/Ide/hooks/pre-push.bash +++ b/Biz/Ide/hooks/pre-push.sh @@ -17,12 +17,11 @@ commit=$(git notes --ref=ci show HEAD || true) if [[ -n "$commit" ]] then - lint_ok=$() - if grep -q "Lint-is: good" <<< $commit + if grep -q "Lint-is: good" <<< "$commit" then exit 0 fi - if grep -q "Test-is: good" <<< $commit + if grep -q "Test-is: good" <<< "$commit" then exit 0 fi @@ -36,7 +35,7 @@ exit 1 fi ## - if bild ${BILD_ARGS:-""} --test "${CODEROOT:?}"/**/* + if bild "${BILD_ARGS:-""}" --test "${CODEROOT:?}"/**/* then test_result="good" else diff --git a/Biz/Ide/hooks/reference-transaction.bash b/Biz/Ide/hooks/reference-transaction.sh index ea0cce6..ea0cce6 100755 --- a/Biz/Ide/hooks/reference-transaction.bash +++ b/Biz/Ide/hooks/reference-transaction.sh diff --git a/Biz/Ide/mktags.bash b/Biz/Ide/mktags.sh index c83f319..aae1505 100755 --- a/Biz/Ide/mktags.bash +++ b/Biz/Ide/mktags.sh @@ -3,39 +3,39 @@ # script to generate tags automatically if there are none. # set -euo pipefail - files=$@ + files="$*" vimtags=${CODEROOT:?}/tags emacstags=${CODEROOT:?}/TAGS # if [[ ! -r $emacstags ]]; then echo Generating emacs TAGS from scratch... - fast-tags -e -R ${CODEROOT:?} + fast-tags -e -R "${CODEROOT:?}" ctags -e \ --append=yes \ --recurse=yes \ --exclude="$CODEROOT/_/*" \ - ${CODEROOT:?} + "${CODEROOT:?}" else - fast-tags -e $files + fast-tags -e "$files" ctags -e \ --append=yes \ --exclude="_/*" \ - $files + "$files" fi # if [[ ! -r $vimtags ]]; then echo Generating vim tags from scratch... - fast-tags "${flags[@]}" -R ${CODEROOT:?} - ctags "${flags[@]}" \ + fast-tags -R "${CODEROOT:?}" + ctags \ --append=yes \ --recurse=yes \ --exclude="${CODEROOT:?}/_/*" \ - ${CODEROOT:?} + "${CODEROOT:?}" else - fast-tags "${flags[@]}" $files - ctags "${flags[@]}" \ + fast-tags "$files" + ctags \ --append=yes \ --exclude="_/*" \ - $files + "$files" fi ## diff --git a/Biz/Ide/ns.bash b/Biz/Ide/ns.sh index e988bfe..555380e 100755 --- a/Biz/Ide/ns.bash +++ b/Biz/Ide/ns.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -euo pipefail -fd --exclude=_ -t f . ${CODEROOT:?} | sed "s,${CODEROOT:?}/*,,g" \ +fd --exclude=_ -t f . "${CODEROOT:?}" | sed "s,${CODEROOT:?}/*,,g" \ | fzf \ --bind "alt-space:execute(bild {} && read -p [fin])" \ --bind "alt-enter:execute(vim {})" \ diff --git a/Biz/Ide/push.bash b/Biz/Ide/push.sh index 2238e06..6729c2f 100755 --- a/Biz/Ide/push.bash +++ b/Biz/Ide/push.sh @@ -2,7 +2,7 @@ # Eventually convert to haskell, see: # - https://github.com/awakesecurity/nix-deploy/blob/master/src/Main.hs # - http://www.haskellforall.com/2018/08/nixos-in-production.html -prefix=$(echo $PWD | sed -e "s|^${CODEROOT:?}/*||g") +prefix=${PWD/$CODEROOT} if [[ "$prefix" == "" ]] then target="$1" @@ -13,7 +13,7 @@ what=$(realpath "${CODEROOT:?}/_/nix/$target") # hack: get the domain from the activation script. there does not seem # to be a way to get it from nix-instantiate where=$(rg -r '$2' -e '(domainname ")(.*)(")' "$what/activate") -nix copy --to ssh://root@$where $what -ssh root@$where $what/bin/switch-to-configuration switch -ssh root@$where nix-env --profile /nix/var/nix/profiles/system --set $what -printf "${GRN}good: push: $target${NC}\n" +nix copy --to ssh://root@"$where" "$what" +ssh root@"$where" "$what"/bin/switch-to-configuration switch +ssh root@"$where" nix-env --profile /nix/var/nix/profiles/system --set "$what" +echo "${GRN}good: push: $target${NC}" diff --git a/Biz/Ide/repl.bash b/Biz/Ide/repl.sh index a14b0b8..78fe1eb 100755 --- a/Biz/Ide/repl.bash +++ b/Biz/Ide/repl.sh @@ -24,20 +24,20 @@ fi CMD="bash" shift fi - targets=${@:?} - json=$(bild --plan ${targets[@]}) - langdeps=$(jq --raw-output '.[].langdeps | join(" ")' <<< $json) - sysdeps=$(jq --raw-output '.[].sysdeps | join(" ")' <<< $json) - rundeps=$(jq --raw-output '.[].rundeps | join(" ")' <<< $json) - exts=$(jq --raw-output '.[].namespace.ext' <<< $json | sort | uniq) - packageSet=$(jq --raw-output '.[].packageSet' <<< $json) - module=$(jq --raw-output '.[].mainModule' <<< $json) + targets="${*:?}" + json=$(bild --plan "${targets[@]}") + mapfile -t langdeps < <(jq --raw-output '.[].langdeps | select(length > 0) | join("\n")' <<< "$json") + mapfile -t sysdeps < <(jq --raw-output '.[].sysdeps | select(length > 0) | join("\n")' <<< "$json") + mapfile -t rundeps < <(jq --raw-output '.[].rundeps | select(length > 0) | join("\n")' <<< "$json") + exts=$(jq --raw-output '.[].namespace.ext' <<< "$json" | sort | uniq) + packageSet=$(jq --raw-output '.[].packageSet' <<< "$json") + module=$(jq --raw-output '.[].mainModule' <<< "$json") BILD="(import ${CODEROOT:?}/Biz/Bild.nix {})" - for lib in ${sysdeps[@]}; do + declare -a flags=(--packages "$BILD.pkgs.pkg-config") + for lib in "${sysdeps[@]}"; do flags+=(--packages "$BILD.pkgs.${lib}") - flags+=(--packages "$BILD.pkgs.pkg-config") done - for lib in ${rundeps[@]}; do + for lib in "${rundeps[@]}"; do flags+=(--packages "$BILD.pkgs.${lib}") done case $exts in @@ -49,18 +49,18 @@ fi if [ -z ${var+PORT} ]; then echo "warn: repl: ghci does not support binding to a port" fi - flags+=(--packages "$BILD.bild.haskell.ghcWith (h: with h; [$langdeps])") + flags+=(--packages "$BILD.bild.haskell.ghcWith (h: with h; [${langdeps[*]}])") command=${CMD:-"ghci -i${CODEROOT:?} -ghci-script ${CODEROOT:?}/.ghci ${targets[@]}"} ;; Scm) - for lib in ${langdeps[@]}; do + for lib in "${langdeps[@]}"; do flags+=(--packages "$BILD.guile-${lib}") done flags+=(--packages "$BILD.guile") command=${CMD:-"guile -L ${CODEROOT:?} -C ${CODEROOT:?}/_/int --r7rs --listen=${PORT:-37146}"} ;; Lisp) - flags+=(--packages "$BILD.bild.$packageSet (p: with p; [asdf swank $langdeps])") + flags+=(--packages "$BILD.bild.$packageSet (p: with p; [asdf swank ${langdeps[*]}])") command=${CMD:-"sbcl --eval '(require :asdf)' --eval '(require :swank)' --eval '(swank:create-server :port ${PORT:-4005})' --load $targets"} ;; Rs) @@ -68,15 +68,15 @@ fi command=bash ;; Py) - langdeps="$langdeps mypy" + langdeps+=("mypy") flags+=(--packages ruff) - flags+=(--packages "$BILD.bild.python.pythonWith (p: with p; [$langdeps])") + flags+=(--packages "$BILD.bild.python.pythonWith (p: with p; [${langdeps[*]}])") PYTHONPATH=$CODEROOT:$PYTHONPATH - pycommand="python -i $CODEROOT/Biz/Repl.py $module ${targets[@]}" + pycommand="python -i $CODEROOT/Biz/Repl.py $module ${targets[*]}" command=${CMD:-"$pycommand"} ;; *) - echo "unsupported targets: ${targets[@]}" + echo "unsupported targets: ${targets[*]}" exit 1 ;; esac diff --git a/Biz/Ide/run.bash b/Biz/Ide/run.sh index f7b9d36..8acb519 100755 --- a/Biz/Ide/run.bash +++ b/Biz/Ide/run.sh @@ -2,5 +2,5 @@ set -eu target=$1 shift -out=$(rg --only-matching ": out (\w*)" -r '$1' $target) +out=$(rg --only-matching ": out (\w*)" -r '$1' "$target") exec "${CODEROOT:?}/_/bin/$out" "$@" diff --git a/Biz/Ide/ship.bash b/Biz/Ide/ship.bash deleted file mode 100755 index 33197c8..0000000 --- a/Biz/Ide/ship.bash +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash -# -# ship <target>... -# -# lint, bild, test, and push one or more targets. if no targets are supplied, -# ship everything we know how to ship -## - set -eu - stuff=(${@}) - if [[ ${#stuff[@]} -eq 0 ]] - then - stuff=$(fd -t l . "$CODEROOT/_" \ - | fzf --multi \ - | sed "s,$CODEROOT/_/nix/,,g" - ) - fi - lint ${stuff[@]} - bild --test ${stuff[@]} - for thing in ${stuff[@]} - do - push $thing - done -## diff --git a/Biz/Ide/ship.sh b/Biz/Ide/ship.sh new file mode 100755 index 0000000..8783e9b --- /dev/null +++ b/Biz/Ide/ship.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# +# ship <target>... +# +# lint, bild, test, and push one or more targets. if no targets are supplied, +# ship everything we know how to ship +## + set -eu + stuff=("${@}") + if [[ ${#stuff[@]} -eq 0 ]] + then + mapfile -t stuff < <(fd -t l . "$CODEROOT/_/nix/" \ + | sed "s,$CODEROOT/_/nix/,,g" \ + | fzf --multi --prompt="ship _/nix/" \ + --preview="file $CODEROOT/_/nix/{}" \ + --preview-window=bottom,wrap + ) + fi + lint "${stuff[@]}" + bild --test "${stuff[@]}" + for thing in "${stuff[@]}" + do + push.sh "$thing" + done +## diff --git a/Biz/Ide/tidy.bash b/Biz/Ide/tidy.bash deleted file mode 100755 index ec666ba..0000000 --- a/Biz/Ide/tidy.bash +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -rm -f $CODEROOT/_/bin/* diff --git a/Biz/Ide/tidy.sh b/Biz/Ide/tidy.sh new file mode 100755 index 0000000..81a07c4 --- /dev/null +++ b/Biz/Ide/tidy.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +rm -f "$CODEROOT"/_/bin/* diff --git a/Biz/Ide/tips.bash b/Biz/Ide/tips.bash deleted file mode 100755 index ba458ac..0000000 --- a/Biz/Ide/tips.bash +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -echo "" -echo "bizdev" | figlet | lolcat -echo "" -echo " bild.bash compile code" -echo " repl.bash start a repl" -echo " deps.bash manage dependencies with niv" -echo " tips.bash show this message" -echo " lint.bash auto-lint all changed files" -echo " push.bash send a namespace to the cloud" -echo " ship.bash lint, bild, and push one (or all) namespace(s)" -echo " tidy.bash cleanup common working files" -echo "" diff --git a/Biz/Ide/tips.sh b/Biz/Ide/tips.sh new file mode 100755 index 0000000..895e54e --- /dev/null +++ b/Biz/Ide/tips.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +echo "" +echo "bizdev" | figlet | lolcat +echo "" +echo " bild.sh compile code" +echo " repl.sh start a repl" +echo " deps.sh manage dependencies with niv" +echo " tips.sh show this message" +echo " lint.sh auto-lint all changed files" +echo " push.sh send a namespace to the cloud" +echo " ship.sh lint, bild, and push one (or all) namespace(s)" +echo " tidy.sh cleanup common working files" +echo "" diff --git a/Biz/Ide/version.bash b/Biz/Ide/version.sh index 5b017d9..60f9c91 100755 --- a/Biz/Ide/version.bash +++ b/Biz/Ide/version.sh @@ -4,11 +4,11 @@ ## ns=$1 if [[ -e "$1" ]]; then - commits=$(git log --oneline --follow $ns | wc -l) + commits=$(git log --oneline --follow "$ns" | wc -l) # gold melts at 1337 kelvin, so we start with this # bc we are forging gold here version=$(bc -l <<< "1337 - $commits") - echo $version + echo "$version" else echo -1 # signal that file doesn't exist fi |