From 3f24682767ea0f78d6933b2f1fc9252f7a57aaa0 Mon Sep 17 00:00:00 2001 From: Glenn 'devalias' Grant Date: Fri, 8 Dec 2023 17:24:19 +1100 Subject: [PATCH 01/11] add truhu 289 --- Casks/t/truhu.rb | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Casks/t/truhu.rb diff --git a/Casks/t/truhu.rb b/Casks/t/truhu.rb new file mode 100644 index 0000000000..33dd0cdf71 --- /dev/null +++ b/Casks/t/truhu.rb @@ -0,0 +1,57 @@ +cask "truhu" do + version "289" + sha256 "a5c1de3ddbf3d001fa88ac745e075b894964898388db1da7bb854c922cec792f" + + url "https://truhu-mobile-builds.s3.us-west-2.amazonaws.com/TruHu+Desktop+#{version}.dmg" + name "TruHu" + desc "Uses a Desktop and Mobile app together to measure your display’s colors and proceed with calibration" + homepage "https://truhu.app/" + + # NOTE: This method isn't stable since the build hash will change + # livecheck do + # url "https://truhu.app/static/js/main.9202b0c2.js" + # regex(/\{no:(\d+),date:"[^"]*"/i) + # end + + # NOTE: This gets an error while trying to run it: + # Error: truhu: private method `open' called for URI:Module + # Is there a better way to check/use content from 2 different URLs in a livecheck? + livecheck do + url "https://truhu.app/downloads/index.html" + regex(%r{/static/js/main\.[a-f0-9]+\.js}) + + strategy :page_match do |page, regex| + # Find the script URL with the hash + script_path = page.match(regex) + next if script_path.blank? + + # Form the complete URL for the script + script_full_url = "https://truhu.app#{script_path}" + + # Fetch the script content + script_content = URI.open(script_full_url).read + + # Extract version and date + script_content.scan(/\{no:(\d+),date:"([^"]+)"/i).map do |match| + version, date = match + # You can format the version and date as needed here + "#{version},#{date}" + end + end + end + + # NOTE: This is a last resort + # livecheck do + # skip "No version information available" + # end + + app "TruHu Mac Desktop.app" + + zap trash: [ + "~/Library/Application Support/TruHuDesktop", + "~/Library/Caches/Seboya.TruHuCalibrator.Mac", + "~/Library/HTTPStorages/Seboya.TruHuCalibrator.Mac", + "~/Library/Preferences/Seboya.TruHuCalibrator.Mac.plist", + "~/Library/WebKit/Seboya.TruHuCalibrator.Mac", + ] +end From b3b1882366299e22b1795c031e0c570fe8f9ff8e Mon Sep 17 00:00:00 2001 From: Bevan Kay Date: Sat, 9 Dec 2023 08:59:48 +1100 Subject: [PATCH 02/11] truhu: update livecheck --- Casks/t/truhu.rb | 38 ++++++-------------------------------- 1 file changed, 6 insertions(+), 32 deletions(-) diff --git a/Casks/t/truhu.rb b/Casks/t/truhu.rb index 33dd0cdf71..4793773695 100644 --- a/Casks/t/truhu.rb +++ b/Casks/t/truhu.rb @@ -4,47 +4,21 @@ cask "truhu" do url "https://truhu-mobile-builds.s3.us-west-2.amazonaws.com/TruHu+Desktop+#{version}.dmg" name "TruHu" - desc "Uses a Desktop and Mobile app together to measure your display’s colors and proceed with calibration" + desc "Display calibration utility" homepage "https://truhu.app/" - # NOTE: This method isn't stable since the build hash will change - # livecheck do - # url "https://truhu.app/static/js/main.9202b0c2.js" - # regex(/\{no:(\d+),date:"[^"]*"/i) - # end - - # NOTE: This gets an error while trying to run it: - # Error: truhu: private method `open' called for URI:Module - # Is there a better way to check/use content from 2 different URLs in a livecheck? livecheck do url "https://truhu.app/downloads/index.html" - regex(%r{/static/js/main\.[a-f0-9]+\.js}) - + regex(/\{no:(\d+)\s*,date/i) strategy :page_match do |page, regex| - # Find the script URL with the hash - script_path = page.match(regex) - next if script_path.blank? + js_file = page[%r{src=["']?/(static/js/main\.[a-f0-9]+\.js)}, 1] + next if js_file.blank? - # Form the complete URL for the script - script_full_url = "https://truhu.app#{script_path}" - - # Fetch the script content - script_content = URI.open(script_full_url).read - - # Extract version and date - script_content.scan(/\{no:(\d+),date:"([^"]+)"/i).map do |match| - version, date = match - # You can format the version and date as needed here - "#{version},#{date}" - end + version_page = Homebrew::Livecheck::Strategy.page_content("https://truhu.app/#{js_file}") + version_page[:content].scan(regex).flatten end end - # NOTE: This is a last resort - # livecheck do - # skip "No version information available" - # end - app "TruHu Mac Desktop.app" zap trash: [ From 0ff0c4aae25d87841b90882885aac18d81685e3c Mon Sep 17 00:00:00 2001 From: Glenn 'devalias' Grant Date: Sat, 9 Dec 2023 10:57:04 +1100 Subject: [PATCH 03/11] add 'verified' + 'depends_on' --- Casks/t/truhu.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Casks/t/truhu.rb b/Casks/t/truhu.rb index 4793773695..fbced64aaf 100644 --- a/Casks/t/truhu.rb +++ b/Casks/t/truhu.rb @@ -2,7 +2,8 @@ cask "truhu" do version "289" sha256 "a5c1de3ddbf3d001fa88ac745e075b894964898388db1da7bb854c922cec792f" - url "https://truhu-mobile-builds.s3.us-west-2.amazonaws.com/TruHu+Desktop+#{version}.dmg" + url "https://truhu-mobile-builds.s3.us-west-2.amazonaws.com/TruHu+Desktop+#{version}.dmg", + verified: "truhu-mobile-builds.s3.us-west-2.amazonaws.com/" name "TruHu" desc "Display calibration utility" homepage "https://truhu.app/" @@ -21,6 +22,8 @@ cask "truhu" do app "TruHu Mac Desktop.app" + depends_on macos: ">= :catalina" + zap trash: [ "~/Library/Application Support/TruHuDesktop", "~/Library/Caches/Seboya.TruHuCalibrator.Mac", From 923f5d0d6e793691f3f0a95148b1b2858ba45ad1 Mon Sep 17 00:00:00 2001 From: Glenn 'devalias' Grant Date: Sat, 9 Dec 2023 11:01:41 +1100 Subject: [PATCH 04/11] fix "The livecheck URL https://truhu.app/downloads/index.html is not reachable (HTTP status code 404)" --- Casks/t/truhu.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Casks/t/truhu.rb b/Casks/t/truhu.rb index fbced64aaf..2a4478b9e8 100644 --- a/Casks/t/truhu.rb +++ b/Casks/t/truhu.rb @@ -9,7 +9,7 @@ cask "truhu" do homepage "https://truhu.app/" livecheck do - url "https://truhu.app/downloads/index.html" + url "https://truhu.app/" regex(/\{no:(\d+)\s*,date/i) strategy :page_match do |page, regex| js_file = page[%r{src=["']?/(static/js/main\.[a-f0-9]+\.js)}, 1] From a81e53d414ad1b15848f1f85cbf035883724e79d Mon Sep 17 00:00:00 2001 From: Bevan Kay Date: Sat, 9 Dec 2023 11:03:29 +1100 Subject: [PATCH 05/11] Update truhu.rb --- Casks/t/truhu.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Casks/t/truhu.rb b/Casks/t/truhu.rb index 2a4478b9e8..e30dc1577c 100644 --- a/Casks/t/truhu.rb +++ b/Casks/t/truhu.rb @@ -9,7 +9,7 @@ cask "truhu" do homepage "https://truhu.app/" livecheck do - url "https://truhu.app/" + url :url regex(/\{no:(\d+)\s*,date/i) strategy :page_match do |page, regex| js_file = page[%r{src=["']?/(static/js/main\.[a-f0-9]+\.js)}, 1] From e5c2488218746e43345696acce01d1cbf9ff0ade Mon Sep 17 00:00:00 2001 From: Glenn 'devalias' Grant Date: Sat, 9 Dec 2023 11:29:11 +1100 Subject: [PATCH 06/11] brew style --fix truhu --- Casks/t/truhu.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Casks/t/truhu.rb b/Casks/t/truhu.rb index e30dc1577c..c621035de1 100644 --- a/Casks/t/truhu.rb +++ b/Casks/t/truhu.rb @@ -20,10 +20,10 @@ cask "truhu" do end end - app "TruHu Mac Desktop.app" - depends_on macos: ">= :catalina" + app "TruHu Mac Desktop.app" + zap trash: [ "~/Library/Application Support/TruHuDesktop", "~/Library/Caches/Seboya.TruHuCalibrator.Mac", From 3819a307bc89c5e5920138ea35e582d236e65a40 Mon Sep 17 00:00:00 2001 From: Glenn 'devalias' Grant Date: Sat, 9 Dec 2023 11:36:41 +1100 Subject: [PATCH 07/11] improve .app name --- Casks/t/truhu.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Casks/t/truhu.rb b/Casks/t/truhu.rb index c621035de1..feb2b10816 100644 --- a/Casks/t/truhu.rb +++ b/Casks/t/truhu.rb @@ -22,7 +22,7 @@ cask "truhu" do depends_on macos: ">= :catalina" - app "TruHu Mac Desktop.app" + app "TruHu Mac Desktop.app", target: "TruHu.app" zap trash: [ "~/Library/Application Support/TruHuDesktop", From a45184038c887871bfb7d571a1658737667efc1c Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Fri, 8 Dec 2023 19:56:05 -0500 Subject: [PATCH 08/11] truhu: update livecheck --- Casks/t/truhu.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Casks/t/truhu.rb b/Casks/t/truhu.rb index feb2b10816..e97db3a5cc 100644 --- a/Casks/t/truhu.rb +++ b/Casks/t/truhu.rb @@ -9,14 +9,16 @@ cask "truhu" do homepage "https://truhu.app/" livecheck do - url :url - regex(/\{no:(\d+)\s*,date/i) + url :homepage + regex(/[{,]\s*no:\s*(\d+)\s*[},]/im) strategy :page_match do |page, regex| - js_file = page[%r{src=["']?/(static/js/main\.[a-f0-9]+\.js)}, 1] + js_file = page[%r{src=["']?/(static/js/main[._-]\h+\.js)}, 1] next if js_file.blank? version_page = Homebrew::Livecheck::Strategy.page_content("https://truhu.app/#{js_file}") - version_page[:content].scan(regex).flatten + next if version_page[:content].blank? + + version_page[:content].scan(regex).map { |match| match[0] } end end From e7fc02bbbbde54a8817ade5a8db2efd53760d21d Mon Sep 17 00:00:00 2001 From: Glenn 'devalias' Grant Date: Sat, 9 Dec 2023 12:02:59 +1100 Subject: [PATCH 09/11] Revert "improve .app name" This reverts commit 3819a307bc89c5e5920138ea35e582d236e65a40. --- Casks/t/truhu.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Casks/t/truhu.rb b/Casks/t/truhu.rb index e97db3a5cc..6ad277e0aa 100644 --- a/Casks/t/truhu.rb +++ b/Casks/t/truhu.rb @@ -24,7 +24,7 @@ cask "truhu" do depends_on macos: ">= :catalina" - app "TruHu Mac Desktop.app", target: "TruHu.app" + app "TruHu Mac Desktop.app" zap trash: [ "~/Library/Application Support/TruHuDesktop", From 1a6e3ed27de0e219f253d851b2dab256279c3b1f Mon Sep 17 00:00:00 2001 From: Bevan Kay Date: Sat, 9 Dec 2023 12:53:27 +1100 Subject: [PATCH 10/11] Update truhu.rb --- Casks/t/truhu.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Casks/t/truhu.rb b/Casks/t/truhu.rb index 6ad277e0aa..fd05ef3e18 100644 --- a/Casks/t/truhu.rb +++ b/Casks/t/truhu.rb @@ -6,7 +6,7 @@ cask "truhu" do verified: "truhu-mobile-builds.s3.us-west-2.amazonaws.com/" name "TruHu" desc "Display calibration utility" - homepage "https://truhu.app/" + homepage "https://truhu.app" livecheck do url :homepage From 49c524e7b302f5b19cc2e5bdf3779aa11d937521 Mon Sep 17 00:00:00 2001 From: Glenn 'devalias' Grant Date: Sat, 9 Dec 2023 12:58:46 +1100 Subject: [PATCH 11/11] Revert "Update truhu.rb" This reverts commit 1a6e3ed27de0e219f253d851b2dab256279c3b1f. --- Casks/t/truhu.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Casks/t/truhu.rb b/Casks/t/truhu.rb index fd05ef3e18..6ad277e0aa 100644 --- a/Casks/t/truhu.rb +++ b/Casks/t/truhu.rb @@ -6,7 +6,7 @@ cask "truhu" do verified: "truhu-mobile-builds.s3.us-west-2.amazonaws.com/" name "TruHu" desc "Display calibration utility" - homepage "https://truhu.app" + homepage "https://truhu.app/" livecheck do url :homepage