@allgemein/config 1.4.1 → 1.5.1
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/browser.d.ts +11 -11
- package/browser.js +8 -23
- package/browser.js.map +1 -1
- package/config/Config.d.ts +4 -4
- package/config/Config.js +31 -35
- package/config/Config.js.map +1 -1
- package/config/ConfigHandler.d.ts +9 -9
- package/config/ConfigHandler.js +17 -21
- package/config/ConfigHandler.js.map +1 -1
- package/config/ConfigJar.d.ts +3 -3
- package/config/ConfigJar.js +19 -23
- package/config/ConfigJar.js.map +1 -1
- package/config/ConfigSupport.d.ts +2 -2
- package/config/ConfigSupport.js +5 -9
- package/config/ConfigSupport.js.map +1 -1
- package/config/IConfigData.js +1 -2
- package/config/IConfigOptions.js +1 -2
- package/config/IJarOptions.js +1 -2
- package/config/IOptions.d.ts +2 -2
- package/config/IOptions.js +1 -2
- package/config/Source.d.ts +1 -1
- package/config/Source.js +1 -5
- package/config/Source.js.map +1 -1
- package/config/handler/DirectoryConfig.d.ts +6 -6
- package/config/handler/DirectoryConfig.js +26 -30
- package/config/handler/DirectoryConfig.js.map +1 -1
- package/config/handler/FileConfig.d.ts +4 -4
- package/config/handler/FileConfig.js +19 -23
- package/config/handler/FileConfig.js.map +1 -1
- package/config/handler/FileSource.d.ts +2 -2
- package/config/handler/FileSource.js +2 -6
- package/config/handler/FileSource.js.map +1 -1
- package/config/handler/IDirectoryConfigOptions.d.ts +2 -2
- package/config/handler/IDirectoryConfigOptions.js +1 -2
- package/config/handler/IFileConfigOptions.d.ts +2 -2
- package/config/handler/IFileConfigOptions.js +1 -2
- package/config/handler/IFilePath.js +1 -2
- package/config/handler/SystemConfig.d.ts +4 -4
- package/config/handler/SystemConfig.js +19 -23
- package/config/handler/SystemConfig.js.map +1 -1
- package/config/handler/index.d.ts +2 -2
- package/config/handler/index.js +2 -18
- package/config/handler/index.js.map +1 -1
- package/filesupport/FileSupport.d.ts +8 -8
- package/filesupport/FileSupport.js +21 -25
- package/filesupport/FileSupport.js.map +1 -1
- package/filesupport/IFileSupport.d.ts +1 -1
- package/filesupport/IFileSupport.js +1 -2
- package/filesupport/IFileSupportInfo.js +1 -2
- package/filesupport/types/JsonFileSupport.d.ts +2 -2
- package/filesupport/types/JsonFileSupport.js +2 -6
- package/filesupport/types/JsonFileSupport.js.map +1 -1
- package/filesupport/types/PropertiesFileSupport.d.ts +2 -2
- package/filesupport/types/PropertiesFileSupport.js +5 -9
- package/filesupport/types/PropertiesFileSupport.js.map +1 -1
- package/filesupport/types/XmlFileSupport.d.ts +2 -2
- package/filesupport/types/XmlFileSupport.js +5 -9
- package/filesupport/types/XmlFileSupport.js.map +1 -1
- package/filesupport/types/YamlFileSupport.d.ts +2 -2
- package/filesupport/types/YamlFileSupport.js +5 -9
- package/filesupport/types/YamlFileSupport.js.map +1 -1
- package/index.d.ts +16 -16
- package/index.js +11 -35
- package/index.js.map +1 -1
- package/package.json +3 -2
- package/supports/InterpolationSupport.d.ts +1 -1
- package/supports/InterpolationSupport.js +3 -7
- package/supports/InterpolationSupport.js.map +1 -1
- package/types.js +6 -9
- package/types.js.map +1 -1
- package/utils/Utils.d.ts +1 -1
- package/utils/Utils.js +16 -20
- package/utils/Utils.js.map +1 -1
|
@@ -1,30 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const base_1 = require("@allgemein/base");
|
|
9
|
-
const micromatch_1 = require("micromatch");
|
|
10
|
-
const lodash_1 = require("lodash");
|
|
1
|
+
import { Utils } from '../../utils/Utils.js';
|
|
2
|
+
import { DEFAULT_JAR_NAME, NAMING_BY_DIRECTORY, NAMING_BY_DIRECTORYPATH, NAMING_BY_FILENAME, NAMING_BY_FULLPATH, SELECTOR_SEPARATOR } from '../../types.js';
|
|
3
|
+
import { ConfigSupport } from '../ConfigSupport.js';
|
|
4
|
+
import { FileConfig } from './FileConfig.js';
|
|
5
|
+
import { Glob, PlatformUtils } from '@allgemein/base';
|
|
6
|
+
import micromatch from 'micromatch';
|
|
7
|
+
import { defaultsDeep } from '@allgemein/base';
|
|
11
8
|
/**
|
|
12
9
|
* Load config
|
|
13
10
|
*/
|
|
14
|
-
class DirectoryConfig extends
|
|
11
|
+
export class DirectoryConfig extends ConfigSupport {
|
|
15
12
|
constructor(options, jarsData = []) {
|
|
16
|
-
super(
|
|
13
|
+
super(defaultsDeep(options, DirectoryConfig.DEFAULT_DIRECTORY_OPTIONS), jarsData);
|
|
17
14
|
}
|
|
18
15
|
type() {
|
|
19
16
|
return 'directory';
|
|
20
17
|
}
|
|
21
18
|
listFilesInDirectory() {
|
|
22
|
-
const dirname =
|
|
23
|
-
if (!
|
|
19
|
+
const dirname = PlatformUtils.pathNormAndResolve(this.$options.dirname);
|
|
20
|
+
if (!PlatformUtils.fileExist(dirname) || !PlatformUtils.isDir(dirname)) {
|
|
24
21
|
throw new Error('wrong directory ' + dirname);
|
|
25
22
|
}
|
|
26
|
-
const list =
|
|
27
|
-
const regex =
|
|
23
|
+
const list = Glob.sync(dirname + '/**');
|
|
24
|
+
const regex = Utils.escapeRegExp(this.$options.patternSeparator);
|
|
28
25
|
const patternRegex = new RegExp(regex, 'g');
|
|
29
26
|
const files = [];
|
|
30
27
|
// const self = this;
|
|
@@ -37,28 +34,28 @@ class DirectoryConfig extends ConfigSupport_1.ConfigSupport {
|
|
|
37
34
|
path = path.replace(/^\//, '');
|
|
38
35
|
if (this.$options.exclude && this.$options.exclude.length > 0) {
|
|
39
36
|
// findes if path is excluded
|
|
40
|
-
const result =
|
|
37
|
+
const result = micromatch.match([path], this.$options.exclude, { dot: true });
|
|
41
38
|
if (result.length && result[0] === path) {
|
|
42
39
|
return;
|
|
43
40
|
}
|
|
44
41
|
}
|
|
45
|
-
const is_file =
|
|
42
|
+
const is_file = PlatformUtils.isFile(file_or_dir);
|
|
46
43
|
const paths = path.replace(/^\//, '').split('/');
|
|
47
44
|
if (is_file) {
|
|
48
45
|
const filename_ext = paths.pop();
|
|
49
|
-
const filename =
|
|
46
|
+
const filename = PlatformUtils.filename(filename_ext);
|
|
50
47
|
if (!patternRegex.test(filename)) {
|
|
51
48
|
const file = {
|
|
52
49
|
dirname: file_or_dir.replace(filename_ext, ''),
|
|
53
50
|
filename: filename,
|
|
54
|
-
type:
|
|
51
|
+
type: PlatformUtils.pathExtname(filename_ext, false)
|
|
55
52
|
};
|
|
56
53
|
const fileCfg = {
|
|
57
|
-
namespace: this.$options.namespace ? this.$options.namespace :
|
|
54
|
+
namespace: this.$options.namespace ? this.$options.namespace : DEFAULT_JAR_NAME,
|
|
58
55
|
file: file,
|
|
59
56
|
pattern: []
|
|
60
57
|
};
|
|
61
|
-
const prefixing = DirectoryConfig.resolveName(this.$options.prefixing, paths, filename,
|
|
58
|
+
const prefixing = DirectoryConfig.resolveName(this.$options.prefixing, paths, filename, SELECTOR_SEPARATOR);
|
|
62
59
|
if (prefixing) {
|
|
63
60
|
fileCfg.prefix = prefixing;
|
|
64
61
|
}
|
|
@@ -83,18 +80,18 @@ class DirectoryConfig extends ConfigSupport_1.ConfigSupport {
|
|
|
83
80
|
static resolveName(named, paths, filename, separator = '.') {
|
|
84
81
|
let v = null;
|
|
85
82
|
if (named) {
|
|
86
|
-
const _paths =
|
|
83
|
+
const _paths = Utils.clone(paths);
|
|
87
84
|
switch (named) {
|
|
88
|
-
case
|
|
85
|
+
case NAMING_BY_DIRECTORY:
|
|
89
86
|
v = _paths.pop();
|
|
90
87
|
break;
|
|
91
|
-
case
|
|
88
|
+
case NAMING_BY_DIRECTORYPATH:
|
|
92
89
|
v = _paths.join(separator);
|
|
93
90
|
break;
|
|
94
|
-
case
|
|
91
|
+
case NAMING_BY_FILENAME:
|
|
95
92
|
v = filename;
|
|
96
93
|
break;
|
|
97
|
-
case
|
|
94
|
+
case NAMING_BY_FULLPATH:
|
|
98
95
|
_paths.push(filename);
|
|
99
96
|
v = _paths.join(separator);
|
|
100
97
|
break;
|
|
@@ -106,7 +103,7 @@ class DirectoryConfig extends ConfigSupport_1.ConfigSupport {
|
|
|
106
103
|
const files = this.listFilesInDirectory();
|
|
107
104
|
const jars = {};
|
|
108
105
|
files.forEach(_options => {
|
|
109
|
-
const fileCfg = new
|
|
106
|
+
const fileCfg = new FileConfig(_options);
|
|
110
107
|
const jar = fileCfg.create();
|
|
111
108
|
if (jar) {
|
|
112
109
|
if (jars[jar.namespace]) {
|
|
@@ -128,9 +125,8 @@ class DirectoryConfig extends ConfigSupport_1.ConfigSupport {
|
|
|
128
125
|
return _jars;
|
|
129
126
|
}
|
|
130
127
|
}
|
|
131
|
-
exports.DirectoryConfig = DirectoryConfig;
|
|
132
128
|
DirectoryConfig.DEFAULT_DIRECTORY_OPTIONS = {
|
|
133
|
-
namespace:
|
|
129
|
+
namespace: DEFAULT_JAR_NAME,
|
|
134
130
|
dirname: null,
|
|
135
131
|
namespaceing: null,
|
|
136
132
|
namespaceSeparator: '.',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DirectoryConfig.js","sourceRoot":"","sources":["../../../../src/config/handler/DirectoryConfig.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DirectoryConfig.js","sourceRoot":"","sources":["../../../../src/config/handler/DirectoryConfig.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,KAAK,EAAC,MAAM,sBAAsB,CAAC;AAG3C,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EAElB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAC,IAAI,EAAE,aAAa,EAAC,MAAM,iBAAiB,CAAC;AACpD,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,YAAY,EAAC,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AAI,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;YAC7B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC;IACf,CAAC;CAEF;AA5JQ,yCAAyB,GAA4B;IAE1D,SAAS,EAAE,gBAAgB;IAE3B,OAAO,EAAE,IAAI;IAEb,YAAY,EAAE,IAAI;IAElB,kBAAkB,EAAE,GAAG;IAEvB,gBAAgB,EAAE,GAAG;IAErB,SAAS,EAAE,IAAI;IAEf,aAAa,EAAE,EAAE;CAElB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ConfigSupport } from '../ConfigSupport';
|
|
2
|
-
import { ConfigJar } from '../ConfigJar';
|
|
3
|
-
import { IFileConfigOptions } from './IFileConfigOptions';
|
|
4
|
-
import { IConfigData } from '../IConfigData';
|
|
1
|
+
import { ConfigSupport } from '../ConfigSupport.js';
|
|
2
|
+
import { ConfigJar } from '../ConfigJar.js';
|
|
3
|
+
import { IFileConfigOptions } from './IFileConfigOptions.js';
|
|
4
|
+
import { IConfigData } from '../IConfigData.js';
|
|
5
5
|
/**
|
|
6
6
|
* Read configuration from file
|
|
7
7
|
*/
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const ConfigJar_1 = require("../ConfigJar");
|
|
7
|
-
const FileSupport_1 = require("../../filesupport/FileSupport");
|
|
8
|
-
const FileSource_1 = require("./FileSource");
|
|
1
|
+
import { PlatformUtils } from '@allgemein/base';
|
|
2
|
+
import { ConfigSupport } from '../ConfigSupport.js';
|
|
3
|
+
import { ConfigJar } from '../ConfigJar.js';
|
|
4
|
+
import { FileSupport } from '../../filesupport/FileSupport.js';
|
|
5
|
+
import { FileSource } from './FileSource.js';
|
|
9
6
|
/**
|
|
10
7
|
* Read configuration from file
|
|
11
8
|
*/
|
|
12
|
-
class FileConfig extends
|
|
9
|
+
export class FileConfig extends ConfigSupport {
|
|
13
10
|
constructor(options, jarsData = []) {
|
|
14
11
|
super(options, jarsData);
|
|
15
12
|
}
|
|
@@ -17,13 +14,13 @@ class FileConfig extends ConfigSupport_1.ConfigSupport {
|
|
|
17
14
|
return 'file';
|
|
18
15
|
}
|
|
19
16
|
readFile(file) {
|
|
20
|
-
const supportedTypes =
|
|
17
|
+
const supportedTypes = FileSupport.getSupportedTypes();
|
|
21
18
|
let used_path = null;
|
|
22
19
|
let used_ext = null;
|
|
23
20
|
while (!used_ext && supportedTypes.length > 0) {
|
|
24
21
|
const ext = supportedTypes.shift();
|
|
25
22
|
used_path = file.dirname + '/' + file.filename + '.' + ext;
|
|
26
|
-
if (
|
|
23
|
+
if (PlatformUtils.fileExist(used_path)) {
|
|
27
24
|
used_ext = ext;
|
|
28
25
|
}
|
|
29
26
|
}
|
|
@@ -31,18 +28,18 @@ class FileConfig extends ConfigSupport_1.ConfigSupport {
|
|
|
31
28
|
return null;
|
|
32
29
|
}
|
|
33
30
|
file.type = used_ext;
|
|
34
|
-
const supportInfo =
|
|
31
|
+
const supportInfo = FileSupport.getInfoByExtension(used_ext);
|
|
35
32
|
if (!supportInfo.enabled) {
|
|
36
33
|
throw new Error(`${used_ext} support not enabled`);
|
|
37
34
|
}
|
|
38
|
-
const support =
|
|
35
|
+
const support = FileSupport.getSupportByExtension(used_ext);
|
|
39
36
|
let content = null;
|
|
40
37
|
let data = null;
|
|
41
38
|
if (supportInfo.readable) {
|
|
42
39
|
data = support.read(used_path);
|
|
43
40
|
}
|
|
44
41
|
else if (supportInfo.parseable) {
|
|
45
|
-
content =
|
|
42
|
+
content = PlatformUtils.readFileSync(used_path);
|
|
46
43
|
data = support.parse(content);
|
|
47
44
|
}
|
|
48
45
|
else {
|
|
@@ -67,7 +64,7 @@ class FileConfig extends ConfigSupport_1.ConfigSupport {
|
|
|
67
64
|
} else
|
|
68
65
|
*/
|
|
69
66
|
if (data) {
|
|
70
|
-
const source = new
|
|
67
|
+
const source = new FileSource({ data: data, file: path, prefix: this.$options.prefix });
|
|
71
68
|
collection.push(source);
|
|
72
69
|
}
|
|
73
70
|
});
|
|
@@ -76,16 +73,16 @@ class FileConfig extends ConfigSupport_1.ConfigSupport {
|
|
|
76
73
|
explodeFilePath(path) {
|
|
77
74
|
let file = null;
|
|
78
75
|
if (typeof path === 'string') {
|
|
79
|
-
const filepath =
|
|
76
|
+
const filepath = PlatformUtils.pathNormilize(PlatformUtils.pathResolve(path));
|
|
80
77
|
file = {
|
|
81
|
-
dirname:
|
|
82
|
-
filename:
|
|
83
|
-
type:
|
|
78
|
+
dirname: PlatformUtils.dirname(filepath),
|
|
79
|
+
filename: PlatformUtils.filename(filepath),
|
|
80
|
+
type: PlatformUtils.pathExtname(filepath),
|
|
84
81
|
};
|
|
85
82
|
}
|
|
86
83
|
else {
|
|
87
84
|
file = path;
|
|
88
|
-
file.dirname =
|
|
85
|
+
file.dirname = PlatformUtils.pathNormilize(PlatformUtils.pathResolve(file.dirname));
|
|
89
86
|
// TODO check if extension is falsely set in filename
|
|
90
87
|
}
|
|
91
88
|
return file;
|
|
@@ -118,15 +115,14 @@ class FileConfig extends ConfigSupport_1.ConfigSupport {
|
|
|
118
115
|
files = files.concat(additional_files);
|
|
119
116
|
}
|
|
120
117
|
const sources = this.readFiles(files);
|
|
121
|
-
if (sources.length
|
|
118
|
+
if (sources.length === 0) {
|
|
122
119
|
return null;
|
|
123
120
|
}
|
|
124
|
-
const jar =
|
|
121
|
+
const jar = ConfigJar.create(this.$options);
|
|
125
122
|
sources.forEach(_source => {
|
|
126
123
|
jar.merge(_source);
|
|
127
124
|
});
|
|
128
125
|
return jar;
|
|
129
126
|
}
|
|
130
127
|
}
|
|
131
|
-
exports.FileConfig = FileConfig;
|
|
132
128
|
//# sourceMappingURL=FileConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileConfig.js","sourceRoot":"","sources":["../../../../src/config/handler/FileConfig.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FileConfig.js","sourceRoot":"","sources":["../../../../src/config/handler/FileConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAC,WAAW,EAAC,MAAM,kCAAkC,CAAC;AAG7D,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAI3C;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,aAAiC;IAG/D,YAAY,OAA2B,EAAE,QAAQ,GAAkB,EAAE;QACnE,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC3B,CAAC;IAED,IAAI;QACF,OAAO,MAAM,CAAC;IAChB,CAAC;IAGO,QAAQ,CAAC,IAAe;QAC9B,MAAM,cAAc,GAAG,WAAW,CAAC,iBAAiB,EAAE,CAAC;QACvD,IAAI,SAAS,GAAG,IAAI,CAAC;QACrB,IAAI,QAAQ,GAAG,IAAI,CAAC;QAEpB,OAAO,CAAC,QAAQ,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9C,MAAM,GAAG,GAAG,cAAc,CAAC,KAAK,EAAE,CAAC;YACnC,SAAS,GAAG,IAAI,CAAC,OAAO,GAAG,GAAG,GAAG,IAAI,CAAC,QAAQ,GAAG,GAAG,GAAG,GAAG,CAAC;YAC3D,IAAI,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC;gBACvC,QAAQ,GAAG,GAAG,CAAC;YACjB,CAAC;QACH,CAAC;QAED,IAAI,CAAC,QAAQ,IAAI,CAAC,SAAS,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,CAAC,IAAI,GAAG,QAAQ,C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,CAAC;qBAAM,CAAC;oBACN,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,OAAO,GAAG,GAAG,GAAG,OAAO,CAAC,CAAC;gBACnE,CAAC;gBACD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACtB,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAGD,MAAM;QACJ,IAAI,KAAK,GAAgB,EAAE,CAAC;QAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC1D,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAErB,MAAM,gBAAgB,GAAG,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QAC3D,IAAI,gBAAgB,CAAC,MAAM,EAAE,CAAC;YAC5B,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACzC,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAEtC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,GAAG,GAAG,SAAS,CAAC,MAAM,CAAc,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzD,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YACxB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,CAAC;IACb,CAAC;CAGF"}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.FileSource = void 0;
|
|
4
|
-
const Source_1 = require("../Source");
|
|
5
|
-
class FileSource extends Source_1.Source {
|
|
1
|
+
import { Source } from '../Source.js';
|
|
2
|
+
export class FileSource extends Source {
|
|
6
3
|
constructor(opts) {
|
|
7
4
|
super({ ...opts, source: 'file' });
|
|
8
5
|
}
|
|
9
6
|
}
|
|
10
|
-
exports.FileSource = FileSource;
|
|
11
7
|
//# sourceMappingURL=FileSource.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileSource.js","sourceRoot":"","sources":["../../../../src/config/handler/FileSource.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FileSource.js","sourceRoot":"","sources":["../../../../src/config/handler/FileSource.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAGpC,MAAM,OAAO,UAAW,SAAQ,MAAM;IAKpC,YAAY,IAAS;QACnB,KAAK,CAAC,EAAC,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,EAAC,CAAC,CAAC;IACnC,CAAC;CAEF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IConfigOptions } from '../IConfigOptions';
|
|
2
|
-
import { NamingResolvePattern } from '../../types';
|
|
1
|
+
import { IConfigOptions } from '../IConfigOptions.js';
|
|
2
|
+
import { NamingResolvePattern } from '../../types.js';
|
|
3
3
|
export interface IDirectoryConfigOptions extends IConfigOptions {
|
|
4
4
|
/**
|
|
5
5
|
* Directory path where the config files are found and loaded from.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IConfigOptions } from '../IConfigOptions';
|
|
2
|
-
import { IFilePath } from './IFilePath';
|
|
1
|
+
import { IConfigOptions } from '../IConfigOptions.js';
|
|
2
|
+
import { IFilePath } from './IFilePath.js';
|
|
3
3
|
export interface IFileConfigOptions extends IConfigOptions {
|
|
4
4
|
/**
|
|
5
5
|
* Direct path for file as a string or a combination dirname and basename
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IConfigData } from '../IConfigData';
|
|
2
|
-
import { ConfigJar } from '../ConfigJar';
|
|
3
|
-
import { IConfigOptions } from '../IConfigOptions';
|
|
4
|
-
import { ConfigSupport } from '../ConfigSupport';
|
|
1
|
+
import { IConfigData } from '../IConfigData.js';
|
|
2
|
+
import { ConfigJar } from '../ConfigJar.js';
|
|
3
|
+
import { IConfigOptions } from '../IConfigOptions.js';
|
|
4
|
+
import { ConfigSupport } from '../ConfigSupport.js';
|
|
5
5
|
/**
|
|
6
6
|
* Load passthrough arguments configuration
|
|
7
7
|
*
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const ConfigSupport_1 = require("../ConfigSupport");
|
|
7
|
-
const Source_1 = require("../Source");
|
|
8
|
-
const base_1 = require("@allgemein/base");
|
|
1
|
+
import { ConfigJar } from '../ConfigJar.js';
|
|
2
|
+
import { Utils } from '../../utils/Utils.js';
|
|
3
|
+
import { ConfigSupport } from '../ConfigSupport.js';
|
|
4
|
+
import { Source } from '../Source.js';
|
|
5
|
+
import { PlatformUtils } from '@allgemein/base';
|
|
9
6
|
/**
|
|
10
7
|
* Load passthrough arguments configuration
|
|
11
8
|
*
|
|
12
9
|
* Named arguments beginning with '--' will be stripped of '--' and put as key-value pair in the array.
|
|
13
10
|
* If no value is set then the value will be 'true'.
|
|
14
11
|
*/
|
|
15
|
-
class SystemConfig extends
|
|
12
|
+
export class SystemConfig extends ConfigSupport {
|
|
16
13
|
constructor(options = { namespace: 'system' }, jarsData = []) {
|
|
17
14
|
super(options, jarsData);
|
|
18
15
|
}
|
|
@@ -21,14 +18,14 @@ class SystemConfig extends ConfigSupport_1.ConfigSupport {
|
|
|
21
18
|
}
|
|
22
19
|
attach_os(jar) {
|
|
23
20
|
try {
|
|
24
|
-
const os =
|
|
25
|
-
|
|
21
|
+
const os = PlatformUtils.load('os');
|
|
22
|
+
const _os = {
|
|
26
23
|
hostname: os.hostname(),
|
|
27
24
|
userdir: os.homedir(),
|
|
28
25
|
platform: os.platform(),
|
|
29
26
|
tmpdir: os.tmpdir()
|
|
30
27
|
};
|
|
31
|
-
jar.merge(new
|
|
28
|
+
jar.merge(new Source({ source: 'os', data: _os, prefix: 'os' }));
|
|
32
29
|
}
|
|
33
30
|
catch (e) {
|
|
34
31
|
console.error(e);
|
|
@@ -36,24 +33,24 @@ class SystemConfig extends ConfigSupport_1.ConfigSupport {
|
|
|
36
33
|
return jar;
|
|
37
34
|
}
|
|
38
35
|
attach_env(jar) {
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
const data = Utils.merge({}, process.env);
|
|
37
|
+
const configData = {};
|
|
41
38
|
Object.keys(data).forEach(k => {
|
|
42
39
|
configData[k] = data[k];
|
|
43
40
|
});
|
|
44
|
-
jar.merge(new
|
|
41
|
+
jar.merge(new Source({ source: 'env', data: configData, prefix: 'env' }));
|
|
45
42
|
return jar;
|
|
46
43
|
}
|
|
47
44
|
attach_argv(jar) {
|
|
48
|
-
|
|
45
|
+
const data = {};
|
|
49
46
|
let i = 0;
|
|
50
|
-
|
|
47
|
+
const pl = process.argv.length;
|
|
51
48
|
for (let k = 0; k < pl; k++) {
|
|
52
|
-
|
|
49
|
+
const v = process.argv[k];
|
|
53
50
|
if (/^\-\-/.test(v)) {
|
|
54
|
-
|
|
51
|
+
const n = k + 1;
|
|
55
52
|
if (n < pl) {
|
|
56
|
-
|
|
53
|
+
const next = process.argv[n];
|
|
57
54
|
if (!/^\-\-/.test(next)) {
|
|
58
55
|
k++;
|
|
59
56
|
data[v.replace(/^\-\-/, '')] = next;
|
|
@@ -71,16 +68,15 @@ class SystemConfig extends ConfigSupport_1.ConfigSupport {
|
|
|
71
68
|
i++;
|
|
72
69
|
}
|
|
73
70
|
}
|
|
74
|
-
jar.merge(new
|
|
71
|
+
jar.merge(new Source({ source: 'argv', data: data, prefix: 'argv' }));
|
|
75
72
|
return jar;
|
|
76
73
|
}
|
|
77
74
|
create() {
|
|
78
|
-
|
|
75
|
+
const jar = ConfigJar.create({ namespace: 'system' });
|
|
79
76
|
this.attach_os(jar);
|
|
80
77
|
this.attach_env(jar);
|
|
81
78
|
this.attach_argv(jar);
|
|
82
79
|
return jar;
|
|
83
80
|
}
|
|
84
81
|
}
|
|
85
|
-
exports.SystemConfig = SystemConfig;
|
|
86
82
|
//# sourceMappingURL=SystemConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SystemConfig.js","sourceRoot":"","sources":["../../../../src/config/handler/SystemConfig.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SystemConfig.js","sourceRoot":"","sources":["../../../../src/config/handler/SystemConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAG1C,OAAO,EAAC,KAAK,EAAC,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AACpC,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAG9C;;;;;GAKG;AACH,MAAM,OAAO,YAAa,SAAQ,aAA6B;IAE7D,YAAY,OAAO,GAAmB,EAAC,SAAS,EAAE,QAAQ,EAAC,EAAE,QAAQ,GAAkB,EAAE;QACvF,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC3B,CAAC;IAED,IAAI;QACF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEO,SAAS,CAAC,GAAc;QAC9B,IAAI,CAAC;YACH,MAAM,EAAE,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACpC,MAAM,GAAG,GAAG;gBACV,QAAQ,EAAE,EAAE,CAAC,QAAQ,EAAE;gBACvB,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE;gBACrB,QAAQ,EAAE,EAAE,CAAC,QAAQ,EAAE;gBACvB,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE;aACpB,CAAC;YAEF,GAAG,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,EAAC,MAAM,EAAE,IAAI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AC,CAAC,CAAC;oBAC7B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;wBACxB,CAAC,EAAE,CAAC;wBACJ,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;oBACtC,CAAC;yBAAM,CAAC;wBACN,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;oBACtC,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACN,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;gBACtC,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;gBAClB,CAAC,EAAE,CAAC;YACN,CAAC;QACH,CAAC;QAED,GAAG,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,EAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAC,CAAC,CAAC,CAAC;QAEpE,OAAO,GAAG,CAAC;IACb,CAAC;IAGD,MAAM;QACJ,MAAM,GAAG,GAAG,SAAS,CAAC,MAAM,CAAC,EAAC,SAAS,EAAE,QAAQ,EAAC,CAAC,CAAC;QACpD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACrB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QACtB,OAAO,GAAG,CAAC;IACb,CAAC;CAEF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './SystemConfig';
|
|
2
|
-
export * from './FileConfig';
|
|
1
|
+
export * from './SystemConfig.js';
|
|
2
|
+
export * from './FileConfig.js';
|
package/config/handler/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./SystemConfig"), exports);
|
|
18
|
-
__exportStar(require("./FileConfig"), exports);
|
|
1
|
+
export * from './SystemConfig.js';
|
|
2
|
+
export * from './FileConfig.js';
|
|
19
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/config/handler/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/config/handler/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IFileSupportInfo } from
|
|
2
|
-
import { IFileSupport } from
|
|
3
|
-
import { StringOrFunction } from
|
|
1
|
+
import { IFileSupportInfo } from './IFileSupportInfo.js';
|
|
2
|
+
import { IFileSupport } from './IFileSupport.js';
|
|
3
|
+
import { StringOrFunction } from '@allgemein/base';
|
|
4
4
|
/**
|
|
5
5
|
* FileSupport
|
|
6
6
|
*/
|
|
@@ -8,11 +8,11 @@ export declare class FileSupport {
|
|
|
8
8
|
static DEFAULT_TYPES: StringOrFunction[];
|
|
9
9
|
private static $supports;
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
* Loades classes in *.js or *.ts files from given directories, verifing if they implement the
|
|
12
|
+
* IConfigReader interface. For each valid class an info entry is created and added to $reader
|
|
13
|
+
*
|
|
14
|
+
* @param directories
|
|
15
|
+
*/
|
|
16
16
|
static reload(directories?: StringOrFunction | StringOrFunction[]): boolean;
|
|
17
17
|
static getSupportedTypes(force_all?: boolean): string[];
|
|
18
18
|
static amount(): number;
|
|
@@ -1,30 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const YamlFileSupport_1 = require("./types/YamlFileSupport");
|
|
8
|
-
const PropertiesFileSupport_1 = require("./types/PropertiesFileSupport");
|
|
9
|
-
const base_1 = require("@allgemein/base");
|
|
1
|
+
import { Utils } from '../utils/Utils.js';
|
|
2
|
+
import { JsonFileSupport } from './types/JsonFileSupport.js';
|
|
3
|
+
import { XmlFileSupport } from './types/XmlFileSupport.js';
|
|
4
|
+
import { YamlFileSupport } from './types/YamlFileSupport.js';
|
|
5
|
+
import { PropertiesFileSupport } from './types/PropertiesFileSupport.js';
|
|
6
|
+
import { ClassLoader } from '@allgemein/base';
|
|
10
7
|
/**
|
|
11
8
|
* FileSupport
|
|
12
9
|
*/
|
|
13
|
-
class FileSupport {
|
|
10
|
+
export class FileSupport {
|
|
14
11
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
* Loades classes in *.js or *.ts files from given directories, verifing if they implement the
|
|
13
|
+
* IConfigReader interface. For each valid class an info entry is created and added to $reader
|
|
14
|
+
*
|
|
15
|
+
* @param directories
|
|
16
|
+
*/
|
|
20
17
|
static reload(directories = FileSupport.DEFAULT_TYPES) {
|
|
21
18
|
this.reset();
|
|
22
19
|
if (!Array.isArray(directories)) {
|
|
23
20
|
directories = [directories];
|
|
24
21
|
}
|
|
25
|
-
|
|
22
|
+
const classes = ClassLoader.importClassesFromAny(directories);
|
|
26
23
|
classes.forEach((klass) => {
|
|
27
|
-
|
|
24
|
+
const info = {
|
|
28
25
|
klass: klass,
|
|
29
26
|
ext: [],
|
|
30
27
|
enabled: false,
|
|
@@ -40,7 +37,7 @@ class FileSupport {
|
|
|
40
37
|
return;
|
|
41
38
|
}
|
|
42
39
|
if (l.supportedTypes !== undefined) {
|
|
43
|
-
|
|
40
|
+
const types = l.supportedTypes();
|
|
44
41
|
if (typeof types === 'string') {
|
|
45
42
|
info.ext = [types];
|
|
46
43
|
}
|
|
@@ -77,7 +74,7 @@ class FileSupport {
|
|
|
77
74
|
types = types.concat(_x.ext);
|
|
78
75
|
}
|
|
79
76
|
});
|
|
80
|
-
return
|
|
77
|
+
return Utils.unique_array(types);
|
|
81
78
|
}
|
|
82
79
|
static amount() {
|
|
83
80
|
return FileSupport.$supports.length;
|
|
@@ -91,7 +88,7 @@ class FileSupport {
|
|
|
91
88
|
return null;
|
|
92
89
|
}
|
|
93
90
|
static getSupportByExtension(ext) {
|
|
94
|
-
|
|
91
|
+
const info = FileSupport.getInfoByExtension(ext);
|
|
95
92
|
if (info) {
|
|
96
93
|
return Reflect.construct(info.klass, []);
|
|
97
94
|
}
|
|
@@ -101,12 +98,11 @@ class FileSupport {
|
|
|
101
98
|
FileSupport.$supports = [];
|
|
102
99
|
}
|
|
103
100
|
}
|
|
104
|
-
exports.FileSupport = FileSupport;
|
|
105
101
|
FileSupport.DEFAULT_TYPES = [
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
102
|
+
JsonFileSupport,
|
|
103
|
+
YamlFileSupport,
|
|
104
|
+
XmlFileSupport,
|
|
105
|
+
PropertiesFileSupport
|
|
110
106
|
];
|
|
111
107
|
FileSupport.$supports = [];
|
|
112
108
|
//# sourceMappingURL=FileSupport.js.map
|