diff --git a/.editorconfig b/.editorconfig index a0c7aa5..26cc13e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,6 +10,14 @@ indent_size = 2 insert_final_newline = true trim_trailing_whitespace = true +[Makefile] +indent_size = 4 +indent_style = tab +insert_final_newline = true + +[*.json] +insert_final_newline = false + [**.{md,html}] indent_size = 4 x-soft-wrap-text = true diff --git a/.github/workflows/generate.yaml b/.github/workflows/generate.yaml index f4a5bea..5b7dfcd 100644 --- a/.github/workflows/generate.yaml +++ b/.github/workflows/generate.yaml @@ -17,10 +17,7 @@ jobs: - uses: actions/checkout@v4 - run: | - brew tap coatl-dev/coatl-dev - - - run: | - ./script/generate.rb + make tap TAP=coatl-dev/coatl-dev - uses: actions/upload-artifact@v4 with: @@ -37,19 +34,17 @@ jobs: - uses: actions/checkout@v4 - run: | - rm -r _data - rm -r api - rm -r formula + rm -r \ + _data \ + api \ + formula - uses: actions/download-artifact@v4 with: name: site - run: | - ./script/find-replace.sh - - - run: | - ./script/generate-core.sh + make core - uses: coatl-dev/actions/simple-git-diff@v3 id: git-diff diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..affd131 --- /dev/null +++ b/Makefile @@ -0,0 +1,28 @@ +TAP ?= + +all: tap core + +help: + @echo "Usage: make [target] TAP=<[user|org]/repo>" + @echo "" + @echo "Targets:" + @echo " : A blank, or no target will run 'all' target." + @echo " all: Run 'get-tap' and 'get-core' targets." + @echo " core: Generate formulae information for homebrew-core." + @echo " tap: Generate formulae information for TAP." + @echo " help: Display this help message." + +core: + @echo "Getting homebrew/core referenced formulae data..." + @./script/generate-core.sh + +tap: +ifeq ($(strip $(TAP)),) + $(error "Argument TAP is required. E.g., make [all|tap] TAP=<[user|org]/repo>") +endif + @echo "Tapping $(TAP)..." + @$(shell brew tap $(TAP)) + @echo "Generating formulae data for $(TAP)..." + @./script/generate.rb $(TAP) + @echo "Updating core dependencies on $(TAP) formulae..." + @./script/find-replace.sh diff --git a/_config.yml b/_config.yml index aaf11a0..bb4c8ec 100644 --- a/_config.yml +++ b/_config.yml @@ -6,8 +6,10 @@ remote_theme: Homebrew/brew.sh exclude: - script - CNAME - - README.md + - Dockerfile - Gemfile* + - Makefile + - README.md plugins: - jekyll-feed @@ -27,14 +29,6 @@ defaults: search_site: formulae taps: - coatl-dev: - repo: coatl-dev - name: coatl-dev/coatl-dev - fullname: coatl-dev/homebrew-coatl-dev - remote: https://github.com/coatl-dev/homebrew-coatl-dev - api: https://formulae.coatl.dev/api - bottle_dir: bottle - formula_dir: formula core: repo: core name: Homebrew/core @@ -43,6 +37,14 @@ taps: api: https://formulae.brew.sh/api bottle_dir: bottle-core formula_dir: formula-core + tap: + repo: coatl-dev + name: coatl-dev/coatl-dev + fullname: coatl-dev/homebrew-coatl-dev + remote: https://github.com/coatl-dev/homebrew-coatl-dev + api: https://formulae.coatl.dev/api + bottle_dir: bottle + formula_dir: formula logo: assets/coatl.png diff --git a/_includes/install_command.html b/_includes/install_command.html index 57c2d90..2f9bab6 100644 --- a/_includes/install_command.html +++ b/_includes/install_command.html @@ -2,7 +2,7 @@
Tap command:
- {%- highlight bash -%} brew tap {{site.taps.coatl-dev.name}} {%- endhighlight -%} + {%- highlight bash -%} brew tap {{site.taps.tap.name}} {%- endhighlight -%}
diff --git a/_layouts/formula.html b/_layouts/formula.html index c825553..3a6dce6 100644 --- a/_layouts/formula.html +++ b/_layouts/formula.html @@ -37,10 +37,10 @@ {%- assign formula_dir = site.taps.core.formula_dir %} {%- assign remote = site.taps.core.remote %} {%- else %} -{%- assign api = site.taps.coatl-dev.api %} -{%- assign bottle_dir = site.taps.coatl-dev.bottle_dir %} -{%- assign formula_dir = site.taps.coatl-dev.formula_dir %} -{%- assign remote = site.taps.coatl-dev.remote %} +{%- assign api = site.taps.tap.api %} +{%- assign bottle_dir = site.taps.tap.bottle_dir %} +{%- assign formula_dir = site.taps.tap.formula_dir %} +{%- assign remote = site.taps.tap.remote %} {%- endif -%}

Formula JSON API: /api/{{ formula_dir }}/{{ f.name }}.json

{%- if formula_path == "formula-core" %} diff --git a/formula_index.html b/formula_index.html index 99fbb1e..00f344c 100644 --- a/formula_index.html +++ b/formula_index.html @@ -3,9 +3,9 @@ layout: default permalink: /formula/ --- -

This is a listing of all packages available from the {{ site.taps.coatl-dev.repo }} tap via the Homebrew package manager for macOS.

+

This is a listing of all packages available from the {{ site.taps.tap.repo }} tap via the Homebrew package manager for macOS.

-

/api/formula.json (JSON API)

+

/api/formula.json (JSON API)

{%- assign sorted_formulae = site.data.formula | sort -%} diff --git a/index.html b/index.html index 6184a4f..8e27d73 100644 --- a/index.html +++ b/index.html @@ -1,7 +1,7 @@ --- layout: default --- -

{{site.title}} is an online package browser for {{site.taps.coatl-dev.repo}}'s Homebrew tap. For more information on how to install and use Homebrew see Homebrew's homepage.

+

{{site.title}} is an online package browser for {{site.taps.tap.repo}}'s Homebrew tap. For more information on how to install and use Homebrew see Homebrew's homepage.

Browse all coatl-dev formulae

Browse all referenced core formulae

diff --git a/script/find-replace.sh b/script/find-replace.sh index 7e0427b..42fee85 100755 --- a/script/find-replace.sh +++ b/script/find-replace.sh @@ -8,5 +8,5 @@ keys=( for key in "${keys[@]}" do - find _data/formula -name "*.json" -type f -exec sed -i "s/\"$key\"/\"core_$key\"/g" {} + + find _data/formula -name "*.json" -type f -exec sed -i '' "s/\"$key\"/\"core_$key\"/g" {} + done diff --git a/script/formulae.txt b/script/formulae.txt new file mode 100644 index 0000000..e417f6b --- /dev/null +++ b/script/formulae.txt @@ -0,0 +1,102 @@ +autoconf +autoconf@2.13 +autoconf@2.69 +automake +bison@2.7 +bison +ca-certificates +cairo +certifi +cmake +fontconfig +freetype +gawk +gdbm +gettext +giflib +glib +gmp +gobject-introspection +graphite2 +harfbuzz +icu4c +jpeg-turbo +libgit2@1.5 +libgit2@1.6 +libgit2 +libpng +libssh2 +libtermkey +libtiff +libtool +libuv +libvterm +libx11 +libxau +libxcb +libxdmcp +libxext +libxrender +little-cms2 +llvm@8 +llvm@9 +llvm@11 +llvm@12 +llvm@13 +llvm@14 +llvm@15 +llvm@16 +llvm +lpeg +lua +lua@5.1 +lua@5.3 +luajit +luarocks +luv +lz4 +lzo +m4 +meson +mpdecimal +mpfr +msgpack +nasm +neovim +ninja +openjdk@11 +openjdk@17 +openjdk@8 +openssl@1.1 +openssl@3 +openssl@3.0 +page +pcre +pcre2 +pixman +pkg-config +pkgconf +python-setuptools +python@3.10 +python@3.11 +python@3.12 +python@3.7 +python@3.8 +python@3.9 +readline +rust +sphinx-doc +sqlite +swig@3 +swig +tcl-tk +tree-sitter +unibilium +unzip +util-macros +xcb-proto +xorgproto +xtrans +xz +z3 +zstd diff --git a/script/generate-core.sh b/script/generate-core.sh index 6ce14a8..1ff1b44 100755 --- a/script/generate-core.sh +++ b/script/generate-core.sh @@ -1,117 +1,19 @@ #!/bin/bash -formulae=( - "autoconf" - "autoconf@2.13" - "autoconf@2.69" - "automake" - "bison@2.7" - "bison" - "ca-certificates" - "cairo" - "certifi" - "cmake" - "fontconfig" - "freetype" - "gawk" - "gdbm" - "gettext" - "giflib" - "glib" - "gmp" - "gobject-introspection" - "graphite2" - "harfbuzz" - "icu4c" - "jpeg-turbo" - "libgit2@1.5" - "libgit2@1.6" - "libgit2" - "libpng" - "libssh2" - "libtermkey" - "libtiff" - "libtool" - "libuv" - "libvterm" - "libx11" - "libxau" - "libxcb" - "libxdmcp" - "libxext" - "libxrender" - "little-cms2" - "llvm@8" - "llvm@9" - "llvm@11" - "llvm@12" - "llvm@13" - "llvm@14" - "llvm@15" - "llvm@16" - "llvm" - "lpeg" - "lua" - "lua@5.1" - "lua@5.3" - "luajit" - "luarocks" - "luv" - "lz4" - "lzo" - "m4" - "meson" - "mpdecimal" - "mpfr" - "msgpack" - "nasm" - "neovim" - "ninja" - "openjdk@11" - "openjdk@17" - "openjdk@8" - "openssl@1.1" - "openssl@3" - "openssl@3.0" - "page" - "pcre" - "pcre2" - "pixman" - "pkg-config" - "pkgconf" - "python-setuptools" - "python@3.10" - "python@3.11" - "python@3.12" - "python@3.7" - "python@3.8" - "python@3.9" - "readline" - "rust" - "sphinx-doc" - "sqlite" - "swig@3" - "swig" - "tcl-tk" - "tree-sitter" - "unibilium" - "unzip" - "util-macros" - "xcb-proto" - "xorgproto" - "xtrans" - "xz" - "z3" - "zstd" -) +CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +readonly CWD -for formula in "${formulae[@]}" -do +file="$CWD/formulae.txt" + +if [ ! -f "$file" ]; then + echo "File '$file' does not exist." + exit 1 +fi + +while IFS= read -r formula; do # Download and format JSON mkdir -p _data/formula-core - curl --silent --output-dir _data/formula-core --output "$formula_raw.json" "https://formulae.brew.sh/api/formula/$formula.json" - jq '.' "_data/formula-core/$formula_raw.json" > "_data/formula-core/$formula.json" - rm -f "_data/formula-core/$formula_raw.json" + curl -s "https://formulae.brew.sh/api/formula/$formula.json" | jq . > "_data/formula-core/$formula.json" # Make HTML file mkdir -p formula-core @@ -122,7 +24,6 @@ title: "$formula" layout: formula --- {{ content }} - EOF # Make JSON file @@ -133,6 +34,5 @@ EOF layout: formula_json --- {{ content }} - EOF -done +done < "$file" diff --git a/script/generate.rb b/script/generate.rb index b1ce17d..8b92c43 100755 --- a/script/generate.rb +++ b/script/generate.rb @@ -1,6 +1,6 @@ #!/usr/bin/env -S brew ruby -tap = Tap.fetch("coatl-dev/coatl-dev") +tap = Tap.fetch(ARGV.first) directories = ["_data/formula", "api/formula", "formula"] FileUtils.rm_rf directories + ["_data/formula_canonical.json"]