find_appcast: detect electron-builder appcasts (#69968)

* find_appcast: detect electron-builder appcasts

Fixes Homebrew/homebrew-cask#69749.

* find_appcast: address @vitorgalvao's comments
This commit is contained in:
L. E. Segovia
2019-10-02 00:48:53 +01:00
committed by Vítor Galvão
parent 5e9f77552a
commit ee57814d55
2 changed files with 55 additions and 0 deletions
+13
View File
@@ -69,6 +69,18 @@ function find_devmate {
verify_appcast 'DevMate' "${url}"
}
function find_electron_builder {
local app url
app="${1}"
electron_parser_script="$(brew --repo homebrew/cask)/developer/bin/parse_electron_builder_appcast"
url="$("${electron_parser_script}" "${app}")"
verify_appcast 'electron-builder' "${url}"
}
# Exit if no argument (or more than one) was given
if [[ -z "${1}" ]] || [[ -n "${2}" ]]; then
usage
@@ -86,3 +98,4 @@ fi
find_sparkle "${path_to_app}"
find_hockeyapp "${path_to_app}"
find_devmate "${path_to_app}"
find_electron_builder "${path_to_app}"
+42
View File
@@ -0,0 +1,42 @@
#!/usr/bin/env ruby
require "pathname"
require "yaml"
def parse(app_path)
appcast_url = Pathname.new "#{app_path}/Contents/Resources/app-update.yml"
exit 2 unless appcast_url.exist?
data = YAML.load_file appcast_url
case data["provider"]
when "github"
owner = data["owner"]
repo = data["repo"]
puts "https://github.com/#{owner}/#{repo}/releases.atom"
when "s3"
bucket = data["bucket"]
channel = data["channel"]
puts "https://#{bucket}.s3.amazon-aws.yml/#{channel}/latest-mac.yml"
end
end
###
### main
###
usage = <<~EOS
Usage: parse_electron_builder_appcast <application.app>
Given an Application name or a path to an Application, attempt to parse the
included 'app-update.yml' manifest and output the appcast URL.
EOS
unless ARGV.length == 1
puts usage
exit 1
end
parse(ARGV[0])