@travetto/config 5.0.0-rc.2 → 5.0.0-rc.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/config",
3
- "version": "5.0.0-rc.2",
3
+ "version": "5.0.0-rc.3",
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": "^5.0.0-rc.2",
30
- "@travetto/schema": "^5.0.0-rc.2",
29
+ "@travetto/di": "^5.0.0-rc.3",
30
+ "@travetto/schema": "^5.0.0-rc.3",
31
31
  "yaml": "^2.4.5"
32
32
  },
33
33
  "travetto": {
package/src/service.ts CHANGED
@@ -148,7 +148,7 @@ export class ConfigurationService {
148
148
  workspace: Runtime.workspace
149
149
  },
150
150
  runtime: {
151
- name: Runtime.name,
151
+ name: Runtime.envName,
152
152
  debug: Runtime.debug,
153
153
  production: Runtime.production,
154
154
  dynamic: Runtime.dynamic,
@@ -22,7 +22,7 @@ export class FileConfigSource implements ConfigSource {
22
22
  this.#searchPaths = RuntimeResources.searchPaths.slice().reverse();
23
23
  this.#profiles = ([
24
24
  ['application', 100],
25
- [Runtime.name!, 200],
25
+ [Runtime.envName!, 200],
26
26
  ...(Env.TRV_PROFILES.list ?? [])
27
27
  .map((p, i) => [p, 300 + i * 10] as const)
28
28
  ] as const).filter(x => !!x[0]);
@@ -31,16 +31,18 @@ export class FileConfigSource implements ConfigSource {
31
31
  async get(): Promise<ConfigSpec[]> {
32
32
  const cache: Record<string, Promise<string[]>> = {};
33
33
  const configs: Promise<ConfigSpec>[] = [];
34
+
34
35
  for (const [profile, priority] of this.#profiles) {
35
- let i = 0;
36
+ let i = priority;
36
37
  for (const folder of this.#searchPaths) {
37
38
  const files = await (cache[folder] ??= fs.readdir(folder).catch(() => []));
38
39
  for (const file of files) {
39
40
  if (this.#parser.matches(file) && path.basename(file, path.extname(file)) === profile) {
40
41
  const full = path.resolve(folder, file);
42
+ const configPriority = i++;
41
43
  configs.push(this.#parser.parse(full).then(data => ({
42
44
  data,
43
- priority: priority + i++,
45
+ priority: configPriority,
44
46
  source: `file://${profile}`,
45
47
  detail: Runtime.stripWorkspacePath(full)
46
48
  })));