diff options
author | isaacs <i@izs.me> | 2020-07-23 20:58:04 +0300 |
---|---|---|
committer | isaacs <i@izs.me> | 2020-07-29 21:53:42 +0300 |
commit | ad5e07d8bd86d1dbe2b03dc142f8c8d6f4828ffe (patch) | |
tree | 97b66f97d77f35774f10a5e3e9957b1897d150bb /node_modules/spdx-correct/index.js | |
parent | a16994cfdd2f255016f3d8ee60d03473d80eabd8 (diff) |
Full dependency reboot
Reinstall everything from a clean node_modules and package-lock.json
state.
Re-generate list of bundleDependencies and node_modules/.gitignore with
a script that does the right thing based on actual dependency state.
Diffstat (limited to 'node_modules/spdx-correct/index.js')
-rw-r--r-- | node_modules/spdx-correct/index.js | 54 |
1 files changed, 46 insertions, 8 deletions
diff --git a/node_modules/spdx-correct/index.js b/node_modules/spdx-correct/index.js index a5ff877bc..c51a79f5d 100644 --- a/node_modules/spdx-correct/index.js +++ b/node_modules/spdx-correct/index.js @@ -1,5 +1,5 @@ /* -Copyright 2015 Kyle E. Mitchell +Copyright spdx-correct.js contributors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -49,6 +49,7 @@ var transpositions = [ ['GNU GENERAL PUBLIC LICENSE', 'GPL'], ['MTI', 'MIT'], ['Mozilla Public License', 'MPL'], + ['Universal Permissive License', 'UPL'], ['WTH', 'WTF'], ['-License', ''] ] @@ -138,6 +139,26 @@ var transforms = [ function (argument) { return argument.replace(/(-| )clause(-| )(\d)/, '-$3-Clause') }, + // e.g. 'New BSD license' + function (argument) { + return argument.replace(/\b(Modified|New|Revised)(-| )?BSD((-| )License)?/i, 'BSD-3-Clause') + }, + // e.g. 'Simplified BSD license' + function (argument) { + return argument.replace(/\bSimplified(-| )?BSD((-| )License)?/i, 'BSD-2-Clause') + }, + // e.g. 'Free BSD license' + function (argument) { + return argument.replace(/\b(Free|Net)(-| )?BSD((-| )License)?/i, 'BSD-2-Clause-$1BSD') + }, + // e.g. 'Clear BSD license' + function (argument) { + return argument.replace(/\bClear(-| )?BSD((-| )License)?/i, 'BSD-3-Clause-Clear') + }, + // e.g. 'Old BSD License' + function (argument) { + return argument.replace(/\b(Old|Original)(-| )?BSD((-| )License)?/i, 'BSD-4-Clause') + }, // e.g. 'BY-NC-4.0' function (argument) { return 'CC-' + argument @@ -224,7 +245,9 @@ var lastResorts = [ ['GNU', 'GPL-3.0-or-later'], ['LGPL', 'LGPL-3.0-or-later'], ['GPLV1', 'GPL-1.0-only'], + ['GPL-1', 'GPL-1.0-only'], ['GPLV2', 'GPL-2.0-only'], + ['GPL-2', 'GPL-2.0-only'], ['GPL', 'GPL-3.0-or-later'], ['MIT +NO-FALSE-ATTRIBS', 'MITNFA'], ['MIT', 'MIT'], @@ -275,7 +298,12 @@ var anyCorrection = function (identifier, check) { return null } -module.exports = function (identifier) { +module.exports = function (identifier, options) { + options = options || {} + var upgrade = options.upgrade === undefined ? true : !!options.upgrade + function postprocess (value) { + return upgrade ? upgradeGPLs(value) : value + } var validArugment = ( typeof identifier === 'string' && identifier.trim().length !== 0 @@ -283,13 +311,17 @@ module.exports = function (identifier) { if (!validArugment) { throw Error('Invalid argument. Expected non-empty string.') } - identifier = identifier.replace(/\+$/, '').trim() + identifier = identifier.trim() if (valid(identifier)) { - return upgradeGPLs(identifier) + return postprocess(identifier) + } + var noPlus = identifier.replace(/\+$/, '').trim() + if (valid(noPlus)) { + return postprocess(noPlus) } var transformed = validTransformation(identifier) if (transformed !== null) { - return upgradeGPLs(transformed) + return postprocess(transformed) } transformed = anyCorrection(identifier, function (argument) { if (valid(argument)) { @@ -298,15 +330,15 @@ module.exports = function (identifier) { return validTransformation(argument) }) if (transformed !== null) { - return upgradeGPLs(transformed) + return postprocess(transformed) } transformed = validLastResort(identifier) if (transformed !== null) { - return upgradeGPLs(transformed) + return postprocess(transformed) } transformed = anyCorrection(identifier, validLastResort) if (transformed !== null) { - return upgradeGPLs(transformed) + return postprocess(transformed) } return null } @@ -318,6 +350,12 @@ function upgradeGPLs (value) { 'LGPL-2.1' ].indexOf(value) !== -1) { return value + '-only' + } else if ([ + 'GPL-1.0+', 'GPL-2.0+', 'GPL-3.0+', + 'LGPL-2.0+', 'LGPL-2.1+', 'LGPL-3.0+', + 'AGPL-1.0+', 'AGPL-3.0+' + ].indexOf(value) !== -1) { + return value.replace(/\+$/, '-or-later') } else if (['GPL-3.0', 'LGPL-3.0', 'AGPL-3.0'].indexOf(value) !== -1) { return value + '-or-later' } else { |