@xrystal/core 3.18.7 → 3.19.1
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/package.json +1 -1
- package/source/loader/configs/index.d.ts +1 -0
- package/source/loader/configs/index.js +27 -11
- package/source/loader/logger/index.js +1 -1
- package/source/loader/system/index.d.ts +1 -0
- package/source/loader/system/index.js +1 -0
- package/source/utils/models/classes/class.x.d.ts +2 -2
- package/x/tmp.yml +1 -1
- /package/source/utils/{models/classes/configs.project.d.ts → helpers/configs/index.d.ts} +0 -0
- /package/source/utils/{models/classes/configs.project.js → helpers/configs/index.js} +0 -0
package/package.json
CHANGED
|
@@ -8,20 +8,23 @@ export default class ConfigsService {
|
|
|
8
8
|
#systemService;
|
|
9
9
|
constructor({ systemService }) {
|
|
10
10
|
this.#systemService = systemService;
|
|
11
|
+
return new Proxy(this, {
|
|
12
|
+
get: (target, prop) => {
|
|
13
|
+
if (prop in target)
|
|
14
|
+
return target[prop];
|
|
15
|
+
return target.config[prop];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
11
18
|
}
|
|
12
19
|
load = async ({}) => {
|
|
20
|
+
const cwd = process.cwd();
|
|
13
21
|
const tmp = this.#systemService.tmp;
|
|
14
22
|
const extendConfigs = tmp.configs.loaders.configs.loadPath;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
const fullPath = path.resolve(tmp.configs.rootFolderPath, extendConfigs);
|
|
23
|
-
importedModule = await import(pathToFileURL(fullPath).href);
|
|
24
|
-
}
|
|
23
|
+
const fullPath = extendConfigs.startsWith('@/')
|
|
24
|
+
? path.join(process.cwd(), extendConfigs.slice(2))
|
|
25
|
+
: path.resolve(tmp.configs.rootFolderPath, extendConfigs);
|
|
26
|
+
const fileUrl = pathToFileURL(fullPath).href;
|
|
27
|
+
const modulePromise = import(fileUrl);
|
|
25
28
|
this.config = {
|
|
26
29
|
worker: process.env.WORKER === 'true' ? true : false || false,
|
|
27
30
|
nodeEnv: process.env.NODE_ENV,
|
|
@@ -46,8 +49,18 @@ export default class ConfigsService {
|
|
|
46
49
|
secret: process.env.SECRET,
|
|
47
50
|
cwd,
|
|
48
51
|
env: process.env.NODE_ENV,
|
|
49
|
-
...importedModule.configs,
|
|
50
52
|
};
|
|
53
|
+
try {
|
|
54
|
+
const moduleData = await modulePromise;
|
|
55
|
+
const importedConfigs = moduleData?.default || moduleData?.configs || moduleData || {};
|
|
56
|
+
this.config = {
|
|
57
|
+
...this.config,
|
|
58
|
+
...(typeof importedConfigs === 'object' ? importedConfigs : {})
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
// error
|
|
63
|
+
}
|
|
51
64
|
};
|
|
52
65
|
setConfig(newConfigs) {
|
|
53
66
|
const mergedData = {
|
|
@@ -56,6 +69,9 @@ export default class ConfigsService {
|
|
|
56
69
|
};
|
|
57
70
|
this.config = Object.freeze(mergedData);
|
|
58
71
|
}
|
|
72
|
+
_(key) {
|
|
73
|
+
return this.config[key];
|
|
74
|
+
}
|
|
59
75
|
get all() {
|
|
60
76
|
return this.config;
|
|
61
77
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LifetimeType } from 'awilix';
|
|
2
|
-
declare class X {
|
|
2
|
+
declare class X<T = {}> {
|
|
3
3
|
private container;
|
|
4
4
|
private initializedNames;
|
|
5
5
|
constructor();
|
|
@@ -23,5 +23,5 @@ declare class X {
|
|
|
23
23
|
get cradle(): any;
|
|
24
24
|
private isRegistered;
|
|
25
25
|
}
|
|
26
|
-
declare const _default: X
|
|
26
|
+
declare const _default: X<{}>;
|
|
27
27
|
export default _default;
|
package/x/tmp.yml
CHANGED
|
File without changes
|
|
File without changes
|