@rnx-kit/third-party-notices
Advanced tools
Comparing version 1.4.1 to 1.4.2
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createLicenseJSON = void 0; | ||
const package_1 = require("@rnx-kit/tools-node/package"); | ||
function getPackageAuthor(modulePath) { | ||
var _a; | ||
const pkgFile = (0, package_1.findPackage)(modulePath); | ||
if (pkgFile) { | ||
const manifest = (0, package_1.readPackage)(pkgFile); | ||
if (manifest) { | ||
return typeof manifest.author === "string" | ||
? manifest.author | ||
: (_a = manifest.author) === null || _a === void 0 ? void 0 : _a.name; | ||
} | ||
} | ||
return undefined; | ||
} | ||
function parseCopyright(modulePath, licenseText, license, licenseURLs) { | ||
const m = licenseText === null || licenseText === void 0 ? void 0 : licenseText.match(/^Copyright .*$/m); | ||
if (!m) { | ||
const packageAuthor = getPackageAuthor(modulePath); | ||
if (packageAuthor) { | ||
return packageAuthor; | ||
} | ||
if ((licenseURLs === null || licenseURLs === void 0 ? void 0 : licenseURLs.length) > 0) { | ||
return `${license} (${licenseURLs.join(" ")})`; | ||
} | ||
return "No copyright notice"; | ||
} | ||
return m[0].trim(); | ||
} | ||
const copyright_1 = require("./copyright"); | ||
function createLicenseJSON(licenses, fullLicenseText) { | ||
@@ -36,3 +9,3 @@ return JSON.stringify({ | ||
if (!license) { | ||
throw new Error(`No license for ${name}`); | ||
throw new Error(`No license information found for package '${name}'. Consider filing an issue for the project to properly advertise its licence. Pass this module to the tool via '--ignoreModules ${name}' to suppress this message.`); | ||
} | ||
@@ -43,3 +16,3 @@ const info = { | ||
license, | ||
copyright: parseCopyright(modulePath, licenseText, license, licenseURLs), | ||
copyright: (0, copyright_1.parseCopyright)(modulePath, licenseText, license, licenseURLs), | ||
}; | ||
@@ -46,0 +19,0 @@ if (fullLicenseText) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createLicenseFileContents = void 0; | ||
const copyright_1 = require("./copyright"); | ||
const EOL = "\n"; | ||
@@ -9,3 +10,3 @@ const SEPARATOR = `${EOL}${EOL}========================================================================${EOL}${EOL}`; | ||
// Emit combined license text | ||
licenses.forEach(({ name, version, license, licenseText, licenseURLs }) => { | ||
licenses.forEach(({ name, version, license, licenseText, licenseURLs, path: modulePath, }) => { | ||
if ((license === null || license === void 0 ? void 0 : license.toUpperCase()) === "UNLICENSED") { | ||
@@ -19,3 +20,9 @@ // Ignore unlicensed/private packages | ||
} | ||
licenseText = `${license} (${licenseURLs.join(" ")})`; | ||
const copyright = (0, copyright_1.getPackageAuthor)(modulePath); | ||
if (copyright) { | ||
licenseText = `Copyright ${copyright}; licensed under ${license} (${licenseURLs.join(" ")})`; | ||
} | ||
else { | ||
licenseText = `Licensed under ${license} (${licenseURLs.join(" ")})`; | ||
} | ||
} | ||
@@ -22,0 +29,0 @@ const trimmedText = licenseText.replace(/\r\n|\r|\n/g, EOL).trim(); |
{ | ||
"name": "@rnx-kit/third-party-notices", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"description": "Library and tool to build a third party notices file based on a js bundle's source map", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/microsoft/rnx-kit/tree/main/packages/third-party-notices#readme", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34393
20
661