The main thing is that this DSL allows us to provide an
interface that can be serialized to the JSON API.
Changes:
- Homebrew::Service
- Adds `#service_name` and `#plist_name` methods
- Each is now included in the `#serialize` method as well
- Eval block on instantiation
- Before we lazy evaluated this but the cost is not significant
and it complicated the code a bunch. This only gets called
during install, when evaluating caveats and in the `brew service`
command. It skips this evaluation if the service block isn't there.
- Add `#command?` helper to avoid `#command.blank?` and `#command.present?`
- Formula
- `#service` now returns a service whenever it's called. This call is
hidden behind a call to `#service?` most of the time anyway so this
should be fine.
- `#plist_name` and `#service_name` now call the methods of the same name
on the service class. This should have already been in the service object
to begin with and keeping these methods here helps preserve backwards
compatibility with people who were overwriting these methods before.
- Caveats
- Prefer `service#command?`
- Add helpers for checking on service commands
- This duplicates some of the work in `brew services`. Maybe we should
merge that repo in at some point.
- Check for installed service at `#plist_name` or `#service_name`. I think
this should be used instead of `Keg#plist_installed?` which checked for any plist file.
We should think about deprecating `#plist_installed?` in the future.
- Stop using `ps aux | grep #{formula.plist_name}` to check for service files
because it was inaccurate (it always returns true on my machine) because the grep
process is started before the ps process.
- Note: The behavior is the same as it was before. This means that caveats
only show up for custom service files on install or if they're already installed.
Otherwise it won't show up in `brew info`. This is because it has to check
first if the service file has been installed.
- Utils::Service
- Add utils for evaluating if a service is installed and running. This duplicates
some of the work already found in `brew services`. We should seriously consider
merging `brew services` with the main brew repo in the future since it's already
tightly coupled to the code in the main repo.
- Formulary.load_formula_from_api
- Be more explicit about which types can be deserialized into run params since
it is now possible for run params to be nil.
- Update and add tests
- This was pointed out by Carlo in
https://github.com/Homebrew/brew/issues/14925#issuecomment-1473303922,
it annoyed me the moment I saw it too, and it was a very quick fix.
- The caveats items are joined by "\n" before being displayed, so the
extra `\n` here when generating the `keg_only_text` meant that there
were two blank lines which looked weird. This `keg_only_text` method
is only used here so it doesn't affect anywhere else we show the
`keg_only` message, if there are any other places.
- This was done with `brew typecheck --update --suggest-typed` which
(as of the previous commit) uses Spoom, yet another gem. I thought I'd
see how well it works. There are no Sorbet errors after these changes!
- Only display the completions caveats from the current shell (assuming
it's one of Bash, ZSH or Fish)
- If the completions location isn't in the ZSH `FPATH` then link to the
documentation explaining how to do so.
Fixes https://github.com/Homebrew/brew/issues/8984
- This also required auto-fixes for Layout/EmptyLinesAroundBlockBody and
Layout/InconsistentIndentation once the auto-fixer had got rid of the
"redundant begin"s.
These instructions are currently incorrect and need to be ported to
`python` 3.x and `python@2` formulae. Until then it's better to not have
them than have them be incorrect.
Closes#3890.
Current:
```
This formula is keg-only, which means it was not symlinked into /usr/local.
Qt has CMake issues when linked
```
After:
```
This formula is keg-only, which means it was not symlinked into /usr/local,
because Qt has CMake issues when linked.
```
Deprecate more methods. Internal APIs have been verified to be unused
elsewhere and removed. External APIs have had deprecation methods added.
Existing deprecations have been either upgraded to produce warnings or
no longer deprecated and the reasoning documented.
Slim down the existing text and make it more obvious what's happening.
Note specifically how to add it to your PATH to convince people to try
that instead of `brew link --force`.