Skip to content

Commit

Permalink
Merge branch 'main' into feature/github-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
diegotl committed Oct 20, 2023
2 parents 77d736d + 680ddfd commit 63d05fc
Show file tree
Hide file tree
Showing 25 changed files with 715 additions and 207 deletions.
42 changes: 38 additions & 4 deletions Empusa.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
3F3B176E2ADDE117000283AE /* DestinationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F3B176D2ADDE117000283AE /* DestinationView.swift */; };
3F3B17702ADDE16A000283AE /* ResourcesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F3B176F2ADDE16A000283AE /* ResourcesView.swift */; };
3F3B17722ADDE25D000283AE /* DataProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F3B17712ADDE25D000283AE /* DataProgressView.swift */; };
3FCE9D2D2AE0944C00A4E3F5 /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = 3FCE9D2C2AE0944C00A4E3F5 /* Sparkle */; };
3FCE9D312AE17F5F00A4E3F5 /* CheckForUpdatesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FCE9D302AE17F5F00A4E3F5 /* CheckForUpdatesView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -43,6 +45,10 @@
3F3B176D2ADDE117000283AE /* DestinationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DestinationView.swift; sourceTree = "<group>"; };
3F3B176F2ADDE16A000283AE /* ResourcesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResourcesView.swift; sourceTree = "<group>"; };
3F3B17712ADDE25D000283AE /* DataProgressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataProgressView.swift; sourceTree = "<group>"; };
3F54EB962AE2553D008A45B0 /* Empusa.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = Empusa.xctestplan; sourceTree = "<group>"; };
3FC172272AE1D63A00DCBE28 /* EmpusaMacros */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = EmpusaMacros; sourceTree = "<group>"; };
3FCE9D2E2AE0FE2E00A4E3F5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3FCE9D302AE17F5F00A4E3F5 /* CheckForUpdatesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckForUpdatesView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -51,6 +57,7 @@
buildActionMask = 2147483647;
files = (
3F21D3412ADD77E700B6A5D9 /* EmpusaKit in Frameworks */,
3FCE9D2D2AE0944C00A4E3F5 /* Sparkle in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -99,6 +106,7 @@
3F21D31B2ADADC7400B6A5D9 /* Tests */ = {
isa = PBXGroup;
children = (
3F54EB962AE2553D008A45B0 /* Empusa.xctestplan */,
3F21D31C2ADADC7400B6A5D9 /* EmpusaTests.swift */,
);
path = Tests;
Expand All @@ -107,6 +115,7 @@
3F21D3352ADADC8D00B6A5D9 /* Resources */ = {
isa = PBXGroup;
children = (
3FCE9D2E2AE0FE2E00A4E3F5 /* Info.plist */,
3F21D30E2ADADC7400B6A5D9 /* Assets.xcassets */,
);
path = Resources;
Expand All @@ -115,6 +124,7 @@
3F21D3362ADADE8B00B6A5D9 /* Packages */ = {
isa = PBXGroup;
children = (
3FC172272AE1D63A00DCBE28 /* EmpusaMacros */,
3F21D3372ADADEBE00B6A5D9 /* EmpusaKit */,
);
path = Packages;
Expand All @@ -135,6 +145,7 @@
3F3B176D2ADDE117000283AE /* DestinationView.swift */,
3F3B176F2ADDE16A000283AE /* ResourcesView.swift */,
3F3B17712ADDE25D000283AE /* DataProgressView.swift */,
3FCE9D302AE17F5F00A4E3F5 /* CheckForUpdatesView.swift */,
);
path = "UI Components";
sourceTree = "<group>";
Expand All @@ -157,6 +168,7 @@
name = Empusa;
packageProductDependencies = (
3F21D3402ADD77E700B6A5D9 /* EmpusaKit */,
3FCE9D2C2AE0944C00A4E3F5 /* Sparkle */,
);
productName = SwitchSDTool;
productReference = 3F21D3072ADADC7300B6A5D9 /* Empusa.app */;
Expand Down Expand Up @@ -208,6 +220,9 @@
Base,
);
mainGroup = 3F21D2FE2ADADC7300B6A5D9;
packageReferences = (
3FCE9D2B2AE0944C00A4E3F5 /* XCRemoteSwiftPackageReference "Sparkle" */,
);
productRefGroup = 3F21D3082ADADC7300B6A5D9 /* Products */;
projectDirPath = "";
projectRoot = "";
Expand Down Expand Up @@ -243,6 +258,7 @@
files = (
3F3B17702ADDE16A000283AE /* ResourcesView.swift in Sources */,
3F21D30D2ADADC7300B6A5D9 /* MainView.swift in Sources */,
3FCE9D312AE17F5F00A4E3F5 /* CheckForUpdatesView.swift in Sources */,
3F3B17722ADDE25D000283AE /* DataProgressView.swift in Sources */,
3F21D30B2ADADC7300B6A5D9 /* EmpusaApp.swift in Sources */,
3F3B176E2ADDE117000283AE /* DestinationView.swift in Sources */,
Expand Down Expand Up @@ -396,11 +412,12 @@
CODE_SIGN_ENTITLEMENTS = Empusa/Empusa.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 4;
DEVELOPMENT_TEAM = D97MJ3844Q;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Empusa/Resources/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "εmpusa";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
INFOPLIST_KEY_NSHumanReadableCopyright = "";
Expand All @@ -409,7 +426,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.0.1;
MARKETING_VERSION = 1.0.3;
PRODUCT_BUNDLE_IDENTIFIER = nl.trevisa.diego.Empusa;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand All @@ -425,11 +442,12 @@
CODE_SIGN_ENTITLEMENTS = Empusa/Empusa.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 4;
DEVELOPMENT_TEAM = D97MJ3844Q;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Empusa/Resources/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "εmpusa";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
INFOPLIST_KEY_NSHumanReadableCopyright = "";
Expand All @@ -438,7 +456,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.0.1;
MARKETING_VERSION = 1.0.3;
PRODUCT_BUNDLE_IDENTIFIER = nl.trevisa.diego.Empusa;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down Expand Up @@ -516,11 +534,27 @@
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
3FCE9D2B2AE0944C00A4E3F5 /* XCRemoteSwiftPackageReference "Sparkle" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/sparkle-project/Sparkle";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 2.5.1;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
3F21D3402ADD77E700B6A5D9 /* EmpusaKit */ = {
isa = XCSwiftPackageProductDependency;
productName = EmpusaKit;
};
3FCE9D2C2AE0944C00A4E3F5 /* Sparkle */ = {
isa = XCSwiftPackageProductDependency;
package = 3FCE9D2B2AE0944C00A4E3F5 /* XCRemoteSwiftPackageReference "Sparkle" */;
productName = Sparkle;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 3F21D2FF2ADADC7300B6A5D9 /* Project object */;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
{
"pins" : [
{
"identity" : "sparkle",
"kind" : "remoteSourceControl",
"location" : "https://github.com/sparkle-project/Sparkle",
"state" : {
"revision" : "1f07f4096e52f19b5e7abaa697b7fc592b7ff57c",
"version" : "2.5.1"
}
},
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"state" : {
"revision" : "74203046135342e4a4a627476dd6caf8b28fe11b",
"version" : "509.0.0"
}
},
{
"identity" : "zip",
"kind" : "remoteSourceControl",
Expand Down
2 changes: 1 addition & 1 deletion Empusa.xcodeproj/xcshareddata/xcschemes/Empusa.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
shouldUseLaunchSchemeArgsEnv = "YES">
<TestPlans>
<TestPlanReference
reference = "container:Empusa Tests/Empusa.xctestplan"
reference = "container:Tests/Empusa.xctestplan"
default = "YES">
</TestPlanReference>
</TestPlans>
Expand Down
15 changes: 14 additions & 1 deletion Empusa/EmpusaApp.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
import SwiftUI
import Sparkle

@main
struct EmpusaApp: App {
private let updaterController: SPUStandardUpdaterController = .init(
startingUpdater: true,
updaterDelegate: nil,
userDriverDelegate: nil
)

var body: some Scene {
WindowGroup {
MainView(
model: EmpusaModel()
)
.frame(width: 680, height: 400)
.frame(width: 680, height: 420)
}
.windowResizability(.contentSize)
.commands {
CommandGroup(replacing: CommandGroupPlacement.newItem) {}
CommandGroup(after: .appInfo) {
CheckForUpdatesView(updater: updaterController.updater)
}
}
}
}
46 changes: 31 additions & 15 deletions Empusa/EmpusaModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ final class EmpusaModel: ObservableObject {
// MARK: - Init
init() {
loadExternalVolumes()
loadResourcesVersions()
}

// MARK: - Public functions
Expand Down Expand Up @@ -107,18 +106,27 @@ final class EmpusaModel: ObservableObject {
.receive(on: RunLoop.main)
.assign(to: &$progress)

do {
try await contentManager.download(
resources: selectedResources,
into: selectedVolume.url,
progressSubject: progressSubject
)
} catch {
alertData = .init(error: error)
}
let result = await contentManager.download(
resources: selectedResources,
into: selectedVolume,
progressSubject: progressSubject
)

isProcessing = false
self.progress = nil
loadResourcesVersions()

if !result.failedResources.isEmpty {
alertData = .init(
title: "Alert",
message: "Failed to install \(result.failedResourceNames):\n\n\(result.failedResources.last!.error.localizedDescription)"
)
} else {
alertData = .init(
title: "Success",
message: "Selected resources have been downloaded into the selected destination."
)
}
}
}

Expand Down Expand Up @@ -170,16 +178,24 @@ final class EmpusaModel: ObservableObject {

self.alertData = .init(
title: "Success",
message: "Backup sucessfully restored to the selected volume"
message: "Backup sucessfully restored to the selected destination."
)
}
}

func loadResourcesVersions() {
Task { [resourceService, weak self] in
self?.isLoadingResources = true
self?.availableResources = await resourceService.fetchResources()
self?.isLoadingResources = false
Task { [weak self] in
guard let self else { return }
self.isLoadingResources = true

self.availableResources = await resourceService
.fetchResources(for: self.selectedVolume)

self.selectedResources = availableResources
.filter{ $0.preChecked }
.map { $0.resource }

self.isLoadingResources = false
}
}
}
10 changes: 10 additions & 0 deletions Empusa/Resources/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SUFeedURL</key>
<string>https://empusa.pacotevicio.app/sparkle.xml</string>
<key>SUPublicEDKey</key>
<string>62os1l9hx8vk8noKLn706G/htYbpMlhOP2TTJQFa66w=</string>
</dict>
</plist>
26 changes: 26 additions & 0 deletions Empusa/UI Components/CheckForUpdatesView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import SwiftUI
import Sparkle

final class CheckForUpdatesViewModel: ObservableObject {
@Published var canCheckForUpdates = false

init(updater: SPUUpdater) {
updater.publisher(for: \.canCheckForUpdates)
.assign(to: &$canCheckForUpdates)
}
}

struct CheckForUpdatesView: View {
@ObservedObject private var checkForUpdatesViewModel: CheckForUpdatesViewModel
private let updater: SPUUpdater

init(updater: SPUUpdater) {
self.updater = updater
self.checkForUpdatesViewModel = CheckForUpdatesViewModel(updater: updater)
}

var body: some View {
Button("Check for Updates...", action: updater.checkForUpdates)
.disabled(!checkForUpdatesViewModel.canCheckForUpdates)
}
}
16 changes: 14 additions & 2 deletions Empusa/UI Components/ResourcesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ struct ResourcesView: View {
model.selectedResources.remove(at: index)
}
})) {
Text(displayingResource.formattedName)
.frame(maxWidth: .infinity, alignment: .leading)
HStack {
Text(displayingResource.formattedName)
.frame(maxWidth: .infinity, alignment: .leading)

if let version = displayingResource.version {
Text(version)
}
}
}
}
}
Expand All @@ -36,6 +42,12 @@ struct ResourcesView: View {
}
}
.disabled(model.isProcessing)
.onAppear(perform: {
model.loadResourcesVersions()
})
.onChange(of: model.selectedVolume) { _ in
model.loadResourcesVersions()
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions Packages/EmpusaKit/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ let package = Package(
targets: ["EmpusaKit"]),
],
dependencies: [
.package(url: "https://github.com/marmelroy/Zip.git", from: "2.1.2")
.package(url: "https://github.com/marmelroy/Zip.git", from: "2.1.2"),
.package(path: "../EmpusaMacros")
],
targets: [
.target(
name: "EmpusaKit",
dependencies: [
.product(name: "Zip", package: "Zip")
.product(name: "Zip", package: "Zip"),
.product(name: "EmpusaMacros", package: "EmpusaMacros")
]
),
.testTarget(
Expand Down
Loading

0 comments on commit 63d05fc

Please sign in to comment.