topkat-utils 1.2.9 → 1.2.10
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/CHANGELOG.md +4 -0
- package/dist/src/config.d.ts +8 -8
- package/dist/src/config.js +5 -0
- package/dist/src/config.js.map +1 -1
- package/dist/src/is-nodejs.d.ts +1 -0
- package/dist/src/is-nodejs.js +13 -0
- package/dist/src/is-nodejs.js.map +1 -0
- package/package.json +1 -1
- package/src/config.ts +13 -9
- package/src/is-nodejs.ts +9 -0
package/CHANGELOG.md
CHANGED
package/dist/src/config.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Color } from './types';
|
|
2
|
-
export declare type TopkatUtilConfig = {
|
|
2
|
+
export declare type TopkatUtilConfig = Partial<{
|
|
3
3
|
env: string;
|
|
4
4
|
isProd: boolean;
|
|
5
|
-
nbOfLogsToKeep
|
|
5
|
+
nbOfLogsToKeep: number;
|
|
6
6
|
customTypes: object;
|
|
7
7
|
preprocessLog?: Function;
|
|
8
|
-
terminal: {
|
|
8
|
+
terminal: Partial<{
|
|
9
9
|
noColor: boolean;
|
|
10
|
-
theme: {
|
|
10
|
+
theme: Partial<{
|
|
11
11
|
primary: Color;
|
|
12
12
|
shade1: Color;
|
|
13
13
|
shade2: Color;
|
|
@@ -17,9 +17,9 @@ export declare type TopkatUtilConfig = {
|
|
|
17
17
|
fontColor?: Color;
|
|
18
18
|
pageWidth?: number;
|
|
19
19
|
debugModeColor?: Color;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
20
|
+
}>;
|
|
21
|
+
}>;
|
|
22
|
+
}>;
|
|
23
23
|
/** Allow dynamic changing of config */
|
|
24
24
|
export declare function configFn(): TopkatUtilConfig;
|
|
25
25
|
/** Register custom config
|
|
@@ -41,4 +41,4 @@ export declare function configFn(): TopkatUtilConfig;
|
|
|
41
41
|
* * }
|
|
42
42
|
* * },
|
|
43
43
|
*/
|
|
44
|
-
export declare function registerConfig(customConfig:
|
|
44
|
+
export declare function registerConfig(customConfig: TopkatUtilConfig): void;
|
package/dist/src/config.js
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.registerConfig = exports.configFn = void 0;
|
|
4
4
|
const isset_1 = require("./isset");
|
|
5
|
+
const is_nodejs_1 = require("./is-nodejs");
|
|
5
6
|
let config = {
|
|
7
|
+
// Also used as default config
|
|
6
8
|
env: 'development',
|
|
7
9
|
isProd: false,
|
|
8
10
|
nbOfLogsToKeep: 25,
|
|
@@ -43,8 +45,11 @@ exports.configFn = configFn;
|
|
|
43
45
|
* * },
|
|
44
46
|
*/
|
|
45
47
|
function registerConfig(customConfig) {
|
|
48
|
+
const isNode = (0, is_nodejs_1.isNodeJs)();
|
|
46
49
|
if (!(0, isset_1.isset)(customConfig.terminal))
|
|
47
50
|
customConfig.terminal = {};
|
|
51
|
+
if (isNode)
|
|
52
|
+
config.terminal.noColor = false;
|
|
48
53
|
const newconfig = Object.assign(Object.assign({}, config), customConfig);
|
|
49
54
|
newconfig.terminal = Object.assign(Object.assign({}, config.terminal), customConfig.terminal);
|
|
50
55
|
newconfig.terminal.theme = Object.assign(Object.assign({}, config.terminal.theme), (customConfig.terminal.theme || {}));
|
package/dist/src/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":";;;AACA,mCAA+B;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":";;;AACA,mCAA+B;AAC/B,2CAAsC;AAwBtC,IAAI,MAAM,GAAqB;IAC3B,8BAA8B;IAC9B,GAAG,EAAE,aAAa;IAClB,MAAM,EAAE,KAAK;IACb,cAAc,EAAE,EAAE;IAClB,WAAW,EAAE,EAAE;IACf,QAAQ,EAAE;QACN,OAAO,EAAE,IAAI;QAC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0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isNodeJs = void 0;
|
|
4
|
+
function isNodeJs() {
|
|
5
|
+
try {
|
|
6
|
+
return (typeof process !== 'undefined') && (typeof process.versions.node !== 'undefined');
|
|
7
|
+
}
|
|
8
|
+
catch (e) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.isNodeJs = isNodeJs;
|
|
13
|
+
//# sourceMappingURL=is-nodejs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-nodejs.js","sourceRoot":"","sources":["../../src/is-nodejs.ts"],"names":[],"mappings":";;;AAEA,SAAgB,QAAQ;IACpB,IAAI;QACA,OAAO,CAAC,OAAO,OAAO,KAAK,WAAW,CAAC,IAAI,CAAC,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,WAAW,CAAC,CAAA;KAC5F;IAAC,OAAO,CAAC,EAAE;QACR,OAAO,KAAK,CAAA;KACf;AACL,CAAC;AAND,4BAMC"}
|
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { Color } from './types'
|
|
2
2
|
import { isset } from './isset'
|
|
3
|
+
import { isNodeJs } from './is-nodejs'
|
|
3
4
|
|
|
4
|
-
export type TopkatUtilConfig = {
|
|
5
|
+
export type TopkatUtilConfig = Partial<{
|
|
5
6
|
env: string
|
|
6
7
|
isProd: boolean
|
|
7
|
-
nbOfLogsToKeep
|
|
8
|
+
nbOfLogsToKeep: number
|
|
8
9
|
customTypes: object,
|
|
9
10
|
preprocessLog?: Function,
|
|
10
|
-
terminal: {
|
|
11
|
+
terminal: Partial<{
|
|
11
12
|
noColor: boolean
|
|
12
|
-
theme: {
|
|
13
|
+
theme: Partial<{
|
|
13
14
|
primary: Color, // blue theme
|
|
14
15
|
shade1: Color,
|
|
15
16
|
shade2: Color,
|
|
@@ -19,11 +20,12 @@ export type TopkatUtilConfig = {
|
|
|
19
20
|
fontColor?: Color
|
|
20
21
|
pageWidth?: number
|
|
21
22
|
debugModeColor?: Color,
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
23
|
+
}>
|
|
24
|
+
}>
|
|
25
|
+
}>
|
|
25
26
|
|
|
26
27
|
let config: TopkatUtilConfig = {
|
|
28
|
+
// Also used as default config
|
|
27
29
|
env: 'development',
|
|
28
30
|
isProd: false,
|
|
29
31
|
nbOfLogsToKeep: 25,
|
|
@@ -43,7 +45,7 @@ let config: TopkatUtilConfig = {
|
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
/** Allow dynamic changing of config */
|
|
46
|
-
export function configFn() { return config }
|
|
48
|
+
export function configFn(): TopkatUtilConfig { return config }
|
|
47
49
|
|
|
48
50
|
|
|
49
51
|
/** Register custom config
|
|
@@ -65,8 +67,10 @@ export function configFn() { return config }
|
|
|
65
67
|
* * }
|
|
66
68
|
* * },
|
|
67
69
|
*/
|
|
68
|
-
export function registerConfig(customConfig) {
|
|
70
|
+
export function registerConfig(customConfig: TopkatUtilConfig) {
|
|
71
|
+
const isNode = isNodeJs()
|
|
69
72
|
if (!isset(customConfig.terminal)) customConfig.terminal = {}
|
|
73
|
+
if (isNode) config.terminal.noColor = false
|
|
70
74
|
const newconfig = {
|
|
71
75
|
...config,
|
|
72
76
|
...customConfig
|