@spinajs/configuration 1.1.7 → 1.2.12
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/config/configuration.js +3 -3
- package/lib/config/configuration.js.map +1 -1
- package/lib/configuration.d.ts +11 -10
- package/lib/configuration.js +73 -16
- package/lib/configuration.js.map +1 -1
- package/lib/decorators.d.ts +3 -3
- package/lib/decorators.js +4 -3
- package/lib/decorators.js.map +1 -1
- package/lib/exception.d.ts +5 -0
- package/lib/exception.js +11 -0
- package/lib/exception.js.map +1 -0
- package/lib/index.d.ts +5 -5
- package/lib/index.js +14 -1
- package/lib/index.js.map +1 -1
- package/lib/sources.d.ts +1 -1
- package/lib/sources.js +24 -16
- package/lib/sources.js.map +1 -1
- package/lib/types.d.ts +9 -3
- package/lib/types.js.map +1 -1
- package/lib/util.d.ts +1 -1
- package/lib/util.js +3 -1
- package/lib/util.js.map +1 -1
- package/package.json +11 -30
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const config = {
|
|
4
4
|
configuration: {
|
|
5
|
-
isDevelopment: process.env.NODE_ENV ===
|
|
6
|
-
isProduction: process.env.NODE_ENV ===
|
|
7
|
-
}
|
|
5
|
+
isDevelopment: process.env.NODE_ENV === 'development',
|
|
6
|
+
isProduction: process.env.NODE_ENV === 'production',
|
|
7
|
+
},
|
|
8
8
|
};
|
|
9
9
|
exports.default = config;
|
|
10
10
|
//# sourceMappingURL=configuration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../src/config/configuration.ts"],"names":[],"mappings":";;AAAA,MAAM,MAAM,GAAG;
|
|
1
|
+
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../src/config/configuration.ts"],"names":[],"mappings":";;AAAA,MAAM,MAAM,GAAG;IACb,aAAa,EAAE;QACb,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa;QACrD,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;KACpD;CACF,CAAC;AAEF,kBAAe,MAAM,CAAC"}
|
package/lib/configuration.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Container } from '@spinajs/di';
|
|
2
2
|
import { ConfigurationSource } from './sources';
|
|
3
3
|
import { Configuration, ConfigurationOptions } from './types';
|
|
4
4
|
export declare class FrameworkConfiguration extends Configuration {
|
|
@@ -13,14 +13,15 @@ export declare class FrameworkConfiguration extends Configuration {
|
|
|
13
13
|
/**
|
|
14
14
|
* Loaded & merged configuration
|
|
15
15
|
*/
|
|
16
|
-
protected Config:
|
|
16
|
+
protected Config: Record<string, unknown>;
|
|
17
17
|
protected CustomConfigPaths: string[];
|
|
18
18
|
protected Sources: ConfigurationSource[];
|
|
19
|
+
protected Container: Container;
|
|
19
20
|
/**
|
|
20
21
|
*
|
|
21
|
-
* @param app application name, pass it when you run in application mode
|
|
22
|
-
* @param baseDir configuration base dir, where to look for application configs
|
|
23
|
-
* @param cfgCustomPaths custom cfg paths eg. to load config from non standard folders ( usefull in tests )
|
|
22
|
+
* @param app - application name, pass it when you run in application mode
|
|
23
|
+
* @param baseDir - configuration base dir, where to look for application configs
|
|
24
|
+
* @param cfgCustomPaths - custom cfg paths eg. to load config from non standard folders ( usefull in tests )
|
|
24
25
|
*/
|
|
25
26
|
constructor(options?: ConfigurationOptions);
|
|
26
27
|
/**
|
|
@@ -28,23 +29,23 @@ export declare class FrameworkConfiguration extends Configuration {
|
|
|
28
29
|
*
|
|
29
30
|
* @param path - path to property eg. ["system","dirs"]
|
|
30
31
|
* @param defaultValue - optional, if value at specified path not exists returns default value
|
|
31
|
-
* @returns { T | undefined }
|
|
32
32
|
*/
|
|
33
33
|
get<T>(path: string[] | string, defaultValue?: T): T;
|
|
34
34
|
/**
|
|
35
35
|
* Sets at given path configuration value. Use when you want to override config
|
|
36
36
|
* loaded from files programatically
|
|
37
37
|
*
|
|
38
|
-
* @param path config path
|
|
39
|
-
* @param value value to set
|
|
38
|
+
* @param path - config path
|
|
39
|
+
* @param value - value to set
|
|
40
40
|
*/
|
|
41
|
-
set(path: string[] | string, value:
|
|
42
|
-
resolveAsync(
|
|
41
|
+
set(path: string[] | string, value: unknown): void;
|
|
42
|
+
resolveAsync(): Promise<void>;
|
|
43
43
|
protected dir(toJoin: string): string;
|
|
44
44
|
/**
|
|
45
45
|
* adds app dirs to system.dirs config
|
|
46
46
|
*/
|
|
47
47
|
protected applyAppDirs(): void;
|
|
48
|
+
protected validateConfig(): void;
|
|
48
49
|
/**
|
|
49
50
|
* runs configuration func on files
|
|
50
51
|
* eg. when you want to configure stuff at beginning eq. external libs
|
package/lib/configuration.js
CHANGED
|
@@ -27,8 +27,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
27
27
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
28
28
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
29
29
|
};
|
|
30
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
+
};
|
|
30
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
34
|
exports.FrameworkConfiguration = void 0;
|
|
35
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
36
|
+
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
32
37
|
const di_1 = require("@spinajs/di");
|
|
33
38
|
const exceptions_1 = require("@spinajs/exceptions");
|
|
34
39
|
const path_1 = require("path");
|
|
@@ -36,12 +41,15 @@ const sources_1 = require("./sources");
|
|
|
36
41
|
const types_1 = require("./types");
|
|
37
42
|
const util_1 = require("./util");
|
|
38
43
|
const _ = __importStar(require("lodash"));
|
|
44
|
+
const ajv_1 = __importDefault(require("ajv"));
|
|
45
|
+
const exception_1 = require("./exception");
|
|
46
|
+
const internal_logger_1 = require("@spinajs/internal-logger");
|
|
39
47
|
let FrameworkConfiguration = class FrameworkConfiguration extends types_1.Configuration {
|
|
40
48
|
/**
|
|
41
49
|
*
|
|
42
|
-
* @param app application name, pass it when you run in application mode
|
|
43
|
-
* @param baseDir configuration base dir, where to look for application configs
|
|
44
|
-
* @param cfgCustomPaths custom cfg paths eg. to load config from non standard folders ( usefull in tests )
|
|
50
|
+
* @param app - application name, pass it when you run in application mode
|
|
51
|
+
* @param baseDir - configuration base dir, where to look for application configs
|
|
52
|
+
* @param cfgCustomPaths - custom cfg paths eg. to load config from non standard folders ( usefull in tests )
|
|
45
53
|
*/
|
|
46
54
|
constructor(options) {
|
|
47
55
|
var _a, _b, _c, _d;
|
|
@@ -53,7 +61,7 @@ let FrameworkConfiguration = class FrameworkConfiguration extends types_1.Config
|
|
|
53
61
|
/**
|
|
54
62
|
* Current running app name
|
|
55
63
|
*/
|
|
56
|
-
this.RunApp =
|
|
64
|
+
this.RunApp = '';
|
|
57
65
|
/**
|
|
58
66
|
* Loaded & merged configuration
|
|
59
67
|
*/
|
|
@@ -67,7 +75,6 @@ let FrameworkConfiguration = class FrameworkConfiguration extends types_1.Config
|
|
|
67
75
|
*
|
|
68
76
|
* @param path - path to property eg. ["system","dirs"]
|
|
69
77
|
* @param defaultValue - optional, if value at specified path not exists returns default value
|
|
70
|
-
* @returns { T | undefined }
|
|
71
78
|
*/
|
|
72
79
|
get(path, defaultValue) {
|
|
73
80
|
return _.get(this.Config, path, defaultValue);
|
|
@@ -76,23 +83,29 @@ let FrameworkConfiguration = class FrameworkConfiguration extends types_1.Config
|
|
|
76
83
|
* Sets at given path configuration value. Use when you want to override config
|
|
77
84
|
* loaded from files programatically
|
|
78
85
|
*
|
|
79
|
-
* @param path config path
|
|
80
|
-
* @param value value to set
|
|
86
|
+
* @param path - config path
|
|
87
|
+
* @param value - value to set
|
|
81
88
|
*/
|
|
82
89
|
set(path, value) {
|
|
83
90
|
this.Config = _.set(this.Config, path, value);
|
|
84
91
|
}
|
|
85
|
-
async resolveAsync(
|
|
86
|
-
if (!
|
|
87
|
-
throw new exceptions_1.InvalidOperation(
|
|
92
|
+
async resolveAsync() {
|
|
93
|
+
if (!this.Container.hasRegistered(sources_1.ConfigurationSource)) {
|
|
94
|
+
throw new exceptions_1.InvalidOperation('No configuration sources configured. Please ensure that config module have any source to read from !');
|
|
88
95
|
}
|
|
89
|
-
this.Sources =
|
|
90
|
-
|
|
91
|
-
|
|
96
|
+
this.Sources = this.Container.resolve(Array.ofType(sources_1.ConfigurationSource), [
|
|
97
|
+
this.RunApp,
|
|
98
|
+
this.CustomConfigPaths,
|
|
99
|
+
this.AppBaseDir,
|
|
100
|
+
]);
|
|
101
|
+
await Promise.all(this.Sources.map((s) => s.Load())).then((result) => {
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
103
|
+
result.map((c) => _.merge(this.Config, c));
|
|
104
|
+
return;
|
|
92
105
|
});
|
|
106
|
+
this.validateConfig();
|
|
93
107
|
this.applyAppDirs();
|
|
94
108
|
this.configure();
|
|
95
|
-
await super.resolveAsync(container);
|
|
96
109
|
}
|
|
97
110
|
dir(toJoin) {
|
|
98
111
|
return (0, path_1.normalize)((0, path_1.join)((0, path_1.resolve)(this.AppBaseDir), toJoin));
|
|
@@ -108,19 +121,63 @@ let FrameworkConfiguration = class FrameworkConfiguration extends types_1.Config
|
|
|
108
121
|
this.get(['system', 'dirs', prop]).push(this.dir(`/${this.RunApp}/${prop}`));
|
|
109
122
|
}
|
|
110
123
|
}
|
|
124
|
+
validateConfig() {
|
|
125
|
+
const validator = new ajv_1.default({
|
|
126
|
+
logger: {
|
|
127
|
+
log: (msg) => internal_logger_1.InternalLogger.info(msg, 'Configuration'),
|
|
128
|
+
warn: (msg) => internal_logger_1.InternalLogger.warn(msg, 'Configuration'),
|
|
129
|
+
error: (msg) => internal_logger_1.InternalLogger.error(msg, 'Configuration'),
|
|
130
|
+
},
|
|
131
|
+
// enable all errors on validation, not only first one that occurred
|
|
132
|
+
allErrors: true,
|
|
133
|
+
// remove properties that are not defined in schema
|
|
134
|
+
removeAdditional: true,
|
|
135
|
+
// set default values if possible
|
|
136
|
+
useDefaults: true,
|
|
137
|
+
// The option coerceTypes allows you to have your data types coerced to the types specified in your schema type keywords
|
|
138
|
+
coerceTypes: true,
|
|
139
|
+
});
|
|
140
|
+
// add $merge & $patch for json schema
|
|
141
|
+
require('ajv-merge-patch')(validator);
|
|
142
|
+
// add common formats validation eg: date time
|
|
143
|
+
require('ajv-formats')(validator);
|
|
144
|
+
// add keywords
|
|
145
|
+
require('ajv-keywords')(validator);
|
|
146
|
+
// in strict mode ajv will throw when
|
|
147
|
+
// unknown keyword in schema is met
|
|
148
|
+
// we use $configurationModule keyword to identify
|
|
149
|
+
// to match config module with config schema
|
|
150
|
+
validator.addKeyword('$configurationModule');
|
|
151
|
+
const schemas = this.Container.get('__configurationSchema__', true);
|
|
152
|
+
if (schemas) {
|
|
153
|
+
Object.keys(this.Config).forEach((k) => {
|
|
154
|
+
const schema = schemas.find((x) => x.$configurationModule === k);
|
|
155
|
+
if (schema) {
|
|
156
|
+
const result = validator.validate(schema, this.Config[`${k}`]);
|
|
157
|
+
if (!result) {
|
|
158
|
+
throw new exception_1.InvalidConfiguration('invalid configuration ! Check config files and restart app.', validator.errors);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
111
164
|
/**
|
|
112
165
|
* runs configuration func on files
|
|
113
166
|
* eg. when you want to configure stuff at beginning eq. external libs
|
|
114
167
|
*/
|
|
115
168
|
configure() {
|
|
116
169
|
for (const prop of Object.keys(this.Config)) {
|
|
117
|
-
const subconfig = this.Config[prop];
|
|
118
|
-
if (
|
|
170
|
+
const subconfig = this.Config[`${prop}`];
|
|
171
|
+
if (subconfig.configure && typeof subconfig.configure === 'function') {
|
|
119
172
|
subconfig.configure.apply(this);
|
|
120
173
|
}
|
|
121
174
|
}
|
|
122
175
|
}
|
|
123
176
|
};
|
|
177
|
+
__decorate([
|
|
178
|
+
(0, di_1.Autoinject)(),
|
|
179
|
+
__metadata("design:type", di_1.Container)
|
|
180
|
+
], FrameworkConfiguration.prototype, "Container", void 0);
|
|
124
181
|
FrameworkConfiguration = __decorate([
|
|
125
182
|
(0, di_1.Injectable)(types_1.Configuration),
|
|
126
183
|
__metadata("design:paramtypes", [Object])
|
package/lib/configuration.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,sDAAsD;AACtD,oCAAgE;AAChE,oDAAuD;AACvD,+BAAgD;AAChD,uCAAgD;AAChD,mCAAmG;AACnG,iCAAmC;AACnC,0CAA4B;AAC5B,8CAAsB;AACtB,2CAAmD;AACnD,8DAA0D;AAG1D,IAAa,sBAAsB,GAAnC,MAAa,sBAAuB,SAAQ,qBAAa;IAuBvD;;;;;OAKG;IACH,YAAY,OAA8B;;QACxC,KAAK,EAAE,CAAC;QA7BV;;WAEG;QACI,eAAU,GAAG,IAAI,CAAC;QAEzB;;WAEG;QACI,WAAM,GAAG,EAAE,CAAC;QAEnB;;WAEG;QACO,WAAM,GAA4B,EAAE,CAAC;QAkB7C,IAAI,CAAC,iBAAiB,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,cAAc,mCAAI,EAAE,CAAC;QACvD,IAAI,CAAC,MAAM,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,GAAG,mCAAI,IAAA,gBAAS,EAAC,OAAO,CAAC,CAAC;QACjD,IAAI,CAAC,UAAU,GAAG,MAAA,MAAA,OAAO,aAAP,OAAO,uBAA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AK,CAAC,IAAI,CAAC,CAAC;aACjC;SACF;IACH,CAAC;CACF,CAAA;AAlJC;IADC,IAAA,eAAU,GAAE;8BACQ,cAAS;yDAAC;AArBpB,sBAAsB;IADlC,IAAA,eAAU,EAAC,qBAAa,CAAC;;GACb,sBAAsB,CAuKlC;AAvKY,wDAAsB"}
|
package/lib/decorators.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Injects configuration value to given class property
|
|
3
3
|
*
|
|
4
|
-
* @param path path to configuration value eg. "app.dirs.stats"
|
|
5
|
-
* @param dafaultValue default value if path not exists
|
|
4
|
+
* @param path - path to configuration value eg. "app.dirs.stats"
|
|
5
|
+
* @param dafaultValue - default value if path not exists
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
|
-
export declare function Config(path: string, dafaultValue?:
|
|
8
|
+
export declare function Config(path: string, dafaultValue?: unknown): (target?: any, key?: string) => any;
|
package/lib/decorators.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Config = void 0;
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
5
|
const di_1 = require("@spinajs/di");
|
|
5
6
|
const types_1 = require("./types");
|
|
6
7
|
/**
|
|
7
8
|
* Injects configuration value to given class property
|
|
8
9
|
*
|
|
9
|
-
* @param path path to configuration value eg. "app.dirs.stats"
|
|
10
|
-
* @param dafaultValue default value if path not exists
|
|
10
|
+
* @param path - path to configuration value eg. "app.dirs.stats"
|
|
11
|
+
* @param dafaultValue - default value if path not exists
|
|
11
12
|
* @returns
|
|
12
13
|
*/
|
|
13
14
|
function Config(path, dafaultValue) {
|
|
@@ -22,7 +23,7 @@ function Config(path, dafaultValue) {
|
|
|
22
23
|
Object.defineProperty(target, key, {
|
|
23
24
|
get: getter,
|
|
24
25
|
enumerable: false,
|
|
25
|
-
configurable: false
|
|
26
|
+
configurable: false,
|
|
26
27
|
});
|
|
27
28
|
};
|
|
28
29
|
}
|
package/lib/decorators.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":";;;AAAA,oCAAiC;AACjC,
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AACvD,oCAAiC;AACjC,mCAAwC;AAExC;;;;;;GAMG;AACH,SAAgB,MAAM,CAAC,IAAY,EAAE,YAAsB;IACzD,OAAO,CAAC,MAAY,EAAE,GAAY,EAAO,EAAE;QACzC,IAAI,MAAM,GAAkB,IAAI,CAAC;QAEjC,MAAM,MAAM,GAAG,GAAG,EAAE;YAClB,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,GAAG,OAAE,CAAC,GAAG,CAAC,qBAAa,CAAC,CAAC;aAChC;YACD,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QACxC,CAAC,CAAC;QAEF,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE;YACjC,GAAG,EAAE,MAAM;YACX,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAjBD,wBAiBC"}
|
package/lib/exception.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvalidConfiguration = void 0;
|
|
4
|
+
class InvalidConfiguration extends Error {
|
|
5
|
+
constructor(message, validationExceptions) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.validationExceptions = validationExceptions;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.InvalidConfiguration = InvalidConfiguration;
|
|
11
|
+
//# sourceMappingURL=exception.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exception.js","sourceRoot":"","sources":["../src/exception.ts"],"names":[],"mappings":";;;AAEA,MAAa,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,OAAe,EAAS,oBAAmC;QACrE,KAAK,CAAC,OAAO,CAAC,CAAC;QADmB,yBAAoB,GAApB,oBAAoB,CAAe;IAEvE,CAAC;CACF;AAJD,oDAIC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* When we export, we can see configuration variable
|
|
7
7
|
* in webpack module cache and webpack config loader can see it
|
|
8
8
|
*/
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
9
|
+
export * as configuration from './config/configuration';
|
|
10
|
+
export * from './types';
|
|
11
|
+
export * from './sources';
|
|
12
|
+
export * from './decorators';
|
|
13
|
+
export * from './configuration';
|
package/lib/index.js
CHANGED
|
@@ -6,10 +6,23 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
6
6
|
if (k2 === undefined) k2 = k;
|
|
7
7
|
o[k2] = m[k];
|
|
8
8
|
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
9
21
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
22
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
23
|
};
|
|
12
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.configuration = void 0;
|
|
13
26
|
/**
|
|
14
27
|
* We export default configuration for webpack modules
|
|
15
28
|
* Normally we load configuration from disk via filesystem
|
|
@@ -18,7 +31,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
31
|
* When we export, we can see configuration variable
|
|
19
32
|
* in webpack module cache and webpack config loader can see it
|
|
20
33
|
*/
|
|
21
|
-
|
|
34
|
+
exports.configuration = __importStar(require("./config/configuration"));
|
|
22
35
|
__exportStar(require("./types"), exports);
|
|
23
36
|
__exportStar(require("./sources"), exports);
|
|
24
37
|
__exportStar(require("./decorators"), exports);
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;GAOG;AACH,wEAAwD;AACxD,0CAAwB;AACxB,4CAA0B;AAC1B,+CAA6B;AAC7B,kDAAgC"}
|
package/lib/sources.d.ts
CHANGED
package/lib/sources.js
CHANGED
|
@@ -26,14 +26,20 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
26
|
};
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
28
|
exports.JsonFileSource = exports.JsFileSource = exports.BaseFileSource = exports.ConfigurationSource = void 0;
|
|
29
|
+
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
30
|
+
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
31
|
+
/* eslint-disable @typescript-eslint/require-await */
|
|
32
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
33
|
+
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
34
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
29
35
|
const di_1 = require("@spinajs/di");
|
|
30
36
|
const glob_1 = require("glob");
|
|
31
|
-
const _ = require("lodash");
|
|
37
|
+
const _ = __importStar(require("lodash"));
|
|
32
38
|
const path_1 = require("path");
|
|
33
39
|
const util_1 = require("./util");
|
|
34
40
|
const fs = __importStar(require("fs"));
|
|
35
41
|
const path = __importStar(require("path"));
|
|
36
|
-
const
|
|
42
|
+
const internal_logger_1 = require("@spinajs/internal-logger");
|
|
37
43
|
function mergeArrays(target, source) {
|
|
38
44
|
if (_.isArray(target)) {
|
|
39
45
|
return target.concat(source);
|
|
@@ -65,7 +71,7 @@ class BaseFileSource extends ConfigurationSource {
|
|
|
65
71
|
'build/config',
|
|
66
72
|
'config',
|
|
67
73
|
];
|
|
68
|
-
this.BasePath =
|
|
74
|
+
this.BasePath = '';
|
|
69
75
|
this.BasePath = (0, util_1.findBasePath)(process.cwd());
|
|
70
76
|
}
|
|
71
77
|
load(extension, callback) {
|
|
@@ -76,9 +82,9 @@ class BaseFileSource extends ConfigurationSource {
|
|
|
76
82
|
if (this.CustomConfigPaths) {
|
|
77
83
|
this.CommonDirs = this.CommonDirs.concat(this.CustomConfigPaths);
|
|
78
84
|
}
|
|
79
|
-
this.CommonDirs.map(f => path.isAbsolute(f) ? f : (0, path_1.join)(this.BasePath, f))
|
|
85
|
+
this.CommonDirs.map((f) => (path.isAbsolute(f) ? f : (0, path_1.join)(this.BasePath, f)))
|
|
80
86
|
// get all config files
|
|
81
|
-
.map(d => glob_1.glob.sync(path.join(d, `/**/${extension}`)))
|
|
87
|
+
.map((d) => glob_1.glob.sync(path.join(d, `/**/${extension}`)))
|
|
82
88
|
// flatten files
|
|
83
89
|
.reduce((prev, current) => {
|
|
84
90
|
return prev.concat(_.flattenDeep(current));
|
|
@@ -97,17 +103,19 @@ let JsFileSource = class JsFileSource extends BaseFileSource {
|
|
|
97
103
|
async Load() {
|
|
98
104
|
const common = this.load('!(*.dev|*.prod).js', _load);
|
|
99
105
|
if (process.env.NODE_ENV) {
|
|
100
|
-
if (process.env.NODE_ENV ===
|
|
101
|
-
return _.mergeWith(common, this.load(
|
|
106
|
+
if (process.env.NODE_ENV === 'development') {
|
|
107
|
+
return _.mergeWith(common, this.load('*.dev.js', _load), mergeArrays);
|
|
102
108
|
}
|
|
103
|
-
else if (process.env.NODE_ENV ===
|
|
104
|
-
return _.mergeWith(common, this.load(
|
|
109
|
+
else if (process.env.NODE_ENV === 'production') {
|
|
110
|
+
return _.mergeWith(common, this.load('*.prod.js', _load), mergeArrays);
|
|
105
111
|
}
|
|
106
112
|
}
|
|
107
113
|
return common;
|
|
108
114
|
function _load(file) {
|
|
109
|
-
|
|
115
|
+
//Log.trace(`Trying to load file ${file}`, 'Configuration');
|
|
110
116
|
(0, util_1.uncache)(file);
|
|
117
|
+
internal_logger_1.InternalLogger.trace(`Trying to load file ${file}`, 'Configuration');
|
|
118
|
+
// eslint-disable-next-line security/detect-non-literal-require
|
|
111
119
|
return require(file);
|
|
112
120
|
}
|
|
113
121
|
}
|
|
@@ -120,18 +128,18 @@ let JsonFileSource = class JsonFileSource extends BaseFileSource {
|
|
|
120
128
|
async Load() {
|
|
121
129
|
const common = this.load('!(*.dev|*.prod).json', _load);
|
|
122
130
|
if (process.env.NODE_ENV) {
|
|
123
|
-
if (process.env.NODE_ENV ===
|
|
124
|
-
return _.mergeWith(common, this.load(
|
|
131
|
+
if (process.env.NODE_ENV === 'development') {
|
|
132
|
+
return _.mergeWith(common, this.load('*.dev.json', _load), mergeArrays);
|
|
125
133
|
}
|
|
126
|
-
else if (process.env.NODE_ENV ===
|
|
127
|
-
return _.mergeWith(common, this.load(
|
|
134
|
+
else if (process.env.NODE_ENV === 'production') {
|
|
135
|
+
return _.mergeWith(common, this.load('*.prod.json', _load), mergeArrays);
|
|
128
136
|
}
|
|
129
137
|
}
|
|
130
138
|
return common;
|
|
131
139
|
function _load(file) {
|
|
132
140
|
try {
|
|
133
|
-
|
|
134
|
-
return JSON.parse(fs.readFileSync(file,
|
|
141
|
+
internal_logger_1.InternalLogger.trace(`Trying to load file ${file}`, 'Configuration');
|
|
142
|
+
return JSON.parse(fs.readFileSync(file, 'utf-8'));
|
|
135
143
|
}
|
|
136
144
|
catch (err) {
|
|
137
145
|
return null;
|
package/lib/sources.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sources.js","sourceRoot":"","sources":["../src/sources.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAyC;AACzC,+BAA4B;AAC5B,
|
|
1
|
+
{"version":3,"file":"sources.js","sourceRoot":"","sources":["../src/sources.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAA0D;AAC1D,sDAAsD;AACtD,qDAAqD;AACrD,+DAA+D;AAC/D,wDAAwD;AACxD,uDAAuD;AACvD,oCAAyC;AACzC,+BAA4B;AAC5B,0CAA4B;AAC5B,+BAAgD;AAChD,iCAA+C;AAC/C,uCAAyB;AACzB,2CAA6B;AAC7B,8DAA0D;AAE1D,SAAS,WAAW,CAAC,MAAiB,EAAE,MAAiB;IACvD,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACrB,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;KAC9B;AACH,CAAC;AAED,MAAsB,mBAAmB;CAExC;AAFD,kDAEC;AAED,MAAsB,cAAe,SAAQ,mBAAmB;IAyB9D,YAAsB,MAAe,EAAY,iBAA4B,EAAY,UAAmB;QAC1G,KAAK,EAAE,CAAC;QADY,WAAM,GAAN,MAAM,CAAS;QAAY,sBAAiB,GAAjB,iBAAiB,CAAW;QAAY,eAAU,GAAV,UAAU,CAAS;QAxB5G;;WAEG;QACI,YAAO,GAAG,IAAI,CAAC;QAEZ,eAAU,GAAG;YACrB,mBAAmB;YACnB,IAAA,gBAAS,EAA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AAE;gBACZ,OAAO,IAAI,CAAC;aACb;QACH,CAAC;IACH,CAAC;CACF,CAAA;AAxBY,cAAc;IAD1B,IAAA,eAAU,EAAC,mBAAmB,CAAC;GACnB,cAAc,CAwB1B;AAxBY,wCAAc"}
|
package/lib/types.d.ts
CHANGED
|
@@ -6,6 +6,12 @@ export interface IFrameworkVersion {
|
|
|
6
6
|
minor: number;
|
|
7
7
|
major: number;
|
|
8
8
|
}
|
|
9
|
+
export interface IConfigurationSchema {
|
|
10
|
+
$configurationModule: string;
|
|
11
|
+
}
|
|
12
|
+
export interface IConfigurable {
|
|
13
|
+
configure(this: Configuration): void;
|
|
14
|
+
}
|
|
9
15
|
export interface ConfigurationOptions {
|
|
10
16
|
/**
|
|
11
17
|
* application name, pass it when you run in application mode
|
|
@@ -43,8 +49,8 @@ export declare abstract class Configuration extends AsyncModule {
|
|
|
43
49
|
* Sets at given path configuration value. Use when you want to override config
|
|
44
50
|
* loaded from files programatically
|
|
45
51
|
*
|
|
46
|
-
* @param path config path
|
|
47
|
-
* @param value value to set
|
|
52
|
+
* @param path - config path
|
|
53
|
+
* @param value - value to set
|
|
48
54
|
*/
|
|
49
|
-
abstract set(path: string[] | string, value:
|
|
55
|
+
abstract set(path: string[] | string, value: unknown): void;
|
|
50
56
|
}
|
package/lib/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAA,oCAA0C;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAA,oCAA0C;AAwC1C,MAAsB,aAAc,SAAQ,gBAAW;CA0BtD;AA1BD,sCA0BC"}
|
package/lib/util.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function parseArgv(param: string): string;
|
|
2
2
|
export declare function findBasePath(path: string): string;
|
|
3
|
-
export declare function merge(to:
|
|
3
|
+
export declare function merge(to: unknown, from: unknown): unknown;
|
|
4
4
|
export declare function uncache(file: string): string;
|
|
5
5
|
export declare function filterDirs(dir: string): boolean;
|
package/lib/util.js
CHANGED
|
@@ -20,6 +20,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.filterDirs = exports.uncache = exports.merge = exports.findBasePath = exports.parseArgv = void 0;
|
|
23
|
+
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
24
|
+
/* eslint-disable @typescript-eslint/unbound-method */
|
|
23
25
|
const fs = __importStar(require("fs"));
|
|
24
26
|
const _ = require("lodash");
|
|
25
27
|
const path_1 = require("path");
|
|
@@ -54,7 +56,7 @@ exports.merge = merge;
|
|
|
54
56
|
// clean require cache config
|
|
55
57
|
// http://stackoverflow.com/questions/9210542/node-js-require-cache-possible-to-invalidate
|
|
56
58
|
function uncache(file) {
|
|
57
|
-
delete require.cache[file];
|
|
59
|
+
delete require.cache[`${file}`];
|
|
58
60
|
return file;
|
|
59
61
|
}
|
|
60
62
|
exports.uncache = uncache;
|
package/lib/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,4BAA6B;AAC7B,+BAAqC;
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,wDAAwD;AACxD,sDAAsD;AACtD,uCAAyB;AACzB,4BAA6B;AAC7B,+BAAqC;AAQrC,SAAgB,SAAS,CAAC,KAAa;IACrC,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAE1C,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM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CAAC;AALD,gCAKC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spinajs/configuration",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.12",
|
|
4
4
|
"description": "framework configuration module",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"private": false,
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"build": "tsc",
|
|
12
12
|
"build-watch": "tsc -w",
|
|
13
13
|
"prepare": "npm run build",
|
|
14
|
-
"format": "prettier --write \"src/**/*.ts\"
|
|
15
|
-
"lint": "
|
|
14
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
15
|
+
"lint": "eslint -c .eslintrc.js --ext .ts src",
|
|
16
16
|
"prepublishOnly": "npm test && npm run lint",
|
|
17
17
|
"preversion": "npm run lint",
|
|
18
18
|
"version": "npm run format && git add -A src",
|
|
@@ -39,34 +39,15 @@
|
|
|
39
39
|
},
|
|
40
40
|
"homepage": "https://github.com/spinajs/configuration#readme",
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@spinajs/di": "^1.
|
|
43
|
-
"@spinajs/exceptions": "^1.
|
|
44
|
-
"@spinajs/
|
|
42
|
+
"@spinajs/di": "^1.2.12",
|
|
43
|
+
"@spinajs/exceptions": "^1.2.7",
|
|
44
|
+
"@spinajs/internal-logger": "^1.2.12",
|
|
45
|
+
"ajv": "^8.8.2",
|
|
46
|
+
"ajv-formats": "^2.1.1",
|
|
47
|
+
"ajv-keywords": "^5.1.0",
|
|
48
|
+
"ajv-merge-patch": "^5.0.1",
|
|
45
49
|
"glob": "^7.1.4",
|
|
46
50
|
"lodash": "^4.17.14"
|
|
47
51
|
},
|
|
48
|
-
"
|
|
49
|
-
"@types/bunyan": "^1.8.6",
|
|
50
|
-
"@types/chai": "^4.1.7",
|
|
51
|
-
"@types/chai-as-promised": "^7.1.0",
|
|
52
|
-
"@types/glob": "^7.2.0",
|
|
53
|
-
"@types/lodash": "^4.14.136",
|
|
54
|
-
"@types/mocha": "^9.1.0",
|
|
55
|
-
"@types/sinon": "^10.0.8",
|
|
56
|
-
"chai": "^4.2.0",
|
|
57
|
-
"chai-as-promised": "^7.1.1",
|
|
58
|
-
"mocha": "^9.2.0",
|
|
59
|
-
"nyc": "^15.1.0",
|
|
60
|
-
"prettier": "^2.5.1",
|
|
61
|
-
"sinon": "^12.0.1",
|
|
62
|
-
"ts-mocha": "^9.0.2",
|
|
63
|
-
"ts-node": "^10.4.0",
|
|
64
|
-
"tslint": "^6.1.3",
|
|
65
|
-
"tslint-circular-dependencies": "^0.1.0",
|
|
66
|
-
"tslint-config-prettier": "^1.18.0",
|
|
67
|
-
"tslint-config-standard": "^9.0.0",
|
|
68
|
-
"tslint-no-unused-expression-chai": "^0.1.4",
|
|
69
|
-
"typedoc": "^0.22.11",
|
|
70
|
-
"typescript": "^4.2.3"
|
|
71
|
-
}
|
|
52
|
+
"gitHead": "9102c6297adaadad8cb323738b5336d1014936b2"
|
|
72
53
|
}
|