@cenk1cenk2/oclif-common 3.1.0-beta.1 → 3.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +19 -5
- package/dist/index.js +11 -10
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -98,13 +98,20 @@ interface PipeProcessToLoggerOptions {
|
|
|
98
98
|
*/
|
|
99
99
|
declare function pipeProcessToLogger(logger: Logger, instance: ExecaChildProcess, options?: PipeProcessToLoggerOptions): ExecaChildProcess;
|
|
100
100
|
|
|
101
|
-
interface
|
|
101
|
+
interface GlobalConfigInit {
|
|
102
102
|
logLevel: LogLevels;
|
|
103
103
|
ci: boolean;
|
|
104
|
+
json: boolean;
|
|
105
|
+
}
|
|
106
|
+
interface GlobalConfig extends GlobalConfigInit {
|
|
104
107
|
isVerbose: boolean;
|
|
105
108
|
isDebug: boolean;
|
|
106
109
|
isSilent: boolean;
|
|
107
|
-
|
|
110
|
+
}
|
|
111
|
+
interface ConfigIterator {
|
|
112
|
+
key: (string | number)[];
|
|
113
|
+
env: string;
|
|
114
|
+
parser?: string;
|
|
108
115
|
}
|
|
109
116
|
|
|
110
117
|
declare const color: colorette.Colorette;
|
|
@@ -203,9 +210,9 @@ declare class ConfigService implements GlobalConfig {
|
|
|
203
210
|
private readonly logger;
|
|
204
211
|
constructor(oclif: Command['config'], command: Command['ctor'], config: Omit<GlobalConfig, 'isVerbose' | 'isDebug' | 'isSilent'>);
|
|
205
212
|
read<T extends LockableData = LockableData>(path: string): Promise<T>;
|
|
206
|
-
extend<T extends LockableData = LockableData>(paths: string[], strategy?: MergeStrategy): Promise<T>;
|
|
213
|
+
extend<T extends LockableData = LockableData>(paths: (string | Partial<T>)[], strategy?: MergeStrategy): Promise<T>;
|
|
207
214
|
merge<T extends LockableData = LockableData>(configs: Partial<T>[], strategy?: MergeStrategy): T;
|
|
208
|
-
env<T extends LockableData = LockableData>(definition: string, config: T): Promise<T>;
|
|
215
|
+
env<T extends LockableData = LockableData>(definition: string | T, config: T): Promise<T>;
|
|
209
216
|
write<T extends LockableData = LockableData>(path: string, data: T): Promise<void>;
|
|
210
217
|
private recalculate;
|
|
211
218
|
}
|
|
@@ -275,6 +282,13 @@ interface ConfigCommandSetup<T extends string = string, LockFile = any> {
|
|
|
275
282
|
declare type InferFlags<T extends typeof Command$1> = InferredFlags<T['globalFlags'] & T['flags']>;
|
|
276
283
|
declare type InferArgs<T extends typeof Command$1> = Record<T['args'][number]['name'], string>;
|
|
277
284
|
|
|
285
|
+
/**
|
|
286
|
+
* Makes the object deep partial.
|
|
287
|
+
*/
|
|
288
|
+
declare type DeepPartial<T> = {
|
|
289
|
+
[P in keyof T]?: DeepPartial<T[P]>;
|
|
290
|
+
};
|
|
291
|
+
|
|
278
292
|
declare abstract class Command<Ctx extends ListrContext = ListrContext, Flags extends Record<PropertyKey, any> = InferFlags<typeof Command>, Args extends Record<PropertyKey, any> = InferArgs<typeof Command>, Store extends Record<PropertyKey, any> = Record<PropertyKey, any>> extends Command$1 {
|
|
279
293
|
static globalFlags: {
|
|
280
294
|
"log-level": _oclif_core_lib_interfaces.OptionFlag<string>;
|
|
@@ -364,4 +378,4 @@ declare const _default: {
|
|
|
364
378
|
};
|
|
365
379
|
};
|
|
366
380
|
|
|
367
|
-
export { ClassType, Command, CommonLockerData, ConfigCommand, ConfigCommandChoices, ConfigCommandSetup, ConfigService, FileConstants, FileSystemService, GenericParser, GlobalConfig, HelpGroups, InferArgs, InferFlags, JsonParser, LockData, LockableData, LockerService, LogFieldStatus, LogLevels, Logger, LoggerFormat, LoggerOptions, MergeStrategy, ParserService, PipeProcessToLoggerOptions, SetCtxAssignOptions, SetCtxDefaultsOptions, UnlockData, ValidatorService, ValidatorServiceOptions, Winston, YamlParser, color, _default as default, isDebug, isSilent, isVerbose, merge, pipeProcessThroughListr, pipeProcessToLogger, setCtxAssign, setCtxDefaults, setup };
|
|
381
|
+
export { ClassType, Command, CommonLockerData, ConfigCommand, ConfigCommandChoices, ConfigCommandSetup, ConfigIterator, ConfigService, DeepPartial, FileConstants, FileSystemService, GenericParser, GlobalConfig, GlobalConfigInit, HelpGroups, InferArgs, InferFlags, JsonParser, LockData, LockableData, LockerService, LogFieldStatus, LogLevels, Logger, LoggerFormat, LoggerOptions, MergeStrategy, ParserService, PipeProcessToLoggerOptions, SetCtxAssignOptions, SetCtxDefaultsOptions, UnlockData, ValidatorService, ValidatorServiceOptions, Winston, YamlParser, color, _default as default, isDebug, isSilent, isVerbose, merge, pipeProcessThroughListr, pipeProcessToLogger, setCtxAssign, setCtxDefaults, setup };
|
package/dist/index.js
CHANGED
|
@@ -617,11 +617,11 @@ var ConfigService = class {
|
|
|
617
617
|
return config;
|
|
618
618
|
}
|
|
619
619
|
async extend(paths, strategy = "OVERWRITE" /* OVERWRITE */) {
|
|
620
|
-
this.logger.trace("Will generate config from: %
|
|
620
|
+
this.logger.trace("Will generate config from: %o with %s", paths, strategy);
|
|
621
621
|
const configs = (await Promise.all(
|
|
622
622
|
paths.map(async (path) => {
|
|
623
623
|
try {
|
|
624
|
-
const config = await this.parser.read(path);
|
|
624
|
+
const config = typeof path === "string" ? await this.parser.read(path) : path;
|
|
625
625
|
this.logger.trace("Extending config from: %s", path);
|
|
626
626
|
return config;
|
|
627
627
|
} catch (e) {
|
|
@@ -638,8 +638,8 @@ var ConfigService = class {
|
|
|
638
638
|
return merge(strategy, configs.some((config) => Array.isArray(config)) ? [] : {}, ...configs);
|
|
639
639
|
}
|
|
640
640
|
async env(definition, config) {
|
|
641
|
-
const env = await this.parser.read(definition);
|
|
642
|
-
this.logger.trace("Environment variable extensions read: %
|
|
641
|
+
const env = typeof definition === "string" ? await this.parser.read(definition) : definition;
|
|
642
|
+
this.logger.trace("Environment variable extensions read: %o", definition);
|
|
643
643
|
const iter = /* @__PURE__ */ __name(async (obj, parent) => {
|
|
644
644
|
const data = await Promise.all(
|
|
645
645
|
Object.entries(obj).map(async ([key, value]) => {
|
|
@@ -649,7 +649,8 @@ var ConfigService = class {
|
|
|
649
649
|
} else if (typeof value === "object") {
|
|
650
650
|
const extras = [];
|
|
651
651
|
if ("__element" /* ELEMENT */ in value) {
|
|
652
|
-
|
|
652
|
+
this.logger.trace("Expanding location to elements: %s", location);
|
|
653
|
+
extras.push(await iter(value["__element" /* ELEMENT */], [...location, "__element" /* ELEMENT */]));
|
|
653
654
|
}
|
|
654
655
|
if ("__name" /* NAME */ in value && "__format" /* PARSER */ in value) {
|
|
655
656
|
return [
|
|
@@ -690,15 +691,15 @@ var ConfigService = class {
|
|
|
690
691
|
if (Date.now() - startedAt > timeout) {
|
|
691
692
|
throw new Error(`Timed-out in ${timeout}ms while looking for element environment variables.`);
|
|
692
693
|
}
|
|
693
|
-
|
|
694
|
+
const clone = JSON.parse(JSON.stringify(variable));
|
|
695
|
+
data = process.env[clone.env.replace("${i}" /* ELEMENT_REPLACER */, i.toString())];
|
|
694
696
|
if (!data) {
|
|
695
697
|
this.logger.trace("No more variable available: %s -> %d", variable.env, i);
|
|
696
698
|
break;
|
|
697
699
|
}
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
this.logger.trace("Overwriting config with element environment variable: %s -> %s", clone.join("."), variable.env);
|
|
700
|
+
clone.key[clone.key.findIndex((value) => value === "__element" /* ELEMENT */)] = i;
|
|
701
|
+
config = import_object_path_immutable.default.update(config, clone.key, () => {
|
|
702
|
+
this.logger.trace("Overwriting config with element environment variable: %s -> %s", clone.key.join("."), variable.env);
|
|
702
703
|
return data;
|
|
703
704
|
});
|
|
704
705
|
}
|
package/package.json
CHANGED