diff --git a/types/npm-license-crawler/index.d.ts b/types/npm-license-crawler/index.d.ts new file mode 100644 index 0000000000..82c486b795 --- /dev/null +++ b/types/npm-license-crawler/index.d.ts @@ -0,0 +1,43 @@ +// Type definitions for npm-license-crawler 0.1 +// Project: https://github.com/mwittig/npm-license-crawler +// Definitions by: Florian Keller +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +export interface Licenses { + [repository: string]: { + licenses: string; + licenseUrl: string; + parents: string; + repository: string; + }; +} + +export interface CrawlerOptions { + /** export the data as comma-separated values to the given file. The path will be created if it does not exist. */ + csv?: string; + /** show only third-party licenses, i.e., only list the dependencies defined in package.json. */ + dependencies?: boolean; + /** show only development dependencies */ + development?: boolean; + /** path to a directory to be excluded (and its subdirectories) from the search. */ + exclude?: string | string[]; + /** export data as JSON to the given file. The path will be created if it does not exist. */ + json?: string; + /** omit version numbers in result (e.g. "npm-license-crawler@0.1.5" becomes "npm-license-crawler") */ + omitVersion?: boolean; + /** show only direct dependencies licenses, i.e., don't list dependencies of dependencies. */ + onlyDirectDependencies?: boolean; + /** show only production dependencies */ + production?: boolean; + /** output the relative file path for license files. */ + relativeLicensePath?: boolean; + /** path to the directory the license search should start from. If omitted the current working directory is assumed. */ + start: string | string[]; + /** show only licenses that can't be determined or have been guessed. */ + unknown?: boolean; +} + +export type Callback = (error: Error | null, licenses: Licenses) => void; + +export function dumpLicenses(args: CrawlerOptions, callback: Callback): void; diff --git a/types/npm-license-crawler/npm-license-crawler-tests.ts b/types/npm-license-crawler/npm-license-crawler-tests.ts new file mode 100644 index 0000000000..dae39fec09 --- /dev/null +++ b/types/npm-license-crawler/npm-license-crawler-tests.ts @@ -0,0 +1,15 @@ +import { CrawlerOptions, dumpLicenses } from 'npm-license-crawler'; + +const options: CrawlerOptions = { + start: ['../..'], + exclude: ['.'], + json: 'licenses.json', + unknown: true, +}; + +dumpLicenses(options, (error, res) => { + res.name.licenses; // $ExpectType string + res.name.licenseUrl; // $ExpectType string + res.name.parents; // $ExpectType string + res.name.repository; // $ExpectType string +}); diff --git a/types/npm-license-crawler/tsconfig.json b/types/npm-license-crawler/tsconfig.json new file mode 100644 index 0000000000..59df3a8697 --- /dev/null +++ b/types/npm-license-crawler/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "npm-license-crawler-tests.ts" + ] +} diff --git a/types/npm-license-crawler/tslint.json b/types/npm-license-crawler/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/npm-license-crawler/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }