Skip to content

Commit 49992f0

Browse files
committed
Add missing licenses from choosealicense.com.
1 parent 385da91 commit 49992f0

3 files changed

Lines changed: 131 additions & 28 deletions

File tree

Sources/App/Models/License.swift

Lines changed: 89 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,56 @@
1414

1515
enum License: String, Codable, Equatable, CaseIterable {
1616

17-
// This is not an exhaustive list, but includes most commonly used license types
17+
// License identifiers match GitHub's API keys from choosealicense.com
18+
case bsd_0_clause = "0bsd"
1819
case afl_3_0 = "afl-3.0"
20+
case agpl_3_0 = "agpl-3.0"
1921
case apache_2_0 = "apache-2.0"
2022
case artistic_2_0 = "artistic-2.0"
23+
case blueoak_1_0_0 = "blueoak-1.0.0"
2124
case bsd_2_clause = "bsd-2-clause"
25+
case bsd_2_clause_patent = "bsd-2-clause-patent"
2226
case bsd_3_clause = "bsd-3-clause"
2327
case bsd_3_clause_clear = "bsd-3-clause-clear"
28+
case bsd_4_clause = "bsd-4-clause"
2429
case bsl_1_0 = "bsl-1.0"
2530
case cc
26-
case cc0_1_0 = "cc0-1.0"
2731
case cc_by_4_0 = "cc-by-4.0"
2832
case cc_by_sa_4_0 = "cc-by-sa-4.0"
29-
case wtfpl
33+
case cc0_1_0 = "cc0-1.0"
34+
case cecill_2_1 = "cecill-2.1"
35+
case cern_ohl_p_2_0 = "cern-ohl-p-2.0"
36+
case cern_ohl_s_2_0 = "cern-ohl-s-2.0"
37+
case cern_ohl_w_2_0 = "cern-ohl-w-2.0"
3038
case ecl_2_0 = "ecl-2.0"
3139
case epl_1_0 = "epl-1.0"
40+
case epl_2_0 = "epl-2.0"
3241
case eupl_1_1 = "eupl-1.1"
33-
case agpl_3_0 = "agpl-3.0"
42+
case eupl_1_2 = "eupl-1.2"
43+
case gfdl_1_3 = "gfdl-1.3"
3444
case gpl
3545
case gpl_2_0 = "gpl-2.0"
3646
case gpl_3_0 = "gpl-3.0"
47+
case isc
3748
case lgpl
3849
case lgpl_2_1 = "lgpl-2.1"
3950
case lgpl_3_0 = "lgpl-3.0"
40-
case isc
41-
case ms_pl = "ms-pl"
51+
case lppl_1_3c = "lppl-1.3c"
4252
case mit
53+
case mit_0 = "mit-0"
4354
case mpl_2_0 = "mpl-2.0"
55+
case ms_pl = "ms-pl"
56+
case ms_rl = "ms-rl"
57+
case mulanpsl_2_0 = "mulanpsl-2.0"
58+
case ncsa
59+
case odbl_1_0 = "odbl-1.0"
60+
case ofl_1_1 = "ofl-1.1"
4461
case osl_3_0 = "osl-3.0"
4562
case postgresql
46-
case ncsa
63+
case upl_1_0 = "upl-1.0"
4764
case unlicense // NB: This is an actual license and *not* a typo of "unlicensed"
65+
case vim
66+
case wtfpl
4867
case zlib
4968

5069
// These are special cases, not license types
@@ -53,36 +72,55 @@ enum License: String, Codable, Equatable, CaseIterable {
5372

5473
var fullName: String {
5574
switch self {
75+
case .bsd_0_clause: return "BSD Zero Clause License"
5676
case .afl_3_0: return "Academic Free License v3.0"
77+
case .agpl_3_0: return "GNU Affero General Public License v3.0"
5778
case .apache_2_0: return "Apache License 2.0"
5879
case .artistic_2_0: return "Artistic License 2.0"
59-
case .bsd_2_clause: return "BSD 2-clause \"Simplified\" license"
60-
case .bsd_3_clause: return "BSD 3-clause \"New\" or \"Revised\" license"
61-
case .bsd_3_clause_clear: return "BSD 3-clause Clear license"
80+
case .blueoak_1_0_0: return "Blue Oak Model License 1.0.0"
81+
case .bsd_2_clause: return "BSD 2-Clause \"Simplified\" License"
82+
case .bsd_2_clause_patent: return "BSD 2-Clause Plus Patent License"
83+
case .bsd_3_clause: return "BSD 3-Clause \"New\" or \"Revised\" License"
84+
case .bsd_3_clause_clear: return "BSD 3-Clause Clear License"
85+
case .bsd_4_clause: return "BSD 4-Clause \"Original\" License"
6286
case .bsl_1_0: return "Boost Software License 1.0"
6387
case .cc: return "Creative Commons License"
64-
case .cc0_1_0: return "Creative Commons Zero v1.0 Universal"
6588
case .cc_by_4_0: return "Creative Commons Attribution 4.0"
6689
case .cc_by_sa_4_0: return "Creative Commons Attribution Share Alike 4.0"
67-
case .wtfpl: return "Do What The F**k You Want To Public License"
90+
case .cc0_1_0: return "Creative Commons Zero v1.0 Universal"
91+
case .cecill_2_1: return "CeCILL Free Software License Agreement v2.1"
92+
case .cern_ohl_p_2_0: return "CERN Open Hardware Licence Version 2 - Permissive"
93+
case .cern_ohl_s_2_0: return "CERN Open Hardware Licence Version 2 - Strongly Reciprocal"
94+
case .cern_ohl_w_2_0: return "CERN Open Hardware Licence Version 2 - Weakly Reciprocal"
6895
case .ecl_2_0: return "Educational Community License v2.0"
6996
case .epl_1_0: return "Eclipse Public License 1.0"
97+
case .epl_2_0: return "Eclipse Public License 2.0"
7098
case .eupl_1_1: return "European Union Public License 1.1"
71-
case .agpl_3_0: return "GNU Affero General Public License v3.0"
99+
case .eupl_1_2: return "European Union Public License 1.2"
100+
case .gfdl_1_3: return "GNU Free Documentation License v1.3"
72101
case .gpl: return "GNU General Public License family"
73102
case .gpl_2_0: return "GNU General Public License v2.0"
74103
case .gpl_3_0: return "GNU General Public License v3.0"
104+
case .isc: return "ISC License"
75105
case .lgpl: return "GNU Lesser General Public License family"
76106
case .lgpl_2_1: return "GNU Lesser General Public License v2.1"
77107
case .lgpl_3_0: return "GNU Lesser General Public License v3.0"
78-
case .isc: return "ISC License"
79-
case .ms_pl: return "Microsoft Public License"
108+
case .lppl_1_3c: return "LaTeX Project Public License v1.3c"
80109
case .mit: return "MIT License"
110+
case .mit_0: return "MIT No Attribution License"
81111
case .mpl_2_0: return "Mozilla Public License 2.0"
112+
case .ms_pl: return "Microsoft Public License"
113+
case .ms_rl: return "Microsoft Reciprocal License"
114+
case .mulanpsl_2_0: return "Mulan Permissive Software License, Version 2"
115+
case .ncsa: return "University of Illinois/NCSA Open Source License"
116+
case .odbl_1_0: return "Open Data Commons Open Database License v1.0"
117+
case .ofl_1_1: return "SIL Open Font License 1.1"
82118
case .osl_3_0: return "Open Software License 3.0"
83119
case .postgresql: return "PostgreSQL License"
84-
case .ncsa: return "University of Illinois/NCSA Open Source License"
120+
case .upl_1_0: return "Universal Permissive License v1.0"
85121
case .unlicense: return "The Unlicense"
122+
case .vim: return "Vim License"
123+
case .wtfpl: return "Do What The F**k You Want To Public License"
86124
case .zlib: return "zLib License"
87125

88126
case .other: return "Unknown or Unrecognised License"
@@ -92,36 +130,55 @@ enum License: String, Codable, Equatable, CaseIterable {
92130

93131
var shortName: String {
94132
switch self {
133+
case .bsd_0_clause: return "0BSD"
95134
case .afl_3_0: return "AFL 3.0"
135+
case .agpl_3_0: return "AGPL 3.0"
96136
case .apache_2_0: return "Apache 2.0"
97137
case .artistic_2_0: return "Artistic 2.0"
138+
case .blueoak_1_0_0: return "BlueOak 1.0.0"
98139
case .bsd_2_clause: return "BSD 2-Clause"
140+
case .bsd_2_clause_patent: return "BSD 2-Clause Patent"
99141
case .bsd_3_clause: return "BSD 3-Clause"
100142
case .bsd_3_clause_clear: return "BSD 3-Clause Clear"
143+
case .bsd_4_clause: return "BSD 4-Clause"
101144
case .bsl_1_0: return "Boost 1.0"
102145
case .cc: return "CC"
103-
case .cc0_1_0: return "CC Zero 1.0"
104146
case .cc_by_4_0: return "CC Attribution 4.0"
105147
case .cc_by_sa_4_0: return "CC Attribution SA 4.0"
106-
case .wtfpl: return "DWTFYWTPL"
148+
case .cc0_1_0: return "CC Zero 1.0"
149+
case .cecill_2_1: return "CeCILL 2.1"
150+
case .cern_ohl_p_2_0: return "CERN OHL-P 2.0"
151+
case .cern_ohl_s_2_0: return "CERN OHL-S 2.0"
152+
case .cern_ohl_w_2_0: return "CERN OHL-W 2.0"
107153
case .ecl_2_0: return "ECL 2.0"
108154
case .epl_1_0: return "EPL 1.0"
155+
case .epl_2_0: return "EPL 2.0"
109156
case .eupl_1_1: return "EUPL 1.1"
110-
case .agpl_3_0: return "AGPL 3.0"
157+
case .eupl_1_2: return "EUPL 1.2"
158+
case .gfdl_1_3: return "GFDL 1.3"
111159
case .gpl: return "GPL"
112160
case .gpl_2_0: return "GPL 2.0"
113161
case .gpl_3_0: return "GPL 3.0"
162+
case .isc: return "ISC"
114163
case .lgpl: return "LGPL"
115164
case .lgpl_2_1: return "LGPL 2.1"
116165
case .lgpl_3_0: return "LGPL 3.0"
117-
case .isc: return "ISC"
118-
case .ms_pl: return "MSPL"
166+
case .lppl_1_3c: return "LPPL 1.3c"
119167
case .mit: return "MIT"
168+
case .mit_0: return "MIT-0"
120169
case .mpl_2_0: return "MPL 2.0"
170+
case .ms_pl: return "MSPL"
171+
case .ms_rl: return "MSRL"
172+
case .mulanpsl_2_0: return "MulanPSL 2.0"
173+
case .ncsa: return "NCSA"
174+
case .odbl_1_0: return "ODbL 1.0"
175+
case .ofl_1_1: return "OFL 1.1"
121176
case .osl_3_0: return "OSL 3.0"
122177
case .postgresql: return "PostgreSQL"
123-
case .ncsa: return "NCSA"
178+
case .upl_1_0: return "UPL 1.0"
124179
case .unlicense: return "The Unlicense"
180+
case .vim: return "Vim"
181+
case .wtfpl: return "DWTFYWTPL"
125182
case .zlib: return "zLib"
126183

127184
case .other: return "Unknown license"
@@ -136,12 +193,21 @@ enum License: String, Codable, Equatable, CaseIterable {
136193
case .none:
137194
return .none
138195
case .agpl_3_0,
196+
.cecill_2_1,
197+
.cern_ohl_s_2_0,
198+
.cern_ohl_w_2_0,
199+
.eupl_1_1,
200+
.eupl_1_2,
201+
.gfdl_1_3,
139202
.gpl,
140203
.gpl_2_0,
141204
.gpl_3_0,
142205
.lgpl,
143206
.lgpl_2_1,
144-
.lgpl_3_0: return .incompatibleWithAppStore
207+
.lgpl_3_0,
208+
.lppl_1_3c,
209+
.ms_rl,
210+
.osl_3_0: return .incompatibleWithAppStore
145211
default: return .compatibleWithAppStore
146212
}
147213
}

Tests/AppTests/LicenseTests.swift

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,22 @@ extension AllTests.LicenseTests {
2222
@Test func init_from_dto() throws {
2323
#expect(License(from: Github.Metadata.LicenseInfo(key: "mit")) == .mit)
2424
#expect(License(from: Github.Metadata.LicenseInfo(key: "agpl-3.0")) == .agpl_3_0)
25+
#expect(License(from: Github.Metadata.LicenseInfo(key: "0bsd")) == .bsd_0_clause)
26+
#expect(License(from: Github.Metadata.LicenseInfo(key: "blueoak-1.0.0")) == .blueoak_1_0_0)
27+
#expect(License(from: Github.Metadata.LicenseInfo(key: "bsd-2-clause-patent")) == .bsd_2_clause_patent)
28+
#expect(License(from: Github.Metadata.LicenseInfo(key: "cecill-2.1")) == .cecill_2_1)
29+
#expect(License(from: Github.Metadata.LicenseInfo(key: "cern-ohl-s-2.0")) == .cern_ohl_s_2_0)
30+
#expect(License(from: Github.Metadata.LicenseInfo(key: "epl-2.0")) == .epl_2_0)
31+
#expect(License(from: Github.Metadata.LicenseInfo(key: "eupl-1.2")) == .eupl_1_2)
32+
#expect(License(from: Github.Metadata.LicenseInfo(key: "gfdl-1.3")) == .gfdl_1_3)
33+
#expect(License(from: Github.Metadata.LicenseInfo(key: "lppl-1.3c")) == .lppl_1_3c)
34+
#expect(License(from: Github.Metadata.LicenseInfo(key: "mit-0")) == .mit_0)
35+
#expect(License(from: Github.Metadata.LicenseInfo(key: "ms-rl")) == .ms_rl)
36+
#expect(License(from: Github.Metadata.LicenseInfo(key: "mulanpsl-2.0")) == .mulanpsl_2_0)
37+
#expect(License(from: Github.Metadata.LicenseInfo(key: "odbl-1.0")) == .odbl_1_0)
38+
#expect(License(from: Github.Metadata.LicenseInfo(key: "ofl-1.1")) == .ofl_1_1)
39+
#expect(License(from: Github.Metadata.LicenseInfo(key: "upl-1.0")) == .upl_1_0)
40+
#expect(License(from: Github.Metadata.LicenseInfo(key: "vim")) == .vim)
2541
#expect(License(from: Github.Metadata.LicenseInfo(key: "other")) == .other)
2642
#expect(License(from: .none) == .none)
2743
}
@@ -46,8 +62,29 @@ extension AllTests.LicenseTests {
4662
}
4763

4864
@Test func isCompatibleWithAppStore() throws {
65+
// Compatible
4966
#expect(License.mit.licenseKind == .compatibleWithAppStore)
67+
#expect(License.mit_0.licenseKind == .compatibleWithAppStore)
68+
#expect(License.apache_2_0.licenseKind == .compatibleWithAppStore)
69+
#expect(License.blueoak_1_0_0.licenseKind == .compatibleWithAppStore)
70+
#expect(License.bsd_2_clause_patent.licenseKind == .compatibleWithAppStore)
71+
#expect(License.epl_2_0.licenseKind == .compatibleWithAppStore)
72+
#expect(License.cern_ohl_p_2_0.licenseKind == .compatibleWithAppStore)
73+
#expect(License.upl_1_0.licenseKind == .compatibleWithAppStore)
74+
// Incompatible
5075
#expect(License.agpl_3_0.licenseKind == .incompatibleWithAppStore)
76+
#expect(License.cecill_2_1.licenseKind == .incompatibleWithAppStore)
77+
#expect(License.cern_ohl_s_2_0.licenseKind == .incompatibleWithAppStore)
78+
#expect(License.cern_ohl_w_2_0.licenseKind == .incompatibleWithAppStore)
79+
#expect(License.eupl_1_1.licenseKind == .incompatibleWithAppStore)
80+
#expect(License.eupl_1_2.licenseKind == .incompatibleWithAppStore)
81+
#expect(License.gfdl_1_3.licenseKind == .incompatibleWithAppStore)
82+
#expect(License.gpl_2_0.licenseKind == .incompatibleWithAppStore)
83+
#expect(License.lgpl_3_0.licenseKind == .incompatibleWithAppStore)
84+
#expect(License.lppl_1_3c.licenseKind == .incompatibleWithAppStore)
85+
#expect(License.ms_rl.licenseKind == .incompatibleWithAppStore)
86+
#expect(License.osl_3_0.licenseKind == .incompatibleWithAppStore)
87+
// Special
5188
#expect(License.other.licenseKind == .other)
5289
#expect(License.none.licenseKind == .none)
5390
}

Tests/AppTests/SearchFilterTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ extension AllTests.SearchFilterTests {
189189
value: "compatible"))
190190
#expect(filter.key == .license)
191191
#expect(filter.predicate == .init(operator: .in,
192-
bindableValue: .array(["afl-3.0", "apache-2.0", "artistic-2.0", "bsd-2-clause", "bsd-3-clause", "bsd-3-clause-clear", "bsl-1.0", "cc", "cc0-1.0", "cc-by-4.0", "cc-by-sa-4.0", "wtfpl", "ecl-2.0", "epl-1.0", "eupl-1.1", "isc", "ms-pl", "mit", "mpl-2.0", "osl-3.0", "postgresql", "ncsa", "unlicense", "zlib"]),
192+
bindableValue: .array(["0bsd", "afl-3.0", "apache-2.0", "artistic-2.0", "blueoak-1.0.0", "bsd-2-clause", "bsd-2-clause-patent", "bsd-3-clause", "bsd-3-clause-clear", "bsd-4-clause", "bsl-1.0", "cc", "cc-by-4.0", "cc-by-sa-4.0", "cc0-1.0", "cern-ohl-p-2.0", "ecl-2.0", "epl-1.0", "epl-2.0", "isc", "mit", "mit-0", "mpl-2.0", "ms-pl", "mulanpsl-2.0", "ncsa", "odbl-1.0", "ofl-1.1", "postgresql", "upl-1.0", "unlicense", "vim", "wtfpl", "zlib"]),
193193
displayValue: "compatible with the App Store"))
194194

195195
// test view representation
@@ -198,7 +198,7 @@ extension AllTests.SearchFilterTests {
198198
// test sql representation
199199
#expect(app.db.renderSQL(filter.leftHandSide) == #""license""#)
200200
#expect(app.db.renderSQL(filter.sqlOperator) == "IN")
201-
#expect(app.db.binds(filter.rightHandSide) == ["afl-3.0", "apache-2.0", "artistic-2.0", "bsd-2-clause", "bsd-3-clause", "bsd-3-clause-clear", "bsl-1.0", "cc", "cc0-1.0", "cc-by-4.0", "cc-by-sa-4.0", "wtfpl", "ecl-2.0", "epl-1.0", "eupl-1.1", "isc", "ms-pl", "mit", "mpl-2.0", "osl-3.0", "postgresql", "ncsa", "unlicense", "zlib"])
201+
#expect(app.db.binds(filter.rightHandSide) == ["0bsd", "afl-3.0", "apache-2.0", "artistic-2.0", "blueoak-1.0.0", "bsd-2-clause", "bsd-2-clause-patent", "bsd-3-clause", "bsd-3-clause-clear", "bsd-4-clause", "bsl-1.0", "cc", "cc-by-4.0", "cc-by-sa-4.0", "cc0-1.0", "cern-ohl-p-2.0", "ecl-2.0", "epl-1.0", "epl-2.0", "isc", "mit", "mit-0", "mpl-2.0", "ms-pl", "mulanpsl-2.0", "ncsa", "odbl-1.0", "ofl-1.1", "postgresql", "upl-1.0", "unlicense", "vim", "wtfpl", "zlib"])
202202
}
203203
}
204204

@@ -235,7 +235,7 @@ extension AllTests.SearchFilterTests {
235235
#expect(
236236
try LicenseSearchFilter(
237237
expression: .init(operator: .is,
238-
value: "Compatible")).bindableValue == ["afl-3.0", "apache-2.0", "artistic-2.0", "bsd-2-clause", "bsd-3-clause", "bsd-3-clause-clear", "bsl-1.0", "cc", "cc0-1.0", "cc-by-4.0", "cc-by-sa-4.0", "wtfpl", "ecl-2.0", "epl-1.0", "eupl-1.1", "isc", "ms-pl", "mit", "mpl-2.0", "osl-3.0", "postgresql", "ncsa", "unlicense", "zlib"]
238+
value: "Compatible")).bindableValue == ["0bsd", "afl-3.0", "apache-2.0", "artistic-2.0", "blueoak-1.0.0", "bsd-2-clause", "bsd-2-clause-patent", "bsd-3-clause", "bsd-3-clause-clear", "bsd-4-clause", "bsl-1.0", "cc", "cc-by-4.0", "cc-by-sa-4.0", "cc0-1.0", "cern-ohl-p-2.0", "ecl-2.0", "epl-1.0", "epl-2.0", "isc", "mit", "mit-0", "mpl-2.0", "ms-pl", "mulanpsl-2.0", "ncsa", "odbl-1.0", "ofl-1.1", "postgresql", "upl-1.0", "unlicense", "vim", "wtfpl", "zlib"]
239239
)
240240
}
241241

@@ -245,7 +245,7 @@ extension AllTests.SearchFilterTests {
245245
value: "incompatible"))
246246
#expect(filter.key == .license)
247247
#expect(filter.predicate == .init(operator: .in,
248-
bindableValue: .array(["agpl-3.0", "gpl", "gpl-2.0", "gpl-3.0", "lgpl", "lgpl-2.1", "lgpl-3.0"]),
248+
bindableValue: .array(["agpl-3.0", "cecill-2.1", "cern-ohl-s-2.0", "cern-ohl-w-2.0", "eupl-1.1", "eupl-1.2", "gfdl-1.3", "gpl", "gpl-2.0", "gpl-3.0", "lgpl", "lgpl-2.1", "lgpl-3.0", "lppl-1.3c", "ms-rl", "osl-3.0"]),
249249
displayValue: "incompatible with the App Store"))
250250

251251
// test view representation
@@ -254,7 +254,7 @@ extension AllTests.SearchFilterTests {
254254
// test sql representation
255255
#expect(app.db.renderSQL(filter.leftHandSide) == #""license""#)
256256
#expect(app.db.renderSQL(filter.sqlOperator) == "IN")
257-
#expect(app.db.binds(filter.rightHandSide) == ["agpl-3.0", "gpl", "gpl-2.0", "gpl-3.0", "lgpl", "lgpl-2.1", "lgpl-3.0"])
257+
#expect(app.db.binds(filter.rightHandSide) == ["agpl-3.0", "cecill-2.1", "cern-ohl-s-2.0", "cern-ohl-w-2.0", "eupl-1.1", "eupl-1.2", "gfdl-1.3", "gpl", "gpl-2.0", "gpl-3.0", "lgpl", "lgpl-2.1", "lgpl-3.0", "lppl-1.3c", "ms-rl", "osl-3.0"])
258258
}
259259
}
260260

0 commit comments

Comments
 (0)