@spinajs/configuration 1.0.12 → 1.1.2

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.
File without changes
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ configuration: {
3
+ isDevelopment: process.env.NODE_ENV === "development",
4
+ isProduction: process.env.NODE_ENV === "production"
5
+ }
6
+ };
7
+ //# sourceMappingURL=configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../src/config/configuration.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,GAAG;IACb,aAAa,EAAE;QACX,aAAa,EAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa;QACtD,YAAY,EAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;KACxD;CACJ,CAAA"}
@@ -0,0 +1,45 @@
1
+ import { IContainer } from '@spinajs/di';
2
+ import { ConfigurationSource } from './sources';
3
+ import { Configuration, ConfigurationOptions } from './types';
4
+ export declare class FrameworkConfiguration extends Configuration {
5
+ /**
6
+ * Apps configuration base dir, where to look for app config
7
+ */
8
+ AppBaseDir: string;
9
+ /**
10
+ * Current running app name
11
+ */
12
+ RunApp: string;
13
+ /**
14
+ * Loaded & merged configuration
15
+ */
16
+ protected Config: any;
17
+ protected CustomConfigPaths: string[];
18
+ protected Sources: ConfigurationSource[];
19
+ /**
20
+ *
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 )
24
+ */
25
+ constructor(options?: ConfigurationOptions);
26
+ /**
27
+ * Get config value for given property. If value not exists it returns default value, if default value is not provided returns undefined
28
+ *
29
+ * @param path - path to property eg. ["system","dirs"]
30
+ * @param defaultValue - optional, if value at specified path not exists returns default value
31
+ * @returns { T | undefined }
32
+ */
33
+ get<T>(path: string[] | string, defaultValue?: T): T;
34
+ resolveAsync(container: IContainer): Promise<void>;
35
+ protected dir(toJoin: string): string;
36
+ /**
37
+ * adds app dirs to system.dirs config
38
+ */
39
+ protected applyAppDirs(): void;
40
+ /**
41
+ * runs configuration func on files
42
+ * eg. when you want to configure stuff at beginning eq. external libs
43
+ */
44
+ protected configure(): void;
45
+ }
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
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 __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
15
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
17
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
18
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
19
+ };
20
+ var __importStar = (this && this.__importStar) || function (mod) {
21
+ if (mod && mod.__esModule) return mod;
22
+ var result = {};
23
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
+ __setModuleDefault(result, mod);
25
+ return result;
26
+ };
27
+ var __metadata = (this && this.__metadata) || function (k, v) {
28
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
29
+ };
30
+ Object.defineProperty(exports, "__esModule", { value: true });
31
+ exports.FrameworkConfiguration = void 0;
32
+ const di_1 = require("@spinajs/di");
33
+ const exceptions_1 = require("@spinajs/exceptions");
34
+ const path_1 = require("path");
35
+ const sources_1 = require("./sources");
36
+ const types_1 = require("./types");
37
+ const log_1 = require("@spinajs/log");
38
+ const util_1 = require("./util");
39
+ const _ = __importStar(require("lodash"));
40
+ let FrameworkConfiguration = class FrameworkConfiguration extends types_1.Configuration {
41
+ /**
42
+ *
43
+ * @param app application name, pass it when you run in application mode
44
+ * @param baseDir configuration base dir, where to look for application configs
45
+ * @param cfgCustomPaths custom cfg paths eg. to load config from non standard folders ( usefull in tests )
46
+ */
47
+ constructor(options) {
48
+ var _a, _b, _c, _d;
49
+ super();
50
+ /**
51
+ * Apps configuration base dir, where to look for app config
52
+ */
53
+ this.AppBaseDir = './';
54
+ /**
55
+ * Current running app name
56
+ */
57
+ this.RunApp = "";
58
+ /**
59
+ * Loaded & merged configuration
60
+ */
61
+ this.Config = {};
62
+ this.CustomConfigPaths = (_a = options === null || options === void 0 ? void 0 : options.cfgCustomPaths) !== null && _a !== void 0 ? _a : [];
63
+ this.RunApp = (_b = options === null || options === void 0 ? void 0 : options.app) !== null && _b !== void 0 ? _b : (0, util_1.parseArgv)('--app');
64
+ this.AppBaseDir = (_d = (_c = options === null || options === void 0 ? void 0 : options.appBaseDir) !== null && _c !== void 0 ? _c : (0, util_1.parseArgv)('--apppath')) !== null && _d !== void 0 ? _d : (0, path_1.join)(__dirname, '../apps/');
65
+ }
66
+ /**
67
+ * Get config value for given property. If value not exists it returns default value, if default value is not provided returns undefined
68
+ *
69
+ * @param path - path to property eg. ["system","dirs"]
70
+ * @param defaultValue - optional, if value at specified path not exists returns default value
71
+ * @returns { T | undefined }
72
+ */
73
+ get(path, defaultValue) {
74
+ return _.get(this.Config, path, defaultValue);
75
+ }
76
+ async resolveAsync(container) {
77
+ if (!container.hasRegistered(sources_1.ConfigurationSource)) {
78
+ throw new exceptions_1.InvalidOperation("No configuration sources configured. Please ensure that config module have any source to read from !");
79
+ }
80
+ this.Sources = await container.resolve(Array.ofType(sources_1.ConfigurationSource), [this.RunApp, this.CustomConfigPaths, this.AppBaseDir]);
81
+ log_1.Log.trace(`Found ${this.Sources.map(x => x.constructor.name)} log sources`, "Configuration");
82
+ await Promise.all(this.Sources.map(s => s.Load())).then(result => {
83
+ result.map(c => _.merge(this.Config, c));
84
+ });
85
+ this.applyAppDirs();
86
+ this.configure();
87
+ await super.resolveAsync(container);
88
+ }
89
+ dir(toJoin) {
90
+ return (0, path_1.normalize)((0, path_1.join)((0, path_1.resolve)(this.BaseDir), toJoin));
91
+ }
92
+ /**
93
+ * adds app dirs to system.dirs config
94
+ */
95
+ applyAppDirs() {
96
+ if (!this.RunApp) {
97
+ return;
98
+ }
99
+ for (const prop of Object.keys(this.get(['system', 'dirs'], []))) {
100
+ this.get(['system', 'dirs', prop]).push(this.dir(`/${this.RunApp}/${prop}`));
101
+ }
102
+ }
103
+ /**
104
+ * runs configuration func on files
105
+ * eg. when you want to configure stuff at beginning eq. external libs
106
+ */
107
+ configure() {
108
+ for (const prop of Object.keys(this.Config)) {
109
+ const subconfig = this.Config[prop];
110
+ if (_.isFunction(subconfig.configure)) {
111
+ subconfig.configure.apply(this.Config, [subconfig]);
112
+ }
113
+ }
114
+ }
115
+ };
116
+ FrameworkConfiguration = __decorate([
117
+ (0, di_1.Injectable)(types_1.Configuration),
118
+ __metadata("design:paramtypes", [Object])
119
+ ], FrameworkConfiguration);
120
+ exports.FrameworkConfiguration = FrameworkConfiguration;
121
+ //# sourceMappingURL=configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAqD;AACrD,oDAAuD;AACvD,+BAAgD;AAChD,uCAAgD;AAChD,mCAA8D;AAC9D,sCAAmC;AACnC,iCAAmC;AACnC,0CAA4B;AAG5B,IAAa,sBAAsB,GAAnC,MAAa,s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AAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAEpC,IAAI,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE;gBACrC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;aACrD;SACF;IACH,CAAC;CACF,CAAA;AAlGY,sBAAsB;IADlC,IAAA,eAAU,EAAC,qBAAa,CAAC;;GACb,sBAAsB,CAkGlC;AAlGY,wDAAsB"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Injects configuration value to given class property
3
+ *
4
+ * @param path path to configuration value eg. "app.dirs.stats"
5
+ * @param dafaultValue default value if path not exists
6
+ * @returns
7
+ */
8
+ export declare function Config(path: string, dafaultValue?: any): (target?: any, key?: string) => any;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Config = void 0;
4
+ const di_1 = require("@spinajs/di");
5
+ const types_1 = require("./types");
6
+ /**
7
+ * Injects configuration value to given class property
8
+ *
9
+ * @param path path to configuration value eg. "app.dirs.stats"
10
+ * @param dafaultValue default value if path not exists
11
+ * @returns
12
+ */
13
+ function Config(path, dafaultValue) {
14
+ return (target, key) => {
15
+ let config = null;
16
+ const getter = () => {
17
+ if (!config) {
18
+ config = di_1.DI.get(types_1.Configuration);
19
+ }
20
+ return config.get(path, dafaultValue);
21
+ };
22
+ Object.defineProperty(target, key, {
23
+ get: getter,
24
+ enumerable: false,
25
+ configurable: false
26
+ });
27
+ };
28
+ }
29
+ exports.Config = Config;
30
+ //# sourceMappingURL=decorators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":";;;AAAA,oCAAiC;AACjC,mCAAuC;AAEvC;;;;;;GAMG;AACH,SAAgB,MAAM,CAAC,IAAY,EAAE,YAAkB;IACnD,OAAO,CAAC,MAAY,EAAE,GAAY,EAAO,EAAE;QAEvC,IAAI,MAAM,GAAkB,IAAI,CAAC;QAEjC,MAAM,MAAM,GAAG,GAAG,EAAE;YAChB,IAAI,CAAC,MAAM,EAAE;gBACT,MAAM,GAAG,OAAE,CAAC,GAAG,CAAC,qBAAa,CAAC,CAAC;aAClC;YACD,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QAC1C,CAAC,CAAA;QAED,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE;YAC/B,GAAG,EAAE,MAAM;YACX,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,KAAK;SACtB,CAAC,CAAC;IACP,CAAC,CAAA;AACL,CAAC;AAlBD,wBAkBC"}
package/lib/index.d.ts CHANGED
@@ -1,69 +1,4 @@
1
- import { IContainer, SyncModule } from '@spinajs/di';
2
- export declare abstract class Configuration extends SyncModule {
3
- /**
4
- * Configuration base dir, where to look for app config
5
- */
6
- BaseDir: string;
7
- /**
8
- * Current running app name
9
- */
10
- RunApp: string;
11
- /**
12
- * Get config value for given property. Returns any if value is present, default value if provided or null when empty
13
- *
14
- * @param path - path to property eg. ["system","dirs"] or "system" or "system.dirs"
15
- */
16
- abstract get<T>(path: string[] | string, defaultValue?: T): T;
17
- }
18
- export declare class FrameworkConfiguration extends Configuration {
19
- /**
20
- * Configuration base dir, where to look for app config
21
- */
22
- BaseDir: string;
23
- /**
24
- * Current running app name
25
- */
26
- RunApp: string;
27
- /**
28
- * Default dirs to check for configuration files
29
- */
30
- protected CONFIG_DIRS: string[];
31
- /**
32
- * Loaded & merged configuration
33
- */
34
- protected Config: any;
35
- /**
36
- *
37
- * @param app application name, pass it when you run in application mode
38
- * @param baseDir configuration base dir, where to look for application configs
39
- * @param cfgCustomPaths custom cfg paths eg. to load config from non standard folders ( usefull in tests )
40
- */
41
- constructor(app?: string, appBaseDir?: string, cfgCustomPaths?: string[]);
42
- /**
43
- * Get config value for given property. Returns Maybe<any> if value is present or Maybe<null> when empty
44
- *
45
- * @param path - path to property eg. ["system","dirs"]
46
- * @param defaultValue - optional, if value at specified path not exists returns default value
47
- */
48
- get<T>(path: string[] | string, defaultValue?: T): T;
49
- resolve(_container: IContainer): void;
50
- protected load(extension: string, callback: (file: string) => any): void;
51
- protected dir(toJoin: string): string;
52
- /**
53
- * adds app dirs to system.dirs config
54
- */
55
- protected _appDirs(): void;
56
- /**
57
- * runs configuration func on files
58
- * eg. when you want to configure stuff at beginning eq. external libs
59
- */
60
- protected configure(): void;
61
- /**
62
- * Just prints framework version
63
- */
64
- protected version(): void;
65
- /**
66
- * Gets app name passed to CLI & adds proper config dirs to merge
67
- */
68
- protected configureApp(): void;
69
- }
1
+ export * from "./types";
2
+ export * from "./sources";
3
+ export * from "./decorators";
4
+ export * from "./configuration";
package/lib/index.js CHANGED
@@ -1,204 +1,17 @@
1
1
  "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
10
11
  };
11
12
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.FrameworkConfiguration = exports.Configuration = void 0;
13
- const di_1 = require("@spinajs/di");
14
- const fs = require("fs");
15
- const glob = require("glob");
16
- const _ = require("lodash");
17
- const path_1 = require("path");
18
- function log(message) {
19
- if (typeof jasmine === 'undefined') {
20
- console.log('[ CONFIGURATION ] ' + message);
21
- }
22
- }
23
- function merge(to, from) {
24
- _.mergeWith(to, from, (src, dest) => {
25
- if (_.isArray(src) && _.isArray(dest)) {
26
- const tmp = src.concat(dest);
27
- return _.uniqWith(tmp, _.isEqual);
28
- }
29
- else if (!src) {
30
- return dest;
31
- }
32
- });
33
- return to;
34
- }
35
- // clean require cache config
36
- // http://stackoverflow.com/questions/9210542/node-js-require-cache-possible-to-invalidate
37
- function uncache(file) {
38
- delete require.cache[file];
39
- return file;
40
- }
41
- function filterDirs(dir) {
42
- if (fs.existsSync(dir)) {
43
- log(`Found config dir at ${dir}`);
44
- return true;
45
- }
46
- return false;
47
- }
48
- class Configuration extends di_1.SyncModule {
49
- }
50
- exports.Configuration = Configuration;
51
- let FrameworkConfiguration = class FrameworkConfiguration extends Configuration {
52
- /**
53
- *
54
- * @param app application name, pass it when you run in application mode
55
- * @param baseDir configuration base dir, where to look for application configs
56
- * @param cfgCustomPaths custom cfg paths eg. to load config from non standard folders ( usefull in tests )
57
- */
58
- constructor(app, appBaseDir, cfgCustomPaths) {
59
- var _a;
60
- super();
61
- /**
62
- * Configuration base dir, where to look for app config
63
- */
64
- this.BaseDir = './';
65
- /**
66
- * Current running app name
67
- */
68
- this.RunApp = undefined;
69
- /**
70
- * Default dirs to check for configuration files
71
- */
72
- this.CONFIG_DIRS = [
73
- // this module path
74
- path_1.normalize(path_1.join(path_1.resolve(__dirname), '/../config')),
75
- // other @spinajs modules paths
76
- path_1.normalize(path_1.join(path_1.resolve(__dirname).split(path_1.sep + 'node_modules')[0], '/node_modules/@spinajs/orm/lib/config')),
77
- path_1.normalize(path_1.join(path_1.resolve(__dirname).split(path_1.sep + 'node_modules')[0], '/node_modules/@spinajs/orm-sqlite/lib/config')),
78
- path_1.normalize(path_1.join(path_1.resolve(__dirname).split(path_1.sep + 'node_modules')[0], '/node_modules/@spinajs/orm-sql/lib/config')),
79
- path_1.normalize(path_1.join(path_1.resolve(__dirname).split(path_1.sep + 'node_modules')[0], '/node_modules/@spinajs/log/lib/config')),
80
- path_1.normalize(path_1.join(path_1.resolve(__dirname).split(path_1.sep + 'node_modules')[0], '/node_modules/@spinajs/intl/lib/config')),
81
- path_1.normalize(path_1.join(path_1.resolve(__dirname).split(path_1.sep + 'node_modules')[0], '/node_modules/@spinajs/cli/lib/config')),
82
- path_1.normalize(path_1.join(path_1.resolve(__dirname).split(path_1.sep + 'node_modules')[0], '/node_modules/@spinajs/acl/lib/config')),
83
- path_1.normalize(path_1.join(path_1.resolve(__dirname).split(path_1.sep + 'node_modules')[0], '/node_modules/@spinajs/http/lib/config')),
84
- path_1.normalize(path_1.join(path_1.resolve(__dirname).split(path_1.sep + 'node_modules')[0], '/node_modules/@spinajs/acl-http/lib/config')),
85
- path_1.normalize(path_1.join(path_1.resolve(__dirname).split(path_1.sep + 'node_modules')[0], '/node_modules/@spinajs/jobs/lib/config')),
86
- // project paths - last to allow overwrite @spinajs conf
87
- path_1.normalize(path_1.join(path_1.resolve(__dirname).split(path_1.sep + 'node_modules')[0], '/dist/config')),
88
- path_1.normalize(path_1.join(path_1.resolve(__dirname).split(path_1.sep + 'node_modules')[0], '/build/config')),
89
- path_1.normalize(path_1.join(path_1.resolve(__dirname).split(path_1.sep + 'node_modules')[0], '/config')),
90
- ];
91
- /**
92
- * Loaded & merged configuration
93
- */
94
- this.Config = {};
95
- this.RunApp = app !== null && app !== void 0 ? app : parseArgv('--app');
96
- this.BaseDir = (_a = appBaseDir !== null && appBaseDir !== void 0 ? appBaseDir : parseArgv('--appPath')) !== null && _a !== void 0 ? _a : path_1.join(__dirname, '../apps/');
97
- log(`Running app: ${this.RunApp}`);
98
- log(`Base dir at: ${this.BaseDir}`);
99
- if (cfgCustomPaths) {
100
- this.CONFIG_DIRS = this.CONFIG_DIRS.concat(cfgCustomPaths);
101
- }
102
- function parseArgv(param) {
103
- const index = process.argv.indexOf(param);
104
- if (index === -1 || process.argv.length <= index + 1) {
105
- return undefined;
106
- }
107
- return process.argv[index + 1];
108
- }
109
- }
110
- /**
111
- * Get config value for given property. Returns Maybe<any> if value is present or Maybe<null> when empty
112
- *
113
- * @param path - path to property eg. ["system","dirs"]
114
- * @param defaultValue - optional, if value at specified path not exists returns default value
115
- */
116
- get(path, defaultValue) {
117
- return _.get(this.Config, path, defaultValue);
118
- }
119
- resolve(_container) {
120
- this.configureApp();
121
- this.load('js', (file) => {
122
- uncache(file);
123
- return require(file);
124
- });
125
- this.load('json', (file) => {
126
- return JSON.parse(fs.readFileSync(file, 'utf-8'));
127
- });
128
- this.version();
129
- this._appDirs();
130
- this.configure();
131
- }
132
- load(extension, callback) {
133
- this.CONFIG_DIRS.filter(filterDirs)
134
- // get all config files
135
- .map(d => glob.sync(d + `/**/*.${extension}`))
136
- // flatten files
137
- .reduce((prev, current) => {
138
- return prev.concat(_.flattenDeep(current));
139
- }, [])
140
- // normalize & resolve paths to be sure
141
- .map((f) => path_1.normalize(path_1.resolve(f)))
142
- // info about files about to load
143
- .map(f => {
144
- log(`Found file at: ${f}`);
145
- return f;
146
- })
147
- .map(callback)
148
- // load & merge configs
149
- .map(_.curry(merge)(this.Config));
150
- }
151
- dir(toJoin) {
152
- return path_1.normalize(path_1.join(path_1.resolve(this.BaseDir), toJoin));
153
- }
154
- /**
155
- * adds app dirs to system.dirs config
156
- */
157
- _appDirs() {
158
- if (_.isEmpty(this.RunApp)) {
159
- return;
160
- }
161
- for (const prop of Object.keys(this.get(['system', 'dirs'], []))) {
162
- this.get(['system', 'dirs', prop]).push(this.dir(`/${this.RunApp}/${prop}`));
163
- }
164
- }
165
- /**
166
- * runs configuration func on files
167
- * eg. when you want to configure stuff at beginning eq. external libs
168
- */
169
- configure() {
170
- for (const prop of Object.keys(this.Config)) {
171
- const subconfig = this.Config[prop];
172
- if (_.isFunction(subconfig.configure)) {
173
- subconfig.configure.call(subconfig);
174
- }
175
- }
176
- }
177
- /**
178
- * Just prints framework version
179
- */
180
- version() {
181
- const version = this.get('system.version', undefined);
182
- if (version) {
183
- log(`APP VERSION: ${version.major}.${version.minor}`);
184
- }
185
- else {
186
- log('APP VERSION UNKNOWN');
187
- }
188
- }
189
- /**
190
- * Gets app name passed to CLI & adds proper config dirs to merge
191
- */
192
- configureApp() {
193
- if (typeof this.RunApp === 'string') {
194
- log(`Application to run: ${this.RunApp}`);
195
- this.CONFIG_DIRS.push(this.dir(`/${this.RunApp}/config`));
196
- }
197
- }
198
- };
199
- FrameworkConfiguration = __decorate([
200
- di_1.Injectable(Configuration),
201
- __metadata("design:paramtypes", [String, String, Array])
202
- ], FrameworkConfiguration);
203
- exports.FrameworkConfiguration = FrameworkConfiguration;
13
+ __exportStar(require("./types"), exports);
14
+ __exportStar(require("./sources"), exports);
15
+ __exportStar(require("./decorators"), exports);
16
+ __exportStar(require("./configuration"), exports);
204
17
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oCAAiE;AACjE,yBAAyB;AACzB,6BAA6B;AAC7B,4BAA4B;AAC5B,+BAAqD;AAerD,SAAS,GAAG,CAAC,OAAe;IAC1B,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE;QAClC,OAAO,CAAC,GAAG,CAAC,oBAAoB,GAAG,OAAO,CAAC,CAAC;KAC7C;AACH,CAAC;AAED,SAAS,KAAK,CAAC,EAAO,EAAE,IAAS;IAC/B,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,GAAG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C,IAAI,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE;gBACrC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;aACrC;SACF;IACH,CAAC;IAED;;OAEG;IACO,OAAO;QACf,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAoB,gBAAgB,EAAE,SAAS,CAAC,CAAC;QAEzE,IAAI,OAAO,EAAE;YACX,GAAG,CAAC,gBAAgB,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;SACvD;aAAM;YACL,GAAG,CAAC,qBAAqB,CAAC,CAAC;SAC5B;IACH,CAAC;IAED;;OAEG;IACO,YAAY;QACpB,IAAI,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,EAAE;YACnC,GAAG,CAAC,uBAAuB,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;YAC1C,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,SAAS,CAAC,CAAC,CAAC;SAC3D;IACH,CAAC;CACF,CAAA;AA7KY,sBAAsB;IADlC,eAAU,CAAC,aAAa,CAAC;;GACb,sBAAsB,CA6KlC;AA7KY,wDAAsB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAAwB;AACxB,4CAA0B;AAC1B,+CAA6B;AAC7B,kDAAgC"}
@@ -0,0 +1,32 @@
1
+ export declare abstract class ConfigurationSource {
2
+ abstract Load(): Promise<any>;
3
+ }
4
+ export declare abstract class BaseFileSource extends ConfigurationSource {
5
+ protected RunApp?: string;
6
+ protected CustomConfigPaths?: string[];
7
+ protected appBaseDir?: string;
8
+ /**
9
+ * Configuration base dir, where to look for app config
10
+ */
11
+ BaseDir: string;
12
+ /**
13
+ * Default dirs to check for configuration files
14
+ */
15
+ protected CONFIG_DIRS: string[];
16
+ constructor(RunApp?: string, CustomConfigPaths?: string[], appBaseDir?: string);
17
+ protected load(extension: string, callback: (file: string) => any): {};
18
+ }
19
+ export declare class JsFileSource extends BaseFileSource {
20
+ /**
21
+ * Default dirs to check for configuration files
22
+ */
23
+ protected CONFIG_DIRS: string[];
24
+ Load(): Promise<any>;
25
+ }
26
+ export declare class JsonFileSource extends BaseFileSource {
27
+ /**
28
+ * Default dirs to check for configuration files
29
+ */
30
+ protected CONFIG_DIRS: string[];
31
+ Load(): Promise<any>;
32
+ }
package/lib/sources.js ADDED
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
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 __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
15
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
17
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
18
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
19
+ };
20
+ var __importStar = (this && this.__importStar) || function (mod) {
21
+ if (mod && mod.__esModule) return mod;
22
+ var result = {};
23
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
+ __setModuleDefault(result, mod);
25
+ return result;
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.JsonFileSource = exports.JsFileSource = exports.BaseFileSource = exports.ConfigurationSource = void 0;
29
+ const di_1 = require("@spinajs/di");
30
+ const glob_1 = require("glob");
31
+ const _ = require("lodash");
32
+ const path_1 = require("path");
33
+ const util_1 = require("./util");
34
+ const fs = __importStar(require("fs"));
35
+ const path = __importStar(require("path"));
36
+ const log_1 = require("@spinajs/log");
37
+ function mergeArrays(target, source) {
38
+ if (_.isArray(target)) {
39
+ return target.concat(source);
40
+ }
41
+ }
42
+ const DEFAULT_CONFIG_DIRS = [
43
+ // this module path
44
+ (0, path_1.normalize)((0, path_1.join)((0, path_1.resolve)(__dirname), '/../config')),
45
+ // for tests, in src dir
46
+ (0, path_1.normalize)((0, path_1.join)((0, path_1.resolve)(__dirname), '/config')),
47
+ // other @spinajs modules paths
48
+ 'node_modules/@spinajs/*/lib/config',
49
+ // project paths - last to allow overwrite @spinajs conf
50
+ 'lib/config',
51
+ 'dist/config',
52
+ 'build/config',
53
+ 'config',
54
+ ];
55
+ class ConfigurationSource {
56
+ }
57
+ exports.ConfigurationSource = ConfigurationSource;
58
+ class BaseFileSource extends ConfigurationSource {
59
+ constructor(RunApp, CustomConfigPaths, appBaseDir) {
60
+ super();
61
+ this.RunApp = RunApp;
62
+ this.CustomConfigPaths = CustomConfigPaths;
63
+ this.appBaseDir = appBaseDir;
64
+ /**
65
+ * Configuration base dir, where to look for app config
66
+ */
67
+ this.BaseDir = './';
68
+ /**
69
+ * Default dirs to check for configuration files
70
+ */
71
+ this.CONFIG_DIRS = [];
72
+ }
73
+ load(extension, callback) {
74
+ const config = {};
75
+ let dirs = this.CONFIG_DIRS;
76
+ const basePath = (0, util_1.findBasePath)(process.cwd());
77
+ if (this.RunApp) {
78
+ dirs = dirs.concat([(0, path_1.join)(this.appBaseDir, `/${this.RunApp}/config`)]);
79
+ }
80
+ if (this.CustomConfigPaths) {
81
+ dirs = dirs.concat(this.CustomConfigPaths);
82
+ }
83
+ dirs.map(f => path.isAbsolute(f) ? f : (0, path_1.join)(basePath, f))
84
+ // get all config files
85
+ .map(d => glob_1.glob.sync(d + `/**/${extension}`))
86
+ // flatten files
87
+ .reduce((prev, current) => {
88
+ return prev.concat(_.flattenDeep(current));
89
+ }, [])
90
+ // normalize & resolve paths to be sure
91
+ .map((f) => (0, path_1.normalize)((0, path_1.resolve)(f)))
92
+ .map(callback)
93
+ .filter((v) => v !== null)
94
+ // load & merge configs
95
+ .map((c) => _.mergeWith(config, c, mergeArrays));
96
+ return config;
97
+ }
98
+ }
99
+ exports.BaseFileSource = BaseFileSource;
100
+ let JsFileSource = class JsFileSource extends BaseFileSource {
101
+ constructor() {
102
+ super(...arguments);
103
+ /**
104
+ * Default dirs to check for configuration files
105
+ */
106
+ this.CONFIG_DIRS = DEFAULT_CONFIG_DIRS;
107
+ }
108
+ async Load() {
109
+ const common = this.load('!(*.dev|*.prod).js', _load);
110
+ if (process.env.NODE_ENV) {
111
+ if (process.env.NODE_ENV === "development") {
112
+ return _.mergeWith(common, this.load("*.dev.js", _load), mergeArrays);
113
+ }
114
+ else if (process.env.NODE_ENV === "production") {
115
+ return _.mergeWith(common, this.load("*.prod.js", _load), mergeArrays);
116
+ }
117
+ }
118
+ return common;
119
+ function _load(file) {
120
+ log_1.Log.trace(`Found configuration file at ${file}`, "Configuration");
121
+ (0, util_1.uncache)(file);
122
+ return require(file);
123
+ }
124
+ }
125
+ };
126
+ JsFileSource = __decorate([
127
+ (0, di_1.Injectable)(ConfigurationSource)
128
+ ], JsFileSource);
129
+ exports.JsFileSource = JsFileSource;
130
+ let JsonFileSource = class JsonFileSource extends BaseFileSource {
131
+ constructor() {
132
+ super(...arguments);
133
+ /**
134
+ * Default dirs to check for configuration files
135
+ */
136
+ this.CONFIG_DIRS = DEFAULT_CONFIG_DIRS;
137
+ }
138
+ async Load() {
139
+ const common = this.load('!(*.dev|*.prod).json', _load);
140
+ if (process.env.NODE_ENV) {
141
+ if (process.env.NODE_ENV === "development") {
142
+ return _.merge(common, this.load("*.dev.json", _load));
143
+ }
144
+ else if (process.env.NODE_ENV === "production") {
145
+ return _.merge(common, this.load("*.prod.json", _load));
146
+ }
147
+ }
148
+ return common;
149
+ function _load(file) {
150
+ try {
151
+ log_1.Log.trace(`Found configuration file at ${file}`, "Configuration");
152
+ return JSON.parse(fs.readFileSync(file, "utf-8"));
153
+ }
154
+ catch (err) {
155
+ log_1.Log.error(err, `Config ${file} invalid !`, "Configuration");
156
+ return null;
157
+ }
158
+ }
159
+ }
160
+ };
161
+ JsonFileSource = __decorate([
162
+ (0, di_1.Injectable)(ConfigurationSource)
163
+ ], JsonFileSource);
164
+ exports.JsonFileSource = JsonFileSource;
165
+ //# sourceMappingURL=sources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sources.js","sourceRoot":"","sources":["../src/sources.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAyC;AACzC,+BAA4B;AAC5B,4BAA6B;AAC7B,+BAAgD;AAChD,iCAA+C;AAC/C,uCAAyB;AACzB,2CAA6B;AAC7B,sCAAmC;AAGnC,SAAS,WAAW,CAAC,MAAW,EAAE,MAAW;IACzC,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACnB,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;KAChC;AACL,CAAC;AAED,MAAM,mBAAmB,GAAG;IACxB,mBAAmB;IACnB,IAAA,gBAAS,EAAC,IAAA,WAAI,EAAC,IAAA,cAAO,EAAC,SAAS,CAAC,EAAE,YAAY,CAAC,CAAC;IAEjD,wBAAwB;IACxB,IAAA,gBAAS,EAAC,IAAA,WAAI,EAAC,IAAA,cAAO,EAAC,SAAS,CAAC,EAAE,SAAS,CAAC,CAAC;IAG9C,+BAA+B;IAC/B,oCAAoC;IAGpC,wDAAwD;IACxD,YAAY;IACZ,aAAa;IACb,cAAc;IACd,QAAQ;CACX,CAAC;AAEF,MAAsB,m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U,IAAI,YAAY,EAAE,eAAe,CAAC,CAAC;gBAC5D,OAAO,IAAI,CAAC;aACf;QACL,CAAC;IACL,CAAC;CACJ,CAAA;AA/BY,cAAc;IAD1B,IAAA,eAAU,EAAC,mBAAmB,CAAC;GACnB,cAAc,CA+B1B;AA/BY,wCAAc"}
package/lib/types.d.ts ADDED
@@ -0,0 +1,46 @@
1
+ import { AsyncModule } from '@spinajs/di';
2
+ /**
3
+ * App version struct
4
+ */
5
+ export interface IFrameworkVersion {
6
+ minor: number;
7
+ major: number;
8
+ }
9
+ export interface ConfigurationOptions {
10
+ /**
11
+ * application name, pass it when you run in application mode
12
+ */
13
+ app?: string;
14
+ /**
15
+ * configuration base dir, where to look for application configs
16
+ */
17
+ appBaseDir?: string;
18
+ /**
19
+ * custom cfg paths eg. to load config from non standard folders ( usefull in tests )
20
+ */
21
+ cfgCustomPaths?: string[];
22
+ /**
23
+ * Should watch for changes in config files
24
+ */
25
+ watchFileChanges?: boolean;
26
+ }
27
+ export declare abstract class Configuration extends AsyncModule {
28
+ /**
29
+ * Configuration base dir, where to look for app config
30
+ */
31
+ BaseDir: string;
32
+ /**
33
+ * Current running app name
34
+ */
35
+ RunApp: string;
36
+ /**
37
+ * Apps configuration base dir, where to look for app config
38
+ */
39
+ AppBaseDir: string;
40
+ /**
41
+ * Get config value for given property. Returns any if value is present, default value if provided or null when empty
42
+ *
43
+ * @param path - path to property eg. ["system","dirs"] or "system" or "system.dirs"
44
+ */
45
+ abstract get<T>(path: string[] | string, defaultValue?: T): T;
46
+ }
package/lib/types.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Configuration = void 0;
4
+ const di_1 = require("@spinajs/di");
5
+ class Configuration extends di_1.AsyncModule {
6
+ }
7
+ exports.Configuration = Configuration;
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAA,oCAA0C;AAgC1C,MAAsB,aAAc,SAAQ,gBAAW;CAuBtD;AAvBD,sCAuBC"}
package/lib/util.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export declare function parseArgv(param: string): string;
2
+ export declare function findBasePath(path: string): string;
3
+ export declare function merge(to: any, from: any): void;
4
+ export declare function uncache(file: string): string;
5
+ export declare function filterDirs(dir: string): boolean;
package/lib/util.js ADDED
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
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
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.filterDirs = exports.uncache = exports.merge = exports.findBasePath = exports.parseArgv = void 0;
23
+ const fs = __importStar(require("fs"));
24
+ const _ = require("lodash");
25
+ const path_1 = require("path");
26
+ function parseArgv(param) {
27
+ const index = process.argv.indexOf(param);
28
+ if (index === -1 || process.argv.length <= index + 1) {
29
+ return undefined;
30
+ }
31
+ return process.argv[index + 1];
32
+ }
33
+ exports.parseArgv = parseArgv;
34
+ function findBasePath(path) {
35
+ if (fs.existsSync((0, path_1.join)(path, 'node_modules'))) {
36
+ return path;
37
+ }
38
+ return findBasePath((0, path_1.resolve)(path, '..'));
39
+ }
40
+ exports.findBasePath = findBasePath;
41
+ function merge(to, from) {
42
+ _.mergeWith(to, from, (src, dest) => {
43
+ if (_.isArray(src) && _.isArray(dest)) {
44
+ const tmp = src.concat(dest);
45
+ return _.uniqWith(tmp, _.isEqual);
46
+ }
47
+ else if (!src) {
48
+ return dest;
49
+ }
50
+ });
51
+ return to;
52
+ }
53
+ exports.merge = merge;
54
+ // clean require cache config
55
+ // http://stackoverflow.com/questions/9210542/node-js-require-cache-possible-to-invalidate
56
+ function uncache(file) {
57
+ delete require.cache[file];
58
+ return file;
59
+ }
60
+ exports.uncache = uncache;
61
+ function filterDirs(dir) {
62
+ if (fs.existsSync(dir)) {
63
+ return true;
64
+ }
65
+ return false;
66
+ }
67
+ exports.filterDirs = filterDirs;
68
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,4BAA6B;AAC7B,+BAAqC;AAOrC,SAAgB,SAAS,CAAC,KAAa;IACnC,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAE1C,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,KAAK,GAAG,CAAC,EAAE;QAClD,OAAO,SAAS,CAAC;KACpB;IAED,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;AACnC,CAAC;AARD,8BAQC;AAED,SAAgB,YAAY,CAAC,IAAY;IACrC,IAAI,EAAE,CAAC,UAAU,CAAC,IAAA,WAAI,EAAC,IAAI,EAAE,cAAc,CAAC,CAAC,EAAE;QAC3C,OAAO,IAAI,CAAC;KACf;IAED,OAAO,YAAY,CAAC,IAAA,cAAO,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAC7C,CAAC;AAND,oCAMC;AAED,SAAgB,KAAK,CAAC,EAAO,EAAE,IAAS;IACpC,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;QAChC,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACnC,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAC7B,OAAO,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;SACrC;aAAM,IAAI,CAAC,GAAG,EAAE;YACb,OAAO,IAAI,CAAC;SACf;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,CAAC;AACd,CAAC;AAXD,sBAWC;AAGD,6BAA6B;AAC7B,0FAA0F;AAC1F,SAAgB,OAAO,CAAC,IAAY;IAChC,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,IAAI,CAAC;AAChB,CAAC;AAHD,0BAGC;AAED,SAAgB,UAAU,CAAC,GAAW;IAClC,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QACpB,OAAO,IAAI,CAAC;KACf;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AALD,gCAKC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spinajs/configuration",
3
- "version": "1.0.12",
3
+ "version": "1.1.2",
4
4
  "description": "framework configuration module",
5
5
  "main": "lib/index.js",
6
6
  "private": false,
@@ -8,11 +8,12 @@
8
8
  "test": "ts-mocha -p tsconfig.json test/**/*.test.ts",
9
9
  "coverage": "nyc npm run test",
10
10
  "build-docs": "rimraf docs && typedoc --options typedoc.json src/",
11
- "build": "tsc",
11
+ "build": "",
12
+ "build-watch": "tsc -w",
12
13
  "prepare": "npm run build",
13
14
  "format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
14
15
  "lint": "tslint -p tsconfig.json",
15
- "prepublishOnly": "npm test && npm run lint",
16
+
16
17
  "preversion": "npm run lint",
17
18
  "version": "npm run format && git add -A src",
18
19
  "postversion": "git push && git push --tags"
@@ -20,6 +21,7 @@
20
21
  "files": [
21
22
  "lib/**/*"
22
23
  ],
24
+ "types": "lib",
23
25
  "repository": {
24
26
  "type": "git",
25
27
  "url": "git+https://github.com/spinajs/configuration.git"
@@ -37,7 +39,9 @@
37
39
  },
38
40
  "homepage": "https://github.com/spinajs/configuration#readme",
39
41
  "dependencies": {
40
- "@spinajs/di": "^1.0.16",
42
+ "@spinajs/di": "^1.1.7",
43
+ "@spinajs/exceptions": "^1.0.5",
44
+ "@spinajs/log": "^1.1.0",
41
45
  "glob": "^7.1.4",
42
46
  "lodash": "^4.17.14"
43
47
  },
@@ -45,23 +49,24 @@
45
49
  "@types/bunyan": "^1.8.6",
46
50
  "@types/chai": "^4.1.7",
47
51
  "@types/chai-as-promised": "^7.1.0",
52
+ "@types/glob": "^7.2.0",
48
53
  "@types/lodash": "^4.14.136",
49
- "@types/mocha": "^5.2.7",
50
- "@types/sinon": "^7.0.13",
54
+ "@types/mocha": "^9.1.0",
55
+ "@types/sinon": "^10.0.8",
51
56
  "chai": "^4.2.0",
52
57
  "chai-as-promised": "^7.1.1",
53
- "mocha": "^6.1.4",
54
- "nyc": "^14.1.1",
55
- "prettier": "^1.18.2",
56
- "sinon": "^7.3.2",
57
- "ts-mocha": "^6.0.0",
58
- "ts-node": "^8.3.0",
59
- "tslint": "^5.20.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",
60
65
  "tslint-circular-dependencies": "^0.1.0",
61
66
  "tslint-config-prettier": "^1.18.0",
62
- "tslint-config-standard": "^8.0.1",
67
+ "tslint-config-standard": "^9.0.0",
63
68
  "tslint-no-unused-expression-chai": "^0.1.4",
64
- "typedoc": "^0.14.2",
65
- "typescript": "^3.7.3"
69
+ "typedoc": "^0.22.11",
70
+ "typescript": "^4.2.3"
66
71
  }
67
72
  }