@strapi/utils 4.8.1 → 4.9.0-exp.90df253ba90fd6879eb56a720a1f80d04ff745b8
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/lib/env-helper.js +20 -0
- package/package.json +2 -2
- package/coverage/clover.xml +0 -638
- package/coverage/coverage-final.json +0 -24
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -146
- package/coverage/lcov-report/lib/async.js.html +0 -223
- package/coverage/lcov-report/lib/content-types.js.html +0 -643
- package/coverage/lcov-report/lib/env-helper.js.html +0 -319
- package/coverage/lcov-report/lib/errors.js.html +0 -397
- package/coverage/lcov-report/lib/format-yup-error.js.html +0 -145
- package/coverage/lcov-report/lib/hooks.js.html +0 -415
- package/coverage/lcov-report/lib/import-default.js.html +0 -115
- package/coverage/lcov-report/lib/index.html +0 -326
- package/coverage/lcov-report/lib/pagination.js.html +0 -382
- package/coverage/lcov-report/lib/parse-type.js.html +0 -385
- package/coverage/lcov-report/lib/policy.js.html +0 -472
- package/coverage/lcov-report/lib/print-value.js.html +0 -241
- package/coverage/lcov-report/lib/provider-factory.js.html +0 -433
- package/coverage/lcov-report/lib/relations.js.html +0 -178
- package/coverage/lcov-report/lib/sanitize/visitors/allowed-fields.js.html +0 -367
- package/coverage/lcov-report/lib/sanitize/visitors/index.html +0 -191
- package/coverage/lcov-report/lib/sanitize/visitors/index.js.html +0 -112
- package/coverage/lcov-report/lib/sanitize/visitors/remove-password.js.html +0 -106
- package/coverage/lcov-report/lib/sanitize/visitors/remove-private.js.html +0 -118
- package/coverage/lcov-report/lib/sanitize/visitors/remove-restricted-relations.js.html +0 -316
- package/coverage/lcov-report/lib/sanitize/visitors/restricted-fields.js.html +0 -181
- package/coverage/lcov-report/lib/string-formatting.js.html +0 -322
- package/coverage/lcov-report/lib/validators.js.html +0 -445
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
package/lib/env-helper.js
CHANGED
|
@@ -71,6 +71,26 @@ const utils = {
|
|
|
71
71
|
const value = process.env[key];
|
|
72
72
|
return new Date(value);
|
|
73
73
|
},
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Gets a value from env that matches oneOf provided values
|
|
77
|
+
* @param {string} key
|
|
78
|
+
* @param {string[]} expectedValues
|
|
79
|
+
* @param {string|undefined} defaultValue
|
|
80
|
+
* @returns {string|undefined}
|
|
81
|
+
*/
|
|
82
|
+
oneOf(key, expectedValues, defaultValue) {
|
|
83
|
+
if (!expectedValues) {
|
|
84
|
+
throw new Error(`env.oneOf requires expectedValues`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (defaultValue && !expectedValues.includes(defaultValue)) {
|
|
88
|
+
throw new Error(`env.oneOf requires defaultValue to be included in expectedValues`);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const rawValue = env(key, defaultValue);
|
|
92
|
+
return expectedValues.includes(rawValue) ? rawValue : defaultValue;
|
|
93
|
+
},
|
|
74
94
|
};
|
|
75
95
|
|
|
76
96
|
Object.assign(env, utils);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/utils",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.9.0-exp.90df253ba90fd6879eb56a720a1f80d04ff745b8",
|
|
4
4
|
"description": "Shared utilities for the Strapi packages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"node": ">=14.19.1 <=18.x.x",
|
|
47
47
|
"npm": ">=6.0.0"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "366eb8a0d0f06935914854c6d9c4b3fe859468e0"
|
|
50
50
|
}
|