mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
chore(apple): Make update download URL compatible with upcoming standalone macOS release (#7666)
- Updates Apple download URL to point to app store or website depending on package type - Refactors `AppInfoPlistConstants` to `BundleHelper` to better name what it does
This commit is contained in:
@@ -1,12 +1,21 @@
|
||||
//
|
||||
// AppInfoPlistConstants.swift
|
||||
// Bundle.swift
|
||||
// (c) 2024 Firezone, Inc.
|
||||
// LICENSE: Apache-2.0
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
struct AppInfoPlistConstants {
|
||||
enum BundleHelper {
|
||||
static func isAppStore() -> Bool {
|
||||
if let receiptURL = Bundle.main.appStoreReceiptURL,
|
||||
FileManager.default.fileExists(atPath: receiptURL.path) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
static var gitSha: String {
|
||||
guard let gitSha = Bundle.main.object(forInfoDictionaryKey: "GitSha") as? String,
|
||||
!gitSha.isEmpty
|
||||
@@ -21,7 +21,7 @@ public struct SharedAccess {
|
||||
public static var baseFolderURL: URL {
|
||||
guard
|
||||
let url = FileManager.default.containerURL(
|
||||
forSecurityApplicationGroupIdentifier: AppInfoPlistConstants.appGroupId)
|
||||
forSecurityApplicationGroupIdentifier: BundleHelper.appGroupId)
|
||||
else {
|
||||
fatalError("Shared folder unavailable")
|
||||
}
|
||||
|
||||
@@ -95,8 +95,7 @@ public enum Telemetry {
|
||||
return "ios-appstore-\(version)"
|
||||
#else
|
||||
// Apps from the app store have a receipt file
|
||||
if let receiptURL = Bundle.main.appStoreReceiptURL,
|
||||
FileManager.default.fileExists(atPath: receiptURL.path) {
|
||||
if BundleHelper.isAppStore() {
|
||||
return "macos-appstore-\(version)"
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ public struct FirezoneId {
|
||||
private static let query: [CFString: Any] = [
|
||||
kSecAttrLabel: "Firezone id",
|
||||
kSecAttrAccount: "2",
|
||||
kSecAttrService: AppInfoPlistConstants.appGroupId,
|
||||
kSecAttrService: BundleHelper.appGroupId,
|
||||
kSecAttrDescription: "Firezone device id",
|
||||
]
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ public struct Token: CustomStringConvertible {
|
||||
private static let query: [CFString: Any] = [
|
||||
kSecAttrLabel: "Firezone token",
|
||||
kSecAttrAccount: "1",
|
||||
kSecAttrService: AppInfoPlistConstants.appGroupId,
|
||||
kSecAttrService: BundleHelper.appGroupId,
|
||||
kSecAttrDescription: "Firezone access token",
|
||||
]
|
||||
|
||||
|
||||
@@ -308,7 +308,7 @@ public final class MenuBar: NSObject, ObservableObject {
|
||||
}
|
||||
|
||||
@objc private func updateAvailableButtonTapped() {
|
||||
NSWorkspace.shared.open(appStoreLink)
|
||||
NSWorkspace.shared.open(UpdateChecker.downloadURL())
|
||||
}
|
||||
|
||||
@objc private func documentationButtonTapped() {
|
||||
|
||||
@@ -373,7 +373,7 @@ public struct SettingsView: View {
|
||||
}
|
||||
Spacer()
|
||||
HStack {
|
||||
Text("Build: \(AppInfoPlistConstants.gitSha)")
|
||||
Text("Build: \(BundleHelper.gitSha)")
|
||||
.textSelection(.enabled)
|
||||
.foregroundColor(.gray)
|
||||
Spacer()
|
||||
@@ -447,7 +447,7 @@ public struct SettingsView: View {
|
||||
}
|
||||
Spacer()
|
||||
HStack {
|
||||
Text("Build: \(AppInfoPlistConstants.gitSha)")
|
||||
Text("Build: \(BundleHelper.gitSha)")
|
||||
.textSelection(.enabled)
|
||||
.foregroundColor(.gray)
|
||||
Spacer()
|
||||
|
||||
@@ -73,9 +73,15 @@ class UpdateChecker {
|
||||
|
||||
task.resume()
|
||||
}
|
||||
}
|
||||
|
||||
public let appStoreLink = URL(string: "https://apps.apple.com/app/firezone/id6443661826")!
|
||||
static func downloadURL() -> URL {
|
||||
if BundleHelper.isAppStore() {
|
||||
return URL(string: "https://apps.apple.com/app/firezone/id6443661826")!
|
||||
}
|
||||
|
||||
return URL(string: "https://www.firezone.dev/dl/firezone-client-macos/latest")!
|
||||
}
|
||||
}
|
||||
|
||||
private class NotificationAdapter: NSObject, UNUserNotificationCenterDelegate {
|
||||
private var lastNotifiedVersion: SemVerString?
|
||||
@@ -140,7 +146,7 @@ private class NotificationAdapter: NSObject, UNUserNotificationCenterDelegate {
|
||||
return
|
||||
}
|
||||
|
||||
NSWorkspace.shared.open(appStoreLink)
|
||||
NSWorkspace.shared.open(UpdateChecker.downloadURL())
|
||||
|
||||
completionHandler()
|
||||
}
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
// Add all server-side redirects here. Will be loaded by next.config.mjs.
|
||||
|
||||
module.exports = [
|
||||
/*
|
||||
*
|
||||
* macOS Client
|
||||
*
|
||||
*/
|
||||
{
|
||||
source: "/dl/firezone-client-macos/latest",
|
||||
destination:
|
||||
// mark:current-apple-version
|
||||
"https://www.github.com/firezone/firezone/releases/download/macos-client-1.3.9/firezone-macos-client-1.3.9.dmg",
|
||||
permanent: false,
|
||||
},
|
||||
/*
|
||||
*
|
||||
* Android Client
|
||||
|
||||
@@ -3,6 +3,11 @@ import { NextResponse, NextRequest } from "next/server";
|
||||
// This middleware is needed because NextJS doesn't populate params in the destination
|
||||
// more than once. See https://github.com/vercel/next.js/issues/66891
|
||||
const versionedRedirects = [
|
||||
{
|
||||
source: /^\/dl\/firezone-client-macos\/(\d+\.\d+\.\d+)$/,
|
||||
destination:
|
||||
"https://www.github.com/firezone/firezone/releases/download/macos-client-:version/firezone-macos-client-:version.dmg",
|
||||
},
|
||||
{
|
||||
source: /^\/dl\/firezone-client-android\/(\d+\.\d+\.\d+)$/,
|
||||
destination:
|
||||
|
||||
Reference in New Issue
Block a user