Skip to content

Commit 2686496

Browse files
committed
Rename description to summary/overview
1 parent 9400940 commit 2686496

15 files changed

+75
-95
lines changed

Fixtures/Collections/JSON/good.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Sample Package Collection",
3-
"description": "This is a sample package collection listing made-up packages.",
3+
"overview": "This is a sample package collection listing made-up packages.",
44
"keywords": ["sample package collection"],
55
"formatVersion": "1.0",
66
"revision": 3,
@@ -11,7 +11,7 @@
1111
"packages": [
1212
{
1313
"url": "https://www.example.com/repos/RepoOne.git",
14-
"description": "Package One",
14+
"summary": "Package One",
1515
"keywords": ["sample package"],
1616
"readmeURL": "https://www.example.com/repos/RepoOne/README",
1717
"versions": [
@@ -52,7 +52,7 @@
5252
},
5353
{
5454
"url": "https://www.example.com/repos/RepoTwo.git",
55-
"description": "Package Two",
55+
"summary": "Package Two",
5656
"readmeURL": "https://www.example.com/repos/RepoTwo/README",
5757
"versions": [
5858
{

Sources/PackageCollections/JSONModel/JSONCollection+v1.swift

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ extension JSONPackageCollectionModel {
1818
}
1919

2020
extension JSONPackageCollectionModel.V1 {
21-
public struct PackageCollection: Equatable, Codable {
21+
public struct Collection: Equatable, Codable {
2222
/// The name of the package collection, for display purposes only.
2323
public let name: String
2424

2525
/// A description of the package collection.
26-
public let _description: String?
26+
public let overview: String?
2727

2828
/// An array of keywords that the collection is associated with.
2929
public let keywords: [String]?
3030

3131
/// An array of package metadata objects
32-
public let packages: [JSONPackageCollectionModel.V1.PackageCollection.Package]
32+
public let packages: [JSONPackageCollectionModel.V1.Collection.Package]
3333

3434
/// The version of the format to which the collection conforms.
3535
public let formatVersion: JSONPackageCollectionModel.FormatVersion
@@ -43,12 +43,12 @@ extension JSONPackageCollectionModel.V1 {
4343
/// The author of this package collection.
4444
public let generatedBy: Author?
4545

46-
/// Creates a `PackageCollection`
46+
/// Creates a `Collection`
4747
public init(
4848
name: String,
49-
description: String? = nil,
49+
overview: String? = nil,
5050
keywords: [String]? = nil,
51-
packages: [JSONPackageCollectionModel.V1.PackageCollection.Package],
51+
packages: [JSONPackageCollectionModel.V1.Collection.Package],
5252
formatVersion: JSONPackageCollectionModel.FormatVersion,
5353
revision: Int? = nil,
5454
generatedAt: Date = Date(),
@@ -57,7 +57,7 @@ extension JSONPackageCollectionModel.V1 {
5757
precondition(formatVersion == .v1_0, "Unsupported format version: \(formatVersion)")
5858

5959
self.name = name
60-
self._description = description
60+
self.overview = overview
6161
self.keywords = keywords
6262
self.packages = packages
6363
self.formatVersion = formatVersion
@@ -66,17 +66,6 @@ extension JSONPackageCollectionModel.V1 {
6666
self.generatedBy = generatedBy
6767
}
6868

69-
private enum CodingKeys: String, CodingKey {
70-
case name
71-
case _description = "description"
72-
case keywords
73-
case packages
74-
case formatVersion
75-
case revision
76-
case generatedAt
77-
case generatedBy
78-
}
79-
8069
public struct Author: Equatable, Codable {
8170
/// The author name.
8271
public let name: String
@@ -89,49 +78,41 @@ extension JSONPackageCollectionModel.V1 {
8978
}
9079
}
9180

92-
extension JSONPackageCollectionModel.V1.PackageCollection {
81+
extension JSONPackageCollectionModel.V1.Collection {
9382
public struct Package: Equatable, Codable {
9483
/// The URL of the package. Currently only Git repository URLs are supported.
9584
public let url: Foundation.URL
9685

9786
/// A description of the package.
98-
public let _description: String?
87+
public let summary: String?
9988

10089
/// An array of keywords that the package is associated with.
10190
public let keywords: [String]?
10291

10392
/// An array of version objects representing the most recent and/or relevant releases of the package.
104-
public let versions: [JSONPackageCollectionModel.V1.PackageCollection.Package.Version]
93+
public let versions: [JSONPackageCollectionModel.V1.Collection.Package.Version]
10594

10695
/// The URL of the package's README.
10796
public let readmeURL: Foundation.URL?
10897

10998
/// Creates a `Package`
11099
public init(
111100
url: URL,
112-
description: String? = nil,
101+
summary: String? = nil,
113102
keywords: [String]? = nil,
114-
versions: [JSONPackageCollectionModel.V1.PackageCollection.Package.Version],
103+
versions: [JSONPackageCollectionModel.V1.Collection.Package.Version],
115104
readmeURL: URL? = nil
116105
) {
117106
self.url = url
118-
self._description = description
107+
self.summary = summary
119108
self.keywords = keywords
120109
self.versions = versions
121110
self.readmeURL = readmeURL
122111
}
123-
124-
private enum CodingKeys: String, CodingKey {
125-
case url
126-
case _description = "description"
127-
case keywords
128-
case versions
129-
case readmeURL
130-
}
131112
}
132113
}
133114

134-
extension JSONPackageCollectionModel.V1.PackageCollection.Package {
115+
extension JSONPackageCollectionModel.V1.Collection.Package {
135116
public struct Version: Equatable, Codable {
136117
/// The semantic version string.
137118
public let version: String

Sources/PackageCollections/Model/Collection.swift

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ import TSCUtility
1818
public enum PackageCollectionsModel {}
1919

2020
extension PackageCollectionsModel {
21-
/// A `PackageCollection` is a collection of packages.
21+
/// A `Collection` is a collection of packages.
2222
public struct Collection: Equatable, Codable {
2323
public typealias Identifier = CollectionIdentifier
2424
public typealias Source = CollectionSource
25-
public typealias Author = CollectionAuthor
2625

2726
/// The identifier of the collection
2827
public let identifier: Identifier
@@ -34,7 +33,7 @@ extension PackageCollectionsModel {
3433
public let name: String
3534

3635
/// The description of the collection
37-
public let description: String?
36+
public let overview: String?
3837

3938
/// Keywords for the collection
4039
public let keywords: [String]?
@@ -51,11 +50,11 @@ extension PackageCollectionsModel {
5150
/// When this collection was last processed locally
5251
public let lastProcessedAt: Date
5352

54-
/// Initializes a `PackageCollection`
53+
/// Initializes a `Collection`
5554
init(
5655
source: Source,
5756
name: String,
58-
description: String?,
57+
overview: String?,
5958
keywords: [String]?,
6059
packages: [Package],
6160
createdAt: Date,
@@ -65,7 +64,7 @@ extension PackageCollectionsModel {
6564
self.identifier = .init(from: source)
6665
self.source = source
6766
self.name = name
68-
self.description = description
67+
self.overview = overview
6968
self.keywords = keywords
7069
self.packages = packages
7170
self.createdAt = createdAt
@@ -76,7 +75,7 @@ extension PackageCollectionsModel {
7675
}
7776

7877
extension PackageCollectionsModel {
79-
/// Represents the source of a `PackageCollection`
78+
/// Represents the source of a `Collection`
8079
public struct CollectionSource: Equatable, Hashable, Codable {
8180
/// Source type
8281
public let type: CollectionSourceType
@@ -90,14 +89,14 @@ extension PackageCollectionsModel {
9089
}
9190
}
9291

93-
/// Represents the source type of a `PackageCollection`
92+
/// Represents the source type of a `Collection`
9493
public enum CollectionSourceType: String, Codable, CaseIterable {
9594
case json
9695
}
9796
}
9897

9998
extension PackageCollectionsModel {
100-
/// Represents the identifier of a `PackageCollection`
99+
/// Represents the identifier of a `Collection`
101100
public enum CollectionIdentifier: Hashable, Comparable {
102101
/// JSON based package collection at URL
103102
case json(URL)
@@ -119,14 +118,6 @@ extension PackageCollectionsModel {
119118
}
120119
}
121120

122-
extension PackageCollectionsModel {
123-
/// Represents the author of a `PackageCollection`
124-
public struct CollectionAuthor: Equatable, Codable {
125-
/// The name of the author
126-
public let name: String
127-
}
128-
}
129-
130121
extension PackageCollectionsModel.CollectionIdentifier: Codable {
131122
public enum DiscriminatorKeys: String, Codable {
132123
case json
@@ -155,3 +146,11 @@ extension PackageCollectionsModel.CollectionIdentifier: Codable {
155146
}
156147
}
157148
}
149+
150+
extension PackageCollectionsModel.Collection {
151+
/// Represents the author of a `Collection`
152+
public struct Author: Equatable, Codable {
153+
/// The name of the author
154+
public let name: String
155+
}
156+
}

Sources/PackageCollections/Model/Package.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ extension PackageCollectionsModel {
2323
public let repository: RepositorySpecifier
2424

2525
/// Package description
26-
public let description: String?
26+
public let summary: String?
2727

2828
/// Keywords for the package
2929
public let keywords: [String]?
@@ -69,7 +69,7 @@ extension PackageCollectionsModel {
6969
/// Initializes a `PackageMetadata`
7070
init(
7171
repository: RepositorySpecifier,
72-
description: String?,
72+
summary: String?,
7373
keywords: [String]?,
7474
versions: [Version],
7575
latestVersion: Version?,
@@ -79,7 +79,7 @@ extension PackageCollectionsModel {
7979
) {
8080
self.reference = .init(repository: repository)
8181
self.repository = repository
82-
self.description = description
82+
self.summary = summary
8383
self.keywords = keywords
8484
self.versions = versions
8585
self.latestVersion = latestVersion

Sources/PackageCollections/Model/TargetListResult.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extension PackageCollectionsModel.TargetListResult {
3636
public let repository: RepositorySpecifier
3737

3838
/// Package description
39-
public let description: String?
39+
public let summary: String?
4040

4141
/// Package versions that contain the target
4242
public let versions: [Version]

Sources/PackageCollections/PackageCollections.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ public struct PackageCollections: PackageCollectionsProtocol {
330330
.map { pair -> PackageCollectionsModel.TargetListResult.Package in
331331
let versions = pair.package.versions.map { PackageCollectionsModel.TargetListResult.PackageVersion(version: $0.version, packageName: $0.packageName) }
332332
return .init(repository: pair.package.repository,
333-
description: pair.package.description,
333+
summary: pair.package.summary,
334334
versions: versions,
335335
collections: Array(pair.collections))
336336
}
@@ -359,7 +359,7 @@ public struct PackageCollections: PackageCollectionsProtocol {
359359

360360
return .init(
361361
repository: package.repository,
362-
description: basicMetadata?.description ?? package.description,
362+
summary: basicMetadata?.summary ?? package.summary,
363363
keywords: basicMetadata?.keywords ?? package.keywords,
364364
versions: versions,
365365
latestVersion: latestVersion,

Sources/PackageCollections/Providers/GitHubPackageMetadataProvider.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ struct GitHubPackageMetadataProvider: PackageMetadataProvider {
104104
let readme = try results[readmeURL]?.success?.decodeBody(Readme.self, using: self.decoder)
105105

106106
callback(.success(.init(
107-
description: metadata.description,
107+
summary: metadata.description,
108108
keywords: metadata.topics,
109109
versions: tags.compactMap { TSCUtility.Version(string: $0.name) },
110110
watchersCount: metadata.watchersCount,

Sources/PackageCollections/Providers/JSONPackageCollectionProvider.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ struct JSONPackageCollectionProvider: PackageCollectionProvider {
8484
}
8585

8686
func makeCollection(_ response: HTTPClientResponse) -> Result<PackageCollectionsModel.Collection, Error> {
87-
let collection: JSONModel.PackageCollection
87+
let collection: JSONModel.Collection
8888
do {
8989
// parse json
90-
guard let decoded = try response.decodeBody(JSONModel.PackageCollection.self, using: self.decoder) else {
90+
guard let decoded = try response.decodeBody(JSONModel.Collection.self, using: self.decoder) else {
9191
throw Errors.invalidResponse("Invalid body")
9292
}
9393
collection = decoded
@@ -121,7 +121,7 @@ struct JSONPackageCollectionProvider: PackageCollectionProvider {
121121
license: license)
122122
}
123123
return .init(repository: RepositorySpecifier(url: package.url.absoluteString),
124-
description: package._description,
124+
summary: package.summary,
125125
keywords: package.keywords,
126126
versions: versions,
127127
latestVersion: versions.first,
@@ -131,11 +131,11 @@ struct JSONPackageCollectionProvider: PackageCollectionProvider {
131131
}
132132
return .success(.init(source: source,
133133
name: collection.name,
134-
description: collection._description,
134+
overview: collection.overview,
135135
keywords: collection.keywords,
136136
packages: packages,
137137
createdAt: collection.generatedAt,
138-
createdBy: collection.generatedBy.flatMap { PackageCollectionsModel.CollectionAuthor(name: $0.name) },
138+
createdBy: collection.generatedBy.flatMap { PackageCollectionsModel.Collection.Author(name: $0.name) },
139139
lastProcessedAt: Date()))
140140
}
141141
}

Sources/PackageCollections/Providers/PackageMetadataProvider.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protocol PackageMetadataProvider {
2525

2626
extension PackageCollectionsModel {
2727
struct PackageBasicMetadata: Equatable {
28-
let description: String?
28+
let summary: String?
2929
let keywords: [String]?
3030
let versions: [TSCUtility.Version]
3131
let watchersCount: Int?

Sources/PackageCollections/Storage/SQLitePackageCollectionsStorage.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ final class SQLitePackageCollectionsStorage: PackageCollectionsStorage, Closable
233233
var map = partial
234234
map[collection.identifier] = collection.packages.filter { package in
235235
if package.repository.url.lowercased().contains(queryString) { return true }
236-
if let description = package.description, description.lowercased().contains(queryString) { return true }
236+
if let summary = package.summary, summary.lowercased().contains(queryString) { return true }
237237
if let keywords = package.keywords, (keywords.map { $0.lowercased() }).contains(queryString) { return true }
238238
return package.versions.contains(where: { version in
239239
if version.packageName.lowercased().contains(queryString) { return true }
@@ -351,7 +351,7 @@ final class SQLitePackageCollectionsStorage: PackageCollectionsStorage, Closable
351351
.map { pair -> PackageCollectionsModel.TargetListItem.Package in
352352
let versions = pair.package.versions.map { PackageCollectionsModel.TargetListItem.Package.Version(version: $0.version, packageName: $0.packageName) }
353353
return PackageCollectionsModel.TargetListItem.Package(repository: pair.package.repository,
354-
description: pair.package.description,
354+
summary: pair.package.summary,
355355
versions: versions,
356356
collections: Array(pair.collections))
357357
}

Tests/PackageCollectionsTests/GitHubPackageMetadataProviderTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class GitHubPackageMetadataProviderTests: XCTestCase {
7676
let reference = PackageReference(repository: RepositorySpecifier(url: repoURL))
7777
let metadata = try tsc_await { callback in provider.get(reference, callback: callback) }
7878

79-
XCTAssertEqual(metadata.description, "This your first repo!")
79+
XCTAssertEqual(metadata.summary, "This your first repo!")
8080
XCTAssertEqual(metadata.versions, [TSCUtility.Version("0.1.0")])
8181
XCTAssertEqual(metadata.authors, [PackageCollectionsModel.Package.Author(username: "octocat",
8282
url: URL(string: "https://api.github.com/users/octocat")!,
@@ -130,7 +130,7 @@ class GitHubPackageMetadataProviderTests: XCTestCase {
130130
let reference = PackageReference(repository: RepositorySpecifier(url: repoURL))
131131
let metadata = try tsc_await { callback in provider.get(reference, callback: callback) }
132132

133-
XCTAssertEqual(metadata.description, "This your first repo!")
133+
XCTAssertEqual(metadata.summary, "This your first repo!")
134134
XCTAssertEqual(metadata.versions, [])
135135
XCTAssertNil(metadata.authors)
136136
XCTAssertNil(metadata.readmeURL)

0 commit comments

Comments
 (0)