@cenk1cenk2/oclif-common 3.9.5 → 3.9.7
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/base.command-d3038122.d.ts +77 -0
- package/dist/commands/base.command.d.ts +24 -0
- package/dist/commands/base.command.js +174 -0
- package/dist/commands/config.command.d.ts +71 -0
- package/dist/commands/config.command.js +60 -0
- package/dist/commands/index.d.ts +34 -0
- package/dist/commands/index.js +18 -0
- package/dist/constants/file.constants.d.ts +5 -0
- package/dist/constants/file.constants.js +30 -0
- package/dist/constants/global-flags.constants.d.ts +5 -0
- package/dist/constants/global-flags.constants.js +53 -0
- package/dist/constants/help-groups.constants.d.ts +5 -0
- package/dist/constants/help-groups.constants.js +30 -0
- package/dist/constants/index.d.ts +4 -0
- package/dist/constants/index.js +19 -0
- package/dist/hooks/index.d.ts +3 -1
- package/dist/hooks/index.js +4 -746
- package/dist/hooks/not-found.hook.js +4 -688
- package/dist/hooks/store.hook.d.ts +7 -2
- package/dist/hooks/store.hook.js +3 -710
- package/dist/hooks/update-notifier.hook.js +1 -3
- package/dist/index.d.ts +52 -405
- package/dist/index.js +7 -1339
- package/dist/interfaces/class.interface.d.ts +3 -0
- package/dist/interfaces/class.interface.js +15 -0
- package/dist/interfaces/config-command.interface.d.ts +12 -0
- package/dist/interfaces/config-command.interface.js +15 -0
- package/dist/interfaces/index.d.ts +10 -0
- package/dist/interfaces/index.js +20 -0
- package/dist/interfaces/oclif.interface.d.ts +9 -0
- package/dist/interfaces/oclif.interface.js +27 -0
- package/dist/interfaces/type-helper.interface.d.ts +8 -0
- package/dist/interfaces/type-helper.interface.js +15 -0
- package/dist/lib/config/config.constants.d.ts +8 -0
- package/dist/lib/config/config.constants.js +33 -0
- package/dist/lib/config/config.interface.d.ts +15 -0
- package/dist/lib/config/config.interface.js +15 -0
- package/dist/lib/config/config.service.d.ts +24 -0
- package/dist/lib/config/config.service.js +172 -0
- package/dist/lib/config/index.d.ts +24 -0
- package/dist/lib/config/index.js +18 -0
- package/dist/lib/fs/filesystem.service.d.ts +28 -0
- package/dist/lib/fs/filesystem.service.js +162 -0
- package/dist/lib/fs/index.d.ts +2 -0
- package/dist/lib/fs/index.js +17 -0
- package/dist/lib/index.d.ts +29 -0
- package/dist/lib/index.js +23 -0
- package/dist/lib/locker/index.d.ts +4 -0
- package/dist/lib/locker/index.js +18 -0
- package/dist/lib/locker/locker.interface.d.ts +17 -0
- package/dist/lib/locker/locker.interface.js +15 -0
- package/dist/lib/locker/locker.service.d.ts +30 -0
- package/dist/lib/locker/locker.service.js +170 -0
- package/dist/lib/parser/env-parser.service.d.ts +13 -0
- package/dist/lib/parser/env-parser.service.js +62 -0
- package/dist/lib/parser/index.d.ts +8 -0
- package/dist/lib/parser/index.js +21 -0
- package/dist/lib/parser/json-parser.service.d.ts +12 -0
- package/dist/lib/parser/json-parser.service.js +52 -0
- package/dist/lib/parser/parser.interface.d.ts +7 -0
- package/dist/lib/parser/parser.interface.js +15 -0
- package/dist/lib/parser/parser.service.d.ts +21 -0
- package/dist/lib/parser/parser.service.js +87 -0
- package/dist/lib/parser/yaml-parser.service.d.ts +12 -0
- package/dist/lib/parser/yaml-parser.service.js +53 -0
- package/dist/lib/setup.d.ts +3 -0
- package/dist/lib/setup.js +60 -0
- package/dist/lib/store/index.d.ts +2 -0
- package/dist/lib/store/index.js +18 -0
- package/dist/lib/store/store.interface.d.ts +5 -0
- package/dist/lib/store/store.interface.js +15 -0
- package/dist/lib/store/store.service.d.ts +12 -0
- package/dist/lib/store/store.service.js +48 -0
- package/dist/lib/validator/index.d.ts +5 -0
- package/dist/lib/validator/index.js +18 -0
- package/dist/lib/validator/validator.interface.d.ts +9 -0
- package/dist/lib/validator/validator.interface.js +15 -0
- package/dist/lib/validator/validator.service.d.ts +16 -0
- package/dist/lib/validator/validator.service.js +77 -0
- package/dist/utils/color.d.ts +5 -0
- package/dist/utils/color.js +34 -0
- package/dist/utils/defaults.d.ts +11 -0
- package/dist/utils/defaults.js +47 -0
- package/dist/utils/environment.d.ts +7 -0
- package/dist/utils/environment.js +44 -0
- package/dist/utils/index.d.ts +17 -0
- package/dist/utils/index.js +34 -0
- package/dist/utils/logger/index.d.ts +10 -0
- package/dist/utils/logger/index.js +21 -0
- package/dist/utils/logger/listr-logger.d.ts +20 -0
- package/dist/utils/logger/listr-logger.js +60 -0
- package/dist/utils/logger/logger.constants.d.ts +20 -0
- package/dist/utils/logger/logger.constants.js +48 -0
- package/dist/utils/logger/logger.d.ts +31 -0
- package/dist/utils/logger/logger.interface.d.ts +16 -0
- package/dist/utils/logger/logger.interface.js +15 -0
- package/dist/utils/logger/logger.js +200 -0
- package/dist/utils/logger/pipe/index.d.ts +9 -0
- package/dist/utils/logger/pipe/index.js +19 -0
- package/dist/utils/logger/pipe/pipe-process-to-listr.d.ts +6 -0
- package/dist/utils/logger/pipe/pipe-process-to-listr.js +43 -0
- package/dist/utils/logger/pipe/pipe-process-to-logger.d.ts +13 -0
- package/dist/utils/logger/pipe/pipe-process-to-logger.interface.d.ts +16 -0
- package/dist/utils/logger/pipe/pipe-process-to-logger.interface.js +15 -0
- package/dist/utils/logger/pipe/pipe-process-to-logger.js +80 -0
- package/dist/utils/merge.constants.d.ts +6 -0
- package/dist/utils/merge.constants.js +31 -0
- package/dist/utils/merge.d.ts +8 -0
- package/dist/utils/merge.js +47 -0
- package/package.json +7 -7
- package/dist/store.hook-519df5f8.d.ts +0 -18
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var class_interface_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(class_interface_exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LockerService } from '../lib/locker/locker.service.js';
|
|
2
|
+
import '../lib/locker/locker.interface.js';
|
|
3
|
+
import '../utils/merge.constants.js';
|
|
4
|
+
import '../lib/parser/parser.interface.js';
|
|
5
|
+
|
|
6
|
+
type ConfigCommandChoices<T extends string> = Record<T, () => void | Promise<void>>;
|
|
7
|
+
interface ConfigCommandSetup<T extends string = string, LockFile = any> {
|
|
8
|
+
choices: ConfigCommandChoices<T>;
|
|
9
|
+
locker?: LockerService<LockFile>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { ConfigCommandChoices, ConfigCommandSetup };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var config_command_interface_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(config_command_interface_exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { ClassType } from './class.interface.js';
|
|
2
|
+
export { ConfigCommandChoices, ConfigCommandSetup } from './config-command.interface.js';
|
|
3
|
+
export { InferArgs, InferFlags } from './oclif.interface.js';
|
|
4
|
+
export { DeepPartial } from './type-helper.interface.js';
|
|
5
|
+
export { Arg, ArgInput, Flag, FlagInput, InferredFlags } from '@oclif/core/lib/interfaces';
|
|
6
|
+
export { Flags } from '@oclif/core';
|
|
7
|
+
import '../lib/locker/locker.service.js';
|
|
8
|
+
import '../lib/locker/locker.interface.js';
|
|
9
|
+
import '../utils/merge.constants.js';
|
|
10
|
+
import '../lib/parser/parser.interface.js';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var interfaces_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(interfaces_exports);
|
|
17
|
+
__reExport(interfaces_exports, require("./class.interface"), module.exports);
|
|
18
|
+
__reExport(interfaces_exports, require("./config-command.interface"), module.exports);
|
|
19
|
+
__reExport(interfaces_exports, require("./oclif.interface"), module.exports);
|
|
20
|
+
__reExport(interfaces_exports, require("./type-helper.interface"), module.exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export { Flags } from '@oclif/core';
|
|
3
|
+
import { InferredFlags } from '@oclif/core/lib/interfaces';
|
|
4
|
+
export { Arg, ArgInput, Flag, FlagInput, InferredFlags } from '@oclif/core/lib/interfaces';
|
|
5
|
+
|
|
6
|
+
type InferFlags<T extends typeof Command> = InferredFlags<T['globalFlags'] & T['flags']>;
|
|
7
|
+
type InferArgs<T extends typeof Command> = Record<T['args'][number]['name'], string>;
|
|
8
|
+
|
|
9
|
+
export { InferArgs, InferFlags };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var oclif_interface_exports = {};
|
|
19
|
+
__export(oclif_interface_exports, {
|
|
20
|
+
Flags: () => import_core.Flags
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(oclif_interface_exports);
|
|
23
|
+
var import_core = require("@oclif/core");
|
|
24
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
25
|
+
0 && (module.exports = {
|
|
26
|
+
Flags
|
|
27
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var type_helper_interface_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(type_helper_interface_exports);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var config_constants_exports = {};
|
|
19
|
+
__export(config_constants_exports, {
|
|
20
|
+
ConfigEnvKeys: () => ConfigEnvKeys
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(config_constants_exports);
|
|
23
|
+
var ConfigEnvKeys = /* @__PURE__ */ ((ConfigEnvKeys2) => {
|
|
24
|
+
ConfigEnvKeys2["NAME"] = "__name";
|
|
25
|
+
ConfigEnvKeys2["PARSER"] = "__format";
|
|
26
|
+
ConfigEnvKeys2["ELEMENT"] = "__element";
|
|
27
|
+
ConfigEnvKeys2["ELEMENT_REPLACER"] = "${i}";
|
|
28
|
+
return ConfigEnvKeys2;
|
|
29
|
+
})(ConfigEnvKeys || {});
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
ConfigEnvKeys
|
|
33
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LogLevels } from '../../utils/logger/logger.constants.js';
|
|
2
|
+
|
|
3
|
+
interface GlobalConfig {
|
|
4
|
+
logLevel: LogLevels;
|
|
5
|
+
ci: boolean;
|
|
6
|
+
json: boolean;
|
|
7
|
+
}
|
|
8
|
+
interface ConfigIterator {
|
|
9
|
+
key: (string | number)[];
|
|
10
|
+
env: string;
|
|
11
|
+
parser?: string;
|
|
12
|
+
extensions?: ConfigIterator[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { ConfigIterator, GlobalConfig };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var config_interface_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(config_interface_exports);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import './config.interface.js';
|
|
2
|
+
export { a as ConfigService } from '../../base.command-d3038122.js';
|
|
3
|
+
import '../locker/locker.interface.js';
|
|
4
|
+
import '../parser/parser.service.js';
|
|
5
|
+
import '../../utils/logger/logger.constants.js';
|
|
6
|
+
import '../../utils/merge.constants.js';
|
|
7
|
+
import '@oclif/core';
|
|
8
|
+
import 'listr2';
|
|
9
|
+
import '../../utils/logger/logger.js';
|
|
10
|
+
import '../../utils/logger/logger.interface.js';
|
|
11
|
+
import 'winston';
|
|
12
|
+
import '../fs/filesystem.service.js';
|
|
13
|
+
import 'fs-extra';
|
|
14
|
+
import '../../utils/defaults.js';
|
|
15
|
+
import '../store/store.service.js';
|
|
16
|
+
import '../store/store.interface.js';
|
|
17
|
+
import '../validator/validator.service.js';
|
|
18
|
+
import '../validator/validator.interface.js';
|
|
19
|
+
import 'class-transformer';
|
|
20
|
+
import 'class-validator';
|
|
21
|
+
import '../../interfaces/class.interface.js';
|
|
22
|
+
import '../../interfaces/oclif.interface.js';
|
|
23
|
+
import '@oclif/core/lib/interfaces';
|
|
24
|
+
import '../parser/parser.interface.js';
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var config_service_exports = {};
|
|
26
|
+
__export(config_service_exports, {
|
|
27
|
+
ConfigService: () => ConfigService
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(config_service_exports);
|
|
30
|
+
var import_object_path_immutable = __toESM(require("object-path-immutable"));
|
|
31
|
+
var import_path = require("path");
|
|
32
|
+
var import_config = require("./config.constants");
|
|
33
|
+
var import_constants = require("../../constants");
|
|
34
|
+
var import_parser = require("../parser/parser.service");
|
|
35
|
+
var import_utils = require("../../utils");
|
|
36
|
+
var import_logger = require("../../utils/logger");
|
|
37
|
+
class ConfigService {
|
|
38
|
+
constructor(oclif, command, config) {
|
|
39
|
+
this.oclif = oclif;
|
|
40
|
+
this.command = command;
|
|
41
|
+
if (ConfigService.instance) {
|
|
42
|
+
return ConfigService.instance;
|
|
43
|
+
}
|
|
44
|
+
this.root = this.oclif.root;
|
|
45
|
+
this.defaults = (0, import_path.join)(this.oclif.root, import_constants.FileConstants.CONFIG_SERVICE_DEFAULTS_DIR);
|
|
46
|
+
this.logger = new import_logger.Logger(this.constructor.name, { level: config.logLevel });
|
|
47
|
+
Object.assign(this, config);
|
|
48
|
+
this.recalculate();
|
|
49
|
+
this.parser = new import_parser.ParserService();
|
|
50
|
+
ConfigService.instance = this;
|
|
51
|
+
this.logger.trace("Created a new instance.");
|
|
52
|
+
}
|
|
53
|
+
async read(path) {
|
|
54
|
+
const config = await this.parser.read(path);
|
|
55
|
+
this.logger.trace("Read config from: %s", path);
|
|
56
|
+
return config;
|
|
57
|
+
}
|
|
58
|
+
async extend(paths, strategy = import_utils.MergeStrategy.OVERWRITE) {
|
|
59
|
+
this.logger.trace("Will generate config from: %o with %s", paths, strategy);
|
|
60
|
+
const configs = (await Promise.all(
|
|
61
|
+
paths.map(async (path) => {
|
|
62
|
+
try {
|
|
63
|
+
const config = typeof path === "string" ? await this.parser.read(path) : path;
|
|
64
|
+
this.logger.trace("Extending config from: %s", path);
|
|
65
|
+
return config;
|
|
66
|
+
} catch (e) {
|
|
67
|
+
this.logger.trace("Failed to extend config from: %s", e.message);
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
)).filter(Boolean);
|
|
71
|
+
return this.merge(configs, strategy);
|
|
72
|
+
}
|
|
73
|
+
merge(configs, strategy = import_utils.MergeStrategy.OVERWRITE) {
|
|
74
|
+
if (configs.length === 0) {
|
|
75
|
+
throw new Error("Nothing to merge, configuration files are empty.");
|
|
76
|
+
}
|
|
77
|
+
return (0, import_utils.merge)(strategy, ...configs);
|
|
78
|
+
}
|
|
79
|
+
async env(definition, config) {
|
|
80
|
+
const env = typeof definition === "string" ? await this.parser.read(definition) : definition;
|
|
81
|
+
this.logger.trace("Environment variable extensions read: %o", definition);
|
|
82
|
+
const iter = /* @__PURE__ */ __name(async (obj, parent) => {
|
|
83
|
+
const data = await Promise.all(
|
|
84
|
+
Object.entries(obj).map(async ([key, value]) => {
|
|
85
|
+
const location = [...parent ?? [], key];
|
|
86
|
+
if (typeof value === "string") {
|
|
87
|
+
return [{ key: location, env: value }];
|
|
88
|
+
} else if (typeof value === "object") {
|
|
89
|
+
let extensions;
|
|
90
|
+
if (import_config.ConfigEnvKeys.ELEMENT in value) {
|
|
91
|
+
extensions = await iter(value[import_config.ConfigEnvKeys.ELEMENT], [...location, import_config.ConfigEnvKeys.ELEMENT]);
|
|
92
|
+
this.logger.trace("Expanding location to elements: %s -> %s", location, extensions.map((extension) => extension.key.join(".")).join(", "));
|
|
93
|
+
}
|
|
94
|
+
if (import_config.ConfigEnvKeys.NAME in value && import_config.ConfigEnvKeys.PARSER in value) {
|
|
95
|
+
const variable = [
|
|
96
|
+
{
|
|
97
|
+
key: location,
|
|
98
|
+
env: value[import_config.ConfigEnvKeys.NAME],
|
|
99
|
+
parser: value[import_config.ConfigEnvKeys.PARSER],
|
|
100
|
+
extensions
|
|
101
|
+
}
|
|
102
|
+
];
|
|
103
|
+
return variable;
|
|
104
|
+
} else {
|
|
105
|
+
return iter(value, location);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
);
|
|
110
|
+
return data.flatMap((d) => d).filter(Boolean);
|
|
111
|
+
}, "iter");
|
|
112
|
+
const parsed = await iter(env);
|
|
113
|
+
const cb = /* @__PURE__ */ __name((config2, variable, data) => {
|
|
114
|
+
if (variable.parser) {
|
|
115
|
+
try {
|
|
116
|
+
data = this.parser.parse(variable.parser, data);
|
|
117
|
+
} catch (e) {
|
|
118
|
+
this.logger.trace("Can not parse environment environment variable for config: %s -> %s with %s", variable.key.join("."), variable.env, variable.parser);
|
|
119
|
+
throw e;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
this.logger.trace("Overwriting config with environment variable: %s -> %s", variable.key.join("."), variable.env);
|
|
123
|
+
return import_object_path_immutable.default.set(config2, variable.key, data);
|
|
124
|
+
}, "cb");
|
|
125
|
+
parsed.forEach((variable) => {
|
|
126
|
+
let data;
|
|
127
|
+
data = process.env[variable.env];
|
|
128
|
+
if (data) {
|
|
129
|
+
config = cb(config, variable, data);
|
|
130
|
+
}
|
|
131
|
+
if (variable.extensions && variable.extensions.length > 0) {
|
|
132
|
+
const timeout = 6e4;
|
|
133
|
+
const startedAt = Date.now();
|
|
134
|
+
for (let i = 0; i < Infinity; i++) {
|
|
135
|
+
if (Date.now() - startedAt > timeout) {
|
|
136
|
+
throw new Error(`Timed-out in ${timeout}ms while looking for element environment variables.`);
|
|
137
|
+
}
|
|
138
|
+
const extensions = variable.extensions.map((extension) => {
|
|
139
|
+
const clone = JSON.parse(JSON.stringify(extension));
|
|
140
|
+
clone.env = clone.env.replace(import_config.ConfigEnvKeys.ELEMENT_REPLACER, i.toString());
|
|
141
|
+
clone.key[clone.key.findIndex((value) => value === import_config.ConfigEnvKeys.ELEMENT)] = i.toString();
|
|
142
|
+
data = process.env[clone.env];
|
|
143
|
+
if (!data) {
|
|
144
|
+
this.logger.trace("No extension for environment variable: %s -> %s", clone.key.join("."), clone.env);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
config = cb(config, clone, data);
|
|
148
|
+
return true;
|
|
149
|
+
}).filter(Boolean);
|
|
150
|
+
if (extensions.length === 0) {
|
|
151
|
+
this.logger.trace("No more extensions for environment variables: %s -> %d", variable.key.join("."), i);
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
return config;
|
|
158
|
+
}
|
|
159
|
+
async write(path, data) {
|
|
160
|
+
return this.parser.write(path, data);
|
|
161
|
+
}
|
|
162
|
+
recalculate() {
|
|
163
|
+
this.isVerbose = (0, import_utils.isVerbose)(this.logLevel);
|
|
164
|
+
this.isDebug = (0, import_utils.isDebug)(this.logLevel);
|
|
165
|
+
this.isSilent = (0, import_utils.isSilent)(this.logLevel);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
__name(ConfigService, "ConfigService");
|
|
169
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
170
|
+
0 && (module.exports = {
|
|
171
|
+
ConfigService
|
|
172
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export { ConfigIterator, GlobalConfig } from './config.interface.js';
|
|
2
|
+
export { a as ConfigService } from '../../base.command-d3038122.js';
|
|
3
|
+
import '../../utils/logger/logger.constants.js';
|
|
4
|
+
import '@oclif/core';
|
|
5
|
+
import 'listr2';
|
|
6
|
+
import '../../utils/logger/logger.js';
|
|
7
|
+
import '../../utils/logger/logger.interface.js';
|
|
8
|
+
import 'winston';
|
|
9
|
+
import '../fs/filesystem.service.js';
|
|
10
|
+
import 'fs-extra';
|
|
11
|
+
import '../../utils/defaults.js';
|
|
12
|
+
import '../parser/parser.service.js';
|
|
13
|
+
import '../parser/parser.interface.js';
|
|
14
|
+
import '../../interfaces/class.interface.js';
|
|
15
|
+
import '../locker/locker.interface.js';
|
|
16
|
+
import '../../utils/merge.constants.js';
|
|
17
|
+
import '../store/store.service.js';
|
|
18
|
+
import '../store/store.interface.js';
|
|
19
|
+
import '../validator/validator.service.js';
|
|
20
|
+
import '../validator/validator.interface.js';
|
|
21
|
+
import 'class-transformer';
|
|
22
|
+
import 'class-validator';
|
|
23
|
+
import '../../interfaces/oclif.interface.js';
|
|
24
|
+
import '@oclif/core/lib/interfaces';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var config_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(config_exports);
|
|
17
|
+
__reExport(config_exports, require("./config.interface"), module.exports);
|
|
18
|
+
__reExport(config_exports, require("./config.service"), module.exports);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
export { default as fs } from 'fs-extra';
|
|
3
|
+
|
|
4
|
+
declare class FileSystemService {
|
|
5
|
+
private static instance;
|
|
6
|
+
private logger;
|
|
7
|
+
constructor();
|
|
8
|
+
exists(path: string): boolean;
|
|
9
|
+
stats(path: string): fs.Stats;
|
|
10
|
+
dirname(path: string): string;
|
|
11
|
+
extname(path: string): string;
|
|
12
|
+
read(file: string): Promise<string>;
|
|
13
|
+
readSync(file: string): string;
|
|
14
|
+
write(file: string, data: string | Buffer, options?: fs.WriteFileOptions): Promise<void>;
|
|
15
|
+
writeSync(file: string, data: string | Buffer, options?: fs.WriteFileOptions): void;
|
|
16
|
+
append(file: string, data: string | Buffer, options?: fs.WriteFileOptions): Promise<void>;
|
|
17
|
+
appendSync(file: string, data: string | Buffer): void;
|
|
18
|
+
remove(file: string, options?: fs.RmOptions): Promise<void>;
|
|
19
|
+
removeSync(file: string, options?: fs.RmOptions): void;
|
|
20
|
+
emptyDir(directory: string): Promise<void>;
|
|
21
|
+
emptyDirSync(directory: string): void;
|
|
22
|
+
removeDir(directory: string): Promise<void>;
|
|
23
|
+
removeDirSync(directory: string): void;
|
|
24
|
+
mkdir(directory: string): Promise<void>;
|
|
25
|
+
mkdirSync(directory: string): void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { FileSystemService };
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var filesystem_service_exports = {};
|
|
26
|
+
__export(filesystem_service_exports, {
|
|
27
|
+
FileSystemService: () => FileSystemService,
|
|
28
|
+
fs: () => import_fs_extra.default
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(filesystem_service_exports);
|
|
31
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
32
|
+
var import_path = require("path");
|
|
33
|
+
var import_logger = require("../../utils/logger");
|
|
34
|
+
class FileSystemService {
|
|
35
|
+
constructor() {
|
|
36
|
+
if (FileSystemService.instance) {
|
|
37
|
+
return FileSystemService.instance;
|
|
38
|
+
} else {
|
|
39
|
+
FileSystemService.instance = this;
|
|
40
|
+
this.logger = new import_logger.Logger(this.constructor.name);
|
|
41
|
+
this.logger.trace("Created a new instance.");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exists(path) {
|
|
45
|
+
return import_fs_extra.default.existsSync(path);
|
|
46
|
+
}
|
|
47
|
+
stats(path) {
|
|
48
|
+
return import_fs_extra.default.statSync(path, { throwIfNoEntry: true });
|
|
49
|
+
}
|
|
50
|
+
dirname(path) {
|
|
51
|
+
return (0, import_path.dirname)(path);
|
|
52
|
+
}
|
|
53
|
+
extname(path) {
|
|
54
|
+
return (0, import_path.extname)(path);
|
|
55
|
+
}
|
|
56
|
+
async read(file) {
|
|
57
|
+
try {
|
|
58
|
+
const raw = await import_fs_extra.default.readFile(file, "utf-8");
|
|
59
|
+
return raw;
|
|
60
|
+
} catch (e) {
|
|
61
|
+
throw new Error(`Error while reading file from "${file}": ${e.message}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
readSync(file) {
|
|
65
|
+
try {
|
|
66
|
+
const raw = import_fs_extra.default.readFileSync(file, "utf-8");
|
|
67
|
+
return raw;
|
|
68
|
+
} catch (e) {
|
|
69
|
+
throw new Error(`Error while reading file from "${file}": ${e.message}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async write(file, data, options = {}) {
|
|
73
|
+
try {
|
|
74
|
+
await import_fs_extra.default.writeFile(file, data, { encoding: "utf-8", ...options });
|
|
75
|
+
} catch (e) {
|
|
76
|
+
throw new Error(`Error while writing file to "${file}": ${e.message}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
writeSync(file, data, options = {}) {
|
|
80
|
+
try {
|
|
81
|
+
import_fs_extra.default.writeFileSync(file, data, { encoding: "utf-8", ...options });
|
|
82
|
+
} catch (e) {
|
|
83
|
+
throw new Error(`Error while writing file to "${file}": ${e.message}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async append(file, data, options) {
|
|
87
|
+
try {
|
|
88
|
+
await import_fs_extra.default.appendFile(file, data, options);
|
|
89
|
+
} catch (e) {
|
|
90
|
+
throw new Error(`Error while appending to file "${file}": ${e.message}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
appendSync(file, data) {
|
|
94
|
+
try {
|
|
95
|
+
import_fs_extra.default.appendFileSync(file, data);
|
|
96
|
+
} catch (e) {
|
|
97
|
+
throw new Error(`Error while appending to file "${file}": ${e.message}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async remove(file, options) {
|
|
101
|
+
try {
|
|
102
|
+
await import_fs_extra.default.rm(file, options);
|
|
103
|
+
} catch (e) {
|
|
104
|
+
throw new Error(`Error while deleting the file "${file}": ${e.message}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
removeSync(file, options) {
|
|
108
|
+
try {
|
|
109
|
+
import_fs_extra.default.rmSync(file, options);
|
|
110
|
+
} catch (e) {
|
|
111
|
+
throw new Error(`Error while deleting the file "${file}": ${e.message}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async emptyDir(directory) {
|
|
115
|
+
try {
|
|
116
|
+
await import_fs_extra.default.emptyDir(directory);
|
|
117
|
+
} catch (e) {
|
|
118
|
+
throw new Error(`Error while emptying the directory "${directory}": ${e.message}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
emptyDirSync(directory) {
|
|
122
|
+
try {
|
|
123
|
+
import_fs_extra.default.emptyDirSync(directory);
|
|
124
|
+
} catch (e) {
|
|
125
|
+
throw new Error(`Error while emptying the directory "${directory}": ${e.message}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async removeDir(directory) {
|
|
129
|
+
try {
|
|
130
|
+
await import_fs_extra.default.rmdir(directory);
|
|
131
|
+
} catch (e) {
|
|
132
|
+
throw new Error(`Error while removing the directory "${directory}": ${e.message}`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
removeDirSync(directory) {
|
|
136
|
+
try {
|
|
137
|
+
import_fs_extra.default.rmdirSync(directory);
|
|
138
|
+
} catch (e) {
|
|
139
|
+
throw new Error(`Error while removing the directory "${directory}": ${e.message}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
async mkdir(directory) {
|
|
143
|
+
try {
|
|
144
|
+
await import_fs_extra.default.mkdirp(directory);
|
|
145
|
+
} catch (e) {
|
|
146
|
+
throw new Error(`Error while creating the directory "${directory}": ${e.message}`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
mkdirSync(directory) {
|
|
150
|
+
try {
|
|
151
|
+
import_fs_extra.default.mkdirSync(directory);
|
|
152
|
+
} catch (e) {
|
|
153
|
+
throw new Error(`Error while creating the directory "${directory}": ${e.message}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
__name(FileSystemService, "FileSystemService");
|
|
158
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
159
|
+
0 && (module.exports = {
|
|
160
|
+
FileSystemService,
|
|
161
|
+
fs
|
|
162
|
+
});
|