build(deps-dev): replace license-checker with licensee (#653)

* build(deps-dev): replace license-checker with licensee

* build(licensee): sort values
This commit is contained in:
Frazer Smith
2025-06-25 18:31:56 +01:00
committed by GitHub
parent aca19a2ab0
commit cddbc55821
4 changed files with 9 additions and 104 deletions
+7
View File
@@ -0,0 +1,7 @@
{
"corrections": true,
"licenses": {
"blueOak": "bronze",
"spdx": ["CC-BY-3.0"]
}
}
+2 -3
View File
@@ -54,7 +54,7 @@
"build:docs": "jsdoc2md src/index.js > API.md --EOL posix",
"lint": "eslint . --cache --ext js,jsx --ignore-path .gitignore",
"lint:fix": "npm run lint -- --fix",
"lint:licenses": "node scripts/license-checker.js",
"lint:licenses": "licensee --errors-only --production",
"lint:prettier": "prettier . -c -u",
"lint:prettier:fix": "prettier . -w -u",
"prepare": "husky",
@@ -105,9 +105,8 @@
"husky": "^9.1.7",
"jest": "^29.7.0",
"jsdoc-to-markdown": "^9.1.1",
"license-checker": "^25.0.1",
"licensee": "^11.1.1",
"prettier": "^3.4.2",
"spdx-copyleft": "^1.0.0",
"typescript": "~5.8.2"
},
"dependencies": {
-13
View File
@@ -1,13 +0,0 @@
"use strict";
module.exports = {
rules: {
"import/no-extraneous-dependencies": [
"error",
{
devDependencies: true,
},
],
"no-console": "off",
},
};
-88
View File
@@ -1,88 +0,0 @@
"use strict";
const { promisify } = require("node:util");
const { init } = require("license-checker");
/** @type {string[]} */
// @ts-ignore: module is a JSON file
const copyLeftLicenses = require("spdx-copyleft");
const { join } = require("node:path");
const check = promisify(init);
/**
* @author Frazer Smith
* @description Checks licenses of all direct production dependencies to
* ensure they are not copyleft.
*/
async function checkLicenses() {
console.log("Checking licenses of direct production dependencies...");
/**
* List of deprecated copyleft license identifiers.
* @see {@link https://spdx.org/licenses/#deprecated | SPDX Deprecated License Identifiers}
*/
const deprecatedLicenseList = [
"AGPL-1.0",
"AGPL-3.0",
"GFDL-1.1",
"GFDL-1.2",
"GFDL-1.3",
"GPL-1.0",
"GPL-1.0+",
"GPL-2.0",
"GPL-2.0+",
"GPL-2.0-with-autoconf-exception",
"GPL-2.0-with-bison-exception",
"GPL-2.0-with-classpath-exception",
"GPL-2.0-with-font-exception",
"GPL-2.0-with-GCC-exception",
"GPL-3.0",
"GPL-3.0+",
"GPL-3.0-with-autoconf-exception",
"GPL-3.0-with-GCC-exception",
"LGPL-2.0",
"LGPL-2.0+",
"LGPL-2.1",
"LGPL-2.1+",
"LGPL-3.0",
"LGPL-3.0+",
];
// Merge copyleft licenses with deprecated licenses list
copyLeftLicenses.push(...deprecatedLicenseList);
const licenses = await check({
direct: true,
production: true,
start: join(__dirname, ".."),
});
const copyLeftLicensesList = Object.keys(licenses).filter((license) => {
let lic = licenses[license].licenses;
if (!lic) {
console.error(
`No license found for ${license}. Please check the package.json file.`
);
process.exit(1);
}
lic = Array.isArray(lic) ? lic : [lic];
return lic.some((l) => copyLeftLicenses.includes(l));
});
if (copyLeftLicensesList.length > 0) {
console.error(
`The following dependencies are using copyleft licenses: ${copyLeftLicensesList.join(
", "
)}`
);
process.exit(1);
}
console.log("No copyleft licenses found.");
process.exit(0);
}
checkLicenses();