mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-24 04:38:16 +00:00
Forward-port PR #1499 (localized release notes in appcast) to 2.x
This commit is contained in:
8 files changed
+85
-4
No files matched your search
@@ -465,6 +465,7 @@
|
||||
EA1E287E22B66705004AA304 /* libed25519.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EA1E282D22B660BE004AA304 /* libed25519.a */; };
|
||||
F8761EB11ADC5068000C9034 /* SUCodeSigningVerifierTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F8761EB01ADC5068000C9034 /* SUCodeSigningVerifierTest.m */; };
|
||||
F8761EB31ADC50EB000C9034 /* SparkleTestCodeSignApp.zip in Resources */ = {isa = PBXBuildFile; fileRef = F8761EB21ADC50EB000C9034 /* SparkleTestCodeSignApp.zip */; };
|
||||
FA30773D24CBC295007BA37D /* testlocalizedreleasenotesappcast.xml in Resources */ = {isa = PBXBuildFile; fileRef = FA30773C24CBC295007BA37D /* testlocalizedreleasenotesappcast.xml */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@@ -1373,6 +1374,7 @@
|
||||
FA1941CF0D94A70100DD942E /* ConfigCommonDebug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ConfigCommonDebug.xcconfig; sourceTree = "<group>"; };
|
||||
FA1941D00D94A70100DD942E /* ConfigCommon.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ConfigCommon.xcconfig; sourceTree = "<group>"; };
|
||||
FA1941D10D94A70100DD942E /* ConfigFramework.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ConfigFramework.xcconfig; sourceTree = "<group>"; };
|
||||
FA30773C24CBC295007BA37D /* testlocalizedreleasenotesappcast.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = testlocalizedreleasenotesappcast.xml; sourceTree = "<group>"; };
|
||||
FA3AAF3B1050B273004B3130 /* ConfigUnitTest.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ConfigUnitTest.xcconfig; sourceTree = "<group>"; };
|
||||
FE5536F517A2C6A7007CB333 /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ko; path = ko.lproj/Sparkle.strings; sourceTree = "<group>"; };
|
||||
FE5536F617A2C6AB007CB333 /* sk */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sk; path = sk.lproj/Sparkle.strings; sourceTree = "<group>"; };
|
||||
@@ -1728,6 +1730,7 @@
|
||||
5AF6C74E1AEA46D10014A3AB /* test.pkg */,
|
||||
5AD0FA7E1C73F2E2004BCEFF /* testappcast.xml */,
|
||||
5F1510A11C96E591006E1629 /* testnamespaces.xml */,
|
||||
FA30773C24CBC295007BA37D /* testlocalizedreleasenotesappcast.xml */,
|
||||
5A5DD41B249F0F4B0045EB3E /* test-relative-urls.xml */,
|
||||
5A5DD40324958AFF0045EB3E /* SUUpdateValidatorTest */,
|
||||
);
|
||||
@@ -2999,6 +3002,7 @@
|
||||
14958C6F19AEBC980061B14F /* test-pubkey.pem in Resources */,
|
||||
5AF6C74F1AEA46D10014A3AB /* test.pkg in Resources */,
|
||||
5AD0FA7F1C73F2E2004BCEFF /* testappcast.xml in Resources */,
|
||||
FA30773D24CBC295007BA37D /* testlocalizedreleasenotesappcast.xml in Resources */,
|
||||
5F1510A21C96E591006E1629 /* testnamespaces.xml in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
||||
Vendored
+2
@@ -90,4 +90,6 @@ extern NSString *const SURSSElementLink;
|
||||
extern NSString *const SURSSElementPubDate;
|
||||
extern NSString *const SURSSElementTitle;
|
||||
|
||||
extern NSString *const SUXMLLanguage;
|
||||
|
||||
#endif
|
||||
Vendored
+2
@@ -82,3 +82,5 @@ NSString *const SURSSElementEnclosure = @"enclosure";
|
||||
NSString *const SURSSElementLink = @"link";
|
||||
NSString *const SURSSElementPubDate = @"pubDate";
|
||||
NSString *const SURSSElementTitle = @"title";
|
||||
|
||||
NSString *const SUXMLLanguage = @"xml:lang";
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle">
|
||||
<channel>
|
||||
<title>For unit test only</title>
|
||||
<!-- A release testing localized release notes -->
|
||||
<item>
|
||||
<title>Version 6.0</title>
|
||||
<pubDate>Sat, 26 Jul 2019 15:20:13 +0000</pubDate>
|
||||
<enclosure url="http://localhost:1337/Sparkle_Test_App.zip" sparkle:version="6.0" />
|
||||
<sparkle:releaseNotesLink>https://sparkle-project.org/#works</sparkle:releaseNotesLink>
|
||||
<sparkle:releaseNotesLink xml:lang='en'>
|
||||
https://sparkle-project.org/#localized_notes_link_works
|
||||
</sparkle:releaseNotesLink>
|
||||
<sparkle:minimumSystemVersion>2.0.0</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
||||
@@ -66,6 +66,22 @@ class SUAppcastTest: XCTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
func testParseAppcastWithLocalizedReleaseNotes() {
|
||||
let appcast = SUAppcast()
|
||||
let testFile = Bundle(for: SUAppcastTest.self).path(forResource: "testlocalizedreleasenotesappcast",
|
||||
ofType: "xml")!
|
||||
let testFileUrl = URL(fileURLWithPath: testFile)
|
||||
XCTAssertNotNil(testFileUrl)
|
||||
|
||||
do {
|
||||
let items = try appcast.parseAppcastItems(fromXMLFile: testFileUrl) as! [SUAppcastItem];
|
||||
XCTAssertEqual("https://sparkle-project.org/#localized_notes_link_works", items[0].releaseNotesURL.absoluteString)
|
||||
} catch let err as NSError {
|
||||
NSLog("%@", err)
|
||||
XCTFail(err.localizedDescription)
|
||||
}
|
||||
}
|
||||
|
||||
func testNamespaces() {
|
||||
let appcast = SUAppcast()
|
||||
let testFile = Bundle(for: SUAppcastTest.self).path(forResource: "testnamespaces", ofType: "xml")!
|
||||
|
||||
@@ -186,5 +186,23 @@ class ArchiveItem: CustomStringConvertible {
|
||||
return URL(string: escapedFilename)
|
||||
}
|
||||
|
||||
func localizedReleaseNotes() -> [(String, URL)] {
|
||||
let fileManager = FileManager.default
|
||||
var basename = archivePath.deletingPathExtension()
|
||||
if basename.pathExtension == "tar" {
|
||||
basename = basename.deletingPathExtension()
|
||||
}
|
||||
var localizedReleaseNotes = [(String, URL)]()
|
||||
for languageCode in Locale.isoLanguageCodes {
|
||||
let localizedReleaseNoteURL = basename
|
||||
.appendingPathExtension(languageCode)
|
||||
.appendingPathExtension("html")
|
||||
if fileManager.fileExists(atPath: localizedReleaseNoteURL.path) {
|
||||
localizedReleaseNotes.append((languageCode, localizedReleaseNoteURL))
|
||||
}
|
||||
}
|
||||
return localizedReleaseNotes
|
||||
}
|
||||
|
||||
let mimeType = "application/octet-stream"
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import <Sparkle/SUStandardVersionComparator.h>
|
||||
#import "SUStandardVersionComparator.h"
|
||||
#import "SUConstants.h"
|
||||
#import <Sparkle/SUErrors.h>
|
||||
#import "SUErrors.h"
|
||||
#import "SUUnarchiver.h"
|
||||
#import "SUBinaryDeltaUnarchiver.h"
|
||||
#import "SUBinaryDeltaCreate.h"
|
||||
#import "SUSignatures.h"
|
||||
#import "ed25519.h" // Run `git submodule update --init` if you get an error here
|
||||
@@ -108,7 +108,11 @@ func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem]) throws {
|
||||
}
|
||||
minVer?.setChildren([text(update.minimumSystemVersion)])
|
||||
|
||||
let relElement = findElement(name: SUAppcastElementReleaseNotesLink, parent: item)
|
||||
let releaseNotesXpath = "\(SUAppcastElementReleaseNotesLink)"
|
||||
let results = ((try? item.nodes(forXPath: releaseNotesXpath)) as? [XMLElement])?
|
||||
.filter { !($0.attributes ?? [])
|
||||
.contains(where: { $0.name == SUXMLLanguage }) }
|
||||
let relElement = results?.first
|
||||
if let url = update.releaseNotesURL {
|
||||
if nil == relElement {
|
||||
item.addChild(XMLElement.element(withName: SUAppcastElementReleaseNotesLink, stringValue: url.absoluteString) as! XMLElement)
|
||||
@@ -117,6 +121,23 @@ func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem]) throws {
|
||||
item.removeChild(at: childIndex)
|
||||
}
|
||||
|
||||
let languageNotesNodes = ((try? item.nodes(forXPath: releaseNotesXpath)) as? [XMLElement])?
|
||||
.map { ($0, $0.attribute(forName: SUXMLLanguage)?.stringValue )}
|
||||
.filter { $0.1 != nil } ?? []
|
||||
for (node, language) in languageNotesNodes.reversed()
|
||||
where !update.localizedReleaseNotes().contains(where: { $0.0 == language }) {
|
||||
item.removeChild(at: node.index)
|
||||
}
|
||||
for (language, url) in update.localizedReleaseNotes() {
|
||||
if !languageNotesNodes.contains(where: { $0.1 == language }) {
|
||||
let localizedNode = XMLNode.element(
|
||||
withName: SUAppcastElementReleaseNotesLink,
|
||||
children: [XMLNode.text(withStringValue: url.lastPathComponent) as! XMLNode],
|
||||
attributes: [XMLNode.attribute(withName: SUXMLLanguage, stringValue: language) as! XMLNode])
|
||||
item.addChild(localizedNode as! XMLNode)
|
||||
}
|
||||
}
|
||||
|
||||
var enclosure = findElement(name: "enclosure", parent: item)
|
||||
if nil == enclosure {
|
||||
enclosure = XMLElement.element(withName: "enclosure") as? XMLElement
|
||||
@@ -157,7 +178,7 @@ func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem]) throws {
|
||||
XMLNode.attribute(withName: SUAppcastAttributeDeltaFrom, uri: sparkleNS, stringValue: delta.fromVersion) as! XMLNode,
|
||||
XMLNode.attribute(withName: "length", stringValue: String(delta.fileSize)) as! XMLNode,
|
||||
XMLNode.attribute(withName: "type", stringValue: "application/octet-stream") as! XMLNode,
|
||||
]
|
||||
]
|
||||
if let sig = delta.edSignature {
|
||||
attributes.append(XMLNode.attribute(withName: SUAppcastAttributeEDSignature, uri: sparkleNS, stringValue: sig) as! XMLNode)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user