96 Commits

Author SHA1 Message Date
Bo Anderson
b42256d286
Deprecate, disable & delete code for Homebrew 4.2.0 2023-12-07 23:42:13 +00:00
apainintheneck
1111706378 service: add custom service name DSL
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
2023-05-13 14:53:01 -07:00
Issy Long
f10b88ca85
caveats: Add a new line if there isn't one from previous conditions 2023-03-19 18:38:09 +00:00
Issy Long
7bb57612b7
caveats: Remove extra blank line between keg_only and other caveats
- 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.
2023-03-18 12:21:10 +00:00
Issy Long
e9d994622e
rubocop: Drop "f" from Naming/MethodParameterName allowlist
- This either stands for "file" but more often than not "formula".
2023-03-11 00:17:27 +00:00
Dawid Dziurla
0d0c98de29
Allow defining service run command per platform 2023-01-19 11:36:37 +01:00
Sean Molenaar
0cd10ed65e
caveats: print sudo in caveats if service requires it 2022-12-05 12:12:51 +01:00
Issy Long
b7d997e80d
sorbet: Bump some files from typed: false to typed: true
- 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!
2022-10-11 01:09:03 +01:00
Bo Anderson
02164a35db
Use ORIGINAL_PATHS over envs; reject nil PATH 2022-06-17 19:47:57 +01:00
Sean Molenaar
73bc934c85
Caveats: suggest brew services for linux 2021-10-30 18:18:25 +02:00
Sean Molenaar
ef9c49c5b2
service: ensure environment variables are prefixed in command 2021-05-25 11:47:44 +02:00
Sean Molenaar
3ab21cc412
services: replace plist_options :manual with service command 2021-05-01 16:20:47 +02:00
EricFromCanada
6fc116318e fixes for grammar and wording 2021-01-26 16:19:47 -05:00
Seeker
b9854bd4cf rubocops: add unless_multiple_conditions 2021-01-08 10:33:54 -08:00
Mike McQuaid
1f8fd2a9ef
caveats: remove ZSH FPATH logic.
This is too error-prone and full of edge cases.

Fixes #9455
2020-12-09 11:47:48 +00:00
Mike McQuaid
ac84a4b051
Fix ZSH FPATH handling
Don't require it to be exported but shell out to `zsh` instead.

Fixes https://github.com/Homebrew/brew/issues/9387
2020-12-03 16:52:55 +00:00
Mike McQuaid
3002c810be
Improve ZSH completions handling
- 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
2020-11-26 16:08:26 +00:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Markus Reiter
8957422d86 Document Caveats. 2020-08-26 03:13:58 +02:00
Mike McQuaid
3a91c37e66
Fix RuboCop checks. 2020-08-19 17:12:32 +01:00
Issy Long
341ea60807
Auto-fix Style/RedundantBegin offenses
- This also required auto-fixes for Layout/EmptyLinesAroundBlockBody and
  Layout/InconsistentIndentation once the auto-fixer had got rid of the
  "redundant begin"s.
2019-10-13 16:04:27 +01:00
Mike McQuaid
fc6bd2ea1c
Fixup more frozen string handling. 2019-04-20 14:07:29 +09:00
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
Mike McQuaid
2e7a3f3da2
caveats: tweak wording/formatting. 2019-03-13 08:56:16 +00:00
Morgan Tocker
a1f24748e6 caveats: non-macOS platforms warn on services
Only currently supported by macOS. Attempting to use services
should produce a warning for now.  It is possible it might be
supported in the future.
2019-03-12 13:47:54 -06:00
Mike McQuaid
d64429a736
rubocop: enable Style/IfUnlessModifier. 2019-02-21 12:55:49 +00:00
Mike McQuaid
b89367e6d9 caveats: tweak keg_only_text
- make it a public method
- allow skipping the reason
- output how to set the various variables in your current shell
2018-07-26 10:49:07 +01:00
Mike McQuaid
9fca172d03 Fix HOMEBREW_RUBY_WARNINGS="-w"
Fix various circular requirements, method redefinitions, etc.
2018-04-07 20:28:56 +01:00
Mike McQuaid
36dadbee47 caveats: remove python caveats.
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.
2018-03-08 08:34:20 +00:00
Mike McQuaid
d54e670a64 requirements: move more to compat. 2017-12-30 20:56:55 +00:00
Mike McQuaid
cacefb2b99
caveats: tweak root_dir definition style. 2017-12-24 07:59:17 +00:00
Dominyk Tiller
92e62ba583
caveats: correct completion/function paths for keg_only 2017-12-23 23:15:59 +00:00
Dominyk Tiller
55d9750056
caveats: fix fish caveats under env filtering 2017-12-11 09:16:39 +00:00
Dominyk Tiller
d70a406fe7
caveats: fix PKG_CONFIG_PATH nudge under env filtering 2017-12-11 06:26:56 +00:00
Markus Reiter
0ea855c6e6 Add missing require "forwardable". 2017-10-24 19:39:40 +02:00
Markus Reiter
9bee9ca575 Use “squiggly” heredocs. 2017-10-18 14:39:09 +02:00
Maxim Belkin
336fbb5db2
caveats: making plist_caveats macOS-only 2017-10-16 11:15:54 -05:00
Mike McQuaid
01e9ec9a9f Rubocop: automatic rule fixes. 2017-09-24 21:23:59 +01:00
Misty De Meo
2bd8091ae8 Merge pull request #2804 from mansimarkaur/caveats
Increasing test coverage for caveats.rb
2017-07-25 09:28:46 -07:00
mansimarkaur
ae02b9776a Added tests for python caveats 2017-07-25 21:00:37 +05:30
mansimarkaur
9218d3014d Added tests for plist_caveats 2017-07-25 21:00:26 +05:30
mansimarkaur
5fba0c4776 Added tests for function_completion_caveats 2017-07-25 21:00:04 +05:30
Markus Reiter
3b4ee58c49 Refactor using Forwardable and DelegateClass. 2017-06-28 09:25:31 +02:00
Dominyk Tiller
c081b3d975
caveats: chomp keg_only reason 2017-05-02 19:03:03 +01:00
Dominyk Tiller
285b0bc941
caveats: tweak keg_only wording
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.
```
2017-05-01 16:56:16 +01:00
Mike McQuaid
ba3c46d24f More deprecations.
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.
2017-04-22 16:28:07 +01:00
Alex Dunn
00af5250f0 caveats: combine completion and function messages
Fixes https://github.com/Homebrew/homebrew-core/issues/10338.

Closes #2287.

Signed-off-by: Alex Dunn <dunn.alex@gmail.com>
2017-03-19 16:32:23 -07:00
Mike McQuaid
7a2c5c0f2f caveats: add newline after keg only reason. 2017-01-26 15:18:32 +00:00
Mike McQuaid
cc22239c99 caveats: tweak keg-only messaging.
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`.
2017-01-25 08:25:16 +00:00
Mike McQuaid
c0a29d6644 caveats, keg: remove linkapps caveats code. 2017-01-09 14:10:26 +00:00