cask "intellij-idea" do version "2021.2.2,212.5284.40" if Hardware::CPU.intel? sha256 "f18cbaf04e757e98648fb730ba02e3ecb535fad959dce36a5498890a2e9dc3e9" url "https://download.jetbrains.com/idea/ideaIU-#{version.before_comma}.dmg" else sha256 "66690cab8b68764f8fbda157008563585d671253070558bfa23a92e2b33c5a0d" url "https://download.jetbrains.com/idea/ideaIU-#{version.before_comma}-aarch64.dmg" end name "IntelliJ IDEA Ultimate" desc "Java IDE by JetBrains" homepage "https://www.jetbrains.com/idea/" livecheck do url "https://data.services.jetbrains.com/products/releases?code=IIU&latest=true&type=release" strategy :page_match do |page| JSON.parse(page)["IIU"].map do |release| "#{release["version"]},#{release["build"]}" end end end auto_updates true depends_on macos: ">= :high_sierra" app "IntelliJ IDEA.app" uninstall_postflight do ENV["PATH"].split(File::PATH_SEPARATOR).map { |path| File.join(path, "idea") }.each do |path| if File.exist?(path) && File.readlines(path).grep(/# see com.intellij.idea.SocketLock for the server side of this interface/).any? File.delete(path) end end end zap trash: [ "~/Library/Application Support/JetBrains/IntelliJIdea#{version.major_minor}", "~/Library/Caches/JetBrains/IntelliJIdea#{version.major_minor}", "~/Library/Logs/JetBrains/IntelliJIdea#{version.major_minor}", "~/Library/Preferences/com.jetbrains.intellij.plist", "~/Library/Preferences/IntelliJIdea#{version.major_minor}", "~/Library/Preferences/jetbrains.idea.*.plist", "~/Library/Saved Application State/com.jetbrains.intellij.savedState", ] end