forked from DefinitelyTyped/DefinitelyTyped
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🤖 Merge PR DefinitelyTyped#46345 feat(create-banner): new module defi…
…nition by @peterblazejewicz - definition file - tests https://github.com/fengyuanchen/create-banner Thanks!n
- Loading branch information
1 parent
f11aec7
commit 3e31d28
Showing
4 changed files
with
118 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import createBanner = require('create-banner'); | ||
|
||
createBanner(); | ||
createBanner({ case: 'camel-case' }); | ||
createBanner({ case: 'camelCase' }); | ||
createBanner({ case: 'Title Case', template: 'inline' }); | ||
createBanner({ | ||
template: `/*! | ||
* @name v@version | ||
* @license (c) @author.name | ||
*/ | ||
`, | ||
}); | ||
createBanner({ | ||
template: 'Hello world!', | ||
}); | ||
createBanner({ | ||
data: { | ||
name: 'Library.js', | ||
}, | ||
}); | ||
createBanner({ | ||
case: 'param-case', | ||
data: { | ||
name: 'Library.js', | ||
date: new Date().toISOString(), | ||
}, | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Type definitions for create-banner 1.0 | ||
// Project: https://github.com/fengyuanchen/create-banner | ||
// Definitions by: Piotr Błażejewicz <https://github.com/peterblazejewicz> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
// Minimum TypeScript Version: 3.2 | ||
|
||
/** | ||
* Create a banner from a package.json file | ||
*/ | ||
declare function createBanner(options?: createBanner.Options): string; | ||
|
||
declare namespace createBanner { | ||
interface Options { | ||
/** | ||
* The case of the package name in the banner. Not to change the package name case by default. | ||
* @default '' | ||
*/ | ||
case?: LiteralUnion< | ||
| 'camel-case' | ||
| 'capital-case' | ||
| 'constant-case' | ||
| 'dot-case' | ||
| 'header-case' | ||
| 'no-case' | ||
| 'param-case' | ||
| 'pascal-case' | ||
| 'path-case' | ||
| 'sentence-case' | ||
| 'snake-case', | ||
string | ||
>; | ||
/** | ||
* The extra data for creating banner, will be merged into package data. | ||
*/ | ||
data?: BannerData; | ||
/** | ||
* The package data for creating banner. | ||
* If it is null, will read from the closest package.json file by default using the `read-pkg-up` package | ||
* @default null; | ||
*/ | ||
pkg?: { | ||
[key: string]: unknown; | ||
} | null; | ||
/** | ||
* The template for creating banner. | ||
* Property using a dot path is supported by the `dot-prop` package. | ||
* Other values will be used directly as a custom template. | ||
* @default 'normal' | ||
*/ | ||
template?: LiteralUnion<'normal' | 'simple' | 'inline', string>; | ||
} | ||
|
||
interface BannerData { | ||
/** | ||
* @default new Date().toISOString() | ||
*/ | ||
date?: string; | ||
/** | ||
* @default new Date().getFullYear() | ||
*/ | ||
year?: string; | ||
[key: string]: unknown; | ||
} | ||
|
||
// @credit @sindresorhus/type-fest | ||
type Primitive = null | undefined | string | number | boolean | symbol | bigint; | ||
// @credit @sindresorhus/type-fest | ||
type LiteralUnion<LiteralType extends BaseType, BaseType extends Primitive> = | ||
| LiteralType | ||
| (BaseType & { _?: never }); | ||
} | ||
|
||
export = createBanner; |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"lib": ["es6"], | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"strictFunctionTypes": true, | ||
"strictNullChecks": true, | ||
"baseUrl": "../", | ||
"typeRoots": ["../"], | ||
"types": [], | ||
"noEmit": true, | ||
"forceConsistentCasingInFileNames": true | ||
}, | ||
"files": ["index.d.ts", "create-banner-tests.ts"] | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
{ "extends": "dtslint/dt.json" } |