@melfore/clibelt 0.1.3 → 1.0.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/dist/cli/i18n-msg/index.js +51 -19
- package/dist/cli/pwd2hash/index.js +2 -2
- package/dist/cli/pwd2hash/pwd2hash.js +7 -9
- package/dist/cli/pwd2hash/pwd2hash.test.d.ts +1 -0
- package/dist/cli/pwd2hash/pwd2hash.test.js +15 -0
- package/dist/config/config-schema.d.ts +7 -0
- package/dist/config/config-schema.js +7 -0
- package/dist/config/config-validators.js +6 -6
- package/dist/config/index.d.ts +9 -334
- package/dist/config/index.js +7 -18
- package/dist/helpers/config.js +3 -2
- package/package.json +26 -25
|
@@ -7,34 +7,37 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.CLI_NAME = void 0;
|
|
8
8
|
var fs_1 = __importDefault(require("fs"));
|
|
9
9
|
var path_1 = __importDefault(require("path"));
|
|
10
|
-
var os_1 =
|
|
10
|
+
var os_1 = require("os");
|
|
11
11
|
var config_1 = __importDefault(require("../../config"));
|
|
12
12
|
exports.CLI_NAME = "i18nMsg";
|
|
13
|
+
var AUTOGENERATED_HEADER = "// autogenerated with \"i18n-msg\"\n// DO NOT EDIT MANUALLY\n\n";
|
|
13
14
|
var inputFile = path_1.default.join(process.cwd(), config_1.default.get(exports.CLI_NAME).input);
|
|
14
15
|
var mal = require(inputFile);
|
|
15
16
|
var outMsgDir = path_1.default.join(process.cwd(), config_1.default.get(exports.CLI_NAME).outMsg);
|
|
16
17
|
var outTsFile = path_1.default.join(process.cwd(), config_1.default.get(exports.CLI_NAME).outTs);
|
|
18
|
+
var outTempDir = path_1.default.join(process.cwd(), config_1.default.get(exports.CLI_NAME).outTemp);
|
|
19
|
+
var outTsDir = path_1.default.dirname(outTsFile);
|
|
17
20
|
var EXT = "json";
|
|
18
|
-
var info = "Splitting \""
|
|
21
|
+
var info = "Splitting \"".concat(config_1.default.get(exports.CLI_NAME).input, "\" into lang messages in folder \"").concat(config_1.default.get(exports.CLI_NAME).outMsg, "\" and TS constants \"").concat(config_1.default.get(exports.CLI_NAME).outTs, "\"...");
|
|
19
22
|
console.log(info);
|
|
20
23
|
var writeObjJson = function (filename, obj) {
|
|
21
24
|
var data = "";
|
|
22
25
|
switch (EXT) {
|
|
23
26
|
case "js":
|
|
24
|
-
data = "exports.messages = "
|
|
27
|
+
data = "exports.messages = ".concat(JSON.stringify(obj, null, 2), ";");
|
|
25
28
|
break;
|
|
26
29
|
case "json":
|
|
27
30
|
data = JSON.stringify(obj, null, 2);
|
|
28
31
|
break;
|
|
29
32
|
default:
|
|
30
|
-
console.log("Invalid output file extension \""
|
|
33
|
+
console.log("Invalid output file extension \"".concat(filename, "\""));
|
|
31
34
|
break;
|
|
32
35
|
}
|
|
33
36
|
if (data) {
|
|
34
37
|
fs_1.default.writeFile(filename, data, function (err) {
|
|
35
38
|
if (err)
|
|
36
39
|
console.log(err);
|
|
37
|
-
console.log("Successfully written to file \""
|
|
40
|
+
console.log("Successfully written to file \"".concat(filename, "\""));
|
|
38
41
|
});
|
|
39
42
|
}
|
|
40
43
|
};
|
|
@@ -44,25 +47,24 @@ var tsName = function (code) {
|
|
|
44
47
|
});
|
|
45
48
|
};
|
|
46
49
|
var writeTs = function (filename, messages) {
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
output += "export const " + tsName(msg.code) + " = \"" + msg.code + "\";" + EOL;
|
|
51
|
-
});
|
|
50
|
+
var output = messages.reduce(function (result, msg) {
|
|
51
|
+
return result + "export const ".concat(tsName(msg.code), " = \"").concat(msg.code, "\";").concat(os_1.EOL);
|
|
52
|
+
}, AUTOGENERATED_HEADER);
|
|
52
53
|
fs_1.default.writeFile(filename, output, function (err) {
|
|
53
54
|
if (err)
|
|
54
55
|
console.log(err);
|
|
55
|
-
console.log("Successfully written to file \""
|
|
56
|
+
console.log("Successfully written to file \"".concat(filename, "\""));
|
|
56
57
|
});
|
|
57
58
|
};
|
|
58
|
-
var splitMessages = function () {
|
|
59
|
-
var messages = mal.messages;
|
|
59
|
+
var splitMessages = function (messages, namespace) {
|
|
60
60
|
var sortedMessages = messages.sort(function (a, b) { return a.code.localeCompare(b.code); });
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
var sortedName = namespace ? "".concat(namespace, "-sort-temp") : "messages-sort-temp";
|
|
62
|
+
var tsFile = namespace ? "".concat(outTsDir, "/").concat(namespace, ".ts") : outTsFile;
|
|
63
|
+
writeObjJson("".concat(outTempDir, "/").concat(sortedName, ".").concat(EXT), sortedMessages);
|
|
64
|
+
writeTs(tsFile, sortedMessages);
|
|
63
65
|
var res = {};
|
|
64
|
-
sortedMessages.
|
|
65
|
-
k.tr.
|
|
66
|
+
sortedMessages.forEach(function (k) {
|
|
67
|
+
k.tr.forEach(function (t) {
|
|
66
68
|
if (!res[t.l]) {
|
|
67
69
|
res[t.l] = {};
|
|
68
70
|
}
|
|
@@ -70,7 +72,37 @@ var splitMessages = function () {
|
|
|
70
72
|
});
|
|
71
73
|
});
|
|
72
74
|
Object.keys(res).map(function (n) {
|
|
73
|
-
|
|
75
|
+
var dest = namespace ? "".concat(outMsgDir, "/").concat(n, "/").concat(namespace, ".").concat(EXT) : "".concat(outMsgDir, "/").concat(n, ".").concat(EXT);
|
|
76
|
+
var langDir = path_1.default.dirname(dest);
|
|
77
|
+
fs_1.default.mkdirSync(langDir, { recursive: true });
|
|
78
|
+
writeObjJson(dest, res[n]);
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
var writeNamespacesFile = function (namespaces) {
|
|
82
|
+
var content = namespaces.reduce(function (result, _a) {
|
|
83
|
+
var ns = _a[0];
|
|
84
|
+
return result + "export * from './".concat(ns, "';").concat(os_1.EOL);
|
|
85
|
+
}, AUTOGENERATED_HEADER);
|
|
86
|
+
fs_1.default.writeFile(outTsFile, content, function (err) {
|
|
87
|
+
if (err) {
|
|
88
|
+
console.log("Error writing to", outTsFile);
|
|
89
|
+
}
|
|
74
90
|
});
|
|
75
91
|
};
|
|
76
|
-
|
|
92
|
+
var checkNamespaces = function () {
|
|
93
|
+
fs_1.default.mkdirSync(outTempDir, { recursive: true });
|
|
94
|
+
fs_1.default.mkdirSync(outMsgDir, { recursive: true });
|
|
95
|
+
fs_1.default.mkdirSync(outTsDir, { recursive: true });
|
|
96
|
+
var namespaces = mal.namespaces ? Object.entries(mal.namespaces) : [];
|
|
97
|
+
if (namespaces.length > 0) {
|
|
98
|
+
namespaces.forEach(function (_a) {
|
|
99
|
+
var ns = _a[0], messages = _a[1];
|
|
100
|
+
splitMessages(messages, ns);
|
|
101
|
+
});
|
|
102
|
+
writeNamespacesFile(namespaces);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
splitMessages(mal.messages);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
checkNamespaces();
|
|
@@ -5,8 +5,8 @@ var pwd2hash_1 = require("./pwd2hash");
|
|
|
5
5
|
var pwd2hash = function () {
|
|
6
6
|
var password = process.argv[2];
|
|
7
7
|
console.log();
|
|
8
|
-
var pwdHash = pwd2hash_1.passwordHash(password);
|
|
9
|
-
console.log("\t["
|
|
8
|
+
var pwdHash = (0, pwd2hash_1.passwordHash)(password);
|
|
9
|
+
console.log("\t[".concat(password, "] -> [").concat(pwdHash, "]"));
|
|
10
10
|
console.log();
|
|
11
11
|
console.log();
|
|
12
12
|
};
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.passwordHash = exports.genMD5Enc = void 0;
|
|
7
|
-
var
|
|
8
|
-
|
|
4
|
+
var crypto_1 = require("crypto");
|
|
5
|
+
var genMD5Enc = function (str) {
|
|
9
6
|
if (!str) {
|
|
10
7
|
return "";
|
|
11
8
|
}
|
|
12
|
-
var
|
|
13
|
-
var hashEnc = hash.toString(crypto_js_1.default.enc.Hex);
|
|
9
|
+
var hashEnc = (0, crypto_1.createHash)("md5").update(str).digest("hex");
|
|
14
10
|
return hashEnc;
|
|
15
11
|
};
|
|
16
|
-
exports.
|
|
17
|
-
|
|
12
|
+
exports.genMD5Enc = genMD5Enc;
|
|
13
|
+
var passwordHash = function (password) {
|
|
14
|
+
var hash = (0, exports.genMD5Enc)(password);
|
|
18
15
|
return hash;
|
|
19
16
|
};
|
|
17
|
+
exports.passwordHash = passwordHash;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var pwd2hash_1 = require("./pwd2hash");
|
|
4
|
+
describe("verify password hash", function () {
|
|
5
|
+
it("returns md5 hex value of password in case of password hash is running well", function () {
|
|
6
|
+
var password = "NonDireGatto";
|
|
7
|
+
var pwdHash = (0, pwd2hash_1.passwordHash)(password);
|
|
8
|
+
expect(pwdHash).toEqual("07d13c5f2f88ef41e18383e288b9d99a");
|
|
9
|
+
});
|
|
10
|
+
it("returns error in case of password is equal to password hash", function () {
|
|
11
|
+
var password = "NonDireGatto";
|
|
12
|
+
var pwdHash = (0, pwd2hash_1.passwordHash)(password);
|
|
13
|
+
expect(pwdHash).not.toEqual("NonDireGatto");
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -16,6 +16,13 @@ exports.default = {
|
|
|
16
16
|
arg: "i18n-out-msg",
|
|
17
17
|
env: "I18N_OUT_MSG",
|
|
18
18
|
},
|
|
19
|
+
outTemp: {
|
|
20
|
+
doc: "sorted messages directory",
|
|
21
|
+
format: String,
|
|
22
|
+
default: "./src/messages/temp",
|
|
23
|
+
arg: "i18n-out-temp",
|
|
24
|
+
env: "I18N_OUT_TEMP",
|
|
25
|
+
},
|
|
19
26
|
outTs: {
|
|
20
27
|
doc: "TypeScript source output directory",
|
|
21
28
|
format: String,
|
|
@@ -18,42 +18,42 @@ exports.email = {
|
|
|
18
18
|
name: "email",
|
|
19
19
|
coerce: function (v) { return v.toString(); },
|
|
20
20
|
validate: function (x) {
|
|
21
|
-
assert(isEmail_1.default(x), "must be an email address");
|
|
21
|
+
assert((0, isEmail_1.default)(x), "must be an email address");
|
|
22
22
|
},
|
|
23
23
|
};
|
|
24
24
|
exports.ipaddress = {
|
|
25
25
|
name: "ipaddress",
|
|
26
26
|
coerce: function (v) { return v.toString(); },
|
|
27
27
|
validate: function (x) {
|
|
28
|
-
assert(isIP_1.default(x), "must be an IP address");
|
|
28
|
+
assert((0, isIP_1.default)(x), "must be an IP address");
|
|
29
29
|
},
|
|
30
30
|
};
|
|
31
31
|
exports.url = {
|
|
32
32
|
name: "url",
|
|
33
33
|
coerce: function (v) { return v.toString(); },
|
|
34
34
|
validate: function (x) {
|
|
35
|
-
assert(isURL_1.default(x, { require_tld: false }), "must be a URL");
|
|
35
|
+
assert((0, isURL_1.default)(x, { require_tld: false }), "must be a URL");
|
|
36
36
|
},
|
|
37
37
|
};
|
|
38
38
|
exports.strictBoolean = {
|
|
39
39
|
name: "strictBoolean",
|
|
40
40
|
coerce: function (v) { return v.toString(); },
|
|
41
41
|
validate: function (x) {
|
|
42
|
-
assert(isBoolean_1.default(x), "must be a boolean");
|
|
42
|
+
assert((0, isBoolean_1.default)(x), "must be a boolean");
|
|
43
43
|
},
|
|
44
44
|
};
|
|
45
45
|
exports.serverPort = {
|
|
46
46
|
name: "serverPort",
|
|
47
47
|
coerce: function (v) { return v.toString(); },
|
|
48
48
|
validate: function (x) {
|
|
49
|
-
assert(isInt_1.default(x === null || x === void 0 ? void 0 : x.toString(), { min: 1024, max: 65535 }), "must be a valid port number");
|
|
49
|
+
assert((0, isInt_1.default)(x === null || x === void 0 ? void 0 : x.toString(), { min: 1024, max: 65535 }), "must be a valid port number");
|
|
50
50
|
},
|
|
51
51
|
};
|
|
52
52
|
exports.int = {
|
|
53
53
|
name: "int",
|
|
54
54
|
coerce: function (v) { return v.toString(); },
|
|
55
55
|
validate: function (x) {
|
|
56
|
-
assert(isInt_1.default(x === null || x === void 0 ? void 0 : x.toString()), "must be a valid integer number");
|
|
56
|
+
assert((0, isInt_1.default)(x === null || x === void 0 ? void 0 : x.toString()), "must be a valid integer number");
|
|
57
57
|
},
|
|
58
58
|
};
|
|
59
59
|
exports.default = {
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,336 +1,11 @@
|
|
|
1
1
|
import convict from "convict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
outMsg: any;
|
|
9
|
-
outTs: any;
|
|
10
|
-
};
|
|
11
|
-
} : K extends "i18nMsg" ? {
|
|
12
|
-
i18nMsg: {
|
|
13
|
-
input: any;
|
|
14
|
-
outMsg: any;
|
|
15
|
-
outTs: any;
|
|
16
|
-
};
|
|
17
|
-
}[K] : any;
|
|
18
|
-
get<K_1 extends "i18nMsg", K2 extends keyof {
|
|
19
|
-
i18nMsg: {
|
|
20
|
-
input: any;
|
|
21
|
-
outMsg: any;
|
|
22
|
-
outTs: any;
|
|
23
|
-
};
|
|
24
|
-
}[K_1]>(name: string): {
|
|
25
|
-
i18nMsg: {
|
|
26
|
-
input: any;
|
|
27
|
-
outMsg: any;
|
|
28
|
-
outTs: any;
|
|
29
|
-
};
|
|
30
|
-
}[K_1][K2];
|
|
31
|
-
get<K_2 extends "i18nMsg", K2_1 extends keyof {
|
|
32
|
-
i18nMsg: {
|
|
33
|
-
input: any;
|
|
34
|
-
outMsg: any;
|
|
35
|
-
outTs: any;
|
|
36
|
-
};
|
|
37
|
-
}[K_2], K3 extends keyof {
|
|
38
|
-
i18nMsg: {
|
|
39
|
-
input: any;
|
|
40
|
-
outMsg: any;
|
|
41
|
-
outTs: any;
|
|
42
|
-
};
|
|
43
|
-
}[K_2][K2_1]>(name: K_2): {
|
|
44
|
-
i18nMsg: {
|
|
45
|
-
input: any;
|
|
46
|
-
outMsg: any;
|
|
47
|
-
outTs: any;
|
|
48
|
-
};
|
|
49
|
-
}[K_2][K2_1][K3];
|
|
50
|
-
get<K_3 extends "i18nMsg", K2_2 extends keyof {
|
|
51
|
-
i18nMsg: {
|
|
52
|
-
input: any;
|
|
53
|
-
outMsg: any;
|
|
54
|
-
outTs: any;
|
|
55
|
-
};
|
|
56
|
-
}[K_3], K3_1 extends keyof {
|
|
57
|
-
i18nMsg: {
|
|
58
|
-
input: any;
|
|
59
|
-
outMsg: any;
|
|
60
|
-
outTs: any;
|
|
61
|
-
};
|
|
62
|
-
}[K_3][K2_2], K4 extends keyof {
|
|
63
|
-
i18nMsg: {
|
|
64
|
-
input: any;
|
|
65
|
-
outMsg: any;
|
|
66
|
-
outTs: any;
|
|
67
|
-
};
|
|
68
|
-
}[K_3][K2_2][K3_1]>(name: string): {
|
|
69
|
-
i18nMsg: {
|
|
70
|
-
input: any;
|
|
71
|
-
outMsg: any;
|
|
72
|
-
outTs: any;
|
|
73
|
-
};
|
|
74
|
-
}[K_3][K2_2][K3_1][K4];
|
|
75
|
-
default<K_4 extends string | null | undefined = undefined>(name?: K_4 | undefined): K_4 extends "i18nMsg" ? {
|
|
76
|
-
i18nMsg: {
|
|
77
|
-
input: any;
|
|
78
|
-
outMsg: any;
|
|
79
|
-
outTs: any;
|
|
80
|
-
};
|
|
81
|
-
}[K_4] : K_4 extends null | undefined ? {
|
|
82
|
-
i18nMsg: {
|
|
83
|
-
input: any;
|
|
84
|
-
outMsg: any;
|
|
85
|
-
outTs: any;
|
|
86
|
-
};
|
|
87
|
-
} : any;
|
|
88
|
-
default<K_5 extends "i18nMsg">(name?: K_5 | undefined): {
|
|
89
|
-
i18nMsg: {
|
|
90
|
-
input: any;
|
|
91
|
-
outMsg: any;
|
|
92
|
-
outTs: any;
|
|
93
|
-
};
|
|
94
|
-
}[K_5];
|
|
95
|
-
default<K_6 extends "i18nMsg", K2_3 extends keyof {
|
|
96
|
-
i18nMsg: {
|
|
97
|
-
input: any;
|
|
98
|
-
outMsg: any;
|
|
99
|
-
outTs: any;
|
|
100
|
-
};
|
|
101
|
-
}[K_6]>(name: string): {
|
|
102
|
-
i18nMsg: {
|
|
103
|
-
input: any;
|
|
104
|
-
outMsg: any;
|
|
105
|
-
outTs: any;
|
|
106
|
-
};
|
|
107
|
-
}[K_6][K2_3];
|
|
108
|
-
default<K_7 extends "i18nMsg", K2_4 extends keyof {
|
|
109
|
-
i18nMsg: {
|
|
110
|
-
input: any;
|
|
111
|
-
outMsg: any;
|
|
112
|
-
outTs: any;
|
|
113
|
-
};
|
|
114
|
-
}[K_7], K3_2 extends keyof {
|
|
115
|
-
i18nMsg: {
|
|
116
|
-
input: any;
|
|
117
|
-
outMsg: any;
|
|
118
|
-
outTs: any;
|
|
119
|
-
};
|
|
120
|
-
}[K_7][K2_4]>(name: K_7): {
|
|
121
|
-
i18nMsg: {
|
|
122
|
-
input: any;
|
|
123
|
-
outMsg: any;
|
|
124
|
-
outTs: any;
|
|
125
|
-
};
|
|
126
|
-
}[K_7][K2_4][K3_2];
|
|
127
|
-
default<K_8 extends "i18nMsg", K2_5 extends keyof {
|
|
128
|
-
i18nMsg: {
|
|
129
|
-
input: any;
|
|
130
|
-
outMsg: any;
|
|
131
|
-
outTs: any;
|
|
132
|
-
};
|
|
133
|
-
}[K_8], K3_3 extends keyof {
|
|
134
|
-
i18nMsg: {
|
|
135
|
-
input: any;
|
|
136
|
-
outMsg: any;
|
|
137
|
-
outTs: any;
|
|
138
|
-
};
|
|
139
|
-
}[K_8][K2_5], K4_1 extends keyof {
|
|
140
|
-
i18nMsg: {
|
|
141
|
-
input: any;
|
|
142
|
-
outMsg: any;
|
|
143
|
-
outTs: any;
|
|
144
|
-
};
|
|
145
|
-
}[K_8][K2_5][K3_3]>(name: string): {
|
|
146
|
-
i18nMsg: {
|
|
147
|
-
input: any;
|
|
148
|
-
outMsg: any;
|
|
149
|
-
outTs: any;
|
|
150
|
-
};
|
|
151
|
-
}[K_8][K2_5][K3_3][K4_1];
|
|
152
|
-
has<K_9 extends string = string>(name: K_9): boolean;
|
|
153
|
-
has<K_10 extends "i18nMsg", K2_6 extends keyof {
|
|
154
|
-
i18nMsg: {
|
|
155
|
-
input: any;
|
|
156
|
-
outMsg: any;
|
|
157
|
-
outTs: any;
|
|
158
|
-
};
|
|
159
|
-
}[K_10]>(name: string): boolean;
|
|
160
|
-
has<K_11 extends "i18nMsg", K2_7 extends keyof {
|
|
161
|
-
i18nMsg: {
|
|
162
|
-
input: any;
|
|
163
|
-
outMsg: any;
|
|
164
|
-
outTs: any;
|
|
165
|
-
};
|
|
166
|
-
}[K_11], K3_4 extends keyof {
|
|
167
|
-
i18nMsg: {
|
|
168
|
-
input: any;
|
|
169
|
-
outMsg: any;
|
|
170
|
-
outTs: any;
|
|
171
|
-
};
|
|
172
|
-
}[K_11][K2_7]>(name: K_11): boolean;
|
|
173
|
-
has<K_12 extends "i18nMsg", K2_8 extends keyof {
|
|
174
|
-
i18nMsg: {
|
|
175
|
-
input: any;
|
|
176
|
-
outMsg: any;
|
|
177
|
-
outTs: any;
|
|
178
|
-
};
|
|
179
|
-
}[K_12], K3_5 extends keyof {
|
|
180
|
-
i18nMsg: {
|
|
181
|
-
input: any;
|
|
182
|
-
outMsg: any;
|
|
183
|
-
outTs: any;
|
|
184
|
-
};
|
|
185
|
-
}[K_12][K2_8], K4_2 extends keyof {
|
|
186
|
-
i18nMsg: {
|
|
187
|
-
input: any;
|
|
188
|
-
outMsg: any;
|
|
189
|
-
outTs: any;
|
|
190
|
-
};
|
|
191
|
-
}[K_12][K2_8][K3_5]>(name: string): boolean;
|
|
192
|
-
set<K_13 extends string>(name: K_13, value: K_13 extends "i18nMsg" ? {
|
|
193
|
-
i18nMsg: {
|
|
194
|
-
input: any;
|
|
195
|
-
outMsg: any;
|
|
196
|
-
outTs: any;
|
|
197
|
-
};
|
|
198
|
-
}[K_13] : any): convict.Config<{
|
|
199
|
-
i18nMsg: {
|
|
200
|
-
input: any;
|
|
201
|
-
outMsg: any;
|
|
202
|
-
outTs: any;
|
|
203
|
-
};
|
|
204
|
-
}>;
|
|
205
|
-
set<K_14 extends "i18nMsg", K2_9 extends string | keyof {
|
|
206
|
-
i18nMsg: {
|
|
207
|
-
input: any;
|
|
208
|
-
outMsg: any;
|
|
209
|
-
outTs: any;
|
|
210
|
-
};
|
|
211
|
-
}[K_14]>(name: K_14, value: K2_9 extends keyof {
|
|
212
|
-
i18nMsg: {
|
|
213
|
-
input: any;
|
|
214
|
-
outMsg: any;
|
|
215
|
-
outTs: any;
|
|
216
|
-
};
|
|
217
|
-
}[K_14] ? {
|
|
218
|
-
i18nMsg: {
|
|
219
|
-
input: any;
|
|
220
|
-
outMsg: any;
|
|
221
|
-
outTs: any;
|
|
222
|
-
};
|
|
223
|
-
}[K_14][K2_9] : any): convict.Config<{
|
|
224
|
-
i18nMsg: {
|
|
225
|
-
input: any;
|
|
226
|
-
outMsg: any;
|
|
227
|
-
outTs: any;
|
|
228
|
-
};
|
|
229
|
-
}>;
|
|
230
|
-
set<K_15 extends "i18nMsg", K2_10 extends keyof {
|
|
231
|
-
i18nMsg: {
|
|
232
|
-
input: any;
|
|
233
|
-
outMsg: any;
|
|
234
|
-
outTs: any;
|
|
235
|
-
};
|
|
236
|
-
}[K_15], K3_6 extends string | keyof {
|
|
237
|
-
i18nMsg: {
|
|
238
|
-
input: any;
|
|
239
|
-
outMsg: any;
|
|
240
|
-
outTs: any;
|
|
241
|
-
};
|
|
242
|
-
}[K_15][K2_10]>(name: K_15, value: K3_6 extends keyof {
|
|
243
|
-
i18nMsg: {
|
|
244
|
-
input: any;
|
|
245
|
-
outMsg: any;
|
|
246
|
-
outTs: any;
|
|
247
|
-
};
|
|
248
|
-
}[K_15][K2_10] ? {
|
|
249
|
-
i18nMsg: {
|
|
250
|
-
input: any;
|
|
251
|
-
outMsg: any;
|
|
252
|
-
outTs: any;
|
|
253
|
-
};
|
|
254
|
-
}[K_15][K2_10][K3_6] : any): convict.Config<{
|
|
255
|
-
i18nMsg: {
|
|
256
|
-
input: any;
|
|
257
|
-
outMsg: any;
|
|
258
|
-
outTs: any;
|
|
259
|
-
};
|
|
260
|
-
}>;
|
|
261
|
-
set<K_16 extends "i18nMsg", K2_11 extends keyof {
|
|
262
|
-
i18nMsg: {
|
|
263
|
-
input: any;
|
|
264
|
-
outMsg: any;
|
|
265
|
-
outTs: any;
|
|
266
|
-
};
|
|
267
|
-
}[K_16], K3_7 extends keyof {
|
|
268
|
-
i18nMsg: {
|
|
269
|
-
input: any;
|
|
270
|
-
outMsg: any;
|
|
271
|
-
outTs: any;
|
|
272
|
-
};
|
|
273
|
-
}[K_16][K2_11], K4_3 extends string | keyof {
|
|
274
|
-
i18nMsg: {
|
|
275
|
-
input: any;
|
|
276
|
-
outMsg: any;
|
|
277
|
-
outTs: any;
|
|
278
|
-
};
|
|
279
|
-
}[K_16][K2_11][K3_7]>(name: K_16, value: K4_3 extends keyof {
|
|
280
|
-
i18nMsg: {
|
|
281
|
-
input: any;
|
|
282
|
-
outMsg: any;
|
|
283
|
-
outTs: any;
|
|
284
|
-
};
|
|
285
|
-
}[K_16][K2_11][K3_7] ? {
|
|
286
|
-
i18nMsg: {
|
|
287
|
-
input: any;
|
|
288
|
-
outMsg: any;
|
|
289
|
-
outTs: any;
|
|
290
|
-
};
|
|
291
|
-
}[K_16][K2_11][K3_7][K4_3] : any): convict.Config<{
|
|
292
|
-
i18nMsg: {
|
|
293
|
-
input: any;
|
|
294
|
-
outMsg: any;
|
|
295
|
-
outTs: any;
|
|
296
|
-
};
|
|
297
|
-
}>;
|
|
298
|
-
load<U>(conf: U): convict.Config<convict.Overwrite<{
|
|
299
|
-
i18nMsg: {
|
|
300
|
-
input: any;
|
|
301
|
-
outMsg: any;
|
|
302
|
-
outTs: any;
|
|
303
|
-
};
|
|
304
|
-
}, U>>;
|
|
305
|
-
loadFile<U_1>(files: string | string[]): convict.Config<convict.Overwrite<{
|
|
306
|
-
i18nMsg: {
|
|
307
|
-
input: any;
|
|
308
|
-
outMsg: any;
|
|
309
|
-
outTs: any;
|
|
310
|
-
};
|
|
311
|
-
}, U_1>>;
|
|
312
|
-
validate(options?: convict.ValidateOptions | undefined): convict.Config<{
|
|
313
|
-
i18nMsg: {
|
|
314
|
-
input: any;
|
|
315
|
-
outMsg: any;
|
|
316
|
-
outTs: any;
|
|
317
|
-
};
|
|
318
|
-
}>;
|
|
319
|
-
getProperties(): {
|
|
320
|
-
i18nMsg: {
|
|
321
|
-
input: any;
|
|
322
|
-
outMsg: any;
|
|
323
|
-
outTs: any;
|
|
324
|
-
};
|
|
2
|
+
declare const config: convict.Config<{
|
|
3
|
+
i18nMsg: {
|
|
4
|
+
input: string;
|
|
5
|
+
outMsg: string;
|
|
6
|
+
outTemp: string;
|
|
7
|
+
outTs: string;
|
|
325
8
|
};
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
outMsg: any;
|
|
330
|
-
outTs: any;
|
|
331
|
-
};
|
|
332
|
-
}>;
|
|
333
|
-
toString(): string;
|
|
334
|
-
getSchemaString(): string;
|
|
335
|
-
};
|
|
336
|
-
export default _default;
|
|
9
|
+
}>;
|
|
10
|
+
export { config };
|
|
11
|
+
export default config;
|
package/dist/config/index.js
CHANGED
|
@@ -1,32 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
16
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
18
|
-
var convict_1 = __importDefault(require("convict"));
|
|
19
|
-
var convict_format_with_moment = require("convict-format-with-moment");
|
|
6
|
+
exports.config = void 0;
|
|
20
7
|
var path_1 = __importDefault(require("path"));
|
|
21
|
-
var
|
|
8
|
+
var convict_1 = __importDefault(require("convict"));
|
|
22
9
|
var config_schema_1 = __importDefault(require("./config-schema"));
|
|
10
|
+
var config_validators_1 = __importDefault(require("./config-validators"));
|
|
11
|
+
var convict_format_with_moment = require("convict-format-with-moment");
|
|
23
12
|
var VALIDATE_WARN = { allowed: "warn" };
|
|
24
13
|
var VALIDATE_ERROR = { allowed: "strict" };
|
|
25
14
|
convict_1.default.addFormats(config_validators_1.default);
|
|
26
15
|
convict_1.default.addFormats(convict_format_with_moment);
|
|
27
|
-
var config = convict_1.default(config_schema_1.default);
|
|
16
|
+
var config = (0, convict_1.default)(config_schema_1.default);
|
|
17
|
+
exports.config = config;
|
|
28
18
|
var pathName = path_1.default.join(process.cwd(), ".clibelt.json");
|
|
29
19
|
config.loadFile(pathName);
|
|
30
20
|
config.validate(VALIDATE_WARN);
|
|
31
|
-
exports.
|
|
32
|
-
exports.default = __assign(__assign({}, config), { getProp: exports.getProp });
|
|
21
|
+
exports.default = config;
|
package/dist/helpers/config.js
CHANGED
|
@@ -3,12 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.loadConfigFromFile = void 0;
|
|
4
4
|
var path = require("path");
|
|
5
5
|
var fs = require("fs");
|
|
6
|
-
|
|
6
|
+
var loadConfigFromFile = function (_a) {
|
|
7
7
|
var cliName = _a.cliName, _b = _a.dir, dir = _b === void 0 ? "." : _b;
|
|
8
8
|
var pathName = path.join(process.cwd(), dir, ".clibelt.json");
|
|
9
9
|
console.log("pathName", pathName);
|
|
10
|
-
console.log("loadConfig - read configuration for cli:"
|
|
10
|
+
console.log("loadConfig - read configuration for cli:".concat(cliName, " from file:").concat(pathName));
|
|
11
11
|
var content = fs.readFileSync(pathName);
|
|
12
12
|
var config = JSON.parse(content);
|
|
13
13
|
return config[cliName];
|
|
14
14
|
};
|
|
15
|
+
exports.loadConfigFromFile = loadConfigFromFile;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@melfore/clibelt",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"homepage": "https://github.com/melfore/clibelt#readme",
|
|
5
5
|
"description": "CLI belt: the Melfore tool belt",
|
|
6
6
|
"repository": {
|
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
"pwd2hash": "dist/cli/pwd2hash/index.js",
|
|
16
16
|
"i18n-msg": "dist/cli/i18n-msg/index.js"
|
|
17
17
|
},
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=16 <17",
|
|
20
|
+
"npm": ">=8 <9"
|
|
21
|
+
},
|
|
18
22
|
"scripts": {
|
|
19
23
|
"build2": "tsc -p .",
|
|
20
24
|
"build": "npm run prettify && tsc -p . && npm run copy:assets",
|
|
@@ -23,9 +27,8 @@
|
|
|
23
27
|
"copy:assets": "copyfiles --verbose ./src/**/*.{json,png,jpg,svg,xls,xlsx} ./dist/",
|
|
24
28
|
"republish": "npm run build:clean && yalc push",
|
|
25
29
|
"test:i18n": "rm -f test/out/*.json test/out/*.ts && nodemon --watch 'src/**/*.ts' --watch '.clibelt.json' --exec 'ts-node' src/cli/i18n-msg/index.ts",
|
|
26
|
-
"test": "
|
|
27
|
-
"
|
|
28
|
-
"TODOtest:watch": "jest --config jest.config.js --watch --detectOpenHandles",
|
|
30
|
+
"test": "jest --config jest.config.js --runInBand",
|
|
31
|
+
"test:watch": "jest --config jest.config.js --watch --detectOpenHandles",
|
|
29
32
|
"lintify": "eslint .",
|
|
30
33
|
"prettify": "prettier --write .",
|
|
31
34
|
"preversion": "npm run lintify",
|
|
@@ -33,29 +36,27 @@
|
|
|
33
36
|
"upload": "npm run build && npm publish --access public"
|
|
34
37
|
},
|
|
35
38
|
"dependencies": {
|
|
36
|
-
"convict": "^6.
|
|
37
|
-
"convict-format-with-moment": "^6.
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"prettier": "^2.0.5"
|
|
39
|
+
"convict": "^6.2.3",
|
|
40
|
+
"convict-format-with-moment": "^6.2.0",
|
|
41
|
+
"validator": "^13.7.0",
|
|
42
|
+
"prettier": "^2.7.1"
|
|
41
43
|
},
|
|
42
44
|
"devDependencies": {
|
|
43
|
-
"@types/convict": "^
|
|
44
|
-
"@types/
|
|
45
|
-
"@types/
|
|
46
|
-
"@types/
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"eslint": "^
|
|
50
|
-
"eslint-
|
|
51
|
-
"eslint-plugin-
|
|
52
|
-
"eslint-plugin-
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"ts-
|
|
57
|
-
"
|
|
58
|
-
"typescript": "^3.9.3"
|
|
45
|
+
"@types/convict": "^6.1.1",
|
|
46
|
+
"@types/jest": "^29.0.2",
|
|
47
|
+
"@types/node": "^18.7.18",
|
|
48
|
+
"@types/validator": "^13.7.6",
|
|
49
|
+
"copyfiles": "^2.4.1",
|
|
50
|
+
"eslint": "^8.23.1",
|
|
51
|
+
"eslint-config-prettier": "^8.5.0",
|
|
52
|
+
"eslint-plugin-import": "^2.26.0",
|
|
53
|
+
"eslint-plugin-jest": "^27.0.4",
|
|
54
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
55
|
+
"jest": "^29.0.3",
|
|
56
|
+
"nodemon": "^2.0.19",
|
|
57
|
+
"ts-jest": "^29.0.1",
|
|
58
|
+
"ts-node": "^10.9.1",
|
|
59
|
+
"typescript": "^4.8.3"
|
|
59
60
|
},
|
|
60
61
|
"license": "MIT"
|
|
61
62
|
}
|