-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: jest snapshots initial check-in
- Loading branch information
1 parent
11e2c86
commit 19f712c
Showing
51 changed files
with
1,016 additions
and
133 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
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
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
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
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
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 @@ | ||
dist |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Atanas Stoyanov | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,133 @@ | ||
# Table of contents | ||
|
||
- [Overview](#overview) | ||
- [Installation](#installation) | ||
- [API](#api) | ||
- [LogOptions](#logoptions) | ||
- [LogLevel](#loglevel) | ||
- [error](#error) | ||
- [log](#log) | ||
- [output](#output) | ||
- [setLogOptions](#setlogoptions) | ||
- [defaultOptions](#defaultoptions) | ||
- [logOptions](#logoptions-1) | ||
- [LogLevel](#loglevel-1) | ||
|
||
# Overview | ||
|
||
Logging utilities. Uses the [chalk](https://github.com/chalk/chalk#readme) package for logging utput | ||
|
||
# Installation | ||
|
||
This package is usually installed as part of the @component-controls package, but you can also install it standalone: | ||
|
||
```bash | ||
$ npm install @component-controls/logger --save-dev | ||
``` | ||
|
||
# API | ||
|
||
<tsdoc-typescript entry="./src/index.ts" files="../specification/src/configuration.ts"/> | ||
|
||
<!-- START-TSDOC-TYPESCRIPT --> | ||
|
||
## LogOptions | ||
|
||
_defined in [@component-controls/logger/src/index.ts](https://github.com/ccontrols/component-controls/tree/master/core/logger/src/index.ts#L5)_ | ||
|
||
|
||
|
||
### properties | ||
|
||
| Name | Type | Description | | ||
| ---------- | ------------------------- | ----------- | | ||
| `colors*` | \[number, number, number] | | | ||
| `logLevel` | [LogLevel](#loglevel) | | | ||
|
||
## LogLevel | ||
|
||
_defined in [@component-controls/logger/src/index.ts](https://github.com/ccontrols/component-controls/tree/master/core/logger/src/index.ts#L3)_ | ||
|
||
'all' | 'errors' | 'none' | ||
|
||
## error | ||
|
||
_defined in [@component-controls/logger/src/index.ts](https://github.com/ccontrols/component-controls/tree/master/core/logger/src/index.ts#L26)_ | ||
|
||
**function** error(`heading`\*: string, `text`\*: string): void; | ||
|
||
### parameters | ||
|
||
| Name | Type | Description | | ||
| ---------- | ------ | ----------- | | ||
| `heading*` | string | | | ||
| `text*` | string | | | ||
| `returns` | void | | | ||
|
||
## log | ||
|
||
_defined in [@component-controls/logger/src/index.ts](https://github.com/ccontrols/component-controls/tree/master/core/logger/src/index.ts#L21)_ | ||
|
||
**function** log(`heading`\*: string, `text`\*: string): void; | ||
|
||
### parameters | ||
|
||
| Name | Type | Description | | ||
| ---------- | ------ | ----------- | | ||
| `heading*` | string | | | ||
| `text*` | string | | | ||
| `returns` | void | | | ||
|
||
## output | ||
|
||
_defined in [@component-controls/logger/src/index.ts](https://github.com/ccontrols/component-controls/tree/master/core/logger/src/index.ts#L17)_ | ||
|
||
**function** output(`heading`\*: string, `text`\*: string): void; | ||
|
||
### parameters | ||
|
||
| Name | Type | Description | | ||
| ---------- | ------ | ----------- | | ||
| `heading*` | string | | | ||
| `text*` | string | | | ||
| `returns` | void | | | ||
|
||
## setLogOptions | ||
|
||
_defined in [@component-controls/logger/src/index.ts](https://github.com/ccontrols/component-controls/tree/master/core/logger/src/index.ts#L32)_ | ||
|
||
**function** setLogOptions(`options`\*: Partial<[LogOptions](#logoptions)>): void; | ||
|
||
### parameters | ||
|
||
| Name | Type | Description | | ||
| ---------- | ------------------------------------- | ----------- | | ||
| `options*` | Partial<[LogOptions](#logoptions)> | | | ||
| `returns` | void | | | ||
|
||
## defaultOptions | ||
|
||
_defined in [@component-controls/logger/src/index.ts](https://github.com/ccontrols/component-controls/tree/master/core/logger/src/index.ts#L10)_ | ||
|
||
|
||
|
||
### properties | ||
|
||
| Name | Type | Description | | ||
| ----------- | ------------------------- | ----------- | | ||
| `colors*` | \[number, number, number] | | | ||
| `logLevel*` | 'all' | | | ||
|
||
## logOptions | ||
|
||
_defined in [@component-controls/logger/src/index.ts](https://github.com/ccontrols/component-controls/tree/master/core/logger/src/index.ts#L15)_ | ||
|
||
|
||
|
||
## LogLevel | ||
|
||
_defined in [@component-controls/logger/src/index.ts](https://github.com/ccontrols/component-controls/tree/master/core/logger/src/index.ts#L3)_ | ||
|
||
'all' | 'errors' | 'none' | ||
|
||
<!-- END-TSDOC-TYPESCRIPT --> |
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,59 @@ | ||
{ | ||
"name": "@component-controls/logger", | ||
"version": "1.21.0", | ||
"description": "compilation logging utilities", | ||
"main": "dist/index.js", | ||
"module": "dist/index.esm.js", | ||
"typings": "dist/index.d.ts", | ||
"files": [ | ||
"dist/", | ||
"package.json", | ||
"README.md" | ||
], | ||
"scripts": { | ||
"build": "yarn cross-env NODE_ENV=production rollup -c", | ||
"dev": "yarn cross-env NODE_ENV=development rollup -cw", | ||
"docs": "ts-md", | ||
"fix": "yarn lint --fix", | ||
"lint": "yarn eslint . --ext mdx,ts,tsx", | ||
"prepare": "yarn build", | ||
"test": "yarn jest --passWithNoTests" | ||
}, | ||
"homepage": "https://github.com/ccontrols/component-controls", | ||
"bugs": { | ||
"url": "https://github.com/ccontrols/component-controls/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/ccontrols/component-controls.git", | ||
"directory": "core/logger" | ||
}, | ||
"license": "MIT", | ||
"dependencies": { | ||
"chalk": "^4.0.0" | ||
}, | ||
"devDependencies": { | ||
"@component-controls/ts-markdown-docs": "^1.21.0", | ||
"typescript": "^3.8.3", | ||
"@types/jest": "^25.1.2", | ||
"cross-env": "^5.2.1", | ||
"eslint": "^6.5.1", | ||
"jest": "^24.9.0" | ||
}, | ||
"browser": { | ||
"fs": false | ||
}, | ||
"jest": { | ||
"testEnvironment": "node", | ||
"roots": [ | ||
"." | ||
] | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"authors": [ | ||
"Atanas Stoyanov" | ||
], | ||
"gitHead": "c5145d66c6b8a355839e53c3bca97fd361ce9377" | ||
} |
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,5 @@ | ||
import { config } from '../../rollup-config'; | ||
|
||
export default config({ | ||
input: './src/index.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,34 @@ | ||
import chalk from 'chalk'; | ||
|
||
export type LogLevel = 'all' | 'errors' | 'none'; | ||
|
||
export interface LogOptions { | ||
logLevel?: LogLevel; | ||
colors: [number, number, number]; | ||
} | ||
|
||
const defaultOptions: LogOptions = { | ||
logLevel: 'all', | ||
colors: [244, 147, 66], | ||
}; | ||
|
||
let logOptions: LogOptions = { ...defaultOptions }; | ||
|
||
const output = (heading: string, text: string) => { | ||
console.log(chalk.bgRgb(...logOptions.colors)(`@${heading}`), text); | ||
}; | ||
|
||
export const log = (heading: string, text: string) => { | ||
if (logOptions.logLevel === 'all') { | ||
output(heading, text); | ||
} | ||
}; | ||
export const error = (heading: string, text: string) => { | ||
if (logOptions.logLevel !== 'none') { | ||
output(heading, text); | ||
} | ||
}; | ||
|
||
export const setLogOptions = (options: Partial<LogOptions> = {}) => { | ||
logOptions = { ...logOptions, ...options }; | ||
}; |
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,13 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"module": "esnext", | ||
"outDir": "dist", | ||
"rootDir": "src", | ||
"declaration": true, | ||
"types": ["node", "jest"], | ||
"typeRoots": ["../../node_modules/@types", "node_modules/@types"] | ||
}, | ||
"include": ["src/**/*", "test"], | ||
"exclude": ["node_modules/**", "test/**"] | ||
} |
Oops, something went wrong.