diff --git a/Mist.xcodeproj/project.pbxproj b/Mist.xcodeproj/project.pbxproj index fa74dd0..85c5777 100644 --- a/Mist.xcodeproj/project.pbxproj +++ b/Mist.xcodeproj/project.pbxproj @@ -123,8 +123,6 @@ 39CF562F2862A797006FB5D2 /* ISOConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39CF562E2862A797006FB5D2 /* ISOConverter.swift */; }; 39CF56312862A8C5006FB5D2 /* InstallMediaCreator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39CF56302862A8C5006FB5D2 /* InstallMediaCreator.swift */; }; 39CF56332862B7A2006FB5D2 /* PackageCreator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39CF56322862B7A2006FB5D2 /* PackageCreator.swift */; }; - 39CF56352862D4BF006FB5D2 /* FileCompressor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39CF56342862D4BF006FB5D2 /* FileCompressor.swift */; }; - 39CF56392862D75D006FB5D2 /* FileCreator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39CF56382862D75D006FB5D2 /* FileCreator.swift */; }; 39D68B892861369B00A7848C /* InstallerCreator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39D68B882861369B00A7848C /* InstallerCreator.swift */; }; 39FF05EE2859820900A86670 /* AppCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39FF05ED2859820900A86670 /* AppCommands.swift */; }; 39FF05F02859848500A86670 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39FF05EF2859848500A86670 /* SettingsView.swift */; }; @@ -265,8 +263,6 @@ 39CF562E2862A797006FB5D2 /* ISOConverter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ISOConverter.swift; sourceTree = ""; }; 39CF56302862A8C5006FB5D2 /* InstallMediaCreator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstallMediaCreator.swift; sourceTree = ""; }; 39CF56322862B7A2006FB5D2 /* PackageCreator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PackageCreator.swift; sourceTree = ""; }; - 39CF56342862D4BF006FB5D2 /* FileCompressor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileCompressor.swift; sourceTree = ""; }; - 39CF56382862D75D006FB5D2 /* FileCreator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileCreator.swift; sourceTree = ""; }; 39D68B882861369B00A7848C /* InstallerCreator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstallerCreator.swift; sourceTree = ""; }; 39FF05ED2859820900A86670 /* AppCommands.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppCommands.swift; sourceTree = ""; }; 39FF05EF2859848500A86670 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = ""; }; @@ -376,8 +372,6 @@ 39CF56232861CA85006FB5D2 /* DiskImageUnmounter.swift */, 3935F47D2864813B00760AB0 /* DownloadManager.swift */, 39CA25E22941D8BB0030711E /* FileAttributesUpdater.swift */, - 39CF56382862D75D006FB5D2 /* FileCreator.swift */, - 39CF56342862D4BF006FB5D2 /* FileCompressor.swift */, 39CF56162861BE66006FB5D2 /* FileCopier.swift */, 398734C728601FFC00B4C357 /* FileMover.swift */, 39D68B882861369B00A7848C /* InstallerCreator.swift */, @@ -815,7 +809,6 @@ 39148CFC28DD55B300011FF5 /* PathControl.swift in Sources */, 3935F4892866C68000760AB0 /* DownloadSectionHeaderView.swift in Sources */, 39252AB5285C706000956C74 /* URL+Extension.swift in Sources */, - 39CF56352862D4BF006FB5D2 /* FileCompressor.swift in Sources */, 390451D828573A2500E0B563 /* ExportListView.swift in Sources */, 39FF05EE2859820900A86670 /* AppCommands.swift in Sources */, 39252AA3285C3CC400956C74 /* CodesigningPickerView.swift in Sources */, @@ -833,7 +826,6 @@ 39CB5E3F2941486D00CFDBB8 /* CatalogSeedType.swift in Sources */, 39252A7F285AC6F600956C74 /* SettingsPackagesView.swift in Sources */, 39CF562F2862A797006FB5D2 /* ISOConverter.swift in Sources */, - 39CF56392862D75D006FB5D2 /* FileCreator.swift in Sources */, 39FF05FA285985DD00A86670 /* SettingsAboutView.swift in Sources */, 3935F4AC286B04BC00760AB0 /* HelperToolLaunchdPropertyList.swift in Sources */, 39FF05F42859850500A86670 /* SettingsGeneralView.swift in Sources */, diff --git a/Mist/Extensions/Dictionary+Extension.swift b/Mist/Extensions/Dictionary+Extension.swift index ed43a2e..de0def5 100644 --- a/Mist/Extensions/Dictionary+Extension.swift +++ b/Mist/Extensions/Dictionary+Extension.swift @@ -5,9 +5,6 @@ // Created by Nindi Gill on 13/6/2022. // -import Foundation -import Yams - extension Dictionary where Key == String { func firmwareCSVString() -> String { @@ -41,18 +38,4 @@ extension Dictionary where Key == String { let string: String = "\"\(identifier)\",\"\(name)\",\"=\"\"\(version)\"\"\",\"=\"\"\(build)\"\"\",\(size),\(date),\(compatible ? "YES" : "NO")\n" return string } - - func jsonString() throws -> String { - let data: Data = try JSONSerialization.data(withJSONObject: self, options: [.prettyPrinted, .sortedKeys]) - return String(data: data, encoding: .utf8) ?? "" - } - - func propertyListString() throws -> String { - let data: Data = try PropertyListSerialization.data(fromPropertyList: self, format: .xml, options: .bitWidth) - return String(data: data, encoding: .utf8) ?? "" - } - - func yamlString() throws -> String { - try Yams.dump(object: self) - } } diff --git a/Mist/Helpers/FileCompressor.swift b/Mist/Helpers/FileCompressor.swift deleted file mode 100644 index 9812ec0..0000000 --- a/Mist/Helpers/FileCompressor.swift +++ /dev/null @@ -1,30 +0,0 @@ -// -// FileCompressor.swift -// Mist -// -// Created by Nindi Gill on 22/6/2022. -// - -import Foundation - -/// Helper struct to create Zip archives. -struct FileCompressor { - - /// Compress a file or the contents of a directory. - /// - /// - Parameters: - /// - url: The URL of the file or directory to be compressed. - /// - destination: The URL of the Zip file to be created. - /// - /// - Throws: An `Error` if the command failed to execute. - static func compress(_ url: URL, to destination: URL) async throws { - try await DirectoryRemover.remove(destination) - - let arguments: [String] = ["ditto", "-c", "-k", "--keepParent", "--sequesterRsrc", "--zlibCompressionLevel", "0", url.path, destination.path] - let result: (terminationStatus: Int32, standardOutput: String?, standardError: String?) = try ShellExecutor.shared.execute(arguments) - - guard result.terminationStatus == 0 else { - throw MistError.invalidTerminationStatus(status: result.terminationStatus, string: result.standardError) - } - } -} diff --git a/Mist/Helpers/FileCreator.swift b/Mist/Helpers/FileCreator.swift deleted file mode 100644 index 8811389..0000000 --- a/Mist/Helpers/FileCreator.swift +++ /dev/null @@ -1,26 +0,0 @@ -// -// FileCreator.swift -// Mist -// -// Created by Nindi Gill on 22/6/2022. -// - -import Foundation - -/// Helper struct to create files with textual content. -struct FileCreator { - - /// Create a file with the provided string and POSIX permissions. - /// - /// - Parameters: - /// - url: The URL of the file to create. - /// - contents: The string to write to disk. - /// - permissions: The POSIX permissions to apply to the file being created. - /// - /// - Throws: An `Error` if the command failed to execute. - static func create(_ url: URL, contents: String, permissions: Int) async throws { - try await DirectoryRemover.remove(url) - try contents.write(to: url, atomically: true, encoding: .utf8) - try FileManager.default.setAttributes([.posixPermissions: permissions], ofItemAtPath: url.path) - } -} diff --git a/Mist/Helpers/PackageCreator.swift b/Mist/Helpers/PackageCreator.swift index 04a4069..8909f24 100644 --- a/Mist/Helpers/PackageCreator.swift +++ b/Mist/Helpers/PackageCreator.swift @@ -10,35 +10,6 @@ import Foundation /// Helper struct to create macOS Installer Packages. struct PackageCreator { - /// Create a macOS Installer Package with a custom root directory and scripts. - /// - /// - Parameters: - /// - url: The URL of the Package to be created. - /// - installer: The `Installer` struct containing metadata of the macOS Installer. - /// - identifier: The package identifier. - /// - root: The URL of the package root directory. - /// - scripts: The URL of the package scripts directory. - /// - identity: Optional Codesigning identity used to sign the package. - /// - /// - Throws: An `Error` if the command failed to execute. - static func create(_ url: URL, from installer: Installer, identifier: String, root: URL, scripts: URL, identity: String? = nil) async throws { - var arguments: [String] = [ - "pkgbuild", - "--identifier", identifier, - "--version", installer.version, - "--root", root.path, - "--scripts", scripts.path, - "--install-location", "\(String.temporaryDirectory)/\(installer.id)" - ] - - if let identity: String = identity { - arguments.append(contentsOf: ["--sign", identity]) - } - - arguments.append(url.path) - try await create(url, with: arguments) - } - /// Create a macOS Installer Package based off the passed in `Installer` struct. /// /// - Parameters: diff --git a/Mist/Views/Download/DownloadView.swift b/Mist/Views/Download/DownloadView.swift index d0b4bfd..c6f65a3 100644 --- a/Mist/Views/Download/DownloadView.swift +++ b/Mist/Views/Download/DownloadView.swift @@ -13,8 +13,6 @@ struct DownloadView: View { @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate: AppDelegate @Environment(\.presentationMode) var presentationMode: Binding @AppStorage("enableNotifications") private var enableNotifications: Bool = false - @AppStorage("retries") private var retries: Int = 10 - @AppStorage("retryDelay") private var retryDelay: Int = 30 var downloadType: DownloadType var imageName: String var name: String diff --git a/Mist/Views/Refresh/RefreshView.swift b/Mist/Views/Refresh/RefreshView.swift index c9cef57..ba42dad 100644 --- a/Mist/Views/Refresh/RefreshView.swift +++ b/Mist/Views/Refresh/RefreshView.swift @@ -14,7 +14,6 @@ struct RefreshView: View { @Binding var installers: [Installer] @State private var firmwaresState: RefreshState = .pending @State private var installersState: RefreshState = .pending - private let length: CGFloat = 18 private let width: CGFloat = 200 private let height: CGFloat = 200 private var buttonText: String { diff --git a/Mist/Views/Settings/SettingsGeneralView.swift b/Mist/Views/Settings/SettingsGeneralView.swift index c7f786f..94c8f4d 100644 --- a/Mist/Views/Settings/SettingsGeneralView.swift +++ b/Mist/Views/Settings/SettingsGeneralView.swift @@ -26,7 +26,6 @@ struct SettingsGeneralView: View { private let enableAutomaticChecksDefault: Bool = true private let scheduledCheckIntervalDefault: Int = 86_400 private let width: CGFloat = 150 - private let length: CGFloat = 24 var body: some View { VStack(alignment: .leading) {