UNPKG

@onboardbase/cli

Version:

[![Version](https://img.shields.io/npm/v/@onboardbase/cli.svg)](https://www.npmjs.com/package/@onboardbase/cli) [![Downloads/week](https://img.shields.io/npm/dw/@onboardbase/cli.svg)](https://www.npmjs.com/package/@onboardbase/cli) [![License](https://img

81 lines (80 loc) 3.91 kB
import Command from "@oclif/command"; import { ConfigManager, IGlobalConfigurationScope } from "../config"; import { ArgsFlags, IFlags } from "./base.command"; import { HTTPService } from "./http.service"; export interface IBaseCommandService { initialize(args: ArgsFlags): Promise<void>; preInit(): Promise<void>; setCurrentDirScope(scope: string): void; getConfigForCurrentScope(supPath?: string): any; } export declare class BaseService implements IBaseCommandService { executor: Command; configManager: ConfigManager; httpInstance: HTTPService; private _CURRENT_DIR_SCOPE; constructor(configManager?: ConfigManager); setCurrentDirScope(path?: string): void; getCurrentDirScope(): string; setScopeConfig(key: keyof IGlobalConfigurationScope, value: any): IGlobalConfigurationScope; initialize(argsFlags: ArgsFlags): Promise<void>; preInit(): Promise<void>; /** * Get the current project and environment from the user input * @returns {currentProject: string, currentEnvironment: string} */ protected _handleGetProjectAndEnvironment({ project, environment }: IFlags): { currentProject: string; currentEnvironment: string; }; /** * Reads the configuration from an onboardbase.yml file * It prioritizes the value of the envName, * then check if the userConfig has a value, * before proceeeding to read the value from onboardbase.yml file, * * @param options parameters to use when reading the config value from .onboardbase.yaml file * @property {options.envName} {string} An environment variable name to read from. * @property {options.userConfig} {string} The value entered by a user from the command line for a given flag or argument * @property {options.configPath} {string} A valid json path using dot separator inside of onboardbase.yml file * @returns {string} */ protected _getFromProjectConfigOrThrow<T = string>({ userConfig, configPath, envName, errMsg, }: { userConfig: string; configPath: string; envName?: string; errMsg?: string; }): T; /** * Reads the configuration values from the Global config file at {configDir}/config.json file * It prioritizes the value of the envName, * then check if the userConfig has a value, * before proceeeding to read the value from config.json file. * * TO read from config.json file requires checking if there is an existing config for the present working directory(refered to as pwd scope), before checking the root directory(the global scope). If none of these has a value for the required env, it throws a bad configuration error. * * @param options parameters to use when reading the config value from .onboardbase.yaml file * @property {options.envName} {string} An environment variable name to read from. * @property {options.userConfig} {string} The value entered by a user from the command line for a given flag or argument * @property {options.configPath} {string} A valid json path using dot separator inside of onboardbase.yaml file * @returns {string} */ protected _getFromGlobalConfigOrThrow({ userConfig, configPath, envName, }: { userConfig?: string; configPath: string; envName?: string; }): string; /** * Sets a configuration for the current scope. * @param subPath - Optional sub-path within the current scope. * @returns The configuration for the current scope. */ getConfigForCurrentScope(subPath?: string): any; /** * Retrieves the configuration for the current scope. * @param subPath - Optional sub-path within the current scope. * @returns The configuration for the current scope. */ setConfigForCurrentScope(subPath: string, val: any): any; ensureConfigExists(): Promise<void>; }