base.d.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { CommandLineInputs, CommandLineOptions, IConfig, IProject } from '../../definitions';
  2. import { Command } from '../../lib/command';
  3. export interface BaseConfigContext {
  4. json: boolean;
  5. force: boolean;
  6. root: boolean;
  7. property?: string;
  8. value?: any;
  9. }
  10. export interface GlobalConfigContext extends BaseConfigContext {
  11. global: true;
  12. config: IConfig;
  13. }
  14. export interface ProjectConfigContext extends BaseConfigContext {
  15. global: false;
  16. config: IProject['config'];
  17. }
  18. export declare type ConfigContext = GlobalConfigContext | ProjectConfigContext;
  19. export declare abstract class BaseConfigCommand extends Command {
  20. generateContext(inputs: CommandLineInputs, options: CommandLineOptions): ConfigContext;
  21. jsonStringify(v: any): string;
  22. interpretValue(v?: string, expectJson?: boolean): any;
  23. }
  24. interface FlexibleConfigFile {
  25. [key: string]: any;
  26. }
  27. export declare function getConfig(ctx: ConfigContext): FlexibleConfigFile;
  28. export declare function getConfigValue(ctx: ConfigContext): any;
  29. export declare function setConfigValue(ctx: ConfigContext & {
  30. property: string;
  31. originalValue: any;
  32. }): void;
  33. export declare function unsetConfigValue(ctx: ConfigContext & {
  34. property: string;
  35. }): void;
  36. export {};