@backstage/config
Advanced tools
Comparing version 0.0.0-nightly-20221220022526 to 0.0.0-nightly-20221230022354
# @backstage/config | ||
## 0.0.0-nightly-20221220022526 | ||
## 0.0.0-nightly-20221230022354 | ||
### Patch Changes | ||
- ba2d69ee17: Adds the ability to coerce values to their boolean representatives. | ||
Values such as `"true"` `1` `on` and `y` will become `true` when using `getBoolean` and the opposites `false`. | ||
This happens particularly when such parameters are used with environmental substitution as environment variables are always strings. | ||
- Updated dependencies | ||
- @backstage/types@0.0.0-nightly-20221220022526 | ||
- @backstage/types@1.0.2 | ||
## 1.0.5 | ||
### Patch Changes | ||
- Updated dependencies | ||
- @backstage/types@1.0.2 | ||
## 1.0.5-next.1 | ||
@@ -11,0 +21,0 @@ |
@@ -205,6 +205,17 @@ 'use strict'; | ||
getOptionalBoolean(key) { | ||
return this.readConfigValue( | ||
const value = this.readConfigValue( | ||
key, | ||
(value) => typeof value === "boolean" || { expected: "boolean" } | ||
(val) => typeof val === "boolean" || typeof val === "number" || typeof val === "string" || { expected: "boolean" } | ||
); | ||
if (typeof value === "boolean" || value === void 0) { | ||
return value; | ||
} | ||
const valueString = String(value).trim(); | ||
if (/^(?:y|yes|true|1|on)$/i.test(valueString)) { | ||
return true; | ||
} | ||
if (/^(?:n|no|false|0|off)$/i.test(valueString)) { | ||
return false; | ||
} | ||
throw new Error(errors.convert(this.fullKey(key), this.context, "boolean")); | ||
} | ||
@@ -211,0 +222,0 @@ getString(key) { |
@@ -196,6 +196,17 @@ import cloneDeep from 'lodash/cloneDeep'; | ||
getOptionalBoolean(key) { | ||
return this.readConfigValue( | ||
const value = this.readConfigValue( | ||
key, | ||
(value) => typeof value === "boolean" || { expected: "boolean" } | ||
(val) => typeof val === "boolean" || typeof val === "number" || typeof val === "string" || { expected: "boolean" } | ||
); | ||
if (typeof value === "boolean" || value === void 0) { | ||
return value; | ||
} | ||
const valueString = String(value).trim(); | ||
if (/^(?:y|yes|true|1|on)$/i.test(valueString)) { | ||
return true; | ||
} | ||
if (/^(?:n|no|false|0|off)$/i.test(valueString)) { | ||
return false; | ||
} | ||
throw new Error(errors.convert(this.fullKey(key), this.context, "boolean")); | ||
} | ||
@@ -202,0 +213,0 @@ getString(key) { |
{ | ||
"name": "@backstage/config", | ||
"description": "Config API used by Backstage core, backend, and CLI", | ||
"version": "0.0.0-nightly-20221220022526", | ||
"version": "0.0.0-nightly-20221230022354", | ||
"publishConfig": { | ||
@@ -35,8 +35,8 @@ "access": "public", | ||
"dependencies": { | ||
"@backstage/types": "^0.0.0-nightly-20221220022526", | ||
"@backstage/types": "^1.0.2", | ||
"lodash": "^4.17.21" | ||
}, | ||
"devDependencies": { | ||
"@backstage/cli": "^0.0.0-nightly-20221220022526", | ||
"@backstage/test-utils": "^0.0.0-nightly-20221220022526", | ||
"@backstage/cli": "^0.0.0-nightly-20221230022354", | ||
"@backstage/test-utils": "^0.0.0-nightly-20221230022354", | ||
"@types/node": "^16.0.0" | ||
@@ -43,0 +43,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87551
837
+ Added@backstage/types@1.2.0(transitive)
- Removed@backstage/types@0.0.0-nightly-20241119023621(transitive)
Updated@backstage/types@^1.0.2