@meltstudio/config-loader 1.0.3 → 1.0.4
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 +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +10 -10
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
# Config Loader
|
|
2
|
+
> ⚠️ **WARNING**: This project is in beta, so some features may change in the future. Use at your own discretion
|
|
3
|
+
|
|
2
4
|
## Project Description
|
|
3
5
|
|
|
4
6
|
The Config Loader package is a powerful and user-friendly tool that simplifies the process of retrieving and collecting variables from one or multiple files for your project. It provides an efficient way to extract specific information from files and access those variables in your code. The result is a JSON object, making it easy to work with in various applications.
|
package/dist/index.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ declare class ArrayValueContainer {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
type Value = boolean | string | number | object | InvalidValue;
|
|
40
|
-
type DefaultValue = Value | (() => string) | (() => number);
|
|
40
|
+
type DefaultValue = Value | (() => string) | (() => number) | (() => boolean);
|
|
41
41
|
type RecursiveNode<T> = {
|
|
42
42
|
[key: string]: OptionBase | T;
|
|
43
43
|
};
|
package/dist/index.js
CHANGED
|
@@ -231,10 +231,18 @@ var OptionBase = class {
|
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
233
|
if (this.params.defaultValue !== void 0) {
|
|
234
|
+
let defaultValue;
|
|
234
235
|
if (typeof this.params.defaultValue === "function") {
|
|
236
|
+
defaultValue = this.params.defaultValue();
|
|
237
|
+
} else {
|
|
238
|
+
defaultValue = this.params.defaultValue;
|
|
239
|
+
}
|
|
240
|
+
if (this.params.kind === "array" && Array.isArray(defaultValue)) {
|
|
241
|
+
defaultValue = this.buildArrayOption(defaultValue);
|
|
242
|
+
}
|
|
243
|
+
if (!valueIsInvalid(defaultValue)) {
|
|
235
244
|
return new configNode_default(
|
|
236
|
-
|
|
237
|
-
this.checkType(this.params.defaultValue(), path, "default"),
|
|
245
|
+
this.checkType(defaultValue, path, "default"),
|
|
238
246
|
ident,
|
|
239
247
|
"default",
|
|
240
248
|
null,
|
|
@@ -242,14 +250,6 @@ var OptionBase = class {
|
|
|
242
250
|
null
|
|
243
251
|
);
|
|
244
252
|
}
|
|
245
|
-
return new configNode_default(
|
|
246
|
-
this.checkType(this.params.defaultValue, path, "default"),
|
|
247
|
-
ident,
|
|
248
|
-
"default",
|
|
249
|
-
null,
|
|
250
|
-
null,
|
|
251
|
-
null
|
|
252
|
-
);
|
|
253
253
|
}
|
|
254
254
|
if (this.params.required) {
|
|
255
255
|
OptionErrors.errors.push(`Required option '${ident}' not provided.`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meltstudio/config-loader",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Melt Studio's tool for loading configurations into a Node.js application.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -25,7 +25,10 @@
|
|
|
25
25
|
"type-check": "tsc --noEmit",
|
|
26
26
|
"test": "jest --verbose",
|
|
27
27
|
"example:run": "ts-node -r tsconfig-paths/register ./example/index.ts",
|
|
28
|
-
"prepare": "husky install"
|
|
28
|
+
"prepare": "husky install",
|
|
29
|
+
"docs:install": "python -m venv ./mkdocs-py-env && ./mkdocs-py-env/Scripts/pip install -r ./mkdocs-requirements.txt",
|
|
30
|
+
"docs:build": "./mkdocs-py-env/Scripts/mkdocs build",
|
|
31
|
+
"docs:serve": "./mkdocs-py-env/Scripts/mkdocs serve"
|
|
29
32
|
},
|
|
30
33
|
"dependencies": {
|
|
31
34
|
"@types/js-yaml": "^4.0.5",
|