configate 0.1.3 → 0.1.5
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 +9 -0
- package/dist/common.d.ts +15 -0
- package/dist/importConfigFile.js +1 -1
- package/package.json +45 -45
package/README.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# Configate
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/configate)
|
|
4
|
+
[](https://jsr.io/@drob/configate)
|
|
5
|
+
|
|
3
6
|
Configuration helper for TypeScript applications.
|
|
4
7
|
|
|
5
8
|
It acts as a gateway to your configuration, allowing it to be defined in various ways but used only in a single, type-safe manner.
|
|
@@ -20,6 +23,12 @@ Configate supports:
|
|
|
20
23
|
- EcmaScript Modules (ESM) - it works **only** in ESM applications
|
|
21
24
|
- but config files can be in CommonJS format if really necessary
|
|
22
25
|
|
|
26
|
+
## Supported runtimes
|
|
27
|
+
|
|
28
|
+
- Node.js
|
|
29
|
+
- Deno
|
|
30
|
+
- Bun
|
|
31
|
+
|
|
23
32
|
## Installation
|
|
24
33
|
|
|
25
34
|
To install Configate, use your preferred package manager:
|
package/dist/common.d.ts
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
export type DefaultConfig = Record<string, any>;
|
|
2
|
+
/**
|
|
3
|
+
* Environment type represents all allowed application environments
|
|
4
|
+
* string is also allowed to support custom environments
|
|
5
|
+
*/
|
|
2
6
|
export type Environment = 'development' | 'staging' | 'production' | 'test' | string;
|
|
7
|
+
/**
|
|
8
|
+
* FileExtension type represents all allowed file extensions of config files
|
|
9
|
+
*/
|
|
3
10
|
export type FileExtension = 'ts' | 'mts' | 'js' | 'mjs' | 'cjs' | 'json';
|
|
11
|
+
/**
|
|
12
|
+
* DeepPartial allows to make all properties of an object optional recursively
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* type PartialConfig = DeepPartial<YourConfigStructure>
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
4
19
|
export type DeepPartial<T> = T extends object ? {
|
|
5
20
|
[P in keyof T]?: DeepPartial<T[P]>;
|
|
6
21
|
} : T | undefined;
|
package/dist/importConfigFile.js
CHANGED
|
@@ -26,7 +26,7 @@ export async function importConfigFile({ filePath, fileExtensions, shouldThrowEr
|
|
|
26
26
|
}
|
|
27
27
|
const importOptions = selectedExtension === 'json' ? { with: { type: 'json' } } : undefined;
|
|
28
28
|
try {
|
|
29
|
-
const configFile = await import(__rewriteRelativeImportExtension(`${filePath}.${selectedExtension}`), importOptions);
|
|
29
|
+
const configFile = await import(__rewriteRelativeImportExtension(`${filePath}.${selectedExtension}?cacheBuster=${Math.random()}`), importOptions);
|
|
30
30
|
// Named export of `config` variable is preferred over default export
|
|
31
31
|
if (configFile.config) {
|
|
32
32
|
return configFile.config;
|
package/package.json
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
2
|
+
"name": "configate",
|
|
3
|
+
"version": "0.1.5",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Configuration helper for TypeScript applications",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"default": "./dist/index.js",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc",
|
|
18
|
+
"ci": "node --run test && npm run typecheck && node --run lint",
|
|
19
|
+
"lint": "biome check",
|
|
20
|
+
"test": "node --test-isolation=none --test-reporter=spec --experimental-test-coverage --test-coverage-exclude='src/{testConfigDirs/**/*,**/*.test.ts}' --test 'src/**/*.test.ts'",
|
|
21
|
+
"typecheck": "tsc --noEmit"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">= 20"
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/mdrobny/configate.git"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"config"
|
|
35
|
+
],
|
|
36
|
+
"author": "Michal Drobniak",
|
|
37
|
+
"license": "Apache-2.0",
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/mdrobny/configate/issues"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/mdrobny/configate#readme",
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@biomejs/biome": "1.9.4",
|
|
44
|
+
"@types/node": "^22.10.6",
|
|
45
|
+
"typescript": "^5.7.3"
|
|
46
|
+
}
|
|
47
47
|
}
|