@cenk1cenk2/oclif-common 2.0.1 → 2.1.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 CHANGED
@@ -190,7 +190,7 @@ declare class ConfigService<Config extends BaseConfig = BaseConfig> {
190
190
  parser: ParserService;
191
191
  private readonly logger;
192
192
  constructor(command: Command<any, Config>);
193
- read<T extends LockableData = LockableData>(strategy: MergeStrategy, ...paths: string[]): Promise<T>;
193
+ read<T extends LockableData = LockableData>(paths: string): Promise<T>;
194
194
  write<T extends LockableData = LockableData>(path: string, data: T): Promise<void>;
195
195
  }
196
196
 
@@ -257,10 +257,10 @@ declare class Command<Ctx extends ListrContext = ListrContext, Config extends Ba
257
257
  */
258
258
  shouldRunAfter(_ctx?: Ctx): void | Promise<void>;
259
259
  /** Run all tasks from task manager. */
260
- runTasks(): Promise<Ctx>;
260
+ runTasks<C extends Ctx = Ctx>(): Promise<C>;
261
261
  /** Tasks to run before end of the command. */
262
- finally(): Promise<{
263
- ctx: Ctx;
262
+ finally<C extends Ctx = Ctx>(): Promise<{
263
+ ctx: C;
264
264
  }>;
265
265
  /** Catch any error occurred during command. */
266
266
  catch(e: Error): Promise<void>;
@@ -271,17 +271,17 @@ declare class Command<Ctx extends ListrContext = ListrContext, Config extends Ba
271
271
  }
272
272
 
273
273
  declare type ConfigCommandChoices<T extends string> = Record<T, () => void | Promise<void>>;
274
- interface ConfigCommandSetup<T extends string> {
274
+ interface ConfigCommandSetup<T extends string = string, LockFile = any> {
275
275
  choices: ConfigCommandChoices<T>;
276
- locker: LockerService;
276
+ locker: LockerService<LockFile>;
277
277
  }
278
278
 
279
- declare abstract class ConfigCommand<CommandChoices extends string, Ctx extends ListrContext = ListrContext, Config extends BaseConfig = BaseConfig> extends Command<Ctx, Config> {
279
+ declare abstract class ConfigCommand<CommandChoices extends string = string, LockFile = any, Ctx extends ListrContext = ListrContext, Config extends BaseConfig = BaseConfig> extends Command<Ctx, Config> {
280
280
  choices: ConfigCommandChoices<CommandChoices>;
281
- locker: LockerService;
281
+ locker: LockerService<LockFile>;
282
282
  run(): Promise<void>;
283
283
  private generate;
284
- abstract setup(): ConfigCommandSetup<CommandChoices> | Promise<ConfigCommandSetup<CommandChoices>>;
284
+ abstract setup(): ConfigCommandSetup<CommandChoices, LockFile> | Promise<ConfigCommandSetup<CommandChoices, LockFile>>;
285
285
  }
286
286
 
287
287
  declare enum FileConstants {
package/dist/index.js CHANGED
@@ -698,12 +698,21 @@ var ConfigService = class {
698
698
  this.logger.trace("Created a new instance.");
699
699
  }
700
700
  async read(strategy, ...paths) {
701
+ if (!Array.isArray(paths)) {
702
+ paths = [paths];
703
+ }
701
704
  const configs = await Promise.all(
702
705
  paths.map(async (path) => {
703
- return this.parser.read(path);
706
+ try {
707
+ const config2 = await this.parser.read(path);
708
+ return config2;
709
+ } catch (e) {
710
+ this.logger.trace(e);
711
+ return {};
712
+ }
704
713
  })
705
714
  );
706
- return merge(strategy, {}, ...configs);
715
+ return merge(strategy ?? "OVERWRITE" /* OVERWRITE */, {}, ...configs);
707
716
  }
708
717
  async write(path, data) {
709
718
  return this.parser.write(path, data);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cenk1cenk2/oclif-common",
3
- "version": "2.0.1",
3
+ "version": "2.1.2",
4
4
  "description": "Oclif common package for oclif2 projects.",
5
5
  "repository": "https://gitlab.kilic.dev/libraries/oclif-tools",
6
6
  "author": {