Skip to content

Commit

Permalink
chore: use better typings of consola once they are fixed #63
Browse files Browse the repository at this point in the history
  • Loading branch information
regevbr committed May 7, 2020
1 parent 5d2f9ef commit 0163e31
Show file tree
Hide file tree
Showing 11 changed files with 1,008 additions and 1,024 deletions.
1 change: 1 addition & 0 deletions .cspell.json
Expand Up @@ -23,6 +23,7 @@
"simplegit",
"lcov",
"toolbelt",
"Conosla",
"packument"
],
"ignorePaths": [
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -71,6 +71,5 @@ typings/
# stryker temp files
.stryker-tmp
/reports
!@types/**
!/tools

23 changes: 0 additions & 23 deletions @types/consola/index.d.ts

This file was deleted.

38 changes: 19 additions & 19 deletions package.json
Expand Up @@ -87,55 +87,55 @@
"@types/cross-spawn": "^6.0.1",
"@types/jest": "^25.2.1",
"@types/jest-when": "^2.7.1",
"@types/node": "^13.13.4",
"@types/node": "^13.13.5",
"@types/node-fetch": "^2.5.7",
"@types/pacote": "^11.1.0",
"@types/semver": "^7.1.0",
"@types/shell-quote": "^1.6.1",
"@types/tmp": "^0.1.0",
"@types/tmp": "^0.2.0",
"@types/yargs-parser": "^15.0.0",
"@typescript-eslint/eslint-plugin": "^2.29.0",
"@typescript-eslint/parser": "^2.29.0",
"@typescript-eslint/eslint-plugin": "^2.31.0",
"@typescript-eslint/parser": "^2.31.0",
"all-contributors-cli": "^6.14.2",
"cspell": "^4.0.57",
"cspell": "^4.0.60",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-jest": "^23.8.2",
"eslint-plugin-prefer-arrow": "^1.2.0",
"eslint-plugin-jest": "^23.9.0",
"eslint-plugin-prefer-arrow": "^1.2.1",
"eslint-plugin-prettier": "^3.1.3",
"expect": "^25.4.0",
"expect": "^26.0.1",
"generate-changelog": "^1.8.0",
"husky": "^4.2.5",
"jest": "^25.4.0",
"jest": "^26.0.1",
"jest-mock-extended": "^1.0.8",
"jest-serial-runner": "file:./tools/jest-serial-runner",
"jest-when": "^2.7.1",
"lint-staged": "^10.1.7",
"lint-staged": "^10.2.2",
"mock-spawn": "^0.2.6",
"node-fetch": "^2.6.0",
"npm-check-updates": "^4.1.2",
"prettier": "^2.0.5",
"semver": "^7.3.2",
"ts-jest": "^25.4.0",
"ts-node": "^8.9.1",
"ts-toolbelt": "^6.5.1",
"ts-jest": "^25.5.0",
"ts-node": "^8.10.1",
"ts-toolbelt": "^6.6.2",
"typescript": "^3.8.3"
},
"dependencies": {
"array-flat-polyfill": "~1.0.1",
"axios": "~0.19.2",
"chalk": "~4.0.0",
"consola": "~2.11.3",
"consola": "~2.12.0",
"cross-spawn": "~7.0.2",
"figures": "~3.2.0",
"inversify": "~5.0.1",
"moment": "~2.24.0",
"pacote": "~11.1.4",
"moment": "~2.25.3",
"pacote": "~11.1.9",
"reflect-metadata": "~0.1.13",
"shell-quote": "~1.7.2",
"simple-git": "~1.132.0",
"sqlite3": "~4.1.1",
"tmp": "~0.2.0",
"simple-git": "~2.4.0",
"sqlite3": "~4.2.0",
"tmp": "~0.2.1",
"ts-type-guards": "~0.6.1",
"typeorm": "~0.2.24",
"yaml": "~1.9.2",
Expand Down
13 changes: 13 additions & 0 deletions src/utils/logger/impl/logLevel.ts
@@ -0,0 +1,13 @@
import { LogLevel as ConsolaLogLevel } from 'consola';
import { LogLevel } from '../interfaces/ILogger';

const logLevelMap = {
[LogLevel.ERROR]: ConsolaLogLevel.Error,
[LogLevel.WARN]: ConsolaLogLevel.Warn,
[LogLevel.LOG]: ConsolaLogLevel.Log,
[LogLevel.INFO]: ConsolaLogLevel.Info,
[LogLevel.DEBUG]: ConsolaLogLevel.Debug,
[LogLevel.TRACE]: ConsolaLogLevel.Trace,
};

export const getConoslaLogLevel = (level: LogLevel): ConsolaLogLevel => logLevelMap[level];
4 changes: 2 additions & 2 deletions src/utils/logger/impl/logReporter.ts
@@ -1,4 +1,4 @@
import { ConsolaLogObject, ConsolaReporter, FancyReporter, ReporterOptions } from 'consola';
import { ConsolaLogObject, ConsolaReporter, FancyReporter, FancyReporterOptions } from 'consola';
import chalk = require('chalk');
import * as figures from 'figures';
import type { Chalk, BackgroundColor, ForegroundColor } from 'chalk';
Expand Down Expand Up @@ -35,7 +35,7 @@ const TYPE_ICONS: Record<string, Nullable<string>> = {
export type BGColor = typeof BackgroundColor;
export type Color = typeof ForegroundColor;

export interface LogReporterOptions extends ReporterOptions {
export interface LogReporterOptions extends FancyReporterOptions {
secondaryColor: Color;
bgColor: BGColor;
}
Expand Down
3 changes: 2 additions & 1 deletion src/utils/logger/impl/logger.ts
@@ -1,13 +1,14 @@
import { Consola, ConsolaOptions } from 'consola';
import { ILogger, LogLevel } from '../interfaces/ILogger';
import { getConoslaLogLevel } from './logLevel';

export class Logger extends Consola implements ILogger {
constructor(options: ConsolaOptions) {
super(options);
}

public isLevelEnabled(level: LogLevel): boolean {
return this.level >= level;
return this.level >= getConoslaLogLevel(level);
}

public isTraceEnabled(): boolean {
Expand Down
3 changes: 2 additions & 1 deletion src/utils/logger/impl/loggerFactory.ts
Expand Up @@ -7,6 +7,7 @@ import * as chalk from 'chalk';
import { ILogger, LogLevel } from '../interfaces/ILogger';
import { Logger } from './logger';
import { LogReporter } from './logReporter';
import { getConoslaLogLevel } from './logLevel';

@injectable()
export class LoggerFactory extends ILoggerFactory {
Expand All @@ -17,7 +18,7 @@ export class LoggerFactory extends ILoggerFactory {
const isTrace = settings.traceMode;
const level = isTrace ? LogLevel.TRACE : isDebug ? LogLevel.DEBUG : LogLevel.INFO;
this.options = {
level,
level: getConoslaLogLevel(level),
reporters: [
new LogReporter({
secondaryColor: `grey`,
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.build.json
Expand Up @@ -6,5 +6,5 @@
"declaration": true,
"outDir": "dist"
},
"include": ["src", "@types/**/*.d.ts"]
"include": ["src"]
}
2 changes: 1 addition & 1 deletion tsconfig.json
Expand Up @@ -27,5 +27,5 @@
"experimentalDecorators": true,
"emitDecoratorMetadata": true
},
"include": ["src", "test", "testE2E", "testInteg", "tools", "@types/**/*.d.ts"]
"include": ["src", "test", "testE2E", "testInteg", "tools"]
}

0 comments on commit 0163e31

Please sign in to comment.