Skip to content

Commit 00c5b69

Browse files
authoredApr 13, 2023
Add package 'signer' to input (#57)
Motivation: A package version in a package collection can have `signer`, which was added swiftlang/swift-package-manager#6415 Modification: Add `signer` to package level input. If set, all versions of the package will have that `signer`.
1 parent fc8d870 commit 00c5b69

File tree

5 files changed

+44
-6
lines changed

5 files changed

+44
-6
lines changed
 

‎Sources/PackageCollectionGenerator/Models/PackageCollectionGeneratorInput.swift

+7-2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ public extension PackageCollectionGeneratorInput {
9494

9595
/// The URL of the package's README.
9696
public let readmeURL: URL?
97+
98+
public let signer: PackageCollectionModel.V1.Signer?
9799

98100
public init(
99101
url: URL,
@@ -104,7 +106,8 @@ public extension PackageCollectionGeneratorInput {
104106
excludedVersions: [String]? = nil,
105107
excludedProducts: [String]? = nil,
106108
excludedTargets: [String]? = nil,
107-
readmeURL: URL? = nil
109+
readmeURL: URL? = nil,
110+
signer: PackageCollectionModel.V1.Signer? = nil
108111
) {
109112
self.url = url
110113
self.identity = identity
@@ -115,6 +118,7 @@ public extension PackageCollectionGeneratorInput {
115118
self.excludedProducts = excludedProducts
116119
self.excludedTargets = excludedTargets
117120
self.readmeURL = readmeURL
121+
self.signer = signer
118122
}
119123
}
120124
}
@@ -131,7 +135,8 @@ extension PackageCollectionGeneratorInput.Package: CustomStringConvertible {
131135
excludedVersions=\(self.excludedVersions.map { "\($0)" } ?? "nil"),
132136
excludedProducts=\(self.excludedProducts.map { "\($0)" } ?? "nil"),
133137
excludedTargets=\(self.excludedTargets.map { "\($0)" } ?? "nil"),
134-
readmeURL=\(self.readmeURL.map { "\($0)" } ?? "nil")
138+
readmeURL=\(self.readmeURL.map { "\($0)" } ?? "nil"),
139+
signer=\(self.signer.map { "\($0)" } ?? "nil")
135140
}
136141
"""
137142
}

‎Sources/PackageCollectionGenerator/PackageCollectionGenerate.swift

+4
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ public struct PackageCollectionGenerate: ParsableCommand {
233233
for: version,
234234
excludedProducts: package.excludedProducts.map { Set($0) } ?? [],
235235
excludedTargets: package.excludedTargets.map { Set($0) } ?? [],
236+
signer: package.signer,
236237
gitDirectoryPath: gitDirectoryPath,
237238
jsonDecoder: jsonDecoder
238239
)
@@ -266,6 +267,7 @@ public struct PackageCollectionGenerate: ParsableCommand {
266267
private func generateMetadata(for version: String,
267268
excludedProducts: Set<String>,
268269
excludedTargets: Set<String>,
270+
signer: PackageCollectionModel.V1.Signer?,
269271
gitDirectoryPath: AbsolutePath,
270272
jsonDecoder: JSONDecoder) throws -> Model.Collection.Package.Version
271273
{
@@ -291,6 +293,8 @@ public struct PackageCollectionGenerate: ParsableCommand {
291293
defaultToolsVersion: defaultManifest.toolsVersion,
292294
verifiedCompatibility: nil,
293295
license: nil,
296+
author: nil,
297+
signer: signer,
294298
createdAt: gitTagInfo?.createdAt
295299
)
296300
}

‎Tests/PackageCollectionGeneratorTests/Inputs/test-input.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212
"excludedVersions": ["v0.1.0"],
1313
"excludedProducts": ["Foo"],
1414
"excludedTargets": ["Bar"],
15-
"readmeURL": "https://package-collection-tests.com/repos/foobar/README"
15+
"readmeURL": "https://package-collection-tests.com/repos/foobar/README",
16+
"signer": {
17+
"type": "ADP",
18+
"commonName": "J. Appleseed",
19+
"organizationalUnitName": "A1",
20+
"organizationName": "Appleseed Inc."
21+
}
1622
},
1723
{
1824
"url": "https://package-collection-tests.com/repos/foobaz.git"

‎Tests/PackageCollectionGeneratorTests/PackageCollectionGenerateTests.swift

+21-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ final class PackageCollectionGenerateTests: XCTestCase {
4545
let repoThreeArchivePath = try AbsolutePath(validating: #file).parentDirectory.appending(components: "Inputs", "TestRepoThree.tgz")
4646
try systemQuietly(["tar", "-x", "-v", "-C", tmpDir.pathString, "-f", repoThreeArchivePath.pathString])
4747

48+
let signer = PackageCollectionModel.V1.Signer(
49+
type: "ADP",
50+
commonName: "J. Appleseed",
51+
organizationalUnitName: "A1",
52+
organizationName: "Appleseed Inc."
53+
)
54+
4855
// Prepare input.json
4956
let input = PackageCollectionGeneratorInput(
5057
name: "Test Package Collection",
@@ -58,7 +65,8 @@ final class PackageCollectionGenerateTests: XCTestCase {
5865
PackageCollectionGeneratorInput.Package(
5966
url: URL(string: "https://package-collection-tests.com/repos/TestRepoTwo.git")!,
6067
identity: "repos.two",
61-
summary: "Package Foo & Bar"
68+
summary: "Package Foo & Bar",
69+
signer: signer
6270
),
6371
PackageCollectionGeneratorInput.Package(
6472
url: URL(string: "https://package-collection-tests.com/repos/TestRepoThree.git")!,
@@ -93,6 +101,8 @@ final class PackageCollectionGenerateTests: XCTestCase {
93101
defaultToolsVersion: "5.2",
94102
verifiedCompatibility: nil,
95103
license: nil,
104+
author: nil,
105+
signer: nil,
96106
createdAt: nil
97107
),
98108
],
@@ -126,6 +136,8 @@ final class PackageCollectionGenerateTests: XCTestCase {
126136
defaultToolsVersion: "5.2",
127137
verifiedCompatibility: nil,
128138
license: nil,
139+
author: nil,
140+
signer: signer,
129141
createdAt: nil
130142
),
131143
Model.Collection.Package.Version(
@@ -143,6 +155,8 @@ final class PackageCollectionGenerateTests: XCTestCase {
143155
defaultToolsVersion: "5.2",
144156
verifiedCompatibility: nil,
145157
license: nil,
158+
author: nil,
159+
signer: signer,
146160
createdAt: nil
147161
),
148162
],
@@ -169,6 +183,8 @@ final class PackageCollectionGenerateTests: XCTestCase {
169183
defaultToolsVersion: "5.2",
170184
verifiedCompatibility: nil,
171185
license: nil,
186+
author: nil,
187+
signer: nil,
172188
createdAt: nil
173189
),
174190
],
@@ -280,6 +296,8 @@ final class PackageCollectionGenerateTests: XCTestCase {
280296
defaultToolsVersion: "5.2",
281297
verifiedCompatibility: nil,
282298
license: nil,
299+
author: nil,
300+
signer: nil,
283301
createdAt: nil
284302
),
285303
],
@@ -313,6 +331,8 @@ final class PackageCollectionGenerateTests: XCTestCase {
313331
defaultToolsVersion: "5.2",
314332
verifiedCompatibility: nil,
315333
license: nil,
334+
author: nil,
335+
signer: nil,
316336
createdAt: nil
317337
),
318338
],

‎Tests/PackageCollectionGeneratorTests/PackageCollectionGeneratorInputTests.swift

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Foundation
1616
import XCTest
1717

1818
@testable import PackageCollectionGenerator
19+
import PackageCollectionsModel
1920
import TSCBasic
2021

2122
class PackageCollectionGeneratorInputTests: XCTestCase {
@@ -34,7 +35,8 @@ class PackageCollectionGeneratorInputTests: XCTestCase {
3435
excludedVersions: ["v0.1.0"],
3536
excludedProducts: ["Foo"],
3637
excludedTargets: ["Bar"],
37-
readmeURL: URL(string: "https://package-collection-tests.com/repos/foobar/README")!
38+
readmeURL: URL(string: "https://package-collection-tests.com/repos/foobar/README")!,
39+
signer: .init(type: "ADP", commonName: "J. Appleseed", organizationalUnitName: "A1", organizationName: "Appleseed Inc.")
3840
),
3941
PackageCollectionGeneratorInput.Package(
4042
url: URL(string: "https://package-collection-tests.com/repos/foobaz.git")!
@@ -67,7 +69,8 @@ class PackageCollectionGeneratorInputTests: XCTestCase {
6769
excludedVersions: ["0.8.1"],
6870
excludedProducts: ["Foo"],
6971
excludedTargets: ["Bar"],
70-
readmeURL: URL(string: "https://package-collection-tests.com/repos/foobar/README")!
72+
readmeURL: URL(string: "https://package-collection-tests.com/repos/foobar/README")!,
73+
signer: .init(type: "ADP", commonName: "J. Appleseed", organizationalUnitName: "A1", organizationName: "Appleseed Inc.")
7174
),
7275
],
7376
author: .init(name: "Jane Doe")

0 commit comments

Comments
 (0)
Please sign in to comment.