From e2f7ff2e322b0aa5c845aa91b2069b270c61d2dc Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 8 Feb 2024 14:40:27 -0800 Subject: [PATCH 1/3] Lock the language version for the formula This will prevent issues like #57 where a new, incompatible embedded protocol version lands before we release a new Dart Sass version. Closes #57 --- Formula/sass.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Formula/sass.rb b/Formula/sass.rb index 18e885f..ca69436 100644 --- a/Formula/sass.rb +++ b/Formula/sass.rb @@ -15,12 +15,20 @@ class Sass < Formula depends_on "buf" => :build depends_on "dart-lang/dart/dart" => :build + resource "language" do + url "https://github.com/sass/sass.git", revision: "c04dbf6c447caf9d62094597e68fe5bf5d0b4025" + end + def install # Tell the pub server where these installations are coming from. ENV["PUB_ENVIRONMENT"] = "homebrew:sass" + (buildpath/'build/language').install resource("language") + system _dart/"dart", "pub", "get" + ENV["UPDATE_SASS_PROTOCOL"] = "false" system _dart/"dart", "run", "grinder", "protobuf" + ENV.delete "UPDATE_SASS_PROTOCOL" # Build a native-code executable on 64-bit systems only. 32-bit Dart # doesn't support this. From afc14d0609139e0c2641960bd4eee05d8a51eb42 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 8 Feb 2024 14:59:11 -0800 Subject: [PATCH 2/3] Update tests now that `brew audit [path]` is deprecated --- .github/workflows/ci.yaml | 21 ++++++++++++++------- Formula/sass.rb | 3 ++- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0e45b0c..296f1f7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -17,14 +17,21 @@ jobs: fail-fast: false matrix: recipe: - - sass.rb - - dart-sass-embedded@1.62.1.rb - - migrator.rb + - sass + - dart-sass-embedded@1.62.1 + - migrator steps: - uses: actions/checkout@v3 - run: brew update - - run: brew audit --strict --git --online --formula $GITHUB_WORKSPACE/Formula/${{ matrix.recipe }} - - run: brew install --formula $GITHUB_WORKSPACE/Formula/${{ matrix.recipe }} - - run: brew test $GITHUB_WORKSPACE/Formula/${{ matrix.recipe }} - - run: brew uninstall --formula $GITHUB_WORKSPACE/Formula/${{ matrix.recipe }} + - run: brew tap-new sass/sass + - run: brew --repository sass/sass + - run: | + path="$(brew --repository sass/sass)" + rm -rf "$path" + ln -s "$(pwd)" "$path" + # TODO: Add --online once https://github.com/Homebrew/brew/pull/16626 is fixed + - run: brew audit --strict --git sass/sass/${{ matrix.recipe }} + - run: brew install sass/sass/${{ matrix.recipe }} + - run: brew test sass/sass/${{ matrix.recipe }} + - run: brew uninstall sass/sass/${{ matrix.recipe }} diff --git a/Formula/sass.rb b/Formula/sass.rb index ca69436..b69319a 100644 --- a/Formula/sass.rb +++ b/Formula/sass.rb @@ -16,7 +16,8 @@ class Sass < Formula depends_on "dart-lang/dart/dart" => :build resource "language" do - url "https://github.com/sass/sass.git", revision: "c04dbf6c447caf9d62094597e68fe5bf5d0b4025" + url "https://github.com/sass/sass.git", + revision: "c04dbf6c447caf9d62094597e68fe5bf5d0b4025" end def install From 7c2ce4cf247af3b83b686bdf8d8cadd9db7467df Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 8 Feb 2024 15:57:46 -0800 Subject: [PATCH 3/3] Remove the old dart-sass-embedded formula This hasn't actually worked for a number of months and no one has complained, so it should be safe to delete. --- .github/workflows/ci.yaml | 1 - Formula/dart-sass-embedded@1.62.1.rb | 78 ---------------------------- 2 files changed, 79 deletions(-) delete mode 100644 Formula/dart-sass-embedded@1.62.1.rb diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 296f1f7..0226abb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,7 +18,6 @@ jobs: matrix: recipe: - sass - - dart-sass-embedded@1.62.1 - migrator steps: diff --git a/Formula/dart-sass-embedded@1.62.1.rb b/Formula/dart-sass-embedded@1.62.1.rb deleted file mode 100644 index edf2c69..0000000 --- a/Formula/dart-sass-embedded@1.62.1.rb +++ /dev/null @@ -1,78 +0,0 @@ -# typed: false -# frozen_string_literal: true - -require "yaml" - -# A formula for the Dart Sass Embedded CLI. -class DartSassEmbeddedAT1621 < Formula - desc "Stylesheet Preprocessor" - homepage "https://sass-lang.com" - - url "https://github.com/sass/dart-sass-embedded/archive/1.62.1.tar.gz" - sha256 "d7845134c31b6e288d267678fa85c16a89f02891ea70b761063f4e26912f68bd" - - depends_on "buf" => :build - depends_on "dart-lang/dart/dart" => :build - - def install - # Tell the pub server where these installations are coming from. - ENV["PUB_ENVIRONMENT"] = "homebrew:sass" - - system _dart/"dart", "pub", "get" - system _dart/"dart", "run", "grinder", "protobuf" - # Build a native-code executable on 64-bit systems only. 32-bit Dart - # doesn't support this. - if Hardware::CPU.is_64_bit? - _install_native_executable - else - _install_script_snapshot - end - chmod 0555, "#{bin}/dart-sass-embedded" - end - - test do - assert_match '"id": 0', shell_output("#{bin}/dart-sass-embedded --version") - end - - private - - def _dart - @_dart ||= Formula["dart-lang/dart/dart"].libexec/"bin" - end - - def _version - @_version ||= YAML.safe_load(File.read("pubspec.yaml"))["version"] - end - - def _protocol_version - @_protocol_version ||= File.read("build/embedded-protocol/VERSION").strip - end - - def _implementation_version - @_implementation_version ||= YAML.safe_load(File.read("pubspec.lock"))["packages"]["sass"]["version"] - end - - def _install_native_executable - system _dart/"dart", "compile", "exe", - "-Dprotocol-version=#{_protocol_version}", - "-Dcompiler-version=#{_version}", - "-Dimplementation-version=#{_implementation_version}", - "bin/dart_sass_embedded.dart", "-o", "dart-sass-embedded" - bin.install "dart-sass-embedded" - end - - def _install_script_snapshot - system _dart/"dart", "run", "grinder", "pkg-compile-snapshot" - libexec.install "build/dart-sass-embedded.snapshot" - - # Copy the version of the Dart VM we used into our lib directory so that if - # the user upgrades their Dart VM version it doesn't break Sass's snapshot, - # which was compiled with an older version. - cp _dart/"dart", libexec - - (bin/"dart-sass-embedded").write <<~SH - #!/bin/sh - exec "#{libexec}/dart" "#{libexec}/dart-sass-embedded.snapshot" "$@" - SH - end -end