itivrutaha 2.0.15 → 3.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bun.lockb +0 -0
- package/dist/config.d.ts +20 -37
- package/dist/config.js +52 -35
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -0
- package/dist/itivrutaha.d.ts +2 -17
- package/dist/itivrutaha.js +10 -116
- package/dist/renderer.d.ts +2 -0
- package/dist/renderer.js +37 -0
- package/dist/utilts.d.ts +1 -0
- package/dist/utilts.js +7 -0
- package/dist/variables/data.d.ts +1 -0
- package/dist/variables/data.js +35 -0
- package/dist/variables/emoji.d.ts +2 -0
- package/dist/variables/emoji.js +7 -0
- package/dist/variables/index.d.ts +5 -0
- package/dist/variables/index.js +9 -0
- package/dist/variables/scope.d.ts +2 -0
- package/dist/variables/scope.js +8 -0
- package/dist/variables/time.d.ts +2 -0
- package/dist/variables/time.js +9 -0
- package/dist/variables/type.d.ts +2 -0
- package/dist/variables/type.js +7 -0
- package/examples/index.ts +11 -0
- package/package.json +14 -47
- package/src/config.ts +82 -0
- package/src/index.ts +7 -0
- package/src/itivrutaha.ts +22 -0
- package/src/renderer.ts +42 -0
- package/src/utilts.ts +10 -0
- package/src/variables/data.ts +40 -0
- package/src/variables/emoji.ts +10 -0
- package/src/variables/index.ts +10 -0
- package/src/variables/scope.ts +11 -0
- package/src/variables/time.ts +12 -0
- package/src/variables/type.ts +10 -0
- package/tsconfig.json +18 -0
- package/LICENSE.md +0 -9
- package/README.md +0 -82
- package/dist/class/index.d.ts +0 -13
- package/dist/class/index.js +0 -36
- package/dist/class/lifecycle.d.ts +0 -3
- package/dist/class/lifecycle.js +0 -65
- package/dist/class/log.d.ts +0 -5
- package/dist/class/log.js +0 -60
- package/dist/class/renderer.d.ts +0 -3
- package/dist/class/renderer.js +0 -33
- package/dist/class/variables/emoji.d.ts +0 -2
- package/dist/class/variables/emoji.js +0 -15
- package/dist/class/variables/time.d.ts +0 -3
- package/dist/class/variables/time.js +0 -9
- package/dist/class/variables/type.d.ts +0 -3
- package/dist/class/variables/type.js +0 -34
- package/dist/class/wrapper.d.ts +0 -10
- package/dist/class/wrapper.js +0 -29
package/bun.lockb
ADDED
|
Binary file
|
package/dist/config.d.ts
CHANGED
|
@@ -1,40 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export declare enum typeCase {
|
|
6
|
-
'upper' = 0,
|
|
7
|
-
'lower' = 1,
|
|
8
|
-
'title' = 2
|
|
1
|
+
import { ChalkInstance } from "chalk";
|
|
2
|
+
export interface Scope<ScopeName> {
|
|
3
|
+
name: ScopeName;
|
|
4
|
+
color: ChalkInstance;
|
|
9
5
|
}
|
|
10
|
-
export interface
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
clearOnSIGINT?: boolean;
|
|
15
|
-
quietIdentifier?: Array<string>;
|
|
16
|
-
verboseIdentifier?: Array<string>;
|
|
17
|
-
context?: {
|
|
18
|
-
name: string;
|
|
19
|
-
color: (str: string) => string;
|
|
20
|
-
};
|
|
21
|
-
theme?: {
|
|
22
|
-
string?: string;
|
|
23
|
-
colored?: boolean;
|
|
24
|
-
boldType?: boolean;
|
|
25
|
-
typeCase?: typeCase;
|
|
26
|
-
timeFormat?: string;
|
|
27
|
-
};
|
|
28
|
-
logs?: {
|
|
29
|
-
dir?: string;
|
|
30
|
-
error?: string;
|
|
31
|
-
output?: string;
|
|
32
|
-
enable?: boolean;
|
|
33
|
-
};
|
|
6
|
+
export interface LogType<Name> {
|
|
7
|
+
name: Name;
|
|
8
|
+
emoji: string;
|
|
9
|
+
color: ChalkInstance;
|
|
34
10
|
}
|
|
35
|
-
export
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
startedOn: DateTime;
|
|
11
|
+
export interface UnifiedData<ScopeName> {
|
|
12
|
+
scope?: ScopeName;
|
|
13
|
+
msg: string;
|
|
14
|
+
[key: string]: any;
|
|
40
15
|
}
|
|
16
|
+
export interface Config<ScopeName, LogTypeName> {
|
|
17
|
+
theme: string;
|
|
18
|
+
timeFormat: string;
|
|
19
|
+
scopes: Scope<ScopeName>[];
|
|
20
|
+
types: LogType<LogTypeName>[];
|
|
21
|
+
}
|
|
22
|
+
export declare function makeConfig<Scope extends string, LogTypeName extends string>(config: Config<Scope, LogTypeName>): Config<Scope, LogTypeName>;
|
|
23
|
+
export declare const defaultConfig: Config<"app", "error" | "success" | "info" | "okay" | "note" | "verbose" | "warning">;
|
package/dist/config.js
CHANGED
|
@@ -1,38 +1,55 @@
|
|
|
1
1
|
/*
|
|
2
|
-
*
|
|
3
|
-
* Created On
|
|
2
|
+
* Contains configuration related code.
|
|
3
|
+
* Created On 15 January 2024
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
export function makeConfig(config) {
|
|
7
|
+
return config;
|
|
8
|
+
}
|
|
9
|
+
export const defaultConfig = makeConfig({
|
|
10
|
+
theme: `:time ${chalk.gray.dim('•')} :scope :emoji :type :msg :data`,
|
|
11
|
+
timeFormat: 'hh:mm:ss dd-MM-yyyy',
|
|
12
|
+
scopes: [
|
|
13
|
+
{
|
|
14
|
+
name: 'app',
|
|
15
|
+
color: chalk.redBright
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
types: [
|
|
19
|
+
{
|
|
20
|
+
name: 'success',
|
|
21
|
+
emoji: '✅',
|
|
22
|
+
color: chalk.greenBright,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'info',
|
|
26
|
+
emoji: 'ℹ️',
|
|
27
|
+
color: chalk.blueBright,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'okay',
|
|
31
|
+
emoji: '👍',
|
|
32
|
+
color: chalk.gray,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'note',
|
|
36
|
+
emoji: '✍️',
|
|
37
|
+
color: chalk.magentaBright,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'verbose',
|
|
41
|
+
emoji: '🧐',
|
|
42
|
+
color: chalk.cyanBright,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: 'warning',
|
|
46
|
+
emoji: '⚠️',
|
|
47
|
+
color: chalk.yellowBright
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'error',
|
|
51
|
+
emoji: '🚨',
|
|
52
|
+
color: chalk.redBright
|
|
53
|
+
},
|
|
54
|
+
]
|
|
38
55
|
});
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/dist/itivrutaha.d.ts
CHANGED
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
declare const _default: {
|
|
4
|
-
/**
|
|
5
|
-
* Creates a new instance of a logger.
|
|
6
|
-
* @param config {ConfigImpl}
|
|
7
|
-
* @returns Logger
|
|
8
|
-
*/
|
|
9
|
-
createNewLogger: (config?: ConfigImpl) => Promise<Logger>;
|
|
10
|
-
/**
|
|
11
|
-
* Deletes the log directory for a given logger.
|
|
12
|
-
* @param logger {Logger}
|
|
13
|
-
* @returns string[]
|
|
14
|
-
*/
|
|
15
|
-
clearLogs: (logger: Logger) => Promise<string[]>;
|
|
16
|
-
};
|
|
17
|
-
export default _default;
|
|
1
|
+
import { Config, UnifiedData } from "./config.js";
|
|
2
|
+
export declare function itivrutaha<Scope extends string, LogTypeName extends string>(config: Config<Scope, LogTypeName>): { [Type in LogTypeName]: (msgOrData: string | UnifiedData<Scope>, data?: any, scope?: Scope) => void; };
|
package/dist/itivrutaha.js
CHANGED
|
@@ -1,118 +1,12 @@
|
|
|
1
1
|
/*
|
|
2
|
-
*
|
|
3
|
-
* Created On
|
|
2
|
+
* Contains an exportable logger function.
|
|
3
|
+
* Created On 29 October 2023
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
import chalk from 'chalk';
|
|
15
|
-
import merge from 'deepmerge';
|
|
16
|
-
import { deleteAsync } from 'del';
|
|
17
|
-
import { DateTime } from 'luxon';
|
|
18
|
-
import { readPackageUpSync } from 'read-pkg-up';
|
|
19
|
-
import { Logger } from './class/index.js';
|
|
20
|
-
import { open } from './class/log.js';
|
|
21
|
-
import { typeCase } from './config.js';
|
|
22
|
-
// Holds the default configuration which acts like a
|
|
23
|
-
// replacement when no value is provided for a
|
|
24
|
-
// particular configuration key
|
|
25
|
-
const defaults = {
|
|
26
|
-
// The name of your app, if not provided
|
|
27
|
-
// the value will be determined by reading
|
|
28
|
-
// package.json of the above project.
|
|
29
|
-
appName: null,
|
|
30
|
-
// Whether to log when the logger is initialized.
|
|
31
|
-
bootLog: true,
|
|
32
|
-
// Whether to log when the Node.js process exits.
|
|
33
|
-
// Logs when terminating gracefully, due to an error
|
|
34
|
-
// or when POSIX signals are received.
|
|
35
|
-
shutdownLog: true,
|
|
36
|
-
// remove the "^C⏎" after terminating the process
|
|
37
|
-
// when Ctrl+C is pressed
|
|
38
|
-
clearOnSIGINT: true,
|
|
39
|
-
// Command-line arguments that suppress the output
|
|
40
|
-
// to the console if found.
|
|
41
|
-
quietIdentifier: ['--quiet', '-q'],
|
|
42
|
-
// Command-line arguments that render verbose message
|
|
43
|
-
// type to the console if found.
|
|
44
|
-
verboseIdentifier: ['--verbose', '-v'],
|
|
45
|
-
// Configuration for this particular logger.
|
|
46
|
-
// Useful when application has multiple loggers.
|
|
47
|
-
context: {
|
|
48
|
-
// Name of the context, example "app", "api",
|
|
49
|
-
// "bot", "server"...
|
|
50
|
-
name: null,
|
|
51
|
-
// Chalk color function for this context.
|
|
52
|
-
color: chalk.blueBright,
|
|
53
|
-
},
|
|
54
|
-
// Configuration options related to rendering the
|
|
55
|
-
// log messages to the console.
|
|
56
|
-
theme: {
|
|
57
|
-
// The theme string, that determines which variables
|
|
58
|
-
// are to be rendered.
|
|
59
|
-
string: `:time ${chalk.gray.dim('•')} :emoji :type :message`,
|
|
60
|
-
// Whether to log colored output
|
|
61
|
-
// or plain.
|
|
62
|
-
colored: true,
|
|
63
|
-
// Whether to render message type (":type" variable)
|
|
64
|
-
// in bold.
|
|
65
|
-
boldType: true,
|
|
66
|
-
// The character casing to render message type or
|
|
67
|
-
// the (":type" variable).
|
|
68
|
-
typeCase: typeCase.lower,
|
|
69
|
-
// Luxon time formatting used to render the
|
|
70
|
-
// ":time" variable. See 👇 for formatting guide
|
|
71
|
-
// https://moment.github.io/luxon/docs/manual/formatting.html#table-of-tokens
|
|
72
|
-
timeFormat: 'HH:mm:ss dd-LL-yyyy',
|
|
73
|
-
},
|
|
74
|
-
logs: {
|
|
75
|
-
// Whether to enable file logging or not.
|
|
76
|
-
enable: false,
|
|
77
|
-
// The directory where log files are saved.
|
|
78
|
-
dir: null,
|
|
79
|
-
// Filename for writing output (stdout)
|
|
80
|
-
// logs.
|
|
81
|
-
output: `output-${DateTime.local().toFormat('dd-LL-yyyy')}.log`,
|
|
82
|
-
// Filename for writing error (stderr)
|
|
83
|
-
// logs.
|
|
84
|
-
error: `error-${DateTime.local().toFormat('dd-LL-yyyy')}.log`,
|
|
85
|
-
},
|
|
86
|
-
};
|
|
87
|
-
// createNewLogger() will create a new instance of the logger class
|
|
88
|
-
const createNewLogger = (config = defaults) => __awaiter(void 0, void 0, void 0, function* () {
|
|
89
|
-
// if custom properties were given merge those together
|
|
90
|
-
// with defaults so we have all properties defined
|
|
91
|
-
config = merge(defaults, config);
|
|
92
|
-
// fill out the fields which are specific to this
|
|
93
|
-
// particular instance of Logger
|
|
94
|
-
if (config.appName == null)
|
|
95
|
-
config.appName = readPackageUpSync().packageJson.name;
|
|
96
|
-
if (config.context.name)
|
|
97
|
-
config.theme.string = `:time ${chalk.gray.dim('•')} ${config.context.color(config.context.name)} :emoji :type :message`;
|
|
98
|
-
// initialize file logging according to the configuration
|
|
99
|
-
const data = yield open(config);
|
|
100
|
-
// return a new LoggerClass instance
|
|
101
|
-
return new Logger(config, data);
|
|
102
|
-
});
|
|
103
|
-
const clearLogs = (logger) => __awaiter(void 0, void 0, void 0, function* () { return yield deleteAsync(logger.config.logs.dir, { force: true }); });
|
|
104
|
-
// Export the above two functions
|
|
105
|
-
export default {
|
|
106
|
-
/**
|
|
107
|
-
* Creates a new instance of a logger.
|
|
108
|
-
* @param config {ConfigImpl}
|
|
109
|
-
* @returns Logger
|
|
110
|
-
*/
|
|
111
|
-
createNewLogger,
|
|
112
|
-
/**
|
|
113
|
-
* Deletes the log directory for a given logger.
|
|
114
|
-
* @param logger {Logger}
|
|
115
|
-
* @returns string[]
|
|
116
|
-
*/
|
|
117
|
-
clearLogs,
|
|
118
|
-
};
|
|
5
|
+
import { render } from "./renderer.js";
|
|
6
|
+
export function itivrutaha(config) {
|
|
7
|
+
// return all the log functions
|
|
8
|
+
return config.types.reduce((previous, current) => ({
|
|
9
|
+
...previous,
|
|
10
|
+
[current.name]: render(config, current)
|
|
11
|
+
}), {});
|
|
12
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { Config, LogType, UnifiedData } from './config.js';
|
|
2
|
+
export declare function render<ScopeName, LogTypeName extends string>(config: Config<ScopeName, LogTypeName>, type: LogType<LogTypeName>): (msgOrData: string | UnifiedData<ScopeName>, data?: any, scope?: ScopeName) => void;
|
package/dist/renderer.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Renders a single log line by consuming an object.
|
|
3
|
+
* Created On 15 January 2024
|
|
4
|
+
*/
|
|
5
|
+
import { filterObject } from './utilts.js';
|
|
6
|
+
import * as variables from './variables/index.js';
|
|
7
|
+
function line(config, type, msg, scopeName, data) {
|
|
8
|
+
// filter internal keys from data
|
|
9
|
+
if (data)
|
|
10
|
+
data = filterObject(data, ['msg', 'scope']);
|
|
11
|
+
console.log(config.theme
|
|
12
|
+
.replace(/:time/g, variables.time(config))
|
|
13
|
+
.replace(/:scope/g, variables.scope(config, scopeName))
|
|
14
|
+
.replace(/:emoji/g, variables.emoji(type))
|
|
15
|
+
.replace(/:type/g, variables.type(type))
|
|
16
|
+
.replace(/:msg/g, msg)
|
|
17
|
+
.replace(/:data/g, variables.data(data)));
|
|
18
|
+
}
|
|
19
|
+
export function render(config, type) {
|
|
20
|
+
// consume all the log objects
|
|
21
|
+
return (msgOrData, data, scope) => {
|
|
22
|
+
// determine whether we're using unified data or seperate arguments
|
|
23
|
+
if (typeof msgOrData == 'string') {
|
|
24
|
+
// seperate arguments
|
|
25
|
+
line(config, type, msgOrData, scope, data);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
// unified data
|
|
29
|
+
// ensure scope & data are not given in both placces
|
|
30
|
+
if (scope)
|
|
31
|
+
throw Error(`Specifying scope as argument is not allowed`);
|
|
32
|
+
if (data)
|
|
33
|
+
throw Error(`Specifying data separately is not allowed`);
|
|
34
|
+
line(config, type, msgOrData.msg, msgOrData.scope, msgOrData);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
package/dist/utilts.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function filterObject(obj: Record<string, any>, keysToExclude: string[]): Record<string, any>;
|
package/dist/utilts.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function data(input: any): string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Renders the ":data" variable.
|
|
3
|
+
* Created On 15 January 2024
|
|
4
|
+
*/
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import { highlight } from 'cli-highlight';
|
|
7
|
+
function formatJSON(data) {
|
|
8
|
+
return JSON.stringify(data)
|
|
9
|
+
.replace(/{"/g, '{ "')
|
|
10
|
+
.replace(/"}/g, '" }')
|
|
11
|
+
.replace(/,"/g, ", \"")
|
|
12
|
+
.replace(/":/g, '": ');
|
|
13
|
+
}
|
|
14
|
+
export function data(input) {
|
|
15
|
+
if (!input)
|
|
16
|
+
return '';
|
|
17
|
+
let str = '';
|
|
18
|
+
for (const key in input) {
|
|
19
|
+
const value = input[key];
|
|
20
|
+
const keyBlock = `${chalk.cyanBright(key)}${chalk.whiteBright('=')}`;
|
|
21
|
+
if (typeof value == 'object') {
|
|
22
|
+
str = str.concat(keyBlock).concat(highlight(formatJSON(value), {
|
|
23
|
+
language: 'json',
|
|
24
|
+
ignoreIllegals: true,
|
|
25
|
+
})).concat(' ');
|
|
26
|
+
}
|
|
27
|
+
else if (typeof value == 'string') {
|
|
28
|
+
str = str.concat(keyBlock).concat(chalk.magentaBright(value)).concat(' ');
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
str = str.concat(keyBlock).concat(chalk.magentaBright(JSON.stringify(value))).concat(' ');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return str.trim();
|
|
35
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Renders ":scope" variable with the current log line's scope.
|
|
3
|
+
* Created On 15 January 2024
|
|
4
|
+
*/
|
|
5
|
+
export function scope(config, scopeName) {
|
|
6
|
+
const scope = scopeName ? config.scopes.find(sco => sco.name == scopeName) : config.scopes[0];
|
|
7
|
+
return scope.color(scope.name);
|
|
8
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defaultConfig, itivrutaha } from '../dist/index.js'
|
|
2
|
+
|
|
3
|
+
const log = itivrutaha(defaultConfig)
|
|
4
|
+
|
|
5
|
+
log.error('some error')
|
|
6
|
+
log.info('nice info')
|
|
7
|
+
log.note('a useful note')
|
|
8
|
+
log.okay(`it's okay`)
|
|
9
|
+
log.success('that is a success')
|
|
10
|
+
log.verbose('useful for developers')
|
|
11
|
+
log.warning('something is going wrong')
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "itivrutaha",
|
|
3
|
-
"description": "
|
|
4
|
-
"version": "
|
|
3
|
+
"description": "",
|
|
4
|
+
"version": "3.0.0-beta.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"main": "dist/
|
|
7
|
+
"main": "dist/index.js",
|
|
8
8
|
"homepage": "https://github.com/vsnthdev/itivrutaha#readme",
|
|
9
9
|
"bugs": "https://github.com/vsnthdev/itivrutaha/issues",
|
|
10
10
|
"author": {
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
11
|
+
"email": "hey@vsnth.dev",
|
|
12
|
+
"url": "https://vsnth.dev",
|
|
13
|
+
"name": "Vasanth Srivatsa"
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
@@ -18,50 +18,17 @@
|
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
20
|
"dev": "tsc --watch",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"clean": "rimraf dist"
|
|
21
|
+
"clean": "rimraf dist",
|
|
22
|
+
"build": "rimraf dist && tsc"
|
|
24
23
|
},
|
|
25
|
-
"keywords": [
|
|
26
|
-
"cli",
|
|
27
|
-
"tty",
|
|
28
|
-
"log",
|
|
29
|
-
"logs",
|
|
30
|
-
"shell",
|
|
31
|
-
"logger",
|
|
32
|
-
"logging",
|
|
33
|
-
"terminal",
|
|
34
|
-
"command-line"
|
|
35
|
-
],
|
|
36
24
|
"dependencies": {
|
|
37
|
-
"chalk": "^5.
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"del": "^7.0.0",
|
|
41
|
-
"env-paths": "^3.0.0",
|
|
42
|
-
"joi": "^17.9.1",
|
|
43
|
-
"luxon": "^3.3.0",
|
|
44
|
-
"mkdirp": "^3.0.0",
|
|
45
|
-
"node-cleanup": "^2.1.2",
|
|
46
|
-
"node-emoji": "^1.11.0",
|
|
47
|
-
"read-pkg-up": "^9.1.0",
|
|
48
|
-
"strip-ansi": "^7.0.1"
|
|
25
|
+
"chalk": "^5.3.0",
|
|
26
|
+
"cli-highlight": "^2.1.11",
|
|
27
|
+
"date-format": "^4.0.14"
|
|
49
28
|
},
|
|
50
29
|
"devDependencies": {
|
|
51
|
-
"@types/
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"@types/node-emoji": "^1.8.2",
|
|
55
|
-
"@typescript-eslint/eslint-plugin": "^5.59.0",
|
|
56
|
-
"@typescript-eslint/parser": "^5.59.0",
|
|
57
|
-
"es-dirname": "^0.1.0",
|
|
58
|
-
"eslint": "^8.39.0",
|
|
59
|
-
"eslint-config-prettier": "^8.8.0",
|
|
60
|
-
"eslint-plugin-import": "^2.27.5",
|
|
61
|
-
"eslint-plugin-prettier": "^4.2.1",
|
|
62
|
-
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
63
|
-
"prettier": "^2.8.8",
|
|
64
|
-
"rimraf": "^5.0.0",
|
|
65
|
-
"typescript": "^5.0.4"
|
|
30
|
+
"@types/node": "^20.10.6",
|
|
31
|
+
"rimraf": "^5.0.5",
|
|
32
|
+
"typescript": "^5.3.3"
|
|
66
33
|
}
|
|
67
34
|
}
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Contains configuration related code.
|
|
3
|
+
* Created On 15 January 2024
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import chalk, { ChalkInstance } from "chalk"
|
|
7
|
+
|
|
8
|
+
export interface Scope<ScopeName> {
|
|
9
|
+
name: ScopeName
|
|
10
|
+
color: ChalkInstance
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface LogType<Name> {
|
|
14
|
+
name: Name
|
|
15
|
+
emoji: string
|
|
16
|
+
color: ChalkInstance
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface UnifiedData<ScopeName> {
|
|
20
|
+
scope?: ScopeName
|
|
21
|
+
msg: string
|
|
22
|
+
[key: string]: any
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface Config<ScopeName, LogTypeName> {
|
|
26
|
+
theme: string
|
|
27
|
+
timeFormat: string
|
|
28
|
+
scopes: Scope<ScopeName>[]
|
|
29
|
+
types: LogType<LogTypeName>[]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function makeConfig<Scope extends string, LogTypeName extends string>(config: Config<Scope, LogTypeName>) {
|
|
33
|
+
return config
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const defaultConfig = makeConfig({
|
|
37
|
+
theme: `:time ${chalk.gray.dim('•')} :scope :emoji :type :msg :data`,
|
|
38
|
+
timeFormat: 'hh:mm:ss dd-MM-yyyy',
|
|
39
|
+
scopes: [
|
|
40
|
+
{
|
|
41
|
+
name: 'app',
|
|
42
|
+
color: chalk.redBright
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
types: [
|
|
46
|
+
{
|
|
47
|
+
name: 'success',
|
|
48
|
+
emoji: '✅',
|
|
49
|
+
color: chalk.greenBright,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'info',
|
|
53
|
+
emoji: 'ℹ️',
|
|
54
|
+
color: chalk.blueBright,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'okay',
|
|
58
|
+
emoji: '👍',
|
|
59
|
+
color: chalk.gray,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'note',
|
|
63
|
+
emoji: '✍️',
|
|
64
|
+
color: chalk.magentaBright,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'verbose',
|
|
68
|
+
emoji: '🧐',
|
|
69
|
+
color: chalk.cyanBright,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'warning',
|
|
73
|
+
emoji: '⚠️',
|
|
74
|
+
color: chalk.yellowBright
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'error',
|
|
78
|
+
emoji: '🚨',
|
|
79
|
+
color: chalk.redBright
|
|
80
|
+
},
|
|
81
|
+
]
|
|
82
|
+
})
|