@itgorillaz/configify 1.1.3 → 1.2.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/dist/src/configify.module.js +1 -1
- package/dist/src/configify.module.js.map +1 -1
- package/dist/src/configuration/configuration.registry.js.map +1 -1
- package/dist/src/configuration/parsers/configuration-parser.factory.js +1 -1
- package/dist/src/configuration/parsers/configuration-parser.factory.js.map +1 -1
- package/dist/src/configuration/parsers/yaml-configuration.parser.js.map +1 -1
- package/dist/src/configuration/resolvers/aws/parameter-store-configuration.resolver.js +1 -1
- package/dist/src/configuration/resolvers/aws/parameter-store-configuration.resolver.js.map +1 -1
- package/dist/src/configuration/resolvers/aws/secrets-manager-configuration.resolver.js +1 -1
- package/dist/src/configuration/resolvers/aws/secrets-manager-configuration.resolver.js.map +1 -1
- package/dist/src/interpolation/variables.d.ts +1 -1
- package/dist/src/interpolation/variables.js +8 -2
- package/dist/src/interpolation/variables.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/configify.module.ts +2 -2
- package/src/configuration/configuration.registry.ts +1 -1
- package/src/configuration/parsers/configuration-parser.factory.ts +4 -4
- package/src/configuration/parsers/yaml-configuration.parser.ts +1 -1
- package/src/configuration/resolvers/aws/parameter-store-configuration.resolver.ts +1 -1
- package/src/configuration/resolvers/aws/secrets-manager-configuration.resolver.ts +1 -1
- package/src/interpolation/variables.ts +15 -9
- package/tsconfig.json +5 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itgorillaz/configify",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "NestJS Config on Steroids",
|
|
5
5
|
"author": "tommelo",
|
|
6
6
|
"private": false,
|
|
@@ -42,21 +42,21 @@
|
|
|
42
42
|
"@nestjs/cli": "^10.3.2",
|
|
43
43
|
"@nestjs/schematics": "^10.1.1",
|
|
44
44
|
"@nestjs/testing": "^10.3.7",
|
|
45
|
-
"@types/jest": "29.5.
|
|
45
|
+
"@types/jest": "29.5.14",
|
|
46
46
|
"@types/js-yaml": "^4.0.9",
|
|
47
|
-
"@types/node": "
|
|
47
|
+
"@types/node": "22.9.0",
|
|
48
48
|
"@types/supertest": "^6.0.2",
|
|
49
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
50
|
-
"@typescript-eslint/parser": "^
|
|
49
|
+
"@typescript-eslint/eslint-plugin": "^8.1.0",
|
|
50
|
+
"@typescript-eslint/parser": "^8.1.0",
|
|
51
51
|
"eslint": "^8.0.0 || ^9.0.0",
|
|
52
52
|
"eslint-config-prettier": "^9.1.0",
|
|
53
53
|
"eslint-plugin-prettier": "^5.1.3",
|
|
54
54
|
"jest": "29.7.0",
|
|
55
55
|
"prettier": "^3.2.5",
|
|
56
|
-
"prettier-plugin-organize-imports": "^
|
|
56
|
+
"prettier-plugin-organize-imports": "^4.0.0",
|
|
57
57
|
"source-map-support": "^0.5.20",
|
|
58
58
|
"supertest": "^7.0.0",
|
|
59
|
-
"ts-jest": "29.
|
|
59
|
+
"ts-jest": "29.2.5",
|
|
60
60
|
"ts-loader": "^9.2.3",
|
|
61
61
|
"ts-node": "^10.0.0",
|
|
62
62
|
"tsconfig-paths": "4.2.0",
|
package/src/configify.module.ts
CHANGED
|
@@ -231,8 +231,8 @@ export class ConfigifyModule {
|
|
|
231
231
|
* @returns {string[]} list of configuration files
|
|
232
232
|
*/
|
|
233
233
|
private static resolveConfigurationFiles(path?: string | string[]): string[] {
|
|
234
|
-
return []
|
|
235
|
-
.concat(path, this.DEFAULT_CONFIG_FILES)
|
|
234
|
+
return ([] as string[])
|
|
235
|
+
.concat(path || [], this.DEFAULT_CONFIG_FILES)
|
|
236
236
|
.filter(
|
|
237
237
|
(file) =>
|
|
238
238
|
fs.existsSync(file) && ConfigurationParserFactory.supports(file),
|
|
@@ -12,7 +12,7 @@ export class ConfigurationParserFactory {
|
|
|
12
12
|
/**
|
|
13
13
|
* The supported file configuration parsers
|
|
14
14
|
*/
|
|
15
|
-
private static readonly parsers = {
|
|
15
|
+
private static readonly parsers: Record<string, ConfigurationParser> = {
|
|
16
16
|
env: new DotEnvConfigurationParser(),
|
|
17
17
|
yml: new YamlConfigurationParser(),
|
|
18
18
|
yaml: new YamlConfigurationParser(),
|
|
@@ -26,7 +26,7 @@ export class ConfigurationParserFactory {
|
|
|
26
26
|
* @returns {ConfigurationParser} the configuration parser
|
|
27
27
|
*/
|
|
28
28
|
static getParser(file: string): ConfigurationParser {
|
|
29
|
-
const ext = this.getFileExt(file);
|
|
29
|
+
const ext = this.getFileExt(file) as keyof typeof this.parsers;
|
|
30
30
|
return this.parsers[ext];
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -38,7 +38,7 @@ export class ConfigurationParserFactory {
|
|
|
38
38
|
*/
|
|
39
39
|
static supports(file: string): boolean {
|
|
40
40
|
const ext = this.getFileExt(file);
|
|
41
|
-
return this.parsers.hasOwnProperty(ext);
|
|
41
|
+
return ext ? this.parsers.hasOwnProperty(ext) : false;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
@@ -47,7 +47,7 @@ export class ConfigurationParserFactory {
|
|
|
47
47
|
* @param {string} file the file name
|
|
48
48
|
* @returns {string} the file extension
|
|
49
49
|
*/
|
|
50
|
-
private static getFileExt(file: string): string {
|
|
50
|
+
private static getFileExt(file: string): string | undefined {
|
|
51
51
|
return file.split('.').pop();
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -13,6 +13,6 @@ export class YamlConfigurationParser implements ConfigurationParser {
|
|
|
13
13
|
* @returns {Record<string, any>} an object representation of the configuration file
|
|
14
14
|
*/
|
|
15
15
|
public parse(file: string): Record<string, any> {
|
|
16
|
-
return yaml.load(fs.readFileSync(file, 'utf-8'))
|
|
16
|
+
return yaml.load(fs.readFileSync(file, 'utf-8')) as Record<string, any>;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -36,7 +36,7 @@ export class AwsParameterStoreConfigurationResolver
|
|
|
36
36
|
if (errors && errors.length) {
|
|
37
37
|
throw new Error(
|
|
38
38
|
`Unable to resolve parameter:\n${errors
|
|
39
|
-
.map((e) => `${e.key}: ${e.id} - ${e.error
|
|
39
|
+
.map((e) => `${e.key}: ${e.id} - ${e.error?.message}`)
|
|
40
40
|
.join('\n')}`,
|
|
41
41
|
);
|
|
42
42
|
}
|
|
@@ -39,7 +39,7 @@ export class AwsSecretsManagerConfigurationResolver
|
|
|
39
39
|
if (errors && errors.length) {
|
|
40
40
|
throw new Error(
|
|
41
41
|
`Unable to resolve secrets:\n${errors
|
|
42
|
-
.map((e) => `${e.key}: ${e.id} - ${e.error
|
|
42
|
+
.map((e) => `${e.key}: ${e.id} - ${e.error?.message}`)
|
|
43
43
|
.join('\n')}`,
|
|
44
44
|
);
|
|
45
45
|
}
|
|
@@ -33,14 +33,18 @@ export class Variables {
|
|
|
33
33
|
/**
|
|
34
34
|
* Expands the variables of the given object.
|
|
35
35
|
*
|
|
36
|
-
* @param {Record<string,
|
|
37
|
-
* @returns {Record<string,
|
|
36
|
+
* @param {Record<string, unknown>} record The object
|
|
37
|
+
* @returns {Record<string, unknown>} The expanded object
|
|
38
38
|
*/
|
|
39
|
-
static expand(record: Record<string,
|
|
40
|
-
const expanded = {};
|
|
39
|
+
static expand(record: Record<string, unknown>): Record<string, unknown> {
|
|
40
|
+
const expanded: Record<string, unknown> = {};
|
|
41
41
|
for (const key in record) {
|
|
42
42
|
const value = record[key];
|
|
43
|
-
|
|
43
|
+
const interpolated = this.interpolate(value, record);
|
|
44
|
+
expanded[key] =
|
|
45
|
+
typeof interpolated === 'string'
|
|
46
|
+
? this.escapeSequences(interpolated)
|
|
47
|
+
: interpolated;
|
|
44
48
|
}
|
|
45
49
|
return expanded;
|
|
46
50
|
}
|
|
@@ -53,9 +57,11 @@ export class Variables {
|
|
|
53
57
|
* @returns
|
|
54
58
|
*/
|
|
55
59
|
private static interpolate(
|
|
56
|
-
value:
|
|
57
|
-
record: Record<string,
|
|
58
|
-
):
|
|
60
|
+
value: unknown,
|
|
61
|
+
record: Record<string, unknown>,
|
|
62
|
+
): unknown {
|
|
63
|
+
if (typeof value !== 'string') return value;
|
|
64
|
+
|
|
59
65
|
const lastUnescapedDollarSignIndex = this.lastIndexOf(
|
|
60
66
|
value,
|
|
61
67
|
this.UNESCAPED_PATTERN,
|
|
@@ -69,7 +75,7 @@ export class Variables {
|
|
|
69
75
|
if (match != null) {
|
|
70
76
|
const [, group, variableName, defaultValue] = match;
|
|
71
77
|
return this.interpolate(
|
|
72
|
-
value.replace(group, defaultValue || record[variableName] || ''),
|
|
78
|
+
value.replace(group, defaultValue || `${record[variableName]}` || ''),
|
|
73
79
|
record,
|
|
74
80
|
);
|
|
75
81
|
}
|
package/tsconfig.json
CHANGED
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"baseUrl": "./",
|
|
13
13
|
"incremental": true,
|
|
14
14
|
"skipLibCheck": true,
|
|
15
|
-
"strictNullChecks":
|
|
16
|
-
"noImplicitAny":
|
|
17
|
-
"strictBindCallApply":
|
|
18
|
-
"forceConsistentCasingInFileNames":
|
|
19
|
-
"noFallthroughCasesInSwitch":
|
|
15
|
+
"strictNullChecks": true,
|
|
16
|
+
"noImplicitAny": true,
|
|
17
|
+
"strictBindCallApply": true,
|
|
18
|
+
"forceConsistentCasingInFileNames": true,
|
|
19
|
+
"noFallthroughCasesInSwitch": true
|
|
20
20
|
}
|
|
21
21
|
}
|