@onboardbase/cli
Version:
[](https://www.npmjs.com/package/@onboardbase/cli) [](https://www.npmjs.com/package/@onboardbase/cli) [ • 5.53 kB
TypeScript
/// <reference types="node" />
import { IConfig } from "@oclif/config";
import { IAuthenticateTokenResult } from "../common/types/auth";
import * as fs from "fs";
export interface IGlobalConfigurationScope {
token?: string;
"api-host": string;
"dashboard-host": string;
authToken?: string;
"environment-id"?: string;
requirePassword?: boolean;
password?: string;
requirePasswordForCurrentSession?: boolean;
"auth-result"?: IAuthenticateTokenResult;
merged: boolean;
"project-name"?: string;
"environment-name"?: string;
projectConfigLastModified: 0;
}
export interface IGlobalConfiguration {
scoped: {
[x: string]: IGlobalConfigurationScope;
};
"version-check": Record<string, any>;
}
export declare const REFPATH_VALUE = "__REFPATH__";
export interface IProjectConfiguration {
api_key: string;
passcode: string;
setup: {
project: string;
environment: string;
start_script: string;
};
scan: {
for: string[];
};
}
export declare const PROJECT_CONFIG_FILENAME = ".onboardbase.yaml";
export declare class ConfigManager {
static CURRENT_SCOPE_API_HOST: string;
static CURRENT_SCOPE_DASHBOARD_HOST: string;
destroy(): void;
private GLOBAL_CONFIG_DIR;
private GLOBAL_CACHE_DIR;
private OLD_GLOBAL_CONFIG_DIR;
private globalConfig;
private RSA_KEYS;
private projectConfig;
private _CURRENT_DIR_SCOPE;
getConfigDir(): string;
getGlobalConfig(): IGlobalConfiguration;
getCacheDir(): string;
getOldConfigDir(): string;
private _getCurrentProjectConfigFilePath;
private _getCurrentProjectConfigFileContent;
/**
* Use this function to pull out the details from the .onboardbase.yaml file
* into memory
*
* The file is expected to be in the current directory where the command is
* executed e.g:
* $ ~/work/path: onboardbase run env
*
* A `.onboardbase.yaml` file is expected to be found at
* ~/work/path/.onboardbase.yaml
*
*/
private _loadCurrentProjectConfig;
private _getOldGlobalConfigPath;
/**
*
* @returns
*/
private _readOldGlobalConfigFromDisk;
private _getGlobalConfigPath;
private _writeGlobalConfigToDisk;
private _migrateDeprecatedConfigFormat;
private _readGlobalConfigFromDisk;
private _checkIfGlobalConfigExists;
private _loadGlobalConfig;
/**
* Merges the current working directory (cwd) configuration with the root configuration.
* If a key exists in the root configuration but not in the cwd configuration, it is set to REFPATH_VALUE.
* @param cwdConfig The current working directory configuration.
* @returns The merged configuration.
*/
private _mergeCWDConfigWithRootConfig;
private _bootstrapGlobalConfig;
setScopeConfig(key: keyof IGlobalConfigurationScope, value: any): IGlobalConfigurationScope;
/**
* Sets a configuration for the current scope.
* @param subPath - Optional sub-path within the current scope.
* @returns The configuration for the current scope.
*/
getScopeConfig(subPath?: string): any;
getProjectConfigStat(): Promise<fs.Stats>;
loadAllConfig(cmdConfig: IConfig, haltOnErr?: boolean): void;
loadPartialConfig(cmdConfig: IConfig, haltOnErr?: boolean): void;
private _setHostURLs;
private _stringifyCurrentProjectConfig;
private _writeCurrentProjectToDisk;
/**
* Involves reading local and global config objects then storing them to disk
* Both config objects have their different storage paths
* See their implementation for more details
*/
persistConfigs(): Promise<void>;
private _persistCurrentProjectConfig;
private _persistGlobalConfig;
_get(path: string, obj: Record<string, any>): any;
_generateRootConfigKeyFromKey(key: string): string;
/**
* Get a value from the global config
* @param scopedKey: the format is `scoped.${scope_path}.${key}`
* @example`scoped./.token` - get the token from the root config
* @example `scoped./path/to/project/.token` - get the token from scoped config to a project path
* @returns
*/
getFromGlobal(scopedKey: string): any;
/**
* Get a value from the root config. The methood is a wrapper around `getFromGlobal`
* @param key the key to get from the root config
* @returns
*/
getFromRootConfig(key: string): any;
getFromProject(key: string): any;
getFromProcessEnv(key: string): string;
setGlobal(key: string, val: any): any;
setDefaultGlobalConfig(data: {
scope: string;
content: IGlobalConfigurationScope;
}): void;
setProject(key: string, val: any): any;
/**
* Sets the value at the specified path in the given source object.
* If the path does not exist, it creates the necessary nested objects along the way.
*
* @param path - The path to set the value at, using dot notation.
* @param data - The value to set at the specified path.
* @param source - The source object to set the value in.
* @returns The modified source object.
*/
_set(path: string, data: any, source: {}): any;
setRSAKeys(data: {
privateKey: string;
publicKey: string;
}): void;
getRSAKeys(): {
privateKey: string;
publicKey: string;
};
setAndPersistGlobalConfig(key: string, val: any): void;
getEnvPrefix(userPrefix: string): any;
}