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

config-helper: fix edge cases #250

merged 34 commits into from
Sep 17, 2024

Conversation

balupton
Copy link
Member

@balupton balupton commented Sep 3, 2024

/close #249 #241 #239

changes:

  • replace common gsed/sed/sd/ripgrep/rg/grep/teip usage with new echo-regexp that uses deno, affects convert-helper, config-helper, echo-magnet-hash, fs-(bytes|kilobytes|megabytes), fs-speed, get-devices, get-local-to-remote, get-opensuse-release, get-volumes, git-helper, is-bash-version-outdated, mount-helper, network-interface, setup-dns, setup-util, setup-util-1password-cli, setup-util-nerd-fonts, setup-util-node, unziptar, what-is-my-(dns|gateway|interface|ip|submit), get-codec, is-prefix, is-suffix, itunes-owners, mac-address-helper, setup-server
  • bash.bash:
    • simplify eval statements and support spaces in paths
    • add explicit names for __print* helpers, and slightly change their functionality to be aligned with expectations
      • please change __print_line ... to __print_lines ... as in the future __print_line may not support arguments
    • removed deprecated non __ prefixed aliases, e.g. require_globstar is now only __require_globstar
  • ci/dorothy-workflow: don't test PRs until review requested
  • ci/dorothy: don't eslint as no Node.js code
  • ci/vscode: add an awk syntax highlighting extension, and enable Deno
  • command-working: give details of failures, add dash to exceptions
  • dorothy-config/config-helper: significant work to better handle multiple instances (result is no longer garbled), output and process is now clearer, includes multiple strategies for multiple instances, uses new echo-regexp to replace sd/rg/teip/grep combo
  • dorothy minimum deps now only jq and denos,
  • down: add --url=... support
  • echo-gnu-command: fix it not outputting the command after installation
  • echo-if-empty/get-devices/get-local-to-remote: fix sporadic success by adding missing --stdin
  • echo-lines: now support --[no-]quote flags as alias for prior --[no-]quoted flag
  • echo-math/echo-(html|url)-(encode|decode): rewrote and added tests, now they work correctly, in the latter case echo-(html|url)-coder is now used
  • echo-wrap: now awk compatible, removing dependency on gawk
  • eval-tester: output escaped comparison if special characters were used
  • fs-(bytes|kilobytes|megabytes): use dust instead of du to achieve macos support, also fix crash in fs-megabytes
  • fs-rm: fix trash error on alpine, as trash isn't available on alpine
  • get-codec: removed --trim and made it default (prior verbosity available via --verbose), now sensible error if ffprobe is not available
  • get-codec: rewrote and fixed
  • get-filesystem: no longer fail silently when no args are provided
  • get-local-to-remote: improve styling
  • get-opensuse-release: simpler technique
  • get-url-(domain|protocol) split into get-url-(domain|protocol).ts and add tests
  • is-match: deprecated and moved in beta commands, as it is replaced by echo-regexp -q which it now uses internally
  • mac-address-helper: fixed broken new functionality, and improved formatting of outputs
  • set-hostname/setup-hosts/setup-shell: fix break when gsed isn't available, now uses the echo-gnu-command helper
  • setup-util-1password: install stable instead of beta, as stable is now stable
  • setup-util-deno: add apk, uninstall snap (as snap does not allow script execution), use official arm builds as that is now a thing, don't use official yet stupid deno_install script
  • setup-util-devel: add automake for macos
  • setup-util-gawk: add more package systems
  • setup-util-gsed: add bottles for macos, and add uninstall build support
  • setup-util: rename DOWNLOAD_BUILD_EVAL to DOWNLOAD_BUILD_INSTALL and add DOWNLOAD_BUILD_UNINSTALL, affected setup-util-bash, setup-util-gawk, setup-util-gsed
  • sparse-vault: fix broken awk script, use echo-regexp instead
  • sparse-vault: fix broken macos version fetching
  • styles.bash make code styles more readable on light theme by swapping from dim to intense black, add code error, info, and notice styles
  • unziptar: fix alpine compatibility
  • what-is-my-(dns|gateway|inteface|ip|subnet): rewrote and fixed
  • add .gitattributes to prevent formatting issues in tests
  • add echo-escape-backslashes and remove its functionality from echo-escape-regexp-replacement for compat with JavaScript Regular Expression
  • add fs-diff to compute differences between files
  • add get-file and setup-util-file to fix unziptar compat on systems without file preinstalled
  • add setup-util-frawk
  • add tests to echo-math, echo-(html|url)-(coder|encode|decode), echo-magnet-hash, fs-(bytes|kilobytes|megabytes), get-url-(domain|protocol)

needs more testing:

  • get-opensuse-release
  • mount-helper
  • setup-dns
  • setup-server
  • setup-util-gsed on fresh macos
  • unziptar on macos dmg files

squashes:

- replace rg/sd/teip combo with new `echo-regexp` that uses deno
- use new `fs-diff` for showing diffs based on multi strategy
- add new styling
- enable deno in vscode

todos:

- fix tests
- remove lingering sd/rg/teip references
@balupton balupton force-pushed the dev/gawk-bottle branch 4 times, most recently from 77a5358 to 1a385f0 Compare September 13, 2024 01:25
- config-helper: instead of removing a line by replacing it with its indentation, it is now removed, as per the prior expectation
- add `echo-escape-backslashes` and remove it from `echo-escape-regexp-replacement` for compat with JavaScript Regular Expressions
- update some `bash.bash` deprecations
- bash.bash: add explicit names for `__print*` helpers, and slightly change their functionality to be aligned with expectations
@balupton
Copy link
Member Author

balupton commented Sep 13, 2024

There's a few strange edge cases that I'm not sure on what solution I should go with.

The main one is whether config-helper should remove lines, as it did before, or only replace lines (with empty/indented line if removing). I originally had the rewrite do empty/indented replacements, but then that caused the tests to fail, so then I rewrote it for removals as it was before, however tests are now sporadic and I'm not sure if it is actually better in hindsight. I think I will just go back to the simpler and more obvious replacements and just update the tests accordingly. I will evaluate this again after I have more progress on the below.

I believe the new echo-regexp should be able to replace all gsed, sed, grep, ripgrep, and sd usage throughout Dorothy, which will bring complexity of the codebase down, use only a single regex syntax rather than the current three, and require less upfront dependencies to be installed (only jq and deno).

I'm currently rewriting everything to use echo-regexp and expanding echo-regexp to support these wider use cases. Additionally I am adding tests for all modified commands.

This is taking longer than expected, but is such a relief as progress is made due to the reduction of complexity.

- `__print_line ...` to `__print_lines ...`
- `command-(missing|working|exists) ...` to `-- ...`
- add tests to `echo-magent-hash`, `
- `dorothy` minimum deps now only `jq` and `deno`
- `down`: add `--url=...` support
- `echo-regexp(.ts)`: add `-qvf` support, improve performance, change `--multiline-dotall` to `s` flag
- `fs-(bytes|kilobytes|megabytes)`: use `dust` instead of `du` to achieve macos support, also fix crash in `fs-megabytes`
- `get-filesystem`: no longer fail silently when no args are provided
- `get-local-to-remote`: improve styling
- `styles.bash` make code styles more readable on light theme, by swapping from dim to intense black
- `get-opensuse-release`: simpler technique
- `get-url-(domain|protocol)` split into `get-url-(domain|protocol).ts` and add tests
- `what-is-my-(dns|gateway|inteface|ip|subnet)`: rewrote and fixed
- `get-codec`: rewrote and fixed

Requires more testing on:
- `get-devices`
- `mount-helper`
- `get-volumes`
- `git-helper`
- `gpg-helper`
- `setup-util-nerd-fonts`
- `setup-util-node`
- `unziptar` on DMG files
- `itunes-owners`
- `setup-server

New deprecations:
- `is-match` replaced by `echo-regexp -q`
@balupton balupton force-pushed the dev/gawk-bottle branch 4 times, most recently from 9b33b0c to 38a6fc9 Compare September 16, 2024 01:05
@balupton balupton force-pushed the dev/gawk-bottle branch 3 times, most recently from 85b9f9d to ee85edf Compare September 16, 2024 06:18
this now allows tool selection and prompting, as well as testing each tool, for:
- echo-html-coder
- echo-url-coder
- echo-math

/ref https://github.com/bevry/dorothy/actions/runs/10877091411/job/30177948850
@balupton
Copy link
Member Author

balupton commented Sep 16, 2024

Still got some some failures on macos with bash v3

Edit: couldn't reproduce locally... will re-run them

- ask, choose: use echo-wrap in arg form, no need for pipe
- get-devices, get-local-to-remote: fix echo-regexp regression, and fix sporadic nature of success which was due to missing `--stdin`
- bash.bash: simplify eval statements and support spaces in paths
@balupton balupton merged commit b304080 into master Sep 17, 2024
21 checks passed
@balupton balupton changed the title WIP: config-helper: fix edge cases config-helper: fix edge cases Sep 17, 2024
balupton added a commit that referenced this pull request Sep 17, 2024
/close #249 #241 #239

changes:

- replace common gsed/sed/sd/ripgrep/rg/grep/teip usage with new `echo-regexp` that uses deno, affects `convert-helper`, `config-helper`, `echo-magnet-hash`, `fs-(bytes|kilobytes|megabytes)`, `fs-speed`, `get-devices`, `get-local-to-remote`, `get-opensuse-release`, `get-volumes`, `git-helper`, `is-bash-version-outdated`, `mount-helper`, `network-interface`, `setup-dns`, `setup-util`, `setup-util-1password-cli`, `setup-util-nerd-fonts`, `setup-util-node`, `unziptar`, `what-is-my-(dns|gateway|interface|ip|submit)`, `get-codec`, `is-prefix`, `is-suffix`, `itunes-owners`, `mac-address-helper`, `setup-server`
- `bash.bash`:
    - simplify eval statements and support spaces in paths
    - add explicit names for `__print*` helpers, and slightly change their functionality to be aligned with expectations
        - **please change `__print_line ...` to `__print_lines ...` as in the future `__print_line` may not support arguments**
    - **removed deprecated non `__` prefixed aliases, e.g. `require_globstar` is now only `__require_globstar`**
- `ci/dorothy-workflow`: don't test PRs until review requested
- `ci/dorothy`: don't eslint as no Node.js code
- `ci/vscode`: add an awk syntax highlighting extension, and enable Deno
- `command-working`: give details of failures, add `dash` to exceptions
- `dorothy-config`/`config-helper`: significant work to better handle multiple instances (result is no longer garbled), output and process is now clearer, includes multiple strategies for multiple instances, uses new `echo-regexp` to replace `sd/rg/teip/grep` combo
- `dorothy` minimum deps now only `jq` and `deno`s,
- `down`: add `--url=...` support
- `echo-gnu-command`: fix it not outputting the command after installation
- `echo-if-empty`/`get-devices`/`get-local-to-remote`: fix sporadic success by adding missing `--stdin`
- `echo-lines`: now support `--[no-]quote` flags as alias for prior `--[no-]quoted` flag
- `echo-math`/`echo-(html|url)-(encode|decode)`: rewrote and added tests, now they work correctly, in the latter case `echo-(html|url)-coder` is now used
- `echo-wrap`: now awk compatible, removing dependency on `gawk`
- `eval-tester`: output escaped comparison if special characters were used
- `fs-(bytes|kilobytes|megabytes)`: use `dust` instead of `du` to achieve macos support, also fix crash in `fs-megabytes`
- `fs-rm`: fix trash error on alpine, as trash isn't available on alpine
- `get-codec`: removed `--trim` and made it default (prior verbosity available via `--verbose`), now sensible error if `ffprobe` is not available
- `get-codec`: rewrote and fixed
- `get-filesystem`: no longer fail silently when no args are provided
- `get-local-to-remote`: improve styling
- `get-opensuse-release`: simpler technique
- `get-url-(domain|protocol)` split into `get-url-(domain|protocol).ts` and add tests
- `is-match`: deprecated and moved in beta commands, as it is replaced by `echo-regexp -q` which it now uses internally
- `mac-address-helper`: fixed broken `new` functionality, and improved formatting of outputs
- `set-hostname`/`setup-hosts`/`setup-shell`: fix break when gsed isn't available, now uses the `echo-gnu-command` helper
- `setup-util-1password`: install stable instead of beta, as stable is now stable
- `setup-util-deno`: add apk, uninstall snap (as snap does not allow script execution), use official arm builds as that is now a thing, don't use official yet stupid `deno_install` script
- `setup-util-devel`: add `automake` for macos
- `setup-util-gawk`: add more package systems
- `setup-util-gsed`: add bottles for macos, and add uninstall build support
- `setup-util`: rename `DOWNLOAD_BUILD_EVAL` to `DOWNLOAD_BUILD_INSTALL` and add `DOWNLOAD_BUILD_UNINSTALL`, affected `setup-util-bash`, `setup-util-gawk`, `setup-util-gsed`
- `sparse-vault`: fix broken awk script, use `echo-regexp` instead
- `sparse-vault`: fix broken macos version fetching
- `styles.bash` make code styles more readable on light theme by swapping from dim to intense black, add code error, info, and notice styles
- `unziptar`: fix alpine compatibility
- `what-is-my-(dns|gateway|inteface|ip|subnet)`: rewrote and fixed
- add `.gitattributes` to prevent formatting issues in tests
- add `echo-escape-backslashes` and remove its functionality from `echo-escape-regexp-replacement` for compat with JavaScript Regular Expression
- add `fs-diff` to compute differences between files
- add `get-file` and `setup-util-file` to fix `unziptar` compat on systems without `file` preinstalled
- add `setup-util-frawk`
- add tests to `echo-math`, `echo-(html|url)-(coder|encode|decode)`, `echo-magnet-hash`, `fs-(bytes|kilobytes|megabytes)`, `get-url-(domain|protocol)`

needs more testing:

- `get-opensuse-release`
- `mount-helper`
- `setup-dns`
- `setup-server`
- `setup-util-gsed` on fresh macos
- `unziptar` on macos dmg files

squashes:

- be4b3ce
- ada62e0
- 6860035
- d86e060
- 2b24208
- 1fdae98
- 4506b7f
- 6618689
- 7022dba
- fe5050b
- 0e02dc9
- 7c7265d
- bb507bd
- 818d5c0
- b91656b
- 96d91bc
- 6838a37
- 7c7ed59
- a1f96ea
- 2e4d9da
- e2294c4
- 2a83b20
- da3cf12
- d334b8f
- 86de699
- 35593fe
- 62d42ca
- c723ea2
- e68e2e0
- 7deab4e
- ecee164
- 7cc4031
- e035a22
- e9a955a
@balupton
Copy link
Member Author

merged into the amended 7ee7f6c instead as I forgot to remove the WIP: prefix

@balupton balupton deleted the dev/gawk-bottle branch September 17, 2024 01:51
balupton added a commit to balupton/dotfiles that referenced this pull request Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Bug: echo-wrap tests failing
1 participant