@travetto/config 3.0.0-rc.6 → 3.0.0-rc.7
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 +4 -4
- package/src/source/file.ts +13 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/config",
|
|
3
|
-
"version": "3.0.0-rc.
|
|
3
|
+
"version": "3.0.0-rc.7",
|
|
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": "^3.0.0-rc.
|
|
30
|
-
"@travetto/schema": "^3.0.0-rc.
|
|
31
|
-
"@travetto/yaml": "^3.0.0-rc.
|
|
29
|
+
"@travetto/di": "^3.0.0-rc.7",
|
|
30
|
+
"@travetto/schema": "^3.0.0-rc.7",
|
|
31
|
+
"@travetto/yaml": "^3.0.0-rc.5"
|
|
32
32
|
},
|
|
33
33
|
"travetto": {
|
|
34
34
|
"displayName": "Configuration"
|
package/src/source/file.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DependencyRegistry,
|
|
1
|
+
import { FileQueryProvider } from '@travetto/base';
|
|
2
|
+
import { DependencyRegistry, InjectableFactory } from '@travetto/di';
|
|
3
3
|
|
|
4
4
|
import { ConfigParserTarget } from '../internal/types';
|
|
5
5
|
import { ConfigParser } from '../parser/types';
|
|
@@ -8,14 +8,22 @@ import { ConfigSource, ConfigValue } from './types';
|
|
|
8
8
|
/**
|
|
9
9
|
* File-base config source, builds on common file resource provider
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
export class FileConfigSource extends FileQueryProvider implements ConfigSource {
|
|
12
|
+
|
|
13
|
+
@InjectableFactory()
|
|
14
|
+
static getInstance(): ConfigSource {
|
|
15
|
+
return new FileConfigSource();
|
|
16
|
+
}
|
|
13
17
|
|
|
14
18
|
depth = 1;
|
|
15
19
|
extMatch: RegExp;
|
|
16
20
|
parsers: Record<string, ConfigParser>;
|
|
17
21
|
priority = 1;
|
|
18
22
|
|
|
23
|
+
constructor(paths: string[] = []) {
|
|
24
|
+
super({ includeCommon: true, paths });
|
|
25
|
+
}
|
|
26
|
+
|
|
19
27
|
async postConstruct(): Promise<void> {
|
|
20
28
|
const parserClasses = await DependencyRegistry.getCandidateTypes(ConfigParserTarget);
|
|
21
29
|
const parsers = await Promise.all(parserClasses.map(x => DependencyRegistry.getInstance<ConfigParser>(x.class, x.qualifier)));
|
|
@@ -34,7 +42,7 @@ export class FileConfigSource extends CommonFileResourceProvider implements Conf
|
|
|
34
42
|
async getValues(profiles: string[]): Promise<ConfigValue[]> {
|
|
35
43
|
const out: ConfigValue[] = [];
|
|
36
44
|
|
|
37
|
-
for (const file of
|
|
45
|
+
for await (const file of this.query(f => this.extMatch.test(f))) {
|
|
38
46
|
const ext = file.split('.')[1];
|
|
39
47
|
const profile = file.replace(`.${ext}`, '');
|
|
40
48
|
if (!profiles.includes(profile) || !this.parsers[ext]) {
|