mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Add nodejs-license-file (#34242)
This commit is contained in:
parent
b2f87aa2bb
commit
bd3a42fcae
25
types/nodejs-license-file/index.d.ts
vendored
Normal file
25
types/nodejs-license-file/index.d.ts
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
// Type definitions for nodejs-license-file 4.0
|
||||
// Project: https://github.com/bushev/nodejs-license-file
|
||||
// Definitions by: Troy McKinnon <https://github.com/trodi>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export function parse(options: ParseOptions): License;
|
||||
export function generate(options: GenerateOptions): string;
|
||||
export interface License {
|
||||
valid: boolean;
|
||||
serial: string;
|
||||
data: any;
|
||||
}
|
||||
export interface ParseOptions {
|
||||
publicKeyPath?: string;
|
||||
publicKey?: string;
|
||||
licenseFilePath?: string;
|
||||
licenseFile?: string;
|
||||
template: string;
|
||||
}
|
||||
export interface GenerateOptions {
|
||||
privateKeyPath?: string;
|
||||
privateKey?: string;
|
||||
template: string;
|
||||
data: any;
|
||||
}
|
||||
32
types/nodejs-license-file/nodejs-license-file-tests.ts
Normal file
32
types/nodejs-license-file/nodejs-license-file-tests.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import * as LicenseFile from "nodejs-license-file";
|
||||
|
||||
const template: string = [
|
||||
"====BEGIN LICENSE====",
|
||||
"{{&name}}",
|
||||
"{{&id}}",
|
||||
"{{&serial}}",
|
||||
"=====END LICENSE=====",
|
||||
].join("\n");
|
||||
|
||||
const generateOpts: LicenseFile.GenerateOptions = {
|
||||
privateKeyPath: "private_key.pem",
|
||||
template,
|
||||
data: {
|
||||
name: "John Doe",
|
||||
id: "123456789",
|
||||
},
|
||||
};
|
||||
|
||||
/** License data you can write to file. */
|
||||
const licenseString: string = LicenseFile.generate(generateOpts);
|
||||
|
||||
const parseOpts: LicenseFile.ParseOptions = {
|
||||
publicKeyPath: "public_key.pem",
|
||||
licenseFilePath: "license",
|
||||
template,
|
||||
};
|
||||
/** Parsed license obj */
|
||||
const license: LicenseFile.License = LicenseFile.parse(parseOpts);
|
||||
|
||||
// Access license data (e.g., "name"):
|
||||
license.data.name;
|
||||
23
types/nodejs-license-file/tsconfig.json
Normal file
23
types/nodejs-license-file/tsconfig.json
Normal file
@ -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",
|
||||
"nodejs-license-file-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/nodejs-license-file/tslint.json
Normal file
1
types/nodejs-license-file/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user