@travetto/config 6.0.0-rc.2 → 6.0.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/README.md +2 -0
- package/package.json +4 -4
- package/src/service.ts +12 -12
package/README.md
CHANGED
|
@@ -19,12 +19,14 @@ The config module provides support for loading application config on startup. Co
|
|
|
19
19
|
The configuration information is comprised of:
|
|
20
20
|
* configuration files - [YAML](https://en.wikipedia.org/wiki/YAML), [JSON](https://www.json.org), and basic properties file
|
|
21
21
|
* configuration classes
|
|
22
|
+
|
|
22
23
|
Config loading follows a defined resolution path, below is the order in increasing specificity (`ext` can be `yaml`, `yml`, `json`, `properties`):
|
|
23
24
|
1. `resources/application.<ext>` - Priority `100` - Load the default `application.<ext>` if available.
|
|
24
25
|
1. `resources/{env}.<ext>` - Priority `200` - Load environment specific profile configurations as defined by the values of `process.env.TRV_ENV`.
|
|
25
26
|
1. `resources/*.<ext>` - Priority `300` - Load profile specific configurations as defined by the values in `process.env.TRV_PROFILES`
|
|
26
27
|
1. [@Injectable](https://github.com/travetto/travetto/tree/main/module/di/src/decorator.ts#L29) [ConfigSource](https://github.com/travetto/travetto/tree/main/module/config/src/source/types.ts#L11) - Priority `???` - These are custom config sources provided by the module, and are able to define their own priorities
|
|
27
28
|
1. [OverrideConfigSource](https://github.com/travetto/travetto/tree/main/module/config/src/source/override.ts#L20) - Priority `999` - This is for [EnvVar](https://github.com/travetto/travetto/tree/main/module/config/src/decorator.ts#L34) overrides, and is at the top priority for all built-in config sources.
|
|
29
|
+
|
|
28
30
|
By default all configuration data is inert, and will only be applied when constructing an instance of a configuration class.
|
|
29
31
|
|
|
30
32
|
### Mono Repo Support
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/config",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.1",
|
|
4
4
|
"description": "Configuration support",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"yaml",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"directory": "module/config"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@travetto/di": "^6.0.
|
|
30
|
-
"@travetto/schema": "^6.0.
|
|
31
|
-
"yaml": "^2.
|
|
29
|
+
"@travetto/di": "^6.0.1",
|
|
30
|
+
"@travetto/schema": "^6.0.1",
|
|
31
|
+
"yaml": "^2.8.1"
|
|
32
32
|
},
|
|
33
33
|
"travetto": {
|
|
34
34
|
"displayName": "Configuration"
|
package/src/service.ts
CHANGED
|
@@ -31,7 +31,7 @@ export class ConfigurationService {
|
|
|
31
31
|
* Get a sub tree of the config, or everything if namespace is not passed
|
|
32
32
|
* @param ns The namespace of the config to search for, can be dotted for accessing sub namespaces
|
|
33
33
|
*/
|
|
34
|
-
#get
|
|
34
|
+
#get<T extends Record<string, unknown> = Record<string, unknown>>(ns?: string): T {
|
|
35
35
|
const parts = (ns ? ns.split('.') : []);
|
|
36
36
|
let sub: Record<string, unknown> = this.#storage;
|
|
37
37
|
|
|
@@ -40,7 +40,7 @@ export class ConfigurationService {
|
|
|
40
40
|
sub = castTo(sub[next]);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
return sub;
|
|
43
|
+
return castTo(sub);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
@@ -76,9 +76,9 @@ export class ConfigurationService {
|
|
|
76
76
|
this.#specs = specs.map(({ data: _, ...v }) => v);
|
|
77
77
|
|
|
78
78
|
// Initialize Secrets
|
|
79
|
-
const
|
|
80
|
-
for (const el of
|
|
81
|
-
if (
|
|
79
|
+
const { secrets = [] } = this.#get<{ secrets?: string | string[] }>('config') ?? {};
|
|
80
|
+
for (const el of [secrets].flat()) {
|
|
81
|
+
if (typeof el === 'string') {
|
|
82
82
|
if (el.startsWith('/')) {
|
|
83
83
|
this.#secrets.push(DataUtil.coerceType(el, RegExp, true));
|
|
84
84
|
} else {
|
|
@@ -140,13 +140,10 @@ export class ConfigurationService {
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
|
-
*
|
|
143
|
+
* Produce the visible configuration state and runtime information
|
|
144
144
|
*/
|
|
145
|
-
async initBanner(): Promise<
|
|
146
|
-
|
|
147
|
-
util.inspect.defaultOptions.depth = 100;
|
|
148
|
-
|
|
149
|
-
console.log('Initialized', {
|
|
145
|
+
async initBanner(): Promise<string> {
|
|
146
|
+
return util.inspect({
|
|
150
147
|
manifest: {
|
|
151
148
|
main: Runtime.main,
|
|
152
149
|
workspace: Runtime.workspace
|
|
@@ -160,7 +157,10 @@ export class ConfigurationService {
|
|
|
160
157
|
profiles: Env.TRV_PROFILES.list ?? []
|
|
161
158
|
},
|
|
162
159
|
config: await this.exportActive()
|
|
160
|
+
}, {
|
|
161
|
+
...util.inspect.defaultOptions,
|
|
162
|
+
depth: 100,
|
|
163
|
+
colors: false, // Colors are not useful in logs
|
|
163
164
|
});
|
|
164
|
-
util.inspect.defaultOptions.depth = ogDepth;
|
|
165
165
|
}
|
|
166
166
|
}
|