330 Commits

Author SHA1 Message Date
apainintheneck
70ffc31338 formulary: update logic and add regression test 2024-02-11 13:09:53 -08:00
Stephan Jorek
d01de7545c
refactor bugfix to satify brew audit 2024-02-11 11:40:49 +01:00
Stephan Jorek
863654e37c
remove accidentally added newline 2024-02-11 01:39:44 +01:00
Stephan Jorek
1570a4b8a3
Fix support of formulae aliases in taps
Resolves: #16636
2024-02-11 00:38:47 +01:00
Markus Reiter
3e61e3b428
Stop following recursive tap migrations. 2024-02-10 15:07:31 +01:00
Markus Reiter
f72038b116
Fix loading aliases from API. 2024-02-08 12:19:04 +01:00
Markus Reiter
29179e45a1
Refactor rename/migration handling in Formulary. 2024-02-06 00:52:38 +01:00
apainintheneck
3c503cdf56
Normalize service serialization method names 2024-02-04 13:50:57 +01:00
Douglas Eichelberger
f6c7eb7124 Add hash/keys to extend/ 2024-01-19 13:36:17 -08:00
Douglas Eichelberger
a87cdf0d21 Add Hash#deep_transform_values to extend/ 2024-01-19 13:36:16 -08:00
Issy Long
f682147598
Fix RuboCop Style/RedundantFreeze offenses 2024-01-18 22:20:01 +00:00
Mike McQuaid
0f0befc8e0
Merge pull request #16458 from Bo98/json-freeze
api: use freeze option for JSON parsing
2024-01-10 13:18:09 +00:00
apainintheneck
babbf008a1 formulary: allow for more keyless fields when loading from API
These were fields I missed the first time around. Now the values
line up with the expected values.
2024-01-09 23:33:20 -08:00
Bo Anderson
1c3c64a743
api: use freeze option for JSON parsing 2024-01-09 19:07:36 +00:00
Bo Anderson
310b5ecbe7
Introduce Formulary platform cache 2024-01-09 11:12:49 +00:00
apainintheneck
984dcf8c11 API: Load casks/formula from JSON with missing keys
We'd like to reduce the size of the API JSON and to do that we are
going to remove unused and/or blank elements from the cask/formula
definition. This will reduce the amount of data that has to go
over the wire and make it easier to load this data into memory.
2024-01-01 19:10:48 -08:00
Rylan Polster
641a80475e
Update cask logic to handle deprecations and disables 2023-12-16 20:01:47 -05:00
Rylan Polster
036723a668
Add deprecate! and disable! methods to the Cask DSL 2023-12-16 20:01:46 -05:00
Bo Anderson
fe011ca0f9
Partially support pour_bottle? in API 2023-12-07 18:05:41 +00:00
Rylan Polster
fb50cfa13d
Simplify tap assignment 2023-11-13 14:12:35 -05:00
Rylan Polster
74996ab32c
Remove new tap parameter to FormulaAPILoader 2023-11-13 14:07:34 -05:00
Rylan Polster
aa316109d9
Pass new tap to TapLoader
Co-authored-by: Alexander Mancevice <alexander.mancevice@hey.com>
2023-11-13 14:02:50 -05:00
Rylan Polster
237a42974b
Pass original tap to formula when loaded from the API via TapLoader 2023-11-13 13:40:44 -05:00
Rylan Polster
97b411906d
Refactor TapLoader to fix tap migrations with API 2023-11-11 16:48:05 -05:00
Mike McQuaid
41dc533add
Merge pull request #16108 from Bo98/api-rename-fix
formulary: load from API for formula renames
2023-10-12 17:49:58 +01:00
Bo Anderson
408e15f485
formulary: load from API for formula renames 2023-10-12 17:04:54 +01:00
Eric Knibbe
03e743a75e
api: add using: attribute to head & stable URLs 2023-10-11 14:14:18 -04:00
Mike McQuaid
b7114651ac
utils/curl: include or use explicitly.
Include or use `Utils::Curl` explicitly everywhere it is used.
2023-09-04 22:17:57 -04:00
Mike McQuaid
b3c33d34ab
Various sharding fixes
- Load paths with no API when needed (e.g. for `brew edit`)
- Use no API mode for `brew log` as it's needed there
- Define sharding format for homebrew-cask and homebrew-core inside
  `Tap` methods
- Create new formulae/casks in location defined by these `Tap` methods
- Fix a bug in Formulary that made sharded formulae lookup less
  efficient (and possibly broke it for core and some API usage)
- Fix various other hardcoded Formula/Cask directory assumptions

Co-authored-by: Bo Anderson <mail@boanderson.me>
2023-08-04 16:43:13 +01:00
Ruoyu Zhong
26f8f27b3c
formulary: fix type of alias_path
`Formulary.from_rack` only allows `alias_path` to be a `Pathname`. Make
it happy with `String`s too.

Fixes:

    $ brew test openssl
    Error: Parameter 'alias_path': Expected type Pathname, got type String with value "/usr/local/Homebrew/Librar...homebrew-core/Aliases/openssl"
    Caller: /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/sorbet-runtime-0.5.10461/lib/types/private/methods/call_validation.rb:113
    Definition: /usr/local/Homebrew/Library/Homebrew/formulary.rb:787

Signed-off-by: Ruoyu Zhong <zhongruoyu@outlook.com>
2023-08-02 22:49:39 +08:00
Eric Knibbe
b3ecd91f97
dev-cmd/edit: suggest tapping core repositories 2023-08-01 13:39:28 -04:00
Douglas Eichelberger
08e46c18cd Add type to Formula attrs 2023-07-24 14:12:36 -07:00
Douglas Eichelberger
a46430a390 Fix type error when running 'brew doctor' 2023-07-24 07:00:26 -07:00
Mike McQuaid
c940e15a5c
Use HOMEBREW_CELLAR_PLACEHOLDER
Similarly to HOMEBREW_PREFIX_PLACEHOLDER, this allows the substitution
of HOMEBREW_CELLAR in JSON output when using the API.

Fixes #15668.
2023-07-18 10:59:27 +01:00
Bo Anderson
beaa6c32a0
Fix cases of core taps being unnecessarily installed 2023-07-13 20:33:31 +01:00
Bo Anderson
c4077aa076
Support head deps & uses_from_macos bounds in API; strip implicit deps 2023-07-04 13:40:58 +01:00
Bo Anderson
8dc2e80a98
Significantly improve install speeds with smarter postinstall detection 2023-06-22 03:06:45 +01:00
Markus Reiter
e9bfcb9296
Merge pull request #15225 from reitermarkus/audit-os-arch
Add `--os=all` and `--arch=all` options for `brew audit`.
2023-05-19 15:03:32 +02:00
Mike McQuaid
77f94ba5bf
formulary: use a lot more .presence.
Addresses regression in https://github.com/Homebrew/brew/pull/15396.

Fixes https://github.com/Homebrew/homebrew-core/issues/131284
Fixes https://github.com/Homebrew/homebrew-core/issues/131287
Fixes https://github.com/Homebrew/homebrew-bundle/issues/1205
2023-05-18 13:14:52 +01:00
Kevin
946478aed4
Merge pull request #15396 from apainintheneck/custom-service-name
Custom service name
2023-05-17 22:09:31 -07:00
apainintheneck
f2adbf6613 service: change custom name DSL
After some discussion, we decided to change the DSL to get rid of
the `plist_name` and `service_name` methods which aren't meaningful
for most users.

The new DSL looks like this:

```rb
service do
  name macos: "name", linux: "name"
end
```

I also updated some specs here to reflect these changes.

There was some talk about maybe deprecating `plist_name` and `service_name`
but I think that's outside of the scope of this PR so I'm leaving
them as is for now. One benefit of this is that everything here is backwards
compatible.
2023-05-17 21:54:32 -07:00
Markus Reiter
486c3765ce
Add --os=all and --arch=all options. 2023-05-17 15:26:46 +02:00
Markus Reiter
f60612e6b2
Add Formula#loaded_from_api?. 2023-05-15 13:58:33 +02: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
Markus Reiter
a3231a03fa
Implement cask renames. 2023-05-12 21:17:30 +02:00
Markus Reiter
8274920217
Rename OS::Mac::Version to MacOSVersion. 2023-05-09 05:08:38 +02:00
Bo Anderson
44f058edb5
Refactor formula, cask and Ruby source downloads to use shared code 2023-04-27 23:23:07 +01:00
Bo Anderson
a696bd8203
Support multiple oldnames for formulae 2023-04-27 05:15:43 +01:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
apainintheneck
d57f291a1e formulary: sub home placeholder in caveats
We set a placeholder for the home directory when generating
API JSON so we should substitute the actual home directory
back in when printing caveats locally. This allows people
to use `Dir.home` in caveats and have it display correctly
no matter the platform or operating system.
2023-04-22 10:17:16 -07:00