From b5704d4e26835d07c8aa5bbcb7ed25ac2a08a405 Mon Sep 17 00:00:00 2001
From: Mike McQuaid
Date: Sun, 5 Feb 2023 00:06:00 +0100
Subject: [PATCH] Remove cask-source, bottle and versions APIs
These are no longer needed after
https://github.com/Homebrew/brew/pull/14439 and
https://github.com/Homebrew/brew/pull/14500 are merged and in a stable
tag.
---
.github/workflows/scheduled.yml | 4 +--
.gitignore | 2 --
Rakefile | 10 +++----
_api_bottle.json.in | 4 ---
_layouts/bottle_json.json | 6 ----
_layouts/formula.html | 2 --
api/versions-casks.json | 11 --------
api/versions-formulae.json | 11 --------
docs/api.md | 49 ---------------------------------
script/generate-api-samples.rb | 16 -----------
script/generate-cask.rb | 3 +-
script/generate.rb | 8 ++----
12 files changed, 10 insertions(+), 116 deletions(-)
delete mode 100644 _api_bottle.json.in
delete mode 100644 _layouts/bottle_json.json
delete mode 100644 api/versions-casks.json
delete mode 100644 api/versions-formulae.json
diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml
index 07435661071..19b8ca0a4fc 100644
--- a/.github/workflows/scheduled.yml
+++ b/.github/workflows/scheduled.yml
@@ -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:
@@ -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:
diff --git a/.gitignore b/.gitignore
index 7e5a0413228..bd5839f46a1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,9 +8,7 @@ vendor/
.sass-cache/
Gemfile.lock
_data/
-api/bottle/
api/cask/
-api/cask-source/
api/formula/
api/analytics/
api/analytics-linux/
diff --git a/Rakefile b/Rakefile
index 3ccec0f3bf7..f38f7cda508 100644
--- a/Rakefile
+++ b/Rakefile
@@ -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|
@@ -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"]
diff --git a/_api_bottle.json.in b/_api_bottle.json.in
deleted file mode 100644
index a44994b270c..00000000000
--- a/_api_bottle.json.in
+++ /dev/null
@@ -1,4 +0,0 @@
----
-layout: bottle_json
----
-{{ content }}
diff --git a/_layouts/bottle_json.json b/_layouts/bottle_json.json
deleted file mode 100644
index 59a6dcfae14..00000000000
--- a/_layouts/bottle_json.json
+++ /dev/null
@@ -1,6 +0,0 @@
----
----
-{%- assign full_name = page.name | remove: ".json" -%}
-{%- assign data_name = full_name | remove: "@" | remove: "." | replace: "+", "_" -%}
-{%- assign bottle = site.data.bottle[data_name] -%}
-{{ bottle | jsonify }}
diff --git a/_layouts/formula.html b/_layouts/formula.html
index c1425de323c..f6c32588b2b 100644
--- a/_layouts/formula.html
+++ b/_layouts/formula.html
@@ -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] -%}
-Bottle JSON API: /api/{{ bottle_path }}/{{ f.name }}.json
Formula code: {{ f.name }}.rb
on GitHub
diff --git a/api/versions-casks.json b/api/versions-casks.json
deleted file mode 100644
index 7163d31e139..00000000000
--- a/api/versions-casks.json
+++ /dev/null
@@ -1,11 +0,0 @@
----
----
-{
-{%- assign sorted_casks = site.data.cask | sort -%}
-{% for cask in sorted_casks %}
- "{{ cask[1].token }}":{"version":"{{ cask[1].version }}","versions":{{ cask[1].versions | jsonify }}}
- {%- unless forloop.last -%}
- ,
- {%- endunless -%}
-{% endfor %}
-}
diff --git a/api/versions-formulae.json b/api/versions-formulae.json
deleted file mode 100644
index 809d32f2366..00000000000
--- a/api/versions-formulae.json
+++ /dev/null
@@ -1,11 +0,0 @@
----
----
-{
-{%- assign sorted_formulae = site.data.formula | sort -%}
-{% for formula in sorted_formulae %}
- "{{ formula[1].name }}":{"version":"{{ formula[1].versions.stable }}","revision":{{ formula[1].revision }}}
- {%- unless forloop.last -%}
- ,
- {%- endunless -%}
-{% endfor %}
-}
diff --git a/docs/api.md b/docs/api.md
index 14f280696e4..dd3487ee7f5 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -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 ` output for a single, current {{ site.taps.core.fullname }} formula with extra keys containing analytics data and generation date.
@@ -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 ` 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 ` JSON output for a single, current {{ site.taps.cask.fullname }} cask with extra keys containing analytics data and generation date.
@@ -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
diff --git a/script/generate-api-samples.rb b/script/generate-api-samples.rb
index bb19ce3f260..dd3ff223f27 100755
--- a/script/generate-api-samples.rb
+++ b/script/generate-api-samples.rb
@@ -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!
@@ -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
@@ -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"
diff --git a/script/generate-cask.rb b/script/generate-cask.rb
index 8b4ffbd2859..d598c9b67d9 100755
--- a/script/generate-cask.rb
+++ b/script/generate-cask.rb
@@ -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
@@ -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
diff --git a/script/generate.rb b/script/generate.rb
index 736ed40a02d..05e1d626270 100755
--- a/script/generate.rb
+++ b/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")