@sasjs/cli
Version:
Command line interface for SASjs
120 lines (119 loc) • 6.18 kB
TypeScript
import SASjs from '@sasjs/adapter/node';
import { Configuration, Target, AuthConfig, StreamConfig, AuthConfigSas9, SyncDirectoryMap } from '@sasjs/utils';
import { TargetScope } from '../types/targetScope';
/**
* Returns an object that represents the SASjs CLI configuration in a given file.
* @param {string} pathToFile - the path to the file in question.
* @returns {Configuration} configuration object if available.
*/
export declare function getConfiguration(pathToFile: string): Promise<Configuration>;
/**
* Returns the target with the given name.
* If the target is not found in the local configuration,
* this function then looks in the global configuration.
* If it is still unable to find it, it throws an error.
* @param {string} targetName - the name of the target in question.
* @param {TargetScope} targetScope - if specified will either consider only Local OR only Global targets.
* @returns {Target} target or fallback when one is found.
*/
export declare function findTargetInConfiguration(targetName: string, targetScope?: TargetScope): Promise<{
target: Target;
isLocal: boolean;
}>;
export declare function getGlobalRcFile(): Promise<any>;
export declare function getLocalRcFile(): Promise<Configuration | null>;
export declare function saveGlobalRcFile(content: string): Promise<string>;
export declare function saveToGlobalConfig(target: Target, isDefault?: boolean, saveWithDefaultValues?: boolean): Promise<string>;
export declare function removeFromGlobalConfig(targetName: string): Promise<void>;
export declare function removeFromLocalConfig(targetName: string): Promise<void>;
export declare function getLocalConfig(): Promise<Configuration>;
export declare function getLocalOrGlobalConfig(): Promise<{
configuration: Configuration;
isLocal: boolean;
}>;
export declare function getSyncDirectories(target: Target, isLocal: boolean): Promise<SyncDirectoryMap[]>;
export declare function saveLocalConfigFile(content: string): Promise<string>;
export declare function saveToLocalConfig(target: Target, isDefault?: boolean, saveWithDefaultValues?: boolean): Promise<string>;
export declare function getFolders(): Promise<any>;
/**
* Returns SAS program folders from configuration.
* This list includes both common and target-specific folders.
* @param {Target} target- the target to check program folders for.
*/
export declare function getProgramFolders(target: Target): Promise<string[]>;
export declare function getBinaryFolders(target: Target): Promise<string[]>;
/**
* Returns SAS macro folders from configuration.
* This list includes both common and target-specific folders.
* @param {Target} target- the target to check macro folders for.
*/
export declare function getMacroFolders(target?: Target): Promise<string[]>;
/**
* Returns StreamConfig from configuration.
* This configuration includes both common and target-specific configuration.
* @param {Target} target- the target to check stream configuration for.
*/
export declare function getStreamConfig(target?: Target): Promise<StreamConfig>;
/**
* Sanitizes app location string.
* @param {string} appLoc - app location
*/
export declare function sanitizeAppLoc(appLoc: string): string;
export declare function getProjectRoot(): Promise<string>;
/**
* Gets the auth config for the specified target.
* @param {Target} target - the target to get an access token for.
* @returns {AuthConfig} - an object containing an access token, refresh token, client ID and secret.
*/
export declare function getAuthConfig(target: Target): Promise<AuthConfig>;
export declare const saveTokens: (targetName: string, client: string, secret: string, access_token: string, refresh_token: string) => Promise<void>;
/**
* Gets the auth config for the specified SAS9 target.
* @param {Target} target - the target to get an access token for.
* @returns {AuthConfigSas9} - an object containing an userName and password.
*/
export declare function getAuthConfigSAS9(target: Target): AuthConfigSas9;
/**
* Gets an access token for the specified target.
* If the target is from the global `.sasjsrc` file,
* the auth info should be contained in it.
* It should be in the form:
* @example: { targets: [{ "name": "targetName", "authConfig": { "client": "client ID", "secret": "Client Secret", "access_token": "Token", "refresh_token": "Token" }}]}
* If the access token is going to expire in the next hour,
* it is refreshed using a refresh token if available.
* If a refresh token is unavailable, we will use the client ID and secret
* to obtain a new access token. Manual intervention is required in this case
* to navigate to the URL shown and type in an authorization code.
* @param {object} target - the target to get an access token for.
* @param {string} checkIfExpiring - flag that indicates whether to do an expiry check.
*/
export declare function getAccessToken(target: Target, checkIfExpiring?: boolean): Promise<string>;
/**
* Overrides environment variables with values from a target-specific env file if available.
* Displays a warning if the file is unavailable.
* @param {string} targetName - the name of the target corresponding to the .env file.
*/
export declare const overrideEnvVariables: (targetName: string) => Promise<void>;
export declare const getTestSetUp: (target: Target) => Promise<string | undefined>;
export declare const getTestTearDown: (target: Target) => Promise<string | undefined>;
/**
* Provides instance of @sasjs/adapter.
* @param target - server server.
* @returns - instance of @sasjs/adapter.
*/
export declare function getSASjs(target: Target): SASjs;
/**
* Returns configuration object of SAS Adapter and authentication configuration
* @param {Target} target - the target to get auth configuration from.
* @returns an object containing a SAS Adapter configuration object `sasjs`
* and auth configuration `authConfig` or `authConfigSas9`.
*/
export declare function getSASjsAndAuthConfig(target: Target): Promise<{
sasjs: SASjs;
authConfigSas9: AuthConfigSas9;
authConfig?: undefined;
} | {
sasjs: SASjs;
authConfig: AuthConfig | undefined;
authConfigSas9?: undefined;
}>;