Skip to content

Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit

feat(installer): a failed install offers Show Log and Report on GitHub

raymondchins123749c24ed6
diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml
index f653ca1..3b3b30a 100644
--- a/.github/ISSUE_TEMPLATE/bug-report.yml
+++ b/.github/ISSUE_TEMPLATE/bug-report.yml
@@ -29,5 +29,6 @@ body:
label: Logs
description: |
Attach `~/Library/Application Support/bridgeplay/bridgeplay.log`. For a game, also
- attach its `bridgeplay-run.log` (Prefixes page › the game › Open Log).
+ attach its `bridgeplay-run.log` (Prefixes page › the game › Open Log). For the
+ installer, attach `~/Library/Logs/Bridgeplay/installer.log`.
render: text
diff --git a/app/Sources/BridgeplayInstaller/InstallerModel.swift b/app/Sources/BridgeplayInstaller/InstallerModel.swift
index a9bd034..3e0064d 100644
--- a/app/Sources/BridgeplayInstaller/InstallerModel.swift
+++ b/app/Sources/BridgeplayInstaller/InstallerModel.swift
@@ -80,6 +80,7 @@ final class InstallerModel {
guard preview == nil else { return }
stage = .checking
failure = nil
+ InstallerLog.write("Check on \(InstallerLog.system)")
do {
let service = self.service
try await Task.detached(priority: .userInitiated) { try service.recoverIfNeeded() }.value
@@ -92,6 +93,7 @@ final class InstallerModel {
try Task.checkCancellation()
let state = try service.state(for: fetched)
total = (state.isCurrent ? 0 : fetched.archiveLength) + (components?.length ?? 0)
+ InstallerLog.write("Release \(fetched.shortVersion), installed \(state.installedVersion ?? "none"), components \(components == nil ? "present" : "needed")")
switch state {
case .notInstalled: installedVersion = nil; stage = .review
case .updateAvailable(_, let current, _): installedVersion = current; stage = .review
@@ -110,6 +112,7 @@ final class InstallerModel {
defer { operation = nil }
stage = .downloading
failure = nil
+ InstallerLog.write("Install \(release.shortVersion) to \(destination.path)")
received = 0
downloadedBefore = 0
progress = nil
@@ -145,6 +148,7 @@ final class InstallerModel {
componentStatus = nil
try await Task.detached(priority: .userInitiated) {
try InstallerComponents.install(archive: archive, work: work) { line in
+ InstallerLog.write("Install.command: \(line)")
Task { @MainActor [weak self] in self?.componentStatus = Self.status(line) }
}
}.value
@@ -152,6 +156,7 @@ final class InstallerModel {
}
isCurrent = false
stage = .done
+ InstallerLog.write("Done")
} catch is CancellationError {
stage = .review
} catch { fail(error) }
@@ -197,7 +202,17 @@ final class InstallerModel {
}
private func fail(_ error: Error) {
+ InstallerLog.write("Failed: \(String(reflecting: error))")
failure = InstallerMessage.describe(error)
stage = .failed
}
+
+ func report() {
+ guard let failure, let url = InstallerReport.issueURL(failure: failure, version: version, installed: installedVersion) else { return }
+ NSWorkspace.shared.open(url)
+ }
+
+ func showLog() {
+ NSWorkspace.shared.activateFileViewerSelecting([InstallerLog.url])
+ }
}
diff --git a/app/Sources/BridgeplayInstaller/InstallerReport.swift b/app/Sources/BridgeplayInstaller/InstallerReport.swift
new file mode 100644
index 0000000..6b10b1b
--- /dev/null
+++ b/app/Sources/BridgeplayInstaller/InstallerReport.swift
@@ -0,0 +1,23 @@
+import Foundation
+import BridgeplayInstallerCore
+
+/// A GitHub issue prefilled from the bug report form. The user reviews it before posting.
+enum InstallerReport {
+ static func issueURL(failure: String, version: String, installed: String?) -> URL? {
+ let summary = failure.split(separator: "\n").first.map(String.init) ?? failure
+ let fields = [
+ ("template", "bug-report.yml"),
+ ("title", "Installer: \(summary.prefix(80))"),
+ ("what", "The installer stopped with:\n\n\(failure)"),
+ ("version", "Installer, offering \(version)" + (installed.map { ", installed \($0)" } ?? "")),
+ ("macos", InstallerLog.system),
+ ("logs", InstallerLog.tail()),
+ ]
+ var allowed = CharacterSet.urlQueryAllowed
+ allowed.remove(charactersIn: "&+=?#")
+ let query = fields.compactMap { name, value in
+ value.addingPercentEncoding(withAllowedCharacters: allowed).map { "\(name)=\($0)" }
+ }.joined(separator: "&")
+ return URL(string: "https://github.com/raymondchins/Bridgeplay/issues/new?\(query)")
+ }
+}
diff --git a/app/Sources/BridgeplayInstaller/InstallerView.swift b/app/Sources/BridgeplayInstaller/InstallerView.swift
index 3402a16..72b7807 100644
--- a/app/Sources/BridgeplayInstaller/InstallerView.swift
+++ b/app/Sources/BridgeplayInstaller/InstallerView.swift
@@ -200,6 +200,10 @@ struct InstallerView: View {
}
.buttonStyle(.pillPlain).keyboardShortcut(.cancelAction)
}
+ if model.stage == .failed {
+ Button(tr("Show Log")) { model.showLog() }.buttonStyle(.pillPlain)
+ Button(tr("Report on GitHub")) { model.report() }.buttonStyle(.pillPlain)
+ }
Spacer()
switch model.stage {
case .review:
diff --git a/app/Sources/BridgeplayInstaller/Resources/Localization/Localizable.xcstrings b/app/Sources/BridgeplayInstaller/Resources/Localization/Localizable.xcstrings
index 32d3b10..417c55a 100644
--- a/app/Sources/BridgeplayInstaller/Resources/Localization/Localizable.xcstrings
+++ b/app/Sources/BridgeplayInstaller/Resources/Localization/Localizable.xcstrings
@@ -671,6 +671,22 @@
}
}
},
+ "Report on GitHub" : {
+ "localizations" : {
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Segnala su GitHub"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "在 GitHub 上报告"
+ }
+ }
+ }
+ },
"Review" : {
"localizations" : {
"it" : {
@@ -719,6 +735,22 @@
}
}
},
+ "Show Log" : {
+ "localizations" : {
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Mostra registro"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "显示日志"
+ }
+ }
+ }
+ },
"Something went wrong" : {
"localizations" : {
"it" : {