@travetto/config 7.0.0-rc.2 → 7.0.0-rc.4
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 -1
- package/package.json +3 -3
- package/src/parser/json.ts +2 -1
- package/src/service.ts +1 -2
- package/src/source/env.ts +2 -1
package/README.md
CHANGED
|
@@ -124,6 +124,7 @@ export class MemoryConfigSource implements ConfigSource {
|
|
|
124
124
|
|
|
125
125
|
**Code: Environment JSON Provider**
|
|
126
126
|
```typescript
|
|
127
|
+
import { JSONUtil } from '@travetto/runtime';
|
|
127
128
|
import { ConfigSource, ConfigPayload } from './types.ts';
|
|
128
129
|
|
|
129
130
|
/**
|
|
@@ -140,7 +141,7 @@ export class EnvConfigSource implements ConfigSource {
|
|
|
140
141
|
|
|
141
142
|
get(): ConfigPayload | undefined {
|
|
142
143
|
try {
|
|
143
|
-
const data =
|
|
144
|
+
const data: Record<string, unknown> = JSONUtil.parseSafe(process.env[this.#envKey] || '{}');
|
|
144
145
|
return { data, priority: this.#priority, source: `env://${this.#envKey}` };
|
|
145
146
|
} catch {
|
|
146
147
|
console.error(`env.${this.#envKey} is an invalid format`, { text: process.env[this.#envKey] });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/config",
|
|
3
|
-
"version": "7.0.0-rc.
|
|
3
|
+
"version": "7.0.0-rc.4",
|
|
4
4
|
"description": "Configuration support",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"yaml",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"directory": "module/config"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@travetto/di": "^7.0.0-rc.
|
|
30
|
-
"@travetto/schema": "^7.0.0-rc.
|
|
29
|
+
"@travetto/di": "^7.0.0-rc.4",
|
|
30
|
+
"@travetto/schema": "^7.0.0-rc.4",
|
|
31
31
|
"yaml": "^2.8.1"
|
|
32
32
|
},
|
|
33
33
|
"travetto": {
|
package/src/parser/json.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Injectable } from '@travetto/di';
|
|
2
|
+
import { JSONUtil } from '@travetto/runtime';
|
|
2
3
|
|
|
3
4
|
import { ConfigParser } from './types.ts';
|
|
4
5
|
|
|
5
6
|
@Injectable()
|
|
6
7
|
export class JSONConfigParser implements ConfigParser {
|
|
7
8
|
ext = ['.json'];
|
|
8
|
-
parse =
|
|
9
|
+
parse = JSONUtil.parseSafe;
|
|
9
10
|
}
|
package/src/service.ts
CHANGED
|
@@ -150,9 +150,8 @@ export class ConfigurationService {
|
|
|
150
150
|
},
|
|
151
151
|
runtime: {
|
|
152
152
|
env: Runtime.env,
|
|
153
|
+
envType: Runtime.envType,
|
|
153
154
|
debug: Runtime.debug,
|
|
154
|
-
production: Runtime.production,
|
|
155
|
-
dynamic: Runtime.dynamic,
|
|
156
155
|
resourcePaths: RuntimeResources.searchPaths,
|
|
157
156
|
profiles: Env.TRV_PROFILES.list ?? []
|
|
158
157
|
},
|
package/src/source/env.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { JSONUtil } from '@travetto/runtime';
|
|
1
2
|
import { ConfigSource, ConfigPayload } from './types.ts';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -14,7 +15,7 @@ export class EnvConfigSource implements ConfigSource {
|
|
|
14
15
|
|
|
15
16
|
get(): ConfigPayload | undefined {
|
|
16
17
|
try {
|
|
17
|
-
const data =
|
|
18
|
+
const data: Record<string, unknown> = JSONUtil.parseSafe(process.env[this.#envKey] || '{}');
|
|
18
19
|
return { data, priority: this.#priority, source: `env://${this.#envKey}` };
|
|
19
20
|
} catch {
|
|
20
21
|
console.error(`env.${this.#envKey} is an invalid format`, { text: process.env[this.#envKey] });
|