-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathnormalize.js
347 lines (339 loc) · 11.3 KB
/
normalize.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
'use strict';
var opensource = require('./opensource')
, license = opensource.types;
//
// Map commonly used terms to a normal license value as you can usually specify
// your license type in so many ways. By mapping this, we can create a more
// readable format for each license type.
//
var normalized = {
'"BSD"': license.BSD,
'(Un)license': license.UNLICENSE,
'2-clause BSD': license.BSD2,
'3-clause BSD': license.BSD3,
'AFLv2.1': license.AFL2,
'AGPL 3': license.AGPL3,
'AGPL 3.0': license.AGPL3,
'AGPL v3': license.AGPL3,
'AGPL': license.AGPL3,
'AGPL-3': license.AGPL3,
'AGPL-3.0': license.AGPL3,
'AGPL3': license.AGPL3,
'AGPLv3': license.AGPL3,
'AGPLv3+': license.AGPL3,
'ALv2': license.AFL2,
'APACHE 2.0': license.Apache2,
'APACHE V2.0': license.Apache2,
'APACHE': license.Apache,
'APACHE-2.0': license.Apache2,
'APACHE2': license.Apache2,
'APACHE2.0': license.Apache2,
'APACHE2_0': license.Apache2,
'APACHEv2': license.Apache2,
'APL': license.APL1,
'APLv2': license.Apache2,
'ARTISTIC 2.0': license.ARTISTIC2,
'Affero General Public License v3': license.AGPL3,
'Apache (2.0)': license.Apache2,
'Apache 2 License': license.Apache2,
'Apache 2': license.Apache2,
'Apache 2.0': license.Apache2,
'Apache License 2': license.Apache2,
'Apache License 2.0': license.Apache2,
'Apache License Version 2': license.Apache2,
'Apache License Version 2.0': license.Apache2,
'Apache License v2': license.Apache2,
'Apache License v2.0': license.Apache2,
'Apache License version 2.0': license.Apache2,
'Apache License': license.Apache,
'Apache License, Version 2.0': license.Apache2,
'Apache License, Version 2.0, http://www.apache.org/licenses/LICENSE-2.0': license.Apache2,
'Apache Public License (version 2)': license.Apache2,
'Apache Public License v2': license.Apache2,
'Apache Public License, Version 2': license.Apache2,
'Apache Software License 2.0': license.Apache2,
'Apache V2': license.Apache2,
'Apache V2.0': license.Apache2,
'Apache v2 License': license.Apache2,
'Apache v2 license': license.Apache,
'Apache v2': license.Apache2,
'Apache v2.0': license.Apache2,
'Apache version 2.0': license.Apache2,
'Apache': license.Apache,
'Apache, Version 2.0': license.Apache2,
'Apache-2': license.Apache2,
'Apache-2.0': license.Apache2,
'Apache-V2': license.Apache2,
'Apache2': license.Apache2,
'Apache2.0': license.Apache2,
'Appcelerator Proprietary and Confidential': license.PROPRIETARY,
'Artistic-2.0': license.ARTISTIC2,
'Attribution-NonCommercial 2.5 Generic (CC BY-NC 2.5)': license.CCBYNC25,
'Attribution-ShareAlike 3.0 Unported': license.CCBYSA3,
'BOOST': license.BSL1,
'BSD 2 Clause': license.BSD2,
'BSD 2-Clause License': license.BSD2,
'BSD 2-Clause license': license.BSD2,
'BSD 2-Clause': license.BSD2,
'BSD 2-clause license': license.BSD2,
'BSD 3-Clause License': license.BSD3,
'BSD 3-Clause': license.BSD3,
'BSD License': license.BSD,
'BSD New': license.BSD3,
'BSD': license.BSD,
'BSD-2-Clause': license.BSD2,
'BSD-3': license.BSD3,
'BSD-3-Clause': license.BSD3,
'BSD-new': license.BSD3,
'BSD2': license.BSD2,
'BSD3': license.BSD3,
'BeerWare': license.BEER,
'Beerware': license.BEER,
'CC BY-NC 3.0': license.CCBYNC3,
'CC BY-NC': license.CCBYNC3,
'CC BY-NC-SA': license.CCBYNCSA3,
'CC BY-SA 3.0': license.CCBYSA3,
'CC BY-SA v3.0': license.CCBYSA3,
'CC': license.CCBY3,
'CC-0': license.CCBY3,
'CC-BY 2.0': license.CCBY25,
'CC-BY-NC-SA': license.CCBYNCSA3,
'CC-BY-SA': license.CCBYSA3,
'CC-By-SA 3.0': license.CCBYSA3,
'CC-SA-BY-3.0': license.CCBYSA3,
'CC-by-SA': license.CCBYSA3,
'CC0 1.0': license.CCBY3,
'CC3': license.CCBY3,
'CC_by_3.0': license.CCBY3,
'CDDL': license.CDDL1,
'Closed Source': license.PROPRIETARY,
'Copyrighted - CC BY-NC-ND': license.CCBYNCND3,
'Creative Commons - Attribution 3.0': license.CCBY3,
'Creative Commons 3.0': license.CCBY3,
'Creative Commons Attribution 3.0 Unported License': license.CCBY3,
'Creative Commons Attribution': license.CCBY3,
'Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)': license.CCBYNCSA3,
'Creative Commons Attribution-ShareAlike 3.0 Unported': license.CCBYSA3,
'Creative Commons Attribution-ShareAlike 3.0': license.CCBYSA3,
'Creative Commons BY-NC-SA License 3.0': license.CCBYNCSA3,
'Creative Commons Legal Code Attribution-NonCommercial-NoDerivs 3.0': license.CCBYNCND3,
'Creative Commons License 2.5': license.CCBY25,
'Creative Commons attribution and share-alike license': license.CCBYSA3,
'Creative Commons': license.CCBY3,
'DO-WHAT-YOU-WANT': license.WTFPL,
'DWTFYW': license.WTFPL,
'Do What the Fuck You Want to Public License': license.WTFPL,
'Doug Crockford\'s license that allows this module to be used for Good but not for Evil': license.JSON,
'Free as in Hugs Licence': license.PUBLIC,
'Free as in Hugs License': license.PUBLIC,
'Free as in Hugs': license.PUBLIC,
'Free': license.PUBLIC,
'FreeBSD': license.BSD2,
'GLP v.3': license.GPL3,
'GLP v2.0': license.GPL2,
'GLP': license.GPL,
'GNU AFFERO GENERAL PUBLIC LICENSE': license.AGPL3,
'GNU AGPL v3.0': license.AGPL3,
'GNU Affero General Public License': license.AGPL3,
'GNU GENERAL PUBLIC LICENSE': license.GPL,
'GNU GPL 2': license.GPL2,
'GNU GPL V3': license.GPL3,
'GNU GPL v3': license.GPL3,
'GNU GPL': license.GPL,
'GNU GPLv3': license.GPL3,
'GNU General Public License': license.GPL,
'GNU LGPL v3.0': license.LGPL3,
'GNU LGPL': license.LGPL,
'GNU Library General Public License': license.LGPL,
'GNU v3': license.GPL3,
'GNU': license.GPL,
'GNU-GPL-2': license.GPL2,
'GPL 2': license.GPL2,
'GPL 2.0': license.GPL2,
'GPL 3': license.GPL3,
'GPL 3.0': license.GPL3,
'GPL Version 3': license.GPL3,
'GPL v2': license.GPL2,
'GPL v2+': license.GPL2,
'GPL v3': license.GPL3,
'GPL v3.0': license.GPL3,
'GPL': license.GPL,
'GPL-2': license.GPL2,
'GPL-2.0': license.GPL2,
'GPL-3': license.GPL3,
'GPL-3.0': license.GPL3,
'GPL-v2': license.GPL2,
'GPL2': license.GPL2,
'GPL3': license.GPL3,
'GPLv2 (or later)': license.GPL3,
'GPLv2': license.GPL2,
'GPLv3': license.GPL3,
'GPOL': license.GPL,
'Google-BSD': license.BSD,
'ISC (http://www.isc.org/software/license)': license.ISC,
'ISC License': license.ISC,
'ISC': license.ISC,
'JSON': license.JSON,
'LGP': license.LGPL,
'LGPL 2.1': license.LGPL2,
'LGPL 2.1+': license.LGPL2,
'LGPL 3': license.LGPL3,
'LGPL 3.0': license.LGPL3,
'LGPL License': license.LGPL,
'LGPL V3': license.LGPL3,
'LGPL v3': license.LGPL3,
'LGPL': license.LGPL,
'LGPL+': license.LGPL,
'LGPL-2': license.LGPL2,
'LGPL-3': license.LGPL3,
'LGPL-3.0': license.LGPL3,
'LGPL3': license.LGPL3,
'LGPL3.0': license.LGPL3,
'LGPLv2.1': license.GPL2,
'LGPLv2.1+': license.LGPL2,
'LGPLv21': license.LGPL2,
'LGPLv3': license.LGPL3,
'LGPLv3+': license.LGPL3,
'LGPLv3.0': license.LGPL3,
'MIT ': license.MIT,
'MIT (http://mootools.net/license.txt)': license.MIT,
'MIT <http://opensource.org/licenses/MIT>': license.MIT,
'MIT Licence': license.MIT,
'MIT License (see License)': license.MIT,
'MIT License (see Readme)': license.MIT,
'MIT License': license.MIT,
'MIT license': license.MIT,
'MIT': license.MIT,
'MIT-License': license.MIT,
'MIT/X': license.MIT,
'MIT/X11': license.MIT,
'MPL 1.1': license.MPL,
'MPL 2.0': license.MPL2,
'MPL v2.0': license.MPL2,
'MPL': license.MPL,
'MPL-2': license.MPL2,
'MPL-2.0': license.MPL2,
'MPL/2.0': license.MPL2,
'MPL2': license.MPL2,
'MPL2.0': license.MPL2,
'MPLv2': license.MPL2,
'MPLv2.0': license.MPL2,
'MTI': license.MIT,
'Mit': license.MIT,
'Modified MIT / BSD': license.BSD,
'Mozilla Public License 2.0': license.MPL2,
'Mozilla Public License Version 2.0': license.MPL2,
'Mozilla Public License': license.MPL,
'NASA-1.3': license.NASA1,
'NEW BSD': license.BSD3,
'New BSD License': license.BSD3,
'New BSD': license.BSD3,
'New-BSD': license.BSD3,
'NewBSD': license.BSD3,
'Open Source- GPL': license.GPL,
'PROPRIETARY': license.PROPRIETARY,
'PSF': license.PSF,
'PUBLIC DOMAIN (UNLICENSED)': license.PUBLIC,
'PUBLIC LICENSE': license.PUBLIC,
'Private': license.PROPRIETARY,
'Proprietary': license.PROPRIETARY,
'Public Domain': license.PUBLIC,
'Public domain': license.PUBLIC,
'Simplified BSD (see License)': license.BSD2,
'Simplified BSD License': license.BSD2,
'Simplified BSD-3': license.BSD3,
'The MIT Licence': license.MIT,
'The MIT License (MIT)': license.MIT,
'The MIT License': license.MIT,
'The Software shall be used for Good, not Evil. (see LICENSE)': license.JSON,
'To Use: WTFPL, To Contribute: Dojo CLA': license.WTFPL,
'UNLICENSE': license.UNLICENSE,
'UNLICENSED': license.UNLICENSE,
'Unlicense <http://unlicense.org/>': license.UNLICENSE,
'Unlicense': license.UNLICENSE,
'WTFPL': license.WTFPL,
'WTFPLv2': license.WTFPL,
'X11 License': license.MIT,
'X11': license.MIT,
'X11-style': license.MIT,
'ZLIB': license.ZLIB,
'apache 2': license.Apache2,
'apache 2.0': license.Apache2,
'apache2 actually': license.Apache2,
'apache2': license.Apache2,
'apachev2': license.Apache2,
'bsd': license.BSD,
'cc-by-sa': license.CCBYSA3,
'free': license.PUBLIC,
'freeBSD': license.BSD3,
'gnu': license.GPL,
'gpl-3.0': license.GPL3,
'gpl-v3.0': license.GPL3,
'http://creativecommons.org/licenses/by/3.0/': license.CCBY3,
'http://opensource.org/licenses/MIT': license.MIT,
'http://unlicense.org/': license.UNLICENSE,
'http://wtfpl.org': license.WTFPL,
'http://wtfpl.org/': license.WTFPL,
'http://www.apache.org/licenses/LICENSE-2.0': license.Apache2,
'http://www.apache.org/licenses/LICENSE-2.0.txt': license.Apache2,
'mit': license.MIT,
'mti': license.MIT,
'my own': license.PROPRIETARY,
'new BSD': license.BSD3,
'no': license.PUBLIC,
'none': license.PUBLIC,
'nokia': license.NOKIA,
'nokos': license.NOKIA,
'propriatry': license.PROPRIETARY,
'proprietary': license.PROPRIETARY,
'public domain': license.PUBLIC,
'unlicense': license.UNLICENSE,
'unlicensed': license.UNLICENSE,
'wtfpl': license.WTFPL,
'zlib': license.ZLIB,
'zlib/libpng': license.ZLIB
};
//
// Ensure that we didn't create any undefined references and pre-transform the
// normalized values for a higher hit rate.
//
Object.keys(normalized).map(function check(key) {
var uppercase = key.toUpperCase()
, lowercase = key.toLowerCase();
//
// This throw is here for development reasons. If we incorrectly referenced
// a license.id it will throw.
//
if (!normalized[key]) throw new Error('Invalid reference for:'+ key);
if (!normalized[uppercase]) normalized[uppercase] = normalized[key];
if (!normalized[lowercase]) normalized[lowercase] = normalized[key];
});
//
// Also merge in all the data from our full license database.
//
opensource.full.forEach(function each(license) {
var name = license.name || ''
, full = license.full || ''
, url = license.url || ''
, id = license.id || '';
[
id,
id.toUpperCase(),
id.toLowerCase(),
url,
url.toUpperCase(),
url.toLowerCase(),
name,
name.toUpperCase(),
name.toLowerCase(),
full,
full.toUpperCase(),
full.toLowerCase()
].forEach(function each(key) {
if (key && !normalized[key]) normalized[key] = license.name;
});
});
//
// Expose all the mapping.
//
module.exports = normalized;