Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit
Swift apple-silicond3dmetaldxmtdxvkgame-porting-toolkitgptkmac-gamingmacosmetalfxrosetta-2steamsteam-playwinewinecx
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.ymlindex f653ca1..3b3b30a 100644--- a/.github/ISSUE_TEMPLATE/bug-report.yml+++ b/.github/ISSUE_TEMPLATE/bug-report.yml@@ -29,5 +29,6 @@ body:label: Logsdescription: |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: textdiff --git a/app/Sources/BridgeplayInstaller/InstallerModel.swift b/app/Sources/BridgeplayInstaller/InstallerModel.swiftindex 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 = .checkingfailure = nil+ InstallerLog.write("Check on \(InstallerLog.system)")do {let service = self.servicetry 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 = .reviewcase .updateAvailable(_, let current, _): installedVersion = current; stage = .review@@ -110,6 +112,7 @@ final class InstallerModel {defer { operation = nil }stage = .downloadingfailure = nil+ InstallerLog.write("Install \(release.shortVersion) to \(destination.path)")received = 0downloadedBefore = 0progress = nil@@ -145,6 +148,7 @@ final class InstallerModel {componentStatus = niltry 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 = falsestage = .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.swiftnew file mode 100644index 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.swiftindex 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.xcstringsindex 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" : {