@platformatic/foundation 3.64.0 → 3.65.0

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/index.d.ts CHANGED
@@ -6,6 +6,7 @@ import { LevelWithSilentOrString, Logger } from 'pino'
6
6
 
7
7
  // Symbols
8
8
  export declare const kCanceled: unique symbol
9
+ export declare const kEnvFileFallbackKeys: unique symbol
9
10
  export declare const kFailedImport: unique symbol
10
11
  export declare const kHandledError: unique symbol
11
12
  export declare const kMetadata: unique symbol
@@ -18,7 +18,7 @@ import {
18
18
  } from './errors.js'
19
19
  import { isFileAccessible } from './file-system.js'
20
20
  import { loadModule, splitModuleFromVersion } from './module.js'
21
- import { kMetadata } from './symbols.js'
21
+ import { kEnvFileFallbackKeys, kMetadata } from './symbols.js'
22
22
 
23
23
  const { parse: parseJSON5, stringify: rawStringifyJSON5 } = JSON5
24
24
  const { parse: parseTOML, stringify: stringifyTOML } = toml
@@ -386,11 +386,21 @@ export async function loadEnv (root, ignoreProcessEnv = false, additionalEnv = {
386
386
  // The env file provides fallback defaults: variables already set in the real
387
387
  // environment (and explicit programmatic values) take precedence over it,
388
388
  // matching the dotenv/docker-compose/Vite convention.
389
- return {
389
+ const env = {
390
390
  ...envFromFile,
391
391
  ...baseEnv,
392
392
  ...additionalEnv
393
393
  }
394
+
395
+ // Keys whose only source is the env file are not real environment variables, they are defaults:
396
+ // a more specific env file, like the one of a single application inside a runtime, must still be
397
+ // able to override them. The list is attached non enumerably, so spreading, Object.keys,
398
+ // JSON.stringify and structuredClone of the returned environment are all unchanged.
399
+ const fallbackKeys = Object.keys(envFromFile).filter(key => !(key in baseEnv) && !(key in additionalEnv))
400
+
401
+ Object.defineProperty(env, kEnvFileFallbackKeys, { value: fallbackKeys, enumerable: false })
402
+
403
+ return env
394
404
  }
395
405
 
396
406
  export function replaceEnv (config, env, onMissingEnv, ignore) {
package/lib/symbols.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export const kCanceled = Symbol('plt.foundation.canceled')
2
+ export const kEnvFileFallbackKeys = Symbol('plt.foundation.envFileFallbackKeys')
2
3
  export const kFailedImport = Symbol('plt.foundation.failedImport')
3
4
  export const kHandledError = Symbol('plt.foundation.handledError')
4
5
  export const kMetadata = Symbol('plt.foundation.metadata')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/foundation",
3
- "version": "3.64.0",
3
+ "version": "3.65.0",
4
4
  "description": "Platformatic Foundation",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",