@ibm-wch-sdk/cli-utils
Exposes framework independent utilities to support the implementation command line utilities for @ibm-wch-sdk/ng and similar SDK.
Class documentation
Refer to the documentation.
Usage
Install the module via
npm install --save @ibm-wch-sdk/cli-utils
Home > @ibm-wch-sdk/cli-utils
cli-utils package
Enumerations
Functions
addLayoutToMapping(aLayoutMapping, aLayout) | Adds a layout to a layout mapping entry, inplace |
blackWhiteList(aInclude, aExclude) | |
canonicalizeJson(aData) | Performs an inplace canonicalization of a JSON object |
canTypeHaveLayout(aType) | Tests if an authoring type can have a layout |
cmdCreateProject(aRootFolder, aProjectName, aApiUrl) | Constructs a brand new angular project and adds the SDK to the project |
createGuid(aId, aSecret) | Constructs a GUID in a reproducible way from an ID |
createTypePredicate(aOptions) | Creates a predicate that filters authoring types |
fromRegExp(aRegexp) | Returns a regular expression tester from a sequence of expressions |
fromRegExpString(aRegexp) | |
ngGetDefaultProject(aJson) | Returns the default project, either the configured project or the first one |
ngGetSourceFolder(aAngularJson, aProject) | Returns the source folder for the angular application |
packageInstaller(aDirOrFile) | Returns a function that allows to install packages via the configured package installer. The function will invoke the package manager in the directory of the package JSON located in the given directory |
rxFindAngularJson(aRootDir) | Locates the angular configuration file, next to the package json file |
rxFindAngularVersion(aRootDir) | Locates the version of angular to use |
rxFindAuthoringLayoutMappings(aRoot) | Reads the authoring layouts from a directory |
rxFindAuthoringLayouts(aRoot) | Reads the authoring layouts from a directory |
rxFindAuthoringTypes(aRoot) | Reads the authoring types from a directory |
rxFindDataDir(aDirOrFile) | Locates the data directory |
rxFindPackageJson(aDirOrFile) | Locates the package json relative to the given directory |
rxFindPackageManager(aDirOrFile) | Locates the configured package manager |
rxFindSdkVersion(aRootDir) | Locates the version of the SDK to use, either from the package JSON or from our own build |
rxReadAngularJson(aRootDir) | Reads the angular configuration file, next to the package json file |
rxReadAuthoringLayoutMappings(aRoot) | Reads the authoring layouts from a directory |
rxReadAuthoringLayouts(aRoot) | Reads the authoring layouts from a directory |
rxReadAuthoringTypes(aRoot) | Reads the authoring types from a directory |
rxReadPackageJson(aDirOrFile) | Locates and reads the package json |
rxReadWchToolsOptions(aDirOrFile) | Reads the wchtools options object |
rxVerifyPreRequisites(aPrereq, aRootDir) | Verifies if the installed prerequisites meet the requirements. |
rxWchToolsGetCredentials(aApiUrl) | Reads the wch credentials from the given API URL |
rxWriteJsonEntryMap(aMap) | Persists the entries in the map |
sdkVersionFromAngularVersion(aAngularVersion) | Returns the SDK version from the Angular version |
Interfaces
Type Aliases
Home > @ibm-wch-sdk/cli-utils > PACKAGE_INSTALL
PACKAGE_INSTALL enum
Signature:
export declare enum PACKAGE_INSTALL
Enumeration Members
DEPENDENCIES | 0 | |
DEV_DEPENDENCIES | 1 | |
GLOBAL | 2 | |
Home > @ibm-wch-sdk/cli-utils > addLayoutToMapping
addLayoutToMapping() function
Adds a layout to a layout mapping entry, inplace
Signature:
export declare function addLayoutToMapping(aLayoutMapping: AuthoringLayoutMapping, aLayout: AuthoringLayout): AuthoringLayoutMapping;
Parameters
aLayoutMapping | AuthoringLayoutMapping | the layout mapping entry |
aLayout | AuthoringLayout | the layout |
Returns:
AuthoringLayoutMapping
the mapping
Home > @ibm-wch-sdk/cli-utils > blackWhiteList
blackWhiteList() function
Signature:
export declare function blackWhiteList(aInclude?: string[], aExclude?: string[]): Predicate<string>;
Parameters
aInclude | string[] | |
aExclude | string[] | |
Returns:
Predicate<string>
Home > @ibm-wch-sdk/cli-utils > canonicalizeJson
canonicalizeJson() function
Performs an inplace canonicalization of a JSON object
Signature:
export declare function canonicalizeJson(aData: any): any;
Parameters
Returns:
any
the canonicalized object
Home > @ibm-wch-sdk/cli-utils > canTypeHaveLayout
canTypeHaveLayout() function
Tests if an authoring type can have a layout
Signature:
export declare function canTypeHaveLayout(aType: AuthoringType): boolean;
Parameters
aType | AuthoringType | the type |
Returns:
boolean
true if the type can have a layout, else false
Home > @ibm-wch-sdk/cli-utils > cmdCreateProject
cmdCreateProject() function
Constructs a brand new angular project and adds the SDK to the project
Signature:
export declare function cmdCreateProject(aRootFolder: string, aProjectName: string, aApiUrl: string): Observable<SpawnLine>;
Parameters
aRootFolder | string | the root folder of the project |
aProjectName | string | the project name |
aApiUrl | string | the WCH API URL |
Returns:
Observable<SpawnLine>
an observable of the command output
Home > @ibm-wch-sdk/cli-utils > createGuid
createGuid() function
Constructs a GUID in a reproducible way from an ID
Signature:
export declare function createGuid(aId: string, aSecret?: string): string;
Parameters
aId | string | the original ID |
aSecret | string | some optional secret |
Returns:
string
the guid
Home > @ibm-wch-sdk/cli-utils > createTypePredicate
createTypePredicate() function
Creates a predicate that filters authoring types
Signature:
export declare function createTypePredicate(aOptions: {
include?: string[];
exclude?: string[];
}): Predicate<AuthoringType>;
Parameters
aOptions | { include?: string[];
exclude?: string[];
}
| black whitelist options |
Returns:
Predicate<AuthoringType>
the predicate
Home > @ibm-wch-sdk/cli-utils > fromRegExp
fromRegExp() function
Returns a regular expression tester from a sequence of expressions
Signature:
export declare function fromRegExp(aRegexp?: RegExp[]): Predicate<string>;
Parameters
aRegexp | RegExp[] | the expressions |
Returns:
Predicate<string>
the predicate
Home > @ibm-wch-sdk/cli-utils > fromRegExpString
fromRegExpString() function
Signature:
export declare function fromRegExpString(aRegexp?: string[]): Predicate<string>;
Parameters
Returns:
Predicate<string>
Home > @ibm-wch-sdk/cli-utils > ngGetDefaultProject
ngGetDefaultProject() function
Returns the default project, either the configured project or the first one
Signature:
export declare function ngGetDefaultProject(aJson: any): string;
Parameters
Returns:
string
the default project
Home > @ibm-wch-sdk/cli-utils > ngGetSourceFolder
ngGetSourceFolder() function
Returns the source folder for the angular application
Signature:
export declare function ngGetSourceFolder(aAngularJson: JsonFile<any>, aProject?: string): string;
Parameters
aAngularJson | JsonFile<any> | the angular JSON file |
aProject | string | optionally the project, otherwise use the default project |
Returns:
string
the source folder from that file
Home > @ibm-wch-sdk/cli-utils > packageInstaller
packageInstaller() function
Returns a function that allows to install packages via the configured package installer. The function will invoke the package manager in the directory of the package JSON located in the given directory
Signature:
export declare function packageInstaller(aDirOrFile: string): (aType: PACKAGE_INSTALL, ...aPackages: string[]) => Observable<SpawnLine>;
Parameters
aDirOrFile | string | base directory |
Returns:
(aType: PACKAGE_INSTALL, ...aPackages: string[]) => Observable<SpawnLine>
an install callback
Home > @ibm-wch-sdk/cli-utils > rxFindAngularJson
rxFindAngularJson() function
Locates the angular configuration file, next to the package json file
Signature:
export declare function rxFindAngularJson(aRootDir: string): Observable<string>;
Parameters
aRootDir | string | the starting directory |
Returns:
Observable<string>
the angular JSON file
Home > @ibm-wch-sdk/cli-utils > rxFindAngularVersion
rxFindAngularVersion() function
Locates the version of angular to use
Signature:
export declare function rxFindAngularVersion(aRootDir: string): Observable<string>;
Parameters
aRootDir | string | the root directory used to locate the packae |
Returns:
Observable<string>
the angular version as a semantic version string
Home > @ibm-wch-sdk/cli-utils > rxFindAuthoringLayoutMappings
rxFindAuthoringLayoutMappings() function
Reads the authoring layouts from a directory
Signature:
export declare function rxFindAuthoringLayoutMappings(aRoot: string): Observable<JsonEntry<AuthoringLayoutMapping>>;
Parameters
aRoot | string | root directory |
Returns:
Observable<JsonEntry<AuthoringLayoutMapping>>
the result
Home > @ibm-wch-sdk/cli-utils > rxFindAuthoringLayouts
rxFindAuthoringLayouts() function
Reads the authoring layouts from a directory
Signature:
export declare function rxFindAuthoringLayouts(aRoot: string): Observable<JsonEntry<AuthoringLayout>>;
Parameters
aRoot | string | root directory |
Returns:
Observable<JsonEntry<AuthoringLayout>>
the result
Home > @ibm-wch-sdk/cli-utils > rxFindAuthoringTypes
rxFindAuthoringTypes() function
Reads the authoring types from a directory
Signature:
export declare function rxFindAuthoringTypes(aRoot: string): Observable<JsonFile<AuthoringType>>;
Parameters
aRoot | string | root directory |
Returns:
Observable<JsonFile<AuthoringType>>
the result
Home > @ibm-wch-sdk/cli-utils > rxFindDataDir
rxFindDataDir() function
Locates the data directory
Signature:
export declare function rxFindDataDir(aDirOrFile: string): Observable<string>;
Parameters
aDirOrFile | string | root path or file to search from |
Returns:
Observable<string>
the data path
Home > @ibm-wch-sdk/cli-utils > rxFindPackageJson
rxFindPackageJson() function
Locates the package json relative to the given directory
Signature:
export declare function rxFindPackageJson(aDirOrFile: string): Observable<string>;
Parameters
aDirOrFile | string | the starting directory or the name of the package json or the name of a package json |
Returns:
Observable<string>
the name of the package json or an error
Home > @ibm-wch-sdk/cli-utils > rxFindPackageManager
rxFindPackageManager() function
Locates the configured package manager
Signature:
export declare function rxFindPackageManager(aDirOrFile: string): Observable<string>;
Parameters
aDirOrFile | string | root directory |
Returns:
Observable<string>
the package manager to use
Home > @ibm-wch-sdk/cli-utils > rxFindSdkVersion
rxFindSdkVersion() function
Locates the version of the SDK to use, either from the package JSON or from our own build
Signature:
export declare function rxFindSdkVersion(aRootDir: string): Observable<string>;
Parameters
aRootDir | string | the root directory used to locate the packae |
Returns:
Observable<string>
the SDK version as a semantic version string
Home > @ibm-wch-sdk/cli-utils > rxReadAngularJson
rxReadAngularJson() function
Reads the angular configuration file, next to the package json file
Signature:
export declare function rxReadAngularJson(aRootDir: string): Observable<any>;
Parameters
aRootDir | string | the starting directory |
Returns:
Observable<any>
the angular JSON file
Home > @ibm-wch-sdk/cli-utils > rxReadAuthoringLayoutMappings
rxReadAuthoringLayoutMappings() function
Reads the authoring layouts from a directory
Signature:
export declare function rxReadAuthoringLayoutMappings(aRoot: string): Observable<AuthoringLayoutMappingMap>;
Parameters
aRoot | string | root directory |
Returns:
Observable<AuthoringLayoutMappingMap>
the result
Home > @ibm-wch-sdk/cli-utils > rxReadAuthoringLayouts
rxReadAuthoringLayouts() function
Reads the authoring layouts from a directory
Signature:
export declare function rxReadAuthoringLayouts(aRoot: string): Observable<AuthoringLayoutMap>;
Parameters
aRoot | string | root directory |
Returns:
Observable<AuthoringLayoutMap>
the result
Home > @ibm-wch-sdk/cli-utils > rxReadAuthoringTypes
rxReadAuthoringTypes() function
Reads the authoring types from a directory
Signature:
export declare function rxReadAuthoringTypes(aRoot: string): Observable<AuthoringTypeMap>;
Parameters
aRoot | string | root directory |
Returns:
Observable<AuthoringTypeMap>
the result
Home > @ibm-wch-sdk/cli-utils > rxReadPackageJson
rxReadPackageJson() function
Locates and reads the package json
Signature:
export declare function rxReadPackageJson(aDirOrFile: string): Observable<any>;
Parameters
aDirOrFile | string | directory or file as a starting point |
Returns:
Observable<any>
the package
Home > @ibm-wch-sdk/cli-utils > rxReadWchToolsOptions
rxReadWchToolsOptions() function
Reads the wchtools options object
Signature:
export declare function rxReadWchToolsOptions(aDirOrFile: string): Observable<WchToolsOptions>;
Parameters
aDirOrFile | string | the candidate directory for the options |
Returns:
Observable<WchToolsOptions>
the options
Home > @ibm-wch-sdk/cli-utils > rxVerifyPreRequisites
rxVerifyPreRequisites() function
Verifies if the installed prerequisites meet the requirements.
Signature:
export declare function rxVerifyPreRequisites(aPrereq: PreRequisites, aRootDir: string): Observable<PreRequisites>;
Parameters
aPrereq | PreRequisites | required prerequisites |
aRootDir | string | root directory |
Returns:
Observable<PreRequisites>
the missing prerequisites from the input or the empty object
Home > @ibm-wch-sdk/cli-utils > rxWchToolsGetCredentials
rxWchToolsGetCredentials() function
Reads the wch credentials from the given API URL
Signature:
export declare function rxWchToolsGetCredentials(aApiUrl: string): Observable<Credentials>;
Parameters
Returns:
Observable<Credentials>
the attached credentials
Home > @ibm-wch-sdk/cli-utils > rxWriteJsonEntryMap
rxWriteJsonEntryMap() function
Persists the entries in the map
Signature:
export declare function rxWriteJsonEntryMap<T>(aMap: JsonEntryMap<T>): Observable<JsonEntry<T>>;
Parameters
aMap | JsonEntryMap<T> | the map to persist |
Returns:
Observable<JsonEntry<T>>
an observable stream of the persisted entries
Home > @ibm-wch-sdk/cli-utils > sdkVersionFromAngularVersion
sdkVersionFromAngularVersion() function
Returns the SDK version from the Angular version
Signature:
export declare function sdkVersionFromAngularVersion(aAngularVersion: string): string;
Parameters
aAngularVersion | string | the angular version string |
Returns:
string
the matching SDK version string
Home > @ibm-wch-sdk/cli-utils > JsonEntry
JsonEntry interface
Signature:
export interface JsonEntry<T> extends JsonFile<T>
Properties
Home > @ibm-wch-sdk/cli-utils > AuthoringLayoutMap
AuthoringLayoutMap type
Mapping from type id to json record for authoring layouts
Signature:
export declare type AuthoringLayoutMap = JsonEntryMap<AuthoringLayout>;
Home > @ibm-wch-sdk/cli-utils > AuthoringLayoutMappingMap
AuthoringLayoutMappingMap type
Mapping from type id to json record for authoring layout mappings
Signature:
export declare type AuthoringLayoutMappingMap = JsonEntryMap<AuthoringLayoutMapping>;
Home > @ibm-wch-sdk/cli-utils > AuthoringTypeMap
AuthoringTypeMap type
Mapping from type id to json record for authoring types
Signature:
export declare type AuthoringTypeMap = JsonEntryMap<AuthoringType>;
Home > @ibm-wch-sdk/cli-utils > JsonEntryMap
JsonEntryMap type
Signature:
export declare type JsonEntryMap<T> = Record<string, JsonEntry<T>>;
Home > @ibm-wch-sdk/cli-utils > PreRequisites
PreRequisites type
Prerequisites as module name to string
Signature:
export declare type PreRequisites = Record<string, string>;
Home > @ibm-wch-sdk/cli-utils > JsonEntry > id
JsonEntry.id property
Signature:
id: string;