@travetto/config 3.4.0-rc.4 → 3.4.0-rc.5

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
@@ -23,9 +23,14 @@ Config loading follows a defined resolution path, below is the order in increasi
23
23
  1. `resources/application.<ext>` - Priority `100` - Load the default `application.<ext>` if available.
24
24
  1. `resources/{env}.<ext>` - Priority `200` - Load environment specific profile configurations as defined by the values of `process.env.TRV_ENV`.
25
25
  1. `resources/*.<ext>` - Priority `300` - Load profile specific configurations as defined by the values in `process.env.TRV_PROFILES`
26
+ 1. [@Injectable](https://github.com/travetto/travetto/tree/main/module/di/src/decorator.ts#L31) [ConfigSource](https://github.com/travetto/travetto/tree/main/module/config/src/source/types.ts#L6) - Priority `???` - These are custom config sources provided by the module, and are able to define their own priorities
27
+ 1. [OverrideConfigSource](https://github.com/travetto/travetto/tree/main/module/config/src/source/override.ts#L11) - 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.
26
28
  By default all configuration data is inert, and will only be applied when constructing an instance of a configuration class.
27
29
 
28
- **Note**: When working in a monorepo, the parent resources folder will also be searched with a lower priority than the the module's specific resources. This allows for shared-global configuration that can be overridden at the module level. The general rule is that the longest path has the highest priority.
30
+ **Note**: When working in a monorepo, the parent resources folder will also be searched with a lower priority than the the module's specific resources. This allows for shared-global configuration that can be overridden at the module level. The general priority is:
31
+ 1. Mono-repo root
32
+ 1. Module root
33
+ 1. Folders for `TRV_RESOURCES`, in order
29
34
 
30
35
  ### A Complete Example
31
36
  A more complete example setup would look like:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/config",
3
- "version": "3.4.0-rc.4",
3
+ "version": "3.4.0-rc.5",
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.4.0-rc.4",
30
- "@travetto/schema": "^3.4.0-rc.4",
31
- "@travetto/yaml": "^3.4.0-rc.4"
29
+ "@travetto/di": "^3.4.0-rc.5",
30
+ "@travetto/schema": "^3.4.0-rc.5",
31
+ "@travetto/yaml": "^3.4.0-rc.5"
32
32
  },
33
33
  "travetto": {
34
34
  "displayName": "Configuration"
@@ -24,21 +24,19 @@ export class FileConfigSource extends FileQueryProvider implements ConfigSource
24
24
  }
25
25
 
26
26
  async getData(): Promise<ConfigData[]> {
27
- const out: { file: string, data: ConfigData }[] = [];
27
+ const out: ConfigData[] = [];
28
28
  for await (const file of this.query(f => this.parser.matches(f))) {
29
29
  const ext = path.extname(file);
30
30
  const base = path.basename(file, ext);
31
31
  if (base === this.profile && !file.includes('/')) { // Ensures no nesting
32
32
  for (const resolved of await this.resolveAll(file)) {
33
- out.push({ file: resolved, data: await this.parser.parse(resolved) });
33
+ // Ensure more specific files are processed later, .resolveAll returns with most specific first
34
+ const data = await this.parser.parse(resolved);
35
+ // eslint-disable-next-line @typescript-eslint/naming-convention
36
+ out.push({ ...data, __ID__: resolved.replace(`${RootIndex.manifest.workspacePath}/`, '') });
34
37
  }
35
38
  }
36
39
  }
37
-
38
- // Ensure more specific files are processed later
39
- return out
40
- .sort((a, b) => (a.file.length - b.file.length) || a.file.localeCompare(b.file))
41
- // eslint-disable-next-line @typescript-eslint/naming-convention
42
- .map(a => ({ ...a.data, __ID__: a.file.replace(`${RootIndex.manifest.workspacePath}/`, '') }));
40
+ return out.reverse();
43
41
  }
44
42
  }