topkat-utils 1.2.61 → 1.2.62
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/dist/src/config.d.ts +4 -1
- package/dist/src/config.js +4 -3
- package/dist/src/config.js.map +1 -1
- package/package.json +1 -1
- package/src/config.ts +14 -5
package/dist/src/config.d.ts
CHANGED
|
@@ -31,5 +31,8 @@ export type TopkatUtilConfig = {
|
|
|
31
31
|
export declare function configFn(): Required<TopkatUtilConfig & {
|
|
32
32
|
terminal: TerminalConfigRequired;
|
|
33
33
|
}>;
|
|
34
|
-
export declare function registerConfig(customConfig:
|
|
34
|
+
export declare function registerConfig(customConfig: RecursivePartial<TopkatUtilConfig>): void;
|
|
35
|
+
type RecursivePartial<T> = {
|
|
36
|
+
[P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial<U>[] : T[P] extends object ? RecursivePartial<T[P]> : T[P];
|
|
37
|
+
};
|
|
35
38
|
export {};
|
package/dist/src/config.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.registerConfig = exports.configFn = void 0;
|
|
4
4
|
const is_nodejs_1 = require("./is-nodejs");
|
|
5
|
+
const object_utils_1 = require("./object-utils");
|
|
5
6
|
const isNode = (0, is_nodejs_1.isNodeJs)();
|
|
6
7
|
let config = {
|
|
7
8
|
// Also used as default config
|
|
@@ -26,14 +27,14 @@ let config = {
|
|
|
26
27
|
function configFn() { return config; }
|
|
27
28
|
exports.configFn = configFn;
|
|
28
29
|
function registerConfig(customConfig) {
|
|
29
|
-
var _a, _b
|
|
30
|
+
var _a, _b;
|
|
30
31
|
if ('terminal' in customConfig === false)
|
|
31
32
|
customConfig.terminal = {};
|
|
32
33
|
const newconfig = Object.assign(Object.assign({}, config), customConfig);
|
|
33
34
|
newconfig.terminal = Object.assign(Object.assign({}, config === null || config === void 0 ? void 0 : config.terminal), customConfig === null || customConfig === void 0 ? void 0 : customConfig.terminal);
|
|
34
35
|
newconfig.terminal.theme = Object.assign(Object.assign({}, (_a = config === null || config === void 0 ? void 0 : config.terminal) === null || _a === void 0 ? void 0 : _a.theme), (((_b = customConfig === null || customConfig === void 0 ? void 0 : customConfig.terminal) === null || _b === void 0 ? void 0 : _b.theme) || {}));
|
|
35
|
-
config =
|
|
36
|
-
config.isProd = (
|
|
36
|
+
config = (0, object_utils_1.mergeDeep)(config, customConfig);
|
|
37
|
+
config.isProd = (config === null || config === void 0 ? void 0 : config.env) ? config.env.includes('prod') : true; // preprod | production
|
|
37
38
|
}
|
|
38
39
|
exports.registerConfig = registerConfig;
|
|
39
40
|
//# sourceMappingURL=config.js.map
|
package/dist/src/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":";;;AACA,2CAAsC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":";;;AACA,2CAAsC;AACtC,iDAA0C;AAE1C,MAAM,MAAM,GAAG,IAAA,oBAAQ,GAAE,CAAA;AAiCzB,IAAI,MAAM,GAAG;IACT,8BAA8B;IAC9B,GAAG,EAAE,aAAa;IAClB,MAAM,EAAE,KAAK;IACb,cAAc,EAAE,EAAE;IAClB,WAAW,EAAE,EAAE;IACf,QAAQ,EAAE;QACN,OAAO,EAAE,CAAC,MAAM;QAChB,KAAK,EAAE;YACH,OAAO,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC;YACtB,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC;YACpB,MAAM,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC;YACrB,QAAQ,EAAE,CAAC;YACX,QAAQ,EAAE,CAAC;YACX,SAAS,EAAE,EAAE;YACb,cAAc,EAAE,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,CAAC;SACjC;KACJ;CACJ,CAAA;AAED,uCAAuC;AACvC,SAAgB,QAAQ,KAAwE,OAAO,MAAa,CAAA,CAAC,CAAC;AAAtH,4BAAsH;AAEtH,SAAgB,cAAc,CAAC,YAAgD;;IAC3E,IAAI,UAAU,IAAI,YAAY,KAAK,KAAK;QAAE,YAAY,CAAC,QAAQ,GAAG,EAAkC,CAAA;IACpG,MAAM,SAAS,mCACR,MAAM,GACN,YAAY,CAClB,CAAA;IACD,SAAS,CAAC,QAAQ,mCACX,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,GACf,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,QAAgB,CACrC,CAAA;IACD,SAAS,CAAC,QAAQ,CAAC,KAAK,mCACjB,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,0CAAE,KAAK,GACvB,CAAC,CAAA,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,QAAQ,0CAAE,KAAK,KAAI,EAAE,CAAC,CAC3C,CAAA;IACD,MAAM,GAAG,IAAA,wBAAS,EAAC,MAAM,EAAE,YAAY,CAAC,CAAA;IAExC,MAAM,CAAC,MAAM,GAAG,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,GAAG,EAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA,CAAC,uBAAuB;AAC5F,CAAC;AAjBD,wCAiBC"}
|
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Color, ErrorOptions } from './types'
|
|
2
2
|
import { isNodeJs } from './is-nodejs'
|
|
3
|
+
import { mergeDeep } from './object-utils'
|
|
3
4
|
|
|
4
5
|
const isNode = isNodeJs()
|
|
5
6
|
|
|
@@ -15,11 +16,11 @@ type TerminalTheme = {
|
|
|
15
16
|
debugModeColor?: Color,
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
type TerminalConfig = {
|
|
19
|
+
type TerminalConfig = {
|
|
19
20
|
noColor: boolean
|
|
20
21
|
theme: TerminalTheme
|
|
21
22
|
}
|
|
22
|
-
type TerminalConfigRequired = {
|
|
23
|
+
type TerminalConfigRequired = {
|
|
23
24
|
noColor: boolean
|
|
24
25
|
theme: Required<TerminalTheme>
|
|
25
26
|
}
|
|
@@ -57,7 +58,7 @@ let config = {
|
|
|
57
58
|
/** Allow dynamic changing of config */
|
|
58
59
|
export function configFn(): Required<TopkatUtilConfig & { terminal: TerminalConfigRequired }> { return config as any }
|
|
59
60
|
|
|
60
|
-
export function registerConfig(customConfig:
|
|
61
|
+
export function registerConfig(customConfig: RecursivePartial<TopkatUtilConfig>) {
|
|
61
62
|
if ('terminal' in customConfig === false) customConfig.terminal = {} as TopkatUtilConfig['terminal']
|
|
62
63
|
const newconfig = {
|
|
63
64
|
...config,
|
|
@@ -71,7 +72,15 @@ export function registerConfig(customConfig: Partial<TopkatUtilConfig>) {
|
|
|
71
72
|
...config?.terminal?.theme,
|
|
72
73
|
...(customConfig?.terminal?.theme || {})
|
|
73
74
|
}
|
|
74
|
-
config =
|
|
75
|
+
config = mergeDeep(config, customConfig)
|
|
75
76
|
|
|
76
|
-
config.isProd = config?.env
|
|
77
|
+
config.isProd = config?.env ? config.env.includes('prod') : true // preprod | production
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
type RecursivePartial<T> = {
|
|
82
|
+
[P in keyof T]?:
|
|
83
|
+
T[P] extends (infer U)[] ? RecursivePartial<U>[] :
|
|
84
|
+
T[P] extends object ? RecursivePartial<T[P]> :
|
|
85
|
+
T[P]
|
|
77
86
|
}
|