mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-28 05:14:34 +00:00
command line option to provide a download url prefix is now parsed and set on each archive item
This commit is contained in:
1 parent
01b48d44e8
commit
96d162c7e5
2 files changed
+26
-1
No files matched your search
@@ -46,6 +46,7 @@ class ArchiveItem: CustomStringConvertible {
|
||||
|
||||
var dsaSignature: String?;
|
||||
var edSignature: String?;
|
||||
var downloadUrlPrefix: URL?;
|
||||
|
||||
init(version: String, shortVersion: String?, feedURL: URL?, minimumSystemVersion: String?, publicEdKey: String?, supportsDSA: Bool, appPath: URL, archivePath: URL) throws {
|
||||
self.version = version;
|
||||
|
||||
@@ -120,7 +120,7 @@ func main() {
|
||||
else if args.count == 4 && args[1] == "-s" {
|
||||
privateEdString = args[2]
|
||||
}
|
||||
else if args.count != 2 {
|
||||
else if args.count != 2 && !args.contains("--download-url-prefix") {
|
||||
printUsage()
|
||||
exit(1)
|
||||
}
|
||||
@@ -131,6 +131,30 @@ func main() {
|
||||
do {
|
||||
let allUpdates = try makeAppcast(archivesSourceDir: archivesSourceDir, keys: keys, verbose:verbose);
|
||||
|
||||
// if the beginning of a static url for downloading the updates was provided set the download url
|
||||
if args.contains("--download-url-prefix") {
|
||||
// check that an url was provided
|
||||
let optionIndex = args.firstIndex(of: "--download-url-prefix")
|
||||
var downloadUrl: URL? = nil
|
||||
if optionIndex != nil && optionIndex! + 1 < args.count {
|
||||
// check that the next argument is a valid url
|
||||
let detector = try! NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue)
|
||||
let nextArgument = args[optionIndex! + 1]
|
||||
if detector.numberOfMatches(in: nextArgument, options: [], range: NSMakeRange(0, nextArgument.count)) != 1 {
|
||||
print("Please provide a valid download prefix url")
|
||||
}
|
||||
downloadUrl = URL(string: nextArgument)
|
||||
}
|
||||
|
||||
// set the download prefix url for each archive item
|
||||
for (_, archiveItems) in allUpdates {
|
||||
for archiveItem in archiveItems {
|
||||
archiveItem.downloadUrlPrefix = downloadUrl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (appcastFile, updates) in allUpdates {
|
||||
let appcastDestPath = URL(fileURLWithPath: appcastFile, relativeTo: archivesSourceDir);
|
||||
try writeAppcast(appcastDestPath:appcastDestPath, updates:updates);
|
||||
|
||||
Reference in new issue
Block a user