Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config-helper: fix edge cases #250

Merged
merged 34 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
be4b3ce
WIP: gawk+gsed bottles, build_(install|uninstall), 1password stable i…
balupton Aug 28, 2024
ada62e0
WIP: config-helper: improved strategy for multi instances
balupton Sep 3, 2024
6860035
WIP: fix config-helper tests
balupton Sep 13, 2024
d86e060
WIP: move all deno scripts to .ts files, allow their discovery, prep …
balupton Sep 13, 2024
2b24208
WIP: same package.json on deno scripts, try a different technique: ht…
balupton Sep 13, 2024
1fdae98
WIP: be specific about gnu command fallbacks
balupton Sep 13, 2024
4506b7f
get-installer: remove unnecessary regex complexity
balupton Sep 13, 2024
6618689
echo-regexp.ts: support passing flags directly
balupton Sep 13, 2024
7022dba
WIP: initial pass of migrating gsed/gsed/ripgrep/sd/grep to echo-regexp
balupton Sep 15, 2024
fe5050b
partially fix and debug unziptar on alpine
balupton Sep 15, 2024
0e02dc9
don't use official yet stupid deno_install script
balupton Sep 15, 2024
7c7265d
more linting and fixes re regexp, deno, unziptar
balupton Sep 15, 2024
bb507bd
fix trash error on alpine, as trash is n/a
balupton Sep 15, 2024
818d5c0
command-working: give details on failure, setup-util-deno: update for…
balupton Sep 15, 2024
b91656b
setup-util-deno: disable snap to try fix perm issues
balupton Sep 15, 2024
96d91bc
setup-util-deno: try --classic on deno snap, as removing snap solved …
balupton Sep 15, 2024
6838a37
setup-util-deno: use deno from apk edge, document snap --classic works
balupton Sep 15, 2024
7c7ed59
echo-regexp.ts: fix for alpine linux
balupton Sep 15, 2024
a1f96ea
bash v3 compat
balupton Sep 15, 2024
2e4d9da
echo-regexp: add tests
balupton Sep 15, 2024
e2294c4
deno: try to fix (os error 13) on ubuntu
balupton Sep 15, 2024
2a83b20
deno: same (os error 13) failure on ubuntu, disabling snap earlier fi…
balupton Sep 15, 2024
da3cf12
setup-util-deno: uninstall snap, as --classic is ignored
balupton Sep 15, 2024
d334b8f
dorothy-workflow: don't test PRs until review requested
balupton Sep 16, 2024
86de699
updates for cross operating system compat
balupton Sep 16, 2024
35593fe
echo-math: don't use awk, it is too fragile, use deno as bc fallback …
balupton Sep 16, 2024
62d42ca
improve get-installer --invoke usage, implement echo-(html|url)-coder
balupton Sep 16, 2024
c723ea2
add .gitattributes from bevry/base to attempt fix #249
balupton Sep 16, 2024
e68e2e0
setup-util-gawk: disable bottle and building on macos
balupton Sep 16, 2024
7deab4e
echo-wrap: awk/mawk compat
balupton Sep 16, 2024
ecee164
dorothy-config: fix tests, restore output revised items
balupton Sep 16, 2024
7cc4031
fix lint issues, move unused commands to beta
balupton Sep 16, 2024
e035a22
command-working: add dash to exceptions
balupton Sep 16, 2024
e9a955a
small fixes with recent regexp changes:
balupton Sep 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# 2024 January 3
# https://github.com/bevry/base

# never modify any line ending in any file, disregarding all nonsense from eol, autocrlf, renormalize, safecrlf, usecrlfattr, allBinary
* -text

# =====================================
# CUSTOM
22 changes: 13 additions & 9 deletions .github/workflows/dorothy-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# don't use [shell: bash] unless needed, as for macos-fresh that caused an infinite queue for the test step, and for linux bash may not exist yet
# https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
name: dorothy-workflow
'on':
on:
- push
- pull_request
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
login-shells-and-linting:
if: github.event_name == 'push' || ( github.event_name == 'pull_request' && (toJSON(github.event.pull_request.requested_reviewers) != '[]' || toJSON(github.event.pull_request.requested_teams) != '[]' ) )
runs-on: ubuntu-latest
steps:
- name: 'Dorothy Install'
Expand Down Expand Up @@ -39,17 +40,17 @@ jobs:
- name: 'Dorothy Login Shell: bash'
shell: bash -leo pipefail {0}
run: |
command-exists dorothy
command-exists -- dorothy
echo-style --success='ok'
- name: 'Dorothy Login Shell: zsh'
shell: zsh -l {0}
run: |
command-exists dorothy
command-exists -- dorothy
echo-style --success='ok'
- name: 'Dorothy Login Shell: fish'
shell: fish -l {0}
run: |
command-exists dorothy
command-exists -- dorothy
echo-style --success='ok'
- name: 'Dorothy Login Shell: nu'
shell: nu -l {0}
Expand All @@ -58,7 +59,7 @@ jobs:
# source '/Users/runner/Library/Application Support/nushell/login.nu' # macos
source '/home/runner/.config/nushell/login.nu' # linux
# continue as normal
command-exists dorothy
command-exists -- dorothy
echo-style --success='ok'
- name: 'Dorothy Login Shell: xonsh'
env:
Expand All @@ -69,7 +70,7 @@ jobs:
CC: '' #fix: https://github.com/bevry/dorothy/actions/runs/7538922544/job/20520381661#step:8:13
shell: xonsh -DXONSH_SHOW_TRACEBACK=True -l {0}
run: |
command-exists dorothy
command-exists -- dorothy
echo-style --success='ok'
- name: 'Dorothy Login Shell: elvish'
shell: elvish {0}
Expand All @@ -78,17 +79,17 @@ jobs:
# for details see: https://github.com/elves/elvish/issues/1726
eval (cat '/home/runner/.local/share/dorothy/init.elv' | slurp)
# continue as normal
command-exists dorothy
command-exists -- dorothy
echo-style --success='ok'
- name: 'Dorothy Login Shell: dash'
shell: dash -l {0}
run: |
command-exists dorothy
command-exists -- dorothy
echo-style --success='ok'
- name: 'Dorothy Login Shell: ksh'
shell: ksh -l {0}
run: |
command-exists dorothy
command-exists -- dorothy
echo-style --success='ok'
- name: 'Trunk Format'
if: github.event_name == 'push'
Expand All @@ -111,6 +112,7 @@ jobs:
run: dorothy check
# https://github.com/actions/runner-images?tab=readme-ov-file#available-images
runner-test:
if: github.event_name == 'push' || ( github.event_name == 'pull_request' && (toJSON(github.event.pull_request.requested_reviewers) != '[]' || toJSON(github.event.pull_request.requested_teams) != '[]' ) )
strategy:
fail-fast: false
matrix:
Expand All @@ -125,6 +127,7 @@ jobs:
# ensure dorothy is cloned, and run command
bash -c "$(curl -fsSL 'https://dorothy.bevry.me/run?slug=${{ github.repository }}&commit=${{ github.event.pull_request.head.sha || github.sha }}')" -- dorothy test
fresh-macos-test:
if: github.event_name == 'push' || ( github.event_name == 'pull_request' && (toJSON(github.event.pull_request.requested_reviewers) != '[]' || toJSON(github.event.pull_request.requested_teams) != '[]' ) )
strategy:
fail-fast: false
matrix:
Expand All @@ -142,6 +145,7 @@ jobs:
# ensure dorothy is cloned, and run command
bash -c "$(curl -fsSL 'https://dorothy.bevry.me/run?slug=${{ github.repository }}&commit=${{ github.event.pull_request.head.sha || github.sha }}')" -- dorothy test
container-test:
if: github.event_name == 'push' || ( github.event_name == 'pull_request' && (toJSON(github.event.pull_request.requested_reviewers) != '[]' || toJSON(github.event.pull_request.requested_teams) != '[]' ) )
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down
4 changes: 2 additions & 2 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ plugins:
runtimes:
enabled:
- go@1.21.0
- node@18.12.1
- python@3.10.8
# - node@18.12.1 <-- there's only a single Node.js file: echo-url-coder.js
actions:
disabled:
- trunk-announce
Expand All @@ -23,7 +23,6 @@ lint:
- actionlint@1.6.27
- black@24.3.0
- checkov@3.2.48
- eslint@8.57.0
- flake8@7.0.0
- git-diff-check@SYSTEM
- gitleaks@8.18.2
Expand All @@ -37,6 +36,7 @@ lint:
- trufflehog@3.71.0
- yamllint@1.35.1
disabled:
- eslint # it can't find the bevry config extensions for some reason
- trivy
- oxipng # broken for some reason on my mac mini
ignore:
Expand Down
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"codezombiech.gitignore",
"editorconfig.editorconfig",
"jeff-hykin.better-shellscript-syntax",
"luggage66.awk",
"sidneys1.gitconfig",
"skyapps.fish-vscode",
"streetsidesoftware.code-spell-checker",
Expand Down
3 changes: 2 additions & 1 deletion .vscode/workspace.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"Xonsh",
"Zsh",
"Bevry"
]
],
"deno.enable": true
}
}
5 changes: 3 additions & 2 deletions commands.beta/convert-helper
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,11 @@ function convert_helper() (
filename="$(fs-filename -- "$path")"
extension="$(fs-extension -- "$path")"
if test -n "$option_timestamp"; then
# prefix filename with timestamp
if test "$option_timestamp" = 'yes'; then
filename="$(date-helper --8601 | sd ':' '-') $filename"
filename="$(date-helper --8601 | echo-regexp -g ':' '-') $filename"
else
filename="$(date-helper --8601 | sd ':' '-') $option_timestamp"
filename="$(date-helper --8601 | echo-regexp -g ':' '-') $option_timestamp"
fi
cp "$path" "$filename.$extension"
path="$filename.$extension"
Expand Down
2 changes: 1 addition & 1 deletion commands.beta/echo-exit-status
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function echo_exit_status() (

local cmd_status
eval_capture --statusvar=cmd_status -- "${cmd[@]}"
__print_line "$cmd_status"
__print_lines "$cmd_status"
)

# fire if invoked standalone
Expand Down
7 changes: 7 additions & 0 deletions commands.beta/echo-html-coder.recode
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# recode decoding fails with: recode: Untranslatable input in step `ISO-10646-UCS-2..ANSI_X3.4-1968'
if test "$1" = 'decode'; then
recode html..ascii <<<"$2"
else
recode ascii..html <<<"$2"
fi
7 changes: 7 additions & 0 deletions commands.beta/echo-html-coder.textutil
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# this doesn't work as expected
if test "$1" = 'decode'; then
textutil -convert html -format txt -inputencoding UTF-8 -stdin -stdout <<<"$2"
else
textutil -convert txt -format html -inputencoding UTF-8 -stdin -stdout <<<"$2"
fi
7 changes: 7 additions & 0 deletions commands.beta/echo-html-coder.xmlstarlet
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# xmlstarlet is too old to be available
if test "$1" = 'decode'; then
xmlstarlet unesc "$2"
else
xmlstarlet esc "$1"
fi
2 changes: 1 addition & 1 deletion commands.beta/echo-if-directory
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function echo_if_directory() (

function on_input {
if test -n "$1" -a -d "$1"; then
__print_line "$1"
__print_lines "$1"
fi
}

Expand Down
4 changes: 2 additions & 2 deletions commands.beta/echo-if-empty
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ function echo_if_empty() (
my-fallback-value
# exit status: 0

echo | echo-if-empty 'my-fallback-value'
echo | echo-if-empty 'my-fallback-value' --stdin

my-fallback-value
# exit status: 0

echo 'a-value' | echo-if-empty 'my-fallback-value'
echo 'a-value' | echo-if-empty 'my-fallback-value' --stdin

'a-value'
# exit status: 0
Expand Down
2 changes: 1 addition & 1 deletion commands.beta/echo-if-executable
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function echo_if_executable() (

function on_input {
if test -n "$1" -a -x "$1"; then
__print_line "$1"
__print_lines "$1"
fi
}

Expand Down
2 changes: 1 addition & 1 deletion commands.beta/echo-if-path
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function echo_if_path() (

function on_input {
if is-present -- "$1"; then
__print_line "$1"
__print_lines "$1"
fi
}

Expand Down
2 changes: 1 addition & 1 deletion commands.beta/echo-nonflags
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function echo_nonflags() (

function on_input {
if [[ $1 != -* ]]; then
__print_line "$1"
__print_lines "$1"
fi
}

Expand Down
2 changes: 1 addition & 1 deletion commands.beta/echo-numeric
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function echo_numeric() (
local had_an_invalid_input=no
function on_input {
if is-number -- "$1"; then
__print_line "$1"
__print_lines "$1"
else
echo-style --error="[$1] is not a number" >/dev/stderr
had_an_invalid_input=yes
Expand Down
2 changes: 1 addition & 1 deletion commands.beta/echo-sort
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function echo_sort() (
}
# and sort once we have all of them
function on_finish {
echo-lines -- "${inputs[@]}" | sort
__print_lines "${inputs[@]}" | sort
}

stdinargs "$@"
Expand Down
8 changes: 8 additions & 0 deletions commands.beta/echo-url-coder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env php
<?php
# space is turned to +, not %20
if ( $argv[1] == "decode" ) {
printf("%s\n", urldecode($argv[2]));
} else {
printf("%s\n", urlencode($argv[2]));
}
2 changes: 1 addition & 1 deletion commands.beta/echo-values
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function echo_values() (

function on_input {
if is-value -- "$1"; then
__print_line "$1"
__print_lines "$1"
fi
}

Expand Down
8 changes: 4 additions & 4 deletions commands.beta/edit-dns
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ function edit_dns() (
# edit /etc/resolv.conf

if get-app --quiet -- 'ProtonVPN'; then
__print_line 'ProtonVPN enforces its own DNS'
elif command-exists dnscrypt-proxy; then
__print_line 'Editing DNS configuration of dnscrypt-proxy'
__print_lines 'ProtonVPN enforces its own DNS'
elif command-exists -- dnscrypt-proxy; then
__print_lines 'Editing DNS configuration of dnscrypt-proxy'
edit --wait -- "${HOMEBREW_PREFIX:-"/usr/local"}/etc/dnscrypt-proxy.toml"
else
__print_line 'DNS editing only supported for dnscrypt-proxy'
__print_lines 'DNS editing only supported for dnscrypt-proxy'
fi
)

Expand Down
8 changes: 4 additions & 4 deletions commands.beta/ensure-trailing-slash
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ function ensure_trailing_slash() (
for path in "${option_paths[@]}"; do
if test -d "$path"; then
if [[ $path != */ ]]; then
__print_line "$path/"
__print_lines "$path/"
else
__print_line "$path"
__print_lines "$path"
fi
elif test -f "$path"; then
if [[ $path == */ ]]; then
length="${#path}"
__print_line "${path:0:length-1}"
__print_lines "${path:0:length-1}"
else
__print_line "$path"
__print_lines "$path"
fi
else
echo-style --error='Not a file nor directory:' ' ' --code="$path" >/dev/stderr
Expand Down
Loading
Loading