@platformatic/foundation 3.65.0 → 3.67.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 +1 -0
- package/lib/configuration.js +27 -7
- package/lib/schema.js +4 -0
- package/package.json +6 -4
package/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { JSONSchemaType } from 'ajv'
|
|
|
3
3
|
import { EventEmitter } from 'node:events'
|
|
4
4
|
import { ParseArgsOptionsConfig } from 'node:util'
|
|
5
5
|
import { LevelWithSilentOrString, Logger } from 'pino'
|
|
6
|
+
import type debug from 'debug';
|
|
6
7
|
|
|
7
8
|
// Symbols
|
|
8
9
|
export declare const kCanceled: unique symbol
|
package/lib/configuration.js
CHANGED
|
@@ -513,6 +513,7 @@ export async function loadConfiguration (source, schema, options = {}) {
|
|
|
513
513
|
|
|
514
514
|
if (shouldReplaceEnv) {
|
|
515
515
|
const missingEnv = new Set()
|
|
516
|
+
const fallbackEnv = new Set()
|
|
516
517
|
|
|
517
518
|
config = replaceEnv(
|
|
518
519
|
config,
|
|
@@ -522,6 +523,11 @@ export async function loadConfiguration (source, schema, options = {}) {
|
|
|
522
523
|
|
|
523
524
|
if (typeof value === 'undefined' || value === null) {
|
|
524
525
|
missingEnv.add(key)
|
|
526
|
+
} else {
|
|
527
|
+
// The variable is not set: it only has a value because onMissingEnv provided a fallback.
|
|
528
|
+
// Track it separately so that strictEnv can still report it, as a fallback can silently
|
|
529
|
+
// mask a misconfiguration.
|
|
530
|
+
fallbackEnv.add(key)
|
|
525
531
|
}
|
|
526
532
|
|
|
527
533
|
return value
|
|
@@ -533,17 +539,31 @@ export async function loadConfiguration (source, schema, options = {}) {
|
|
|
533
539
|
// (runtime configurations) or in the runtime property (capabilities configurations).
|
|
534
540
|
const strictEnv = normalizeStrictEnv(strictEnvOption ?? config.strictEnv ?? config.runtime?.strictEnv)
|
|
535
541
|
|
|
542
|
+
function warn (message) {
|
|
543
|
+
if (logger) {
|
|
544
|
+
logger.warn(message)
|
|
545
|
+
} else {
|
|
546
|
+
process.emitWarning(message)
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
// Variables resolved by a fallback are always reported as a warning, never as an error: they did
|
|
551
|
+
// resolve to a value, so failing on them would change which configurations are able to boot.
|
|
552
|
+
// This is emitted before handling the missing ones so that a throw does not swallow it.
|
|
553
|
+
if (strictEnv && fallbackEnv.size > 0) {
|
|
554
|
+
const keys = Array.from(fallbackEnv).sort().join(', ')
|
|
555
|
+
|
|
556
|
+
warn(
|
|
557
|
+
'The configuration references the following environment variables which are not set ' +
|
|
558
|
+
`and have been replaced by a fallback value: ${keys}`
|
|
559
|
+
)
|
|
560
|
+
}
|
|
561
|
+
|
|
536
562
|
if (strictEnv && missingEnv.size > 0) {
|
|
537
563
|
const keys = Array.from(missingEnv).sort().join(', ')
|
|
538
564
|
|
|
539
565
|
if (strictEnv === 'warn') {
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
if (logger) {
|
|
543
|
-
logger.warn(message)
|
|
544
|
-
} else {
|
|
545
|
-
process.emitWarning(message)
|
|
546
|
-
}
|
|
566
|
+
warn(`The configuration references the following environment variables which are not set: ${keys}`)
|
|
547
567
|
} else {
|
|
548
568
|
throw new MissingEnvVariablesError(keys)
|
|
549
569
|
}
|
package/lib/schema.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/foundation",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.67.0",
|
|
4
4
|
"description": "Platformatic Foundation",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -30,10 +30,11 @@
|
|
|
30
30
|
"pino": "^9.9.0",
|
|
31
31
|
"pino-pretty": "^13.0.0",
|
|
32
32
|
"semver": "^7.6.3",
|
|
33
|
-
"undici": "7.28.0",
|
|
33
|
+
"undici": "^7.28.0",
|
|
34
34
|
"yaml": "^2.4.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
+
"@types/debug": "^4.0.0",
|
|
37
38
|
"c8": "^11.0.0",
|
|
38
39
|
"cleaner-spec-reporter": "^0.5.0",
|
|
39
40
|
"eslint": "9",
|
|
@@ -42,7 +43,7 @@
|
|
|
42
43
|
"pino": "^9.9.0",
|
|
43
44
|
"pino-test": "^1.0.1",
|
|
44
45
|
"tstyche": "^6.2.0",
|
|
45
|
-
"typescript": "
|
|
46
|
+
"typescript": "~6.0.3"
|
|
46
47
|
},
|
|
47
48
|
"engines": {
|
|
48
49
|
"node": ">=22.19.0"
|
|
@@ -50,6 +51,7 @@
|
|
|
50
51
|
"scripts": {
|
|
51
52
|
"test": "npm run test:types && node --test --test-reporter=cleaner-spec-reporter --test-concurrency=1 --test-timeout=2000000 test/*.test.js test/**/*.test.js",
|
|
52
53
|
"test:types": "tstyche",
|
|
53
|
-
"lint": "eslint"
|
|
54
|
+
"lint": "eslint",
|
|
55
|
+
"lint:fix": "eslint --fix"
|
|
54
56
|
}
|
|
55
57
|
}
|