-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add --allowList and --allowLicenses to license-validate script (#21
- Loading branch information
Showing
1 changed file
with
28 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ const cli = meow( | |
Options | ||
--debug Show full packages list | ||
--allowPackages Semi-colon separated list of packages to ignore (eg [email protected];[email protected]) | ||
--allowList Which default list of licenses to use. Possible values: "MIT", "none". Defaults to "MIT" | ||
--allowLicenses Semi-colon separated list of licenses to allow in addition to the default list (eg GPL-3.0-only;MIT) | ||
`, | ||
{ | ||
importMeta: import.meta, | ||
|
@@ -32,17 +34,40 @@ const cli = meow( | |
const pkgInfo = readPackageUpSync() | ||
const projectNameAndVersion = `${pkgInfo.packageJson.name}@${pkgInfo.packageJson.version}` | ||
|
||
// TODO - Add option driven allowList selection with a list for GPL projects | ||
const allowListForMit = 'MIT;BSD;ISC;Apache-2.0;CC0;CC-BY-3.0;CC-BY-4.0;Unlicense;Artistic-2.0;Python-2.0;BlueOak-1.0.0' | ||
const allowLists = { | ||
MIT: 'MIT;BSD;ISC;Apache-2.0;CC0;CC-BY-3.0;CC-BY-4.0;Unlicense;Artistic-2.0;Python-2.0;BlueOak-1.0.0', | ||
none: '', | ||
// TODO - Add allowList with a list for GPL projects | ||
} | ||
|
||
const useAllowList = cli.flags.allowList || 'MIT' | ||
let allowList = '' | ||
if (useAllowList === 'none') { | ||
allowList = allowLists.none | ||
} else if (useAllowList === 'MIT') { | ||
allowList = allowLists.MIT | ||
} else { | ||
console.error(`Invalid argument value: --allowList: ${useAllowList} (possible values: "MIT", "none")`) | ||
process.exit(1) | ||
} | ||
if (cli.flags.allowLicenses) { | ||
allowList += `;${cli.flags.allowLicenses}` | ||
} | ||
|
||
let excludePackages = projectNameAndVersion | ||
if (cli.flags.allowPackages) { | ||
excludePackages += `;${cli.flags.allowPackages}` | ||
} | ||
|
||
if (cli.flags.debug) { | ||
console.log('CLI flags', cli.flags) | ||
console.log('excludePackages', excludePackages) | ||
console.log('allowList', allowList) | ||
} | ||
|
||
checker.init({ | ||
start: path.resolve('.'), | ||
onlyAllow: allowListForMit, | ||
onlyAllow: allowList, | ||
excludePackages: excludePackages, | ||
summary: !cli.flags.debug | ||
}, (err, packages) => { | ||
|