@calvear/env 2.6.0 → 2.7.0
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/arguments.d.ts +25 -25
- package/arguments.js +125 -125
- package/commands/env.command.d.ts +7 -7
- package/commands/env.command.d.ts.map +1 -1
- package/commands/env.command.js +77 -83
- package/commands/env.command.js.map +1 -1
- package/commands/export.command.d.ts +7 -7
- package/commands/export.command.js +53 -53
- package/commands/index.d.ts +5 -5
- package/commands/index.js +13 -13
- package/commands/pull.command.d.ts +6 -6
- package/commands/pull.command.js +38 -38
- package/commands/push.command.d.ts +6 -6
- package/commands/push.command.js +37 -37
- package/commands/schema.command.d.ts +3 -3
- package/commands/schema.command.js +18 -18
- package/exec.d.ts +2 -2
- package/exec.js +145 -145
- package/exec.js.map +1 -1
- package/index.d.ts +3 -3
- package/index.js +19 -19
- package/interfaces/index.d.ts +1 -1
- package/interfaces/index.js +17 -17
- package/interfaces/loader.interface.d.ts +20 -20
- package/interfaces/loader.interface.d.ts.map +1 -1
- package/interfaces/loader.interface.js +2 -2
- package/main.d.ts +2 -2
- package/main.js +5 -5
- package/package.json +19 -20
- package/providers/app-settings.provider.d.ts +8 -8
- package/providers/app-settings.provider.d.ts.map +1 -1
- package/providers/app-settings.provider.js +53 -51
- package/providers/app-settings.provider.js.map +1 -1
- package/providers/index.d.ts +6 -6
- package/providers/index.js +29 -29
- package/providers/local.provider.d.ts +7 -7
- package/providers/local.provider.js +41 -41
- package/providers/package-json.provider.d.ts +7 -7
- package/providers/package-json.provider.js +29 -29
- package/providers/secrets.provider.d.ts +7 -7
- package/providers/secrets.provider.js +34 -34
- package/tsconfig.build.tsbuildinfo +1 -1
- package/utils/command.util.d.ts +12 -12
- package/utils/command.util.js +138 -138
- package/utils/command.util.js.map +1 -1
- package/utils/index.d.ts +6 -6
- package/utils/index.js +22 -22
- package/utils/interpolate.util.d.ts +3 -3
- package/utils/interpolate.util.js +32 -32
- package/utils/json.util.d.ts +4 -4
- package/utils/json.util.js +47 -47
- package/utils/logger.d.ts +2 -2
- package/utils/logger.js +17 -17
- package/utils/normalize.util.d.ts +2 -2
- package/utils/normalize.util.js +60 -60
- package/utils/schema.util.d.ts +10 -10
- package/utils/schema.util.js +99 -99
package/utils/schema.util.js
CHANGED
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createValidators = exports.createValidator = exports.flatSchema = exports.schemaToJson = exports.isJsonSchemaObject = exports.schemaFrom = void 0;
|
|
7
|
-
const ajv_1 = __importDefault(require("ajv"));
|
|
8
|
-
const ajv_formats_1 = __importDefault(require("ajv-formats"));
|
|
9
|
-
const to_json_schema_1 = __importDefault(require("to-json-schema"));
|
|
10
|
-
const FORMAT_REGEXPS = {
|
|
11
|
-
'ip-address': /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})$/,
|
|
12
|
-
color: /^(#?([\dA-Fa-f]{3}){1,2}\b|aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|(rgb\(\s*\b(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\b\s*,\s*\b(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\b\s*,\s*\b(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\b\s*\))|(rgb\(\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*\)))$/,
|
|
13
|
-
hostname: /^(?=.{1,255}$)[\dA-Za-z](?:(?:[\dA-Za-z]|-){0,61}[\dA-Za-z])?(?:\.[\dA-Za-z](?:(?:[\dA-Za-z]|-){0,61}[\dA-Za-z])?)*\.?$/,
|
|
14
|
-
alphanumeric: /^[\dA-Za-z]+$/,
|
|
15
|
-
'utc-millisec': (input) => !Number.isNaN(+input),
|
|
16
|
-
alpha: /^[A-Za-z]+$/,
|
|
17
|
-
style: /\s*(.+?):\s*([^;]+);?/g,
|
|
18
|
-
phone: /^\+(?:\d ?){6,14}\d$/
|
|
19
|
-
};
|
|
20
|
-
function schemaFrom(json, options) {
|
|
21
|
-
return (0, to_json_schema_1.default)(json, {
|
|
22
|
-
required: false,
|
|
23
|
-
...options,
|
|
24
|
-
postProcessFnc: (type, schema, value, defaultFunc) => {
|
|
25
|
-
var _a;
|
|
26
|
-
if (value !== json) {
|
|
27
|
-
schema.type = [type];
|
|
28
|
-
schema.nullable = (_a = options === null || options === void 0 ? void 0 : options.nullable) !== null && _a !== void 0 ? _a : false;
|
|
29
|
-
}
|
|
30
|
-
return defaultFunc(type, schema, value);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
exports.schemaFrom = schemaFrom;
|
|
35
|
-
function isJsonSchemaObject(schema) {
|
|
36
|
-
if (schema.type === 'object')
|
|
37
|
-
return true;
|
|
38
|
-
return Array.isArray(schema.type) && schema.type.includes('object');
|
|
39
|
-
}
|
|
40
|
-
exports.isJsonSchemaObject = isJsonSchemaObject;
|
|
41
|
-
function schemaToJson(schema, container = {}) {
|
|
42
|
-
var _a;
|
|
43
|
-
if (isJsonSchemaObject(schema)) {
|
|
44
|
-
for (const key in schema.properties)
|
|
45
|
-
container[key] = schemaToJson(schema.properties[key]);
|
|
46
|
-
return container;
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
return (_a = schema.default) !== null && _a !== void 0 ? _a : (schema.nullable ? null : undefined);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
exports.schemaToJson = schemaToJson;
|
|
53
|
-
function flatSchema(schema, parentKey = '', nestingDelimiter = '__', container = {}) {
|
|
54
|
-
if (isJsonSchemaObject(schema)) {
|
|
55
|
-
for (const key in schema.properties) {
|
|
56
|
-
if (key[0] === '#')
|
|
57
|
-
continue;
|
|
58
|
-
const subKey = parentKey + (parentKey ? nestingDelimiter : '') + key;
|
|
59
|
-
container = {
|
|
60
|
-
...container,
|
|
61
|
-
...flatSchema(schema.properties[key], subKey, nestingDelimiter)
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
return container;
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
return { [parentKey]: schema };
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
exports.flatSchema = flatSchema;
|
|
71
|
-
function createValidator(schema, enableFormats = true) {
|
|
72
|
-
const ajv = new ajv_1.default({
|
|
73
|
-
allErrors: true,
|
|
74
|
-
allowUnionTypes: true
|
|
75
|
-
});
|
|
76
|
-
if (enableFormats) {
|
|
77
|
-
(0, ajv_formats_1.default)(ajv, { mode: 'fast' });
|
|
78
|
-
for (const key in FORMAT_REGEXPS)
|
|
79
|
-
ajv.addFormat(key, FORMAT_REGEXPS[key]);
|
|
80
|
-
}
|
|
81
|
-
return ajv.compile(schema);
|
|
82
|
-
}
|
|
83
|
-
exports.createValidator = createValidator;
|
|
84
|
-
function createValidators(schemaLookup, enableFormats = true) {
|
|
85
|
-
const ajv = new ajv_1.default({
|
|
86
|
-
allErrors: true,
|
|
87
|
-
allowUnionTypes: true
|
|
88
|
-
});
|
|
89
|
-
if (enableFormats) {
|
|
90
|
-
(0, ajv_formats_1.default)(ajv, { mode: 'fast' });
|
|
91
|
-
for (const key in FORMAT_REGEXPS)
|
|
92
|
-
ajv.addFormat(key, FORMAT_REGEXPS[key]);
|
|
93
|
-
}
|
|
94
|
-
const validators = {};
|
|
95
|
-
for (const key in schemaLookup)
|
|
96
|
-
validators[key] = ajv.compile(schemaLookup[key]);
|
|
97
|
-
return validators;
|
|
98
|
-
}
|
|
99
|
-
exports.createValidators = createValidators;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createValidators = exports.createValidator = exports.flatSchema = exports.schemaToJson = exports.isJsonSchemaObject = exports.schemaFrom = void 0;
|
|
7
|
+
const ajv_1 = __importDefault(require("ajv"));
|
|
8
|
+
const ajv_formats_1 = __importDefault(require("ajv-formats"));
|
|
9
|
+
const to_json_schema_1 = __importDefault(require("to-json-schema"));
|
|
10
|
+
const FORMAT_REGEXPS = {
|
|
11
|
+
'ip-address': /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})$/,
|
|
12
|
+
color: /^(#?([\dA-Fa-f]{3}){1,2}\b|aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|(rgb\(\s*\b(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\b\s*,\s*\b(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\b\s*,\s*\b(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\b\s*\))|(rgb\(\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*\)))$/,
|
|
13
|
+
hostname: /^(?=.{1,255}$)[\dA-Za-z](?:(?:[\dA-Za-z]|-){0,61}[\dA-Za-z])?(?:\.[\dA-Za-z](?:(?:[\dA-Za-z]|-){0,61}[\dA-Za-z])?)*\.?$/,
|
|
14
|
+
alphanumeric: /^[\dA-Za-z]+$/,
|
|
15
|
+
'utc-millisec': (input) => !Number.isNaN(+input),
|
|
16
|
+
alpha: /^[A-Za-z]+$/,
|
|
17
|
+
style: /\s*(.+?):\s*([^;]+);?/g,
|
|
18
|
+
phone: /^\+(?:\d ?){6,14}\d$/
|
|
19
|
+
};
|
|
20
|
+
function schemaFrom(json, options) {
|
|
21
|
+
return (0, to_json_schema_1.default)(json, {
|
|
22
|
+
required: false,
|
|
23
|
+
...options,
|
|
24
|
+
postProcessFnc: (type, schema, value, defaultFunc) => {
|
|
25
|
+
var _a;
|
|
26
|
+
if (value !== json) {
|
|
27
|
+
schema.type = [type];
|
|
28
|
+
schema.nullable = (_a = options === null || options === void 0 ? void 0 : options.nullable) !== null && _a !== void 0 ? _a : false;
|
|
29
|
+
}
|
|
30
|
+
return defaultFunc(type, schema, value);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
exports.schemaFrom = schemaFrom;
|
|
35
|
+
function isJsonSchemaObject(schema) {
|
|
36
|
+
if (schema.type === 'object')
|
|
37
|
+
return true;
|
|
38
|
+
return Array.isArray(schema.type) && schema.type.includes('object');
|
|
39
|
+
}
|
|
40
|
+
exports.isJsonSchemaObject = isJsonSchemaObject;
|
|
41
|
+
function schemaToJson(schema, container = {}) {
|
|
42
|
+
var _a;
|
|
43
|
+
if (isJsonSchemaObject(schema)) {
|
|
44
|
+
for (const key in schema.properties)
|
|
45
|
+
container[key] = schemaToJson(schema.properties[key]);
|
|
46
|
+
return container;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return (_a = schema.default) !== null && _a !== void 0 ? _a : (schema.nullable ? null : undefined);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.schemaToJson = schemaToJson;
|
|
53
|
+
function flatSchema(schema, parentKey = '', nestingDelimiter = '__', container = {}) {
|
|
54
|
+
if (isJsonSchemaObject(schema)) {
|
|
55
|
+
for (const key in schema.properties) {
|
|
56
|
+
if (key[0] === '#')
|
|
57
|
+
continue;
|
|
58
|
+
const subKey = parentKey + (parentKey ? nestingDelimiter : '') + key;
|
|
59
|
+
container = {
|
|
60
|
+
...container,
|
|
61
|
+
...flatSchema(schema.properties[key], subKey, nestingDelimiter)
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return container;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
return { [parentKey]: schema };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.flatSchema = flatSchema;
|
|
71
|
+
function createValidator(schema, enableFormats = true) {
|
|
72
|
+
const ajv = new ajv_1.default({
|
|
73
|
+
allErrors: true,
|
|
74
|
+
allowUnionTypes: true
|
|
75
|
+
});
|
|
76
|
+
if (enableFormats) {
|
|
77
|
+
(0, ajv_formats_1.default)(ajv, { mode: 'fast' });
|
|
78
|
+
for (const key in FORMAT_REGEXPS)
|
|
79
|
+
ajv.addFormat(key, FORMAT_REGEXPS[key]);
|
|
80
|
+
}
|
|
81
|
+
return ajv.compile(schema);
|
|
82
|
+
}
|
|
83
|
+
exports.createValidator = createValidator;
|
|
84
|
+
function createValidators(schemaLookup, enableFormats = true) {
|
|
85
|
+
const ajv = new ajv_1.default({
|
|
86
|
+
allErrors: true,
|
|
87
|
+
allowUnionTypes: true
|
|
88
|
+
});
|
|
89
|
+
if (enableFormats) {
|
|
90
|
+
(0, ajv_formats_1.default)(ajv, { mode: 'fast' });
|
|
91
|
+
for (const key in FORMAT_REGEXPS)
|
|
92
|
+
ajv.addFormat(key, FORMAT_REGEXPS[key]);
|
|
93
|
+
}
|
|
94
|
+
const validators = {};
|
|
95
|
+
for (const key in schemaLookup)
|
|
96
|
+
validators[key] = ajv.compile(schemaLookup[key]);
|
|
97
|
+
return validators;
|
|
98
|
+
}
|
|
99
|
+
exports.createValidators = createValidators;
|
|
100
100
|
//# sourceMappingURL=schema.util.js.map
|