Add updates to UI license grabber from jlmitch5.

This commit is contained in:
Bill Nottingham
2018-11-19 11:39:13 -05:00
parent a6e00df041
commit 605c1355a8
11 changed files with 66 additions and 56 deletions

View File

@@ -6,7 +6,7 @@ const { join } = require('path');
const licenseTexts = require('./license_texts');
// path to shrinkwrap file
const SHRINKWRAP_PATH = `${__dirname}/../npm-shrinkwrap.json`;
const SHRINKWRAP_PATH = `${__dirname}/../package-lock.json`;
// folder that npm install node_modules to
const NODE_MODULES_FOLDER = `${__dirname}/../node_modules`;
// the folder which we will put the ui license files
@@ -16,7 +16,7 @@ const OMITTED_NODE_MODULES_FOLDERS = ['@uirouter', '.bin', 'cycle'];
// all the ways in which deps with license files have license files named
const LICENSE_FILE_NAMES = ['LICENSE', 'LICENCE', 'LICENSE.md', 'LICENSE.txt', 'MIT-LICENSE.txt', 'LICENSE-MIT.txt', 'LICENSE-MIT', 'LICENSE.MIT', 'LICENSE.APACHE2', 'LICENSE.BSD'];
// all the ways in which deps with license info included in readme have the license header
const LICENSE_HEADER_NAMES = ['LICENSE', 'License', 'Licence'];
const LICENSE_HEADER_NAMES = ['## License'];
// all the ways in which deps with license info included in readme have readme files named
const README_FILE_NAMES = ['README', 'README.md', 'README.markdown'];
// deps that we need to manually grab the license info (and that info)
@@ -89,7 +89,7 @@ const licenseTextIncludedInReadme = (readmeText, returnLicenseText) => LICENSE_H
} else if (a !== false) {
licenseVal = a;
} else if (readmeText.includes(b)) {
licenseVal = readmeText.split(b).slice(-1);
licenseVal = readmeText.split(b).slice(1, readmeText.split(b).length);
} else {
licenseVal = false;
}
@@ -175,7 +175,8 @@ const licenseCheck = () => {
if (noLicensePackage.length === 0) {
console.log('Success! All modules probably have a license associated.');
} else {
console.log(`Warning! The following modules do not have license info associated with them: ${noLicensePackage.join(', ')}.`);
console.log(`ERROR! The following modules do not have license info associated with them: ${noLicensePackage.join(', ')}.`);
process.exit(1);
}
};
@@ -195,7 +196,7 @@ const licenseWrite = () => {
modulesWithLicenseFile.forEach(path => {
writeFileSync(
join(UI_LICENSE_FOLDER, getModulename(path)),
join(UI_LICENSE_FOLDER, `${getModulename(path)}.txt`),
readFileSync(hasLicenseFile(path, true)).toString()
);
});
@@ -207,14 +208,14 @@ const licenseWrite = () => {
modulesWithPackageJSONLicenseAttr.forEach(path => {
const licenseType = hasLicenseAttrInNPM(path, true);
let licenseText = LICENSE_TEXTS[licenseType];
const licenseText = LICENSE_TEXTS[licenseType];
if (!licenseText) {
console.log(`WARNING! License text for ${licenseType} is not in license_texts.js. Please add it. Just adding the license type to the module's file for now.`);
licenseText = licenseType;
console.log(`ERROR! License text for ${licenseType} is not in license_texts.js.`);
process.exit(1);
}
writeFileSync(join(UI_LICENSE_FOLDER, getModulename(path)), licenseText);
writeFileSync(join(UI_LICENSE_FOLDER, `${getModulename(path)}.txt`), licenseText);
});
const modulesWithLicenseInfoInReadme = getSubdirectories(NODE_MODULES_FOLDER)
@@ -225,13 +226,13 @@ const licenseWrite = () => {
console.log(`${modulesWithLicenseInfoInReadme.length} modules with license text in readme.`);
modulesWithLicenseInfoInReadme.forEach(path => {
writeFileSync(join(UI_LICENSE_FOLDER, getModulename(path)), hasLicenseInReadme(path, true));
writeFileSync(join(UI_LICENSE_FOLDER, `${getModulename(path)}.txt`), hasLicenseInReadme(path, true));
});
console.log(`${MANUAL_NODE_MODULES_LICENSE_INFO.length} modules with license info manually added to this script.`);
MANUAL_NODE_MODULES_LICENSE_INFO.forEach(mod => {
writeFileSync(join(UI_LICENSE_FOLDER, mod.module_name), mod.license_info);
writeFileSync(join(UI_LICENSE_FOLDER, `${getModulename(mod.module_name)}.txt`), mod.license_info);
});
};

View File

@@ -130,6 +130,13 @@ express Statement of Purpose.
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.
`,
'MIT OR GPL-2.0': `
MIT
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.`,
ISC: `
ISC
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.