mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-20 03:28:52 +08:00
Update types for license-checker to 15.0
This commit is contained in:
159
types/license-checker/index.d.ts
vendored
159
types/license-checker/index.d.ts
vendored
@@ -1,86 +1,117 @@
|
||||
// Type definitions for license-checker 11.0
|
||||
// Type definitions for license-checker 15.0
|
||||
// Project: https://github.com/davglass/license-checker
|
||||
// Definitions by: Rogier Schouten <https://github.com/rogierschouten>
|
||||
// Definitions by: Rogier Schouten <https://github.com/rogierschouten>, Daniel Perez Alvarez <https://github.com/unindented>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* Options struct for the init() function
|
||||
*/
|
||||
export interface InitOpts {
|
||||
/**
|
||||
* Path to start checking dependencies from
|
||||
*/
|
||||
start: string;
|
||||
/**
|
||||
* only show production dependencies
|
||||
*/
|
||||
production?: boolean;
|
||||
/**
|
||||
* only show development dependencies
|
||||
*/
|
||||
development?: boolean;
|
||||
/**
|
||||
* report guessed licenses as unknown licenses
|
||||
*/
|
||||
unknown?: boolean;
|
||||
/**
|
||||
* only list packages with unknown or guessed licenses
|
||||
*/
|
||||
onlyunknown?: boolean;
|
||||
/**
|
||||
* to add a custom Format file in JSON
|
||||
*/
|
||||
customPath?: string;
|
||||
/**
|
||||
* exclude modules which licenses are in the comma-separated list from the output
|
||||
*/
|
||||
exclude?: string[];
|
||||
/**
|
||||
* Use chalk to colorize the licenses member of each returned module info. Unknown licenses become red.
|
||||
*/
|
||||
color?: boolean;
|
||||
/**
|
||||
* output the location of the license files as relative paths
|
||||
*/
|
||||
relativeLicensePath?: boolean;
|
||||
/**
|
||||
* Path to start checking dependencies from
|
||||
*/
|
||||
start: string;
|
||||
/**
|
||||
* Only show production dependencies
|
||||
*/
|
||||
production?: boolean;
|
||||
/**
|
||||
* Only show development dependencies
|
||||
*/
|
||||
development?: boolean;
|
||||
/**
|
||||
* Report guessed licenses as unknown licenses
|
||||
*/
|
||||
unknown?: boolean;
|
||||
/**
|
||||
* Only list packages with unknown or guessed licenses
|
||||
*/
|
||||
onlyunknown?: boolean;
|
||||
/**
|
||||
* to add a custom Format file in JSON
|
||||
*/
|
||||
customPath?: string | ModuleInfo;
|
||||
/**
|
||||
* Exclude modules which licenses are in the comma-separated list from the output
|
||||
*/
|
||||
exclude?: string[];
|
||||
/**
|
||||
* Output the location of the license files as relative paths
|
||||
*/
|
||||
relativeLicensePath?: boolean;
|
||||
/**
|
||||
* Output a summary of the license usage
|
||||
*/
|
||||
summary?: boolean;
|
||||
/**
|
||||
* Fail (exit with code 1) on the first occurrence of the licenses of the comma-separated list
|
||||
*/
|
||||
failOn?: string[];
|
||||
/**
|
||||
* Use chalk to colorize the licenses member of each returned module info. Unknown licenses become red.
|
||||
*/
|
||||
color?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Information about one dependency
|
||||
*/
|
||||
export interface ModuleInfo {
|
||||
/**
|
||||
* licenses, either one string or an array of multiple licenses
|
||||
*/
|
||||
licenses: string | string[];
|
||||
/**
|
||||
* Repository URL
|
||||
*/
|
||||
repository: string;
|
||||
/**
|
||||
* Publisher name
|
||||
*/
|
||||
publisher?: string;
|
||||
/**
|
||||
* Publisher e-mail
|
||||
*/
|
||||
email?: string;
|
||||
/**
|
||||
* Publisher URL
|
||||
*/
|
||||
url?: string;
|
||||
/**
|
||||
* Path to license file, if available
|
||||
*/
|
||||
licenseFile?: string;
|
||||
/**
|
||||
* Module name
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
* Module version
|
||||
*/
|
||||
version?: string;
|
||||
/**
|
||||
* Module description
|
||||
*/
|
||||
description?: string;
|
||||
/**
|
||||
* Repository URL
|
||||
*/
|
||||
repository?: string;
|
||||
/**
|
||||
* Publisher name
|
||||
*/
|
||||
publisher?: string;
|
||||
/**
|
||||
* Publisher e-mail
|
||||
*/
|
||||
email?: string;
|
||||
/**
|
||||
* Publisher URL
|
||||
*/
|
||||
url?: string;
|
||||
/**
|
||||
* Array of licenses
|
||||
*/
|
||||
licenses?: string | string[];
|
||||
/**
|
||||
* Path to license file, if available
|
||||
*/
|
||||
licenseFile?: string;
|
||||
/**
|
||||
* Contents of the license
|
||||
*/
|
||||
licenseText?: string;
|
||||
/**
|
||||
* Whether the license is modified
|
||||
*/
|
||||
licenseModified?: string;
|
||||
}
|
||||
|
||||
export interface ModuleInfos {
|
||||
[packageName: string]: ModuleInfo;
|
||||
[packageName: string]: ModuleInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the license check
|
||||
* @param opts specifies the path to the module to check dependencies of
|
||||
*/
|
||||
export function init(opts: InitOpts, callback: (err: Error, ret: ModuleInfos) => void): void;
|
||||
export function init(
|
||||
opts: InitOpts,
|
||||
callback: (err: Error, ret: ModuleInfos) => void
|
||||
): void;
|
||||
|
||||
@@ -1,13 +1,31 @@
|
||||
// From README.md:
|
||||
|
||||
import * as checker from 'license-checker';
|
||||
import * as checker from "license-checker";
|
||||
|
||||
checker.init({
|
||||
start: '/path/to/start/looking'
|
||||
}, (err: Error, json: checker.ModuleInfos): void => {
|
||||
if (err) {
|
||||
// Handle error
|
||||
} else {
|
||||
// The sorted json data
|
||||
checker.init(
|
||||
{
|
||||
start: "/path/to/start/looking",
|
||||
production: true,
|
||||
customPath: {
|
||||
licenseText: ""
|
||||
}
|
||||
},
|
||||
(err: Error, json: checker.ModuleInfos): void => {
|
||||
if (err) {
|
||||
throw err;
|
||||
} else {
|
||||
const licenses = Object.keys(json).reduce(
|
||||
(memo, key) => {
|
||||
const license = json[key];
|
||||
const { name, version, repository, licenseText } = license;
|
||||
if (licenseText == null) {
|
||||
return memo;
|
||||
}
|
||||
memo.push(license);
|
||||
return memo;
|
||||
},
|
||||
[] as checker.ModuleInfo[]
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user