Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

u3d/unity_versions: list from additional U3D_ADDITIONAL_PAGES #334

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions lib/u3d/unity_versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ module UnityVersions

MAC_WIN_SHADERS = %r{"(https?://[\w/\.-]+/[0-9a-f\+]{12,13}/)builtin_shaders-(\d+\.\d+\.\d+\w\d+)\.?\w+"}

MAC_DOWNLOAD = %r{"(https?://[\w/\.-]+/[0-9a-f\+]{12,13}/)MacEditorInstaller/[a-zA-Z0-9/\.\+]+-(\d+\.\d+\.\d+\w\d+)\.?\w+"}
MAC_DOWNLOAD_2018_2 = %r{"(https?://[\w/\.-]+/[0-9a-f\+]{12,13}/)UnityDownloadAssistant-(\d+\.\d+\.\d+\w\d+)\.?\w+"}

WIN_DOWNLOAD = %r{"(https?://[\w/\.-]+/[0-9a-f\+]{12,13}/)Windows..EditorInstaller/[a-zA-Z0-9/\.\+]+-(\d+\.\d+\.\d+\w\d+)\.?\w+"}
# NOTE: the version info is no longer contained in the url for the newest Unity beta versions
# As a workaround, we work with the Android package
WIN_BETA_DOWNLOAD_2018_3 = %r{"(https?://[\w/\.-]+/[0-9a-f\+]{12,13}/)TargetSupportInstaller/UnitySetup-Android-Support-for-Editor-(\d+\.\d+\.\d+\w\d+)\.?\w+"}
LINUX_DOWNLOAD_DATED = %r{"(https?://[\w/\._-]+/unity\-editor\-installer\-(\d+\.\d+\.\d+\w\d+).*\.sh)"}
LINUX_DOWNLOAD_RECENT_PAGE = %r{"(https?://beta\.unity3d\.com/download/[a-zA-Z0-9/\.\+]+/public_download\.html)"}
LINUX_DOWNLOAD_RECENT_FILE = %r{'(https?://beta\.unity3d\.com/download/[a-zA-Z0-9/\.\+]+/unity\-editor\-installer\-(\d+\.\d+\.\d+(?:x)?\w\d+).*\.sh)'}
Expand All @@ -138,13 +145,17 @@ class << self
def list_available(os: nil)
os ||= U3dCore::Helper.operating_system

additional_pages_env = ENV['U3D_ADDITIONAL_PAGES']
additional_pages = additional_pages_env ? additional_pages_env.split(',') : []

case os
when :linux
UI.important 'Additional download pages are not yet support on Linux' unless additional_pages.empty?
return U3d::UnityVersions::LinuxVersions.list_available
when :mac
return U3d::UnityVersions::MacVersions.list_available
return U3d::UnityVersions::MacVersions.list_available(additional_pages: additional_pages)
when :win
return U3d::UnityVersions::WindowsVersions.list_available
return U3d::UnityVersions::WindowsVersions.list_available(additional_pages: additional_pages)
else
raise ArgumentError, "Operating system #{os} not supported"
end
Expand Down Expand Up @@ -274,31 +285,34 @@ def fetch_json(os)
@versions
end

def fetch_all_channels
def fetch_all_channels(additional_pages: [])
fetch_some('lts', UNITY_LTSES)
fetch_some('stable', UNITY_DOWNLOADS)
fetch_some('patch', UNITY_PATCHES)
# This does not work any longer
# fetch_some('beta', UNITY_BETAS)
additional_pages.each do |page|
fetch_some('custom', page)
end
@versions
end
end

class MacVersions
class << self
def list_available
def list_available(additional_pages: [])
versions_fetcher = VersionsFetcher.new(pattern: [MAC_WIN_SHADERS])
versions_fetcher.fetch_all_channels
versions_fetcher.fetch_all_channels(additional_pages: additional_pages)
versions_fetcher.fetch_json('darwin')
end
end
end

class WindowsVersions
class << self
def list_available
def list_available(additional_pages: [])
versions_fetcher = VersionsFetcher.new(pattern: MAC_WIN_SHADERS)
versions_fetcher.fetch_all_channels
versions_fetcher.fetch_all_channels(additional_pages: additional_pages)
versions_fetcher.fetch_json('win32')
end
end
Expand Down