Home Manual Reference Source Test
import AtSCMCli from 'atscm-cli/src/AtSCMCli.js'
public class | source

AtSCMCli

Extends:

Liftoff → AtSCMCli

The main class. Handles arguments and runs commands.

Test:

Static Member Summary

Static Public Members
public static get

The name under which the module is available from the command line.

public static get

The filename used for configuration files.

Constructor Summary

Public Constructor
public

constructor(argv: string[])

Creates a new AtSCMCli object based on command line arguments.

Member Summary

Public Members
public

An instance of yargs responible for parsing options.

public

The options parsed from AtSCMCli#_argv.

public

true if the instance was created by running the binaries, false if used programmatically.

Private Members
private

The raw, unparsed command line arguments the Cli was created with.

private

If requiring an external module failed.

Method Summary

Public Methods
public

Returns a Liftoff.Environment for the Cli.

public

async getVersion(): Promise<{cli: string, local: ?string}>

Returns the CLI version and, if a local module could be found, the local version.

public

Parses arguments and runs the specified command.

public

Parses arguments and exposes the project options as environment variables.

public

async printVersion(): Promise<{cli: string, local: ?string}>

Gets and prints the CLI version and, if a local module could be found, the local version.

public

Gets a Liftoff.Environment and validates a config file and a local module was found.

public

Runs the command specified in the command line arguments (AtSCMCli#_argv).

Private Methods
private

_exposeOverride(config: Object, key: string, base: string)

Used to expose project config overrides via environment variables.

private

Reports an error and exits the process with return code 1.

Static Public Members

public static get BinName: string source

The name under which the module is available from the command line.

public static get ConfigName: string source

The filename used for configuration files.

Public Constructors

public constructor(argv: string[]) source

Creates a new AtSCMCli object based on command line arguments.

Params:

NameTypeAttributeDescription
argv string[]

The command line arguments to use. If no command is provided and neither --help nor --version are used, the command run is added.

Throw:

UsageError

Throws an error if option parsing fails.

Test:

Public Members

public argumentsParser: yargs source

An instance of yargs responible for parsing options.

public options: Object source

The options parsed from AtSCMCli#_argv. Note that these options are not complete until AtSCMCli#launch was called.

public runViaCli: Boolean source

true if the instance was created by running the binaries, false if used programmatically.

Private Members

private _argv: String[] source

The raw, unparsed command line arguments the Cli was created with.

private _failedRequires: string[] source

If requiring an external module failed.

Public Methods

public getEnvironment(findUp: boolean): Promise<Object> source

Returns a Liftoff.Environment for the Cli.

Params:

NameTypeAttributeDescription
findUp boolean
  • optional
  • default: false

If the environment should be searched for in parent directories.

Return:

Promise<Object>

Fulfilled with a Liftoff environment.

Test:

public async getVersion(): Promise<{cli: string, local: ?string}> source

Returns the CLI version and, if a local module could be found, the local version.

Return:

Promise<{cli: string, local: ?string}>

Fulfilled with the found cli and local version.

Test:

public launch(): Promise<*, Error> source

Parses arguments and runs the specified command.

Return:

Promise<*, Error>

Fulfilled if the command succeeded. Note that, if the instance is run through the binary all rejections will be handled.

Test:

public parseArguments(): Promise<Object, UsageError> source

Parses arguments and exposes the project options as environment variables.

Return:

Promise<Object, UsageError>

Rejected with a UsageError if parsing failed, otherwise fulfilled with the parsed arguments.

Test:

public async printVersion(): Promise<{cli: string, local: ?string}> source

Gets and prints the CLI version and, if a local module could be found, the local version.

Return:

Promise<{cli: string, local: ?string}>

Fulfilled with the found cli and local version.

Test:

public requireEnvironment(): Promise<Object, Error> source

Gets a Liftoff.Environment and validates a config file and a local module was found.

Return:

Promise<Object, Error>

Resolved with the {@link Liftoff environment}, rejected if the config file or the local module cannot be found.

Test:

public runCommand(): Promise<*, Error> source

Runs the command specified in the command line arguments (AtSCMCli#_argv). Note that this will only work if AtSCMCli#parseArguments was called before..

Return:

Promise<*, Error>

Fulfilled if the command succeeded.

Test:

Private Methods

private _exposeOverride(config: Object, key: string, base: string) source

Used to expose project config overrides via environment variables. All project options are exposed as ATSCM_PROJECT__{KEY}={VALUE}.

Params:

NameTypeAttributeDescription
config Object

The object to expose.

key string

The key currently handled.

base string
  • optional
  • default: ATSCM_PROJECT__

The parent key.

Test:

private _reportCliError(err: Error) source

Reports an error and exits the process with return code 1.

Params:

NameTypeAttributeDescription
err Error

The error that occurred.