@travetto/config 5.0.0-rc.2 → 5.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 CHANGED
@@ -206,7 +206,7 @@ $ trv main doc/dbconfig-run.ts
206
206
  at: '2029-03-14T04:00:00.618Z',
207
207
  details: {
208
208
  class: '@travetto/config:doc/dbconfig○DBConfig',
209
- file: './doc/dbconfig.ts',
209
+ import: '@travetto/config/doc/dbconfig',
210
210
  errors: [
211
211
  {
212
212
  kind: 'required',
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.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": "^5.0.0-rc.2",
30
- "@travetto/schema": "^5.0.0-rc.2",
29
+ "@travetto/di": "^5.0.0-rc.4",
30
+ "@travetto/schema": "^5.0.0-rc.4",
31
31
  "yaml": "^2.4.5"
32
32
  },
33
33
  "travetto": {
package/src/service.ts CHANGED
@@ -126,8 +126,8 @@ export class ConfigurationService {
126
126
  const ogMessage = err.message;
127
127
  err.message = `Failed to construct ${cls.Ⲑid} as validation errors have occurred`;
128
128
  err.stack = err.stack?.replace(ogMessage, err.message);
129
- const file = Runtime.getSource(cls);
130
- Object.defineProperty(err, 'details', { value: { class: cls.Ⲑid, file, ...(err.details ?? {}) } });
129
+ const imp = Runtime.getImport(cls);
130
+ Object.defineProperty(err, 'details', { value: { class: cls.Ⲑid, import: imp, ...(err.details ?? {}) } });
131
131
  }
132
132
  throw err;
133
133
  }
@@ -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
  })));