-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from Kyome22/auto-update
Auto update using Sparkle
- Loading branch information
Showing
18 changed files
with
283 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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://raw.githubusercontent.com/Kyome22/ShiftWindow/main/appcast.xml</string> | ||
<key>SUPublicEDKey</key> | ||
<string>gfW6qX5a5TkPRUrz3AK+pPNb+wr/SxdN4zPTgJjPj28=</string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
ShiftWindowPackages/Sources/DataLayer/Dependency/SPUUpdaterClient.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
SPUUpdaterClient.swift | ||
DataLayer | ||
|
||
Created by Takuto Nakamura on 2024/11/06. | ||
Copyright 2022 Takuto Nakamura (Kyome22) | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import Combine | ||
@preconcurrency import Sparkle | ||
|
||
public struct SPUUpdaterClient: DependencyClient { | ||
var automaticallyChecksForUpdates: @Sendable () -> Bool | ||
var setAutomaticallyChecksForUpdates: @Sendable (Bool) -> Void | ||
public var canCheckForUpdatesPublisher: @Sendable () -> AnyPublisher<Bool, Never> | ||
public var checkForUpdates: @Sendable () -> Void | ||
|
||
public static let liveValue: Self = { | ||
let updaterController = SPUStandardUpdaterController( | ||
startingUpdater: true, | ||
updaterDelegate: nil, | ||
userDriverDelegate: nil | ||
) | ||
return Self( | ||
automaticallyChecksForUpdates: { | ||
updaterController.updater.automaticallyChecksForUpdates | ||
}, | ||
setAutomaticallyChecksForUpdates: { | ||
updaterController.updater.automaticallyChecksForUpdates = $0 | ||
}, | ||
canCheckForUpdatesPublisher: { | ||
updaterController.updater.publisher(for: \.canCheckForUpdates).eraseToAnyPublisher() | ||
}, | ||
checkForUpdates: { | ||
updaterController.updater.checkForUpdates() | ||
} | ||
) | ||
}() | ||
|
||
public static let testValue = Self( | ||
automaticallyChecksForUpdates: { false }, | ||
setAutomaticallyChecksForUpdates: { _ in }, | ||
canCheckForUpdatesPublisher: { Just(false).eraseToAnyPublisher() }, | ||
checkForUpdates: {} | ||
) | ||
} |
37 changes: 37 additions & 0 deletions
37
ShiftWindowPackages/Sources/DataLayer/Repository/CheckForUpdatesRepository.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
CheckForUpdatesRepository.swift | ||
DataLayer | ||
|
||
Created by Takuto Nakamura on 2024/11/07. | ||
Copyright 2022 Takuto Nakamura (Kyome22) | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import Foundation | ||
|
||
public struct CheckForUpdatesRepository: Sendable { | ||
private let spuUpdaterClient: SPUUpdaterClient | ||
|
||
public var isEnabled: Bool { | ||
spuUpdaterClient.automaticallyChecksForUpdates() | ||
} | ||
|
||
public init(_ spuUpdaterClient: SPUUpdaterClient) { | ||
self.spuUpdaterClient = spuUpdaterClient | ||
} | ||
|
||
public func switchStatus(_ isEnabled: Bool) { | ||
spuUpdaterClient.setAutomaticallyChecksForUpdates(isEnabled) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
ShiftWindowPackages/Sources/Domain/Service/UpdateService.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
UpdateService.swift | ||
Domain | ||
|
||
Created by Takuto Nakamura on 2024/11/07. | ||
Copyright 2022 Takuto Nakamura (Kyome22) | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import Combine | ||
import DataLayer | ||
|
||
public actor UpdateService { | ||
private let spuUpdaterClient: SPUUpdaterClient | ||
|
||
public init(_ spuUpdaterClient: SPUUpdaterClient) { | ||
self.spuUpdaterClient = spuUpdaterClient | ||
} | ||
|
||
public func canChecksForUpdatesStream() -> AsyncStream<Bool> { | ||
AsyncStream { continuation in | ||
let cancellable = spuUpdaterClient | ||
.canCheckForUpdatesPublisher() | ||
.sink { value in | ||
continuation.yield(value) | ||
} | ||
continuation.onTermination = { _ in | ||
cancellable.cancel() | ||
} | ||
} | ||
} | ||
|
||
public func checkForUpdates() { | ||
spuUpdaterClient.checkForUpdates() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.