Skip to content

Commit

Permalink
Remove cask-source, bottle and versions APIs
Browse files Browse the repository at this point in the history
These are no longer needed after
Homebrew/brew#14439 and
Homebrew/brew#14500 are merged and in a stable
tag.
  • Loading branch information
MikeMcQuaid committed Feb 8, 2023
1 parent 6cd3554 commit b5704d4
Show file tree
Hide file tree
Showing 12 changed files with 10 additions and 116 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/scheduled.yml
Expand Up @@ -34,7 +34,7 @@ jobs:
/usr/bin/rake cask
- name: Archive data
run: tar czvf data-cask.tar.gz _data/cask/ api/cask/ api/cask-source/ cask/
run: tar czvf data-cask.tar.gz _data/cask/ api/cask/ cask/

- uses: actions/upload-artifact@v3
with:
Expand All @@ -60,7 +60,7 @@ jobs:
run: /usr/bin/rake formulae

- name: Archive data
run: tar czvf data-core.tar.gz _data/bottle/ _data/formula/ _data/formula_canonical.json api/bottle/ api/formula/ formula/
run: tar czvf data-core.tar.gz _data/formula/ _data/formula_canonical.json api/formula/ formula/

- uses: actions/upload-artifact@v3
with:
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Expand Up @@ -8,9 +8,7 @@ vendor/
.sass-cache/
Gemfile.lock
_data/
api/bottle/
api/cask/
api/cask-source/
api/formula/
api/analytics/
api/analytics-linux/
Expand Down
10 changes: 5 additions & 5 deletions Rakefile
Expand Up @@ -12,14 +12,14 @@ end
task default: :formula_and_analytics

desc "Dump macOS formulae data"
task :formulae, [:os, :tap] do |task, args|
args.with_defaults(:os => "mac", :tap => jekyll_config("taps", "core", "name"))
task :formulae, [:tap] do |task, args|
args.with_defaults(:tap => jekyll_config("taps", "core", "name"))

ENV["HOMEBREW_NO_COLOR"] = "1"
ENV["HOMEBREW_NO_INSTALL_FROM_API"] = "1"
sh "brew", "ruby", "script/generate.rb", args[:os], args[:tap]
sh "brew", "ruby", "script/generate.rb", args[:tap]
end
CLOBBER.include FileList[%w[_data/formula _data/bottle api/formula api/bottle formula _data/formula_canonical.json]]
CLOBBER.include FileList[%w[_data/formula api/formula formula _data/formula_canonical.json]]

desc "Dump cask data"
task :cask, [:tap] do |task, args|
Expand All @@ -29,7 +29,7 @@ task :cask, [:tap] do |task, args|
ENV["HOMEBREW_NO_INSTALL_FROM_API"] = "1"
sh "brew", "ruby", "script/generate-cask.rb", args[:tap]
end
CLOBBER.include FileList[%w[_data/cask api/cask api/cask-source cask]]
CLOBBER.include FileList[%w[_data/cask api/cask cask]]

def generate_analytics?(os)
return false if ENV["HOMEBREW_NO_ANALYTICS"]
Expand Down
4 changes: 0 additions & 4 deletions _api_bottle.json.in

This file was deleted.

6 changes: 0 additions & 6 deletions _layouts/bottle_json.json

This file was deleted.

2 changes: 0 additions & 2 deletions _layouts/formula.html
Expand Up @@ -4,7 +4,6 @@
---
{%- assign full_name = page.title -%}
{%- assign formula_path = "formula" -%}
{%- assign bottle_path = "bottle" -%}
{%- assign data_name = full_name | remove: "@" | remove: "." | replace: "+", "_" -%}
{%- assign f = site.data[formula_path][data_name] -%}
<h2
Expand All @@ -27,7 +26,6 @@
{%- endif %}

<p>Formula JSON API: <a href="{{ site.baseurl }}/api/{{ formula_path }}/{{ f.name }}.json"><code>/api/{{ formula_path }}/{{ f.name }}.json</code></a></p>
<p>Bottle JSON API: <a href="{{ site.baseurl }}/api/{{ bottle_path }}/{{ f.name }}.json"><code>/api/{{ bottle_path }}/{{ f.name }}.json</code></a></p>

<p>Formula code: <a target="_blank" href="{{ site.taps.core.remote }}/blob/{{ f.tap_git_head }}/Formula/{{ f.name }}.rb"><code>{{ f.name }}.rb</code></a> on GitHub</p>

Expand Down
11 changes: 0 additions & 11 deletions api/versions-casks.json

This file was deleted.

11 changes: 0 additions & 11 deletions api/versions-formulae.json

This file was deleted.

49 changes: 0 additions & 49 deletions docs/api.md
Expand Up @@ -22,23 +22,6 @@ GET https://formulae.brew.sh/api/cask.json

{% include api-samples/formula.md %}

### List the latest versions for all {{ site.taps.core.name }} formulae or {{ site.taps.cask.name }} casks

List the latest version information for each formula or cask in the given tap. The result is a single JSON object with formula/cask names as keys. The values are JSON objects containing `version` and, for formulae, `revision` keys.

```
GET https://formulae.brew.sh/api/versions-formulae.json
GET https://formulae.brew.sh/api/versions-casks.json
```

#### [Formulae Response](https://formulae.brew.sh/api/versions-formulae.json)

{% include api-samples/versions_formulae.md %}

#### [Casks Response](https://formulae.brew.sh/api/versions-casks.json)

{% include api-samples/versions_casks.md %}

### Get formula metadata for a {{ site.taps.core.name }} formula

Get the `brew info --json --formula <formula>` output for a single, current {{ site.taps.core.fullname }} formula with extra keys containing analytics data and generation date.
Expand All @@ -55,22 +38,6 @@ GET https://formulae.brew.sh/api/formula/${FORMULA}.json

{% include api-samples/formula_wget.md %}

### Get bottle metadata for a {{ site.taps.core.name }} formula

Get the `brew info --json --bottle --formula <formula>` output for a single, current {{ site.taps.core.fullname }} formula.

```
GET https://formulae.brew.sh/api/bottle/${FORMULA}.json
```

#### Variables

- `${FORMULA}`: the name of the formula, e.g. `wget`

#### [Response](https://formulae.brew.sh/api/bottle/wget.json)

{% include api-samples/bottle_wget.md %}

### Get cask metadata for a {{ site.taps.cask.name }} cask

Get the `brew info --json=v2 --cask <cask>` JSON output for a single, current {{ site.taps.cask.fullname }} cask with extra keys containing analytics data and generation date.
Expand All @@ -87,22 +54,6 @@ GET https://formulae.brew.sh/api/cask/${FORMULA}.json

{% include api-samples/cask_docker.md %}

### Get the source code for a cask in {{ site.taps.cask.fullname }}

Get the latest source code for a cask that is defined in the {{ site.taps.cask.fullname }} repo.

```
GET https://formulae.brew.sh/api/cask-source/${FORMULA}.rb
```

#### Variables

- `${FORMULA}`: the name of the cask, e.g. `vagrant`

#### [Response](https://formulae.brew.sh/api/cask-source/vagrant.json)

{% include api-samples/cask_source_vagrant.md %}

## Analytics

### List one category of analytics events
Expand Down
16 changes: 0 additions & 16 deletions script/generate-api-samples.rb
Expand Up @@ -4,13 +4,9 @@
analytics_cask_install_homebrew_cask_30d: "analytics/cask-install/homebrew-cask/30d.json",
analytics_install_30d: "analytics/install/30d.json",
analytics_install_homebrew_core_30d: "analytics/install/homebrew-core/30d.json",
bottle_wget: "bottle/wget.json",
cask_docker: "cask/docker.json",
cask_source_vagrant: "cask-source/vagrant.rb",
formula_wget: "formula/wget.json",
formula: "formula.json",
versions_casks: "versions-casks.json",
versions_formulae: "versions-formulae.json",
}.freeze

def failed!
Expand Down Expand Up @@ -95,14 +91,6 @@ def format_json_contents(name, api_path)
contents.select! do |obj|
obj["name"] == "wget"
end
when :versions_casks
contents.select! do |cask_token, _|
%w[docker onyx].include? cask_token
end
when :versions_formulae
contents.select! do |formula_name, _|
%w[wget zsh].include? formula_name
end
end

contents = JSON.pretty_generate contents
Expand All @@ -127,10 +115,6 @@ def format_json_contents(name, api_path)
when :formula
contents.sub!(/^\[/, "[\n ...")
contents.sub!(/}(?=\n\])/, "},\n ...")
when :versions_casks, :versions_formulae
contents.sub!(/^{/, "{\n ...")
contents.sub!(/( },)(?=\n ")/, "\\1\n ...")
contents.sub!(/}(?=\n})/, "},\n ...")
end

codify contents, language: "json"
Expand Down
3 changes: 1 addition & 2 deletions script/generate-cask.rb
Expand Up @@ -4,7 +4,7 @@
tap_name = ARGV.first
tap = Tap.fetch(tap_name)

directories = ["_data/cask", "api/cask", "api/cask-source", "cask"]
directories = ["_data/cask", "api/cask", "cask"]
FileUtils.rm_rf directories
FileUtils.mkdir_p directories

Expand All @@ -15,6 +15,5 @@
c = Cask::CaskLoader.load(p)
IO.write("_data/cask/#{c.token}.json", "#{JSON.pretty_generate(c.to_hash_with_variations)}\n")
IO.write("api/cask/#{c.token}.json", json_template)
IO.write("api/cask-source/#{c.token}.rb", p.read)
IO.write("cask/#{c.token}.html", html_template.gsub("title: $TITLE", "title: \"#{c.token}\""))
end
8 changes: 2 additions & 6 deletions script/generate.rb
@@ -1,22 +1,18 @@
#!/usr/bin/env brew ruby
os = ARGV.first
tap_name = ARGV.second
tap_name = ARGV.first
tap = Tap.fetch(tap_name)

directories = ["_data/formula", "_data/bottle", "api/formula", "api/bottle", "formula"]
directories = ["_data/formula", "api/formula", "formula"]
FileUtils.rm_rf directories + ["_data/formula_canonical.json"]
FileUtils.mkdir_p directories

json_template = IO.read "_api_formula.json.in"
bottle_template = IO.read "_api_bottle.json.in"
html_template = IO.read "_formula.html.in"

tap.formula_names.each do |n|
f = Formulary.factory(n)
IO.write("_data/formula/#{f.name.tr("+", "_")}.json", "#{JSON.pretty_generate(f.to_hash_with_variations)}\n")
IO.write("_data/bottle/#{f.name.tr("+", "_")}.json", "#{JSON.pretty_generate(f.to_recursive_bottle_hash)}\n")
IO.write("api/formula/#{f.name}.json", json_template)
IO.write("api/bottle/#{f.name}.json", bottle_template)
IO.write("formula/#{f.name}.html", html_template.gsub("title: $TITLE", "title: \"#{f.name}\""))
end
IO.write("_data/formula_canonical.json", "#{JSON.pretty_generate(tap.formula_renames.merge(tap.alias_table))}\n")

0 comments on commit b5704d4

Please sign in to comment.